* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Courier New', monospace;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

a { color: #c4a0ff; text-decoration: none; }
a:hover { color: #e0c8ff; }

code {
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 3px;
  color: #c4a0ff;
}

/* ==================== Navbar ==================== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
  border-bottom: 1px solid #222;
  background: #0a0a0a;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 24px;
  font-size: 14px;
  flex-wrap: wrap;
}

.nav-links a { color: #666; transition: color 0.2s; }
.nav-links a:hover { color: #c4a0ff; }

.nav-hamburger {
  display: none;
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

/* Nav auth — inline key input */
.nav-auth {
  font-size: 12px;
  flex-shrink: 0;
}

.nav-key-wrapper {
  position: relative;
}

.nav-key-prompt {
  color: #555;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}

.nav-key-prompt:hover {
  color: #888;
  border-color: #333;
}

.nav-key-prompt.logged-in {
  color: #8a8;
  background: rgba(123, 47, 247, 0.08);
  border-color: #2a2a3a;
}

.nav-key-input {
  background: transparent;
  border: none;
  outline: none;
  color: #c4a0ff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  width: 280px;
  max-width: 100%;
  padding: 4px 6px;
  border-bottom: 1px solid #7b2ff7;
}

/* ==================== Timer ==================== */
.timer-bar {
  height: 6px;
  background: #111;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #7b2ff7, #c4a0ff);
  width: 100%;
  transition: width 0.1s linear;
}

/* ==================== Writing ==================== */
.writing-container {
  height: calc(100vh - 80px);
  height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
}

#writing-area {
  flex: 1;
  background: #0a0a0a;
  border: none;
  color: #e0e0e0;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  padding: 40px;
  resize: none;
  outline: none;
  line-height: 1.8;
  overflow-y: auto;
}

#writing-area::placeholder { color: #333; }

#response-area {
  padding: 40px;
  border-top: 1px solid #222;
  background: #0d0d12;
  max-height: 40%;
  overflow-y: auto;
  display: none;
}

#response-area.visible { display: block; }

.response-text { line-height: 1.8; }

.anky-notice {
  margin-top: 16px;
  padding: 12px;
  background: rgba(123, 47, 247, 0.15);
  border: 1px solid #7b2ff7;
  border-radius: 4px;
  color: #c4a0ff;
}

.processing {
  text-align: center;
  padding: 20px;
  color: #666;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.new-session-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 24px;
  background: #7b2ff7;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.new-session-btn:hover { background: #6020d0; }

/* ==================== Page headers ==================== */
.page-header {
  padding: 30px 40px 20px;
  border-bottom: 1px solid #222;
}

.page-header h2 { color: #fff; margin-bottom: 4px; }
.subtitle { color: #666; font-size: 14px; }

/* ==================== Gallery ==================== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  padding: 30px 40px;
}

.gallery-item {
  border: 1px solid #222;
  overflow: hidden;
  transition: border-color 0.2s;
}

.gallery-item a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.gallery-item:hover { border-color: #7b2ff7; }

.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.gallery-item .placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-caption {
  padding: 12px;
  border-top: 1px solid #222;
}

.gallery-title {
  display: block;
  color: #fff;
  margin-bottom: 4px;
}

.gallery-thinker {
  display: block;
  color: #666;
  font-size: 12px;
}

/* ==================== Writings list ==================== */
.writings-list {
  padding: 20px 40px;
  max-width: 900px;
  margin: 0 auto;
  height: calc(100vh - 160px);
  overflow-y: auto;
}

.writing-item {
  border: 1px solid #222;
  padding: 20px;
  margin-bottom: 16px;
  line-height: 1.6;
  transition: border-color 0.2s, background 0.2s;
}

.writing-item.selected {
  border-color: #7b2ff7;
  background: #0d0d18;
}

.writing-meta {
  color: #666;
  font-size: 13px;
  margin-bottom: 10px;
}

.anky-badge {
  color: #c4a0ff;
  font-weight: bold;
}

.writing-preview {
  color: #aaa;
  margin-bottom: 10px;
}

.writing-response {
  border-top: 1px solid #222;
  padding-top: 10px;
  margin-top: 10px;
  color: #888;
  font-style: italic;
}

/* ==================== Poiesis console ==================== */
.poiesis-dashboard {
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
}

.poiesis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 1px solid #222;
  flex-wrap: wrap;
  gap: 8px;
}

.poiesis-header h2 { color: #fff; }

.poiesis-stats {
  display: flex;
  gap: 24px;
  font-size: 14px;
  color: #666;
  flex-wrap: wrap;
}

.poiesis-stats strong { color: #c4a0ff; }

.console {
  flex: 1;
  background: #050508;
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.console-line {
  padding: 2px 0;
  color: #8a8;
  white-space: pre-wrap;
  word-break: break-all;
}

.console-line.dim { color: #444; }

/* ==================== Help tabs ==================== */
.help-tabs {
  display: flex;
  gap: 0;
  padding: 0 40px;
  border-bottom: 1px solid #222;
  max-width: 800px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.help-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: #555;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.help-tab:hover { color: #888; }
.help-tab.active { color: #e0e0e0; border-bottom-color: #e0e0e0; }

.help-tab.agent-tab {
  color: #444;
}

.help-tab.agent-tab:hover { color: #7b2ff740; }
.help-tab.agent-tab.active { color: #c4a0ff; border-bottom-color: #7b2ff7; }

.kannada-text {
  font-size: 13px;
  opacity: 0.6;
}

/* ==================== Help content ==================== */
.help-content {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
  line-height: 2;
  height: calc(100vh - 120px);
  overflow-y: auto;
}

.help-content h2 {
  margin-top: 30px;
  margin-bottom: 15px;
  color: #fff;
}

.help-content h3 {
  margin-top: 20px;
  margin-bottom: 8px;
  color: #c4a0ff;
  font-size: 15px;
}

.help-content ul, .help-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.help-content li { margin-bottom: 4px; }

.help-content pre {
  background: #111;
  padding: 12px;
  border: 1px solid #222;
  overflow-x: auto;
  margin: 8px 0 16px;
  font-size: 12px;
  line-height: 1.6;
}

.help-content pre code {
  background: transparent;
  padding: 0;
}

/* ==================== Sleeping ==================== */
.sleeping-container {
  text-align: center;
  padding: 80px 40px;
  max-width: 600px;
  margin: 0 auto;
}

.sleeping-icon {
  position: relative;
  display: inline-block;
  margin-bottom: 30px;
}

.pulse-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid #7b2ff7;
  animation: pulse-expand 2s infinite;
  margin: 0 auto;
}

@keyframes pulse-expand {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.sleeping-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #c4a0ff;
  font-size: 14px;
}

.sleeping-container h2 {
  color: #fff;
  margin-bottom: 8px;
}

.sleeping-container p {
  color: #888;
  margin-bottom: 16px;
}

/* ==================== Progress bar ==================== */
.progress-bar {
  height: 8px;
  background: #1a1a1a;
  border-radius: 4px;
  margin: 20px 0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7b2ff7, #c4a0ff, #d4a0ff);
  border-radius: 4px;
  transition: width 0.5s;
}

.progress-text {
  text-align: center;
  color: #666;
  font-size: 14px;
}

/* ==================== Notify signup ==================== */
.notify-signup {
  margin-top: 40px;
  padding: 24px;
  border: 1px solid #222;
}

.notify-signup h3 {
  color: #fff;
  margin-bottom: 12px;
  font-size: 16px;
}

.notify-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notify-input {
  background: #111;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  flex: 1;
  min-width: 180px;
  outline: none;
}

.notify-input:focus { border-color: #7b2ff7; }

.notify-btn {
  padding: 10px 20px;
  background: #7b2ff7;
  color: #fff;
  border: none;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}

.notify-btn:hover { background: #6020d0; }

/* ==================== Collection ==================== */
.collection-container {
  padding: 40px;
  max-width: 800px;
  margin: 0 auto;
}

.collection-container h2 {
  color: #fff;
  margin-bottom: 16px;
}

.cost-estimate {
  font-size: 18px;
  margin: 16px 0;
}

.cost-estimate strong { color: #c4a0ff; }

.tx-input {
  background: #111;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  margin-bottom: 12px;
  outline: none;
}

.tx-input:focus { border-color: #7b2ff7; }

.payment-section {
  margin-top: 24px;
  padding: 20px;
  border: 1px solid #222;
}

/* ==================== Mint ==================== */
.mint-container {
  padding: 80px 40px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.mint-container h2 {
  color: #fff;
  margin-bottom: 16px;
}

/* ==================== Empty state ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #666;
  grid-column: 1 / -1;
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

.poiesis-link { margin-top: 20px; }
.poiesis-link a { color: #7b2ff7; }

/* ==================== Credits page ==================== */
.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px;
  line-height: 1.8;
}

.container h1 {
  color: #fff;
  margin-bottom: 8px;
}

.credits-section {
  margin-top: 32px;
  padding: 20px;
  border: 1px solid #222;
}

.credits-section h2 {
  color: #fff;
  margin-bottom: 12px;
  font-size: 16px;
}

.credits-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(123, 47, 247, 0.1);
  border: 1px solid #7b2ff7;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
  color: #c4a0ff;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-small {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid #666;
  color: #666;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.btn-small:hover { border-color: #c4a0ff; color: #c4a0ff; }

.key-create,
.key-login,
.verify-payment,
.usage-check {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.credits-section input[type="text"],
.credits-section input[type="number"] {
  background: #111;
  border: 1px solid #333;
  color: #e0e0e0;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  outline: none;
}

.credits-section input:focus { border-color: #7b2ff7; }

.credits-section button {
  padding: 8px 16px;
  background: #7b2ff7;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.credits-section button:hover { background: #6020d0; }

.input-wide { flex: 2; }

.mega-prompt-input {
  width: 100%;
  min-height: 100px;
  background: #111;
  border: 1px solid #333;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 13px;
  padding: 10px;
  resize: vertical;
  outline: none;
}

.mega-prompt-input:focus { border-color: #7b2ff7; }

.btn-generate {
  margin-top: 8px;
  padding: 8px 16px;
  background: #7b2ff7;
  color: #fff;
  border: none;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn-generate:hover { background: #6020d0; }

.key-display {
  margin-top: 12px;
  padding: 12px;
  background: rgba(123, 47, 247, 0.1);
  border: 1px solid #7b2ff7;
}

.key-display code {
  word-break: break-all;
  font-size: 13px;
}

.warning { color: #e0a040; font-size: 12px; margin-top: 4px; }

.treasury-address {
  display: block;
  margin: 8px 0;
  padding: 10px;
  font-size: 13px;
  word-break: break-all;
  background: #111;
  border: 1px solid #333;
}

.key-login { margin-top: 16px; }
.key-login p { color: #666; font-size: 13px; width: 100%; }

.success { color: #8a8; }
.error { color: #e05050; }

#auto-usage {
  padding: 12px;
  background: rgba(123, 47, 247, 0.05);
  border: 1px solid #222;
  margin-bottom: 12px;
}

#auto-usage strong { color: #c4a0ff; }
#auto-usage h3 { color: #fff; font-size: 14px; margin: 8px 0 4px; }
#auto-usage ul { padding-left: 16px; font-size: 12px; color: #888; }

/* ==================== Anky detail page ==================== */
.anky-detail {
  max-width: 720px;
  margin: 0 auto;
  padding: 30px 40px 60px;
}

.anky-image {
  margin-bottom: 30px;
}

.anky-image img {
  width: 100%;
  display: block;
  border: 1px solid #222;
}

.anky-generating {
  width: 100%;
  aspect-ratio: 1;
  background: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #222;
}

.anky-title {
  color: #fff;
  font-size: 28px;
  margin-bottom: 8px;
  line-height: 1.3;
}

.anky-meta {
  color: #666;
  font-size: 14px;
  margin-bottom: 4px;
}

.anky-thinker {
  color: #c4a0ff;
}

.anky-moment {
  margin-left: 8px;
  color: #555;
}

.anky-moment::before {
  content: "// ";
  color: #333;
}

.anky-created {
  color: #444;
  font-size: 12px;
  margin-bottom: 30px;
}

.anky-section {
  margin-top: 30px;
  border-top: 1px solid #1a1a1a;
  padding-top: 24px;
}

.anky-section h2 {
  color: #555;
  font-size: 13px;
  text-transform: lowercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.anky-reflection {
  color: #bbb;
  line-height: 1.9;
  font-size: 15px;
}

.anky-writing {
  color: #888;
  line-height: 2;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}


/* ============================================================
   RESPONSIVE — tablets and smaller (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

  /* --- Navbar: collapse to hamburger --- */
  .navbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .nav-hamburger {
    display: block;
    order: 2;
    margin-left: auto;
  }

  .nav-links {
    display: none;
    width: 100%;
    order: 10;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid #222;
    padding-top: 8px;
    margin-top: 8px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    padding: 10px 0;
    border-bottom: 1px solid #181818;
  }

  .nav-auth {
    order: 3;
  }

  .nav-key-input {
    width: 160px;
  }

  .logo {
    font-size: 20px;
  }

  /* --- Paddings --- */
  .page-header {
    padding: 20px 16px 14px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
  }

  .gallery-caption {
    padding: 8px;
    font-size: 12px;
  }

  .gallery-title { font-size: 13px; }

  /* --- Writing --- */
  #writing-area {
    padding: 20px 16px;
    font-size: 16px;
  }

  #response-area {
    padding: 20px 16px;
  }

  /* --- Writings list --- */
  .writings-list {
    padding: 16px;
    height: calc(100vh - 140px);
  }

  .writing-item {
    padding: 14px;
  }

  /* --- Poiesis --- */
  .poiesis-header {
    padding: 14px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .poiesis-stats {
    gap: 12px;
    font-size: 12px;
  }

  .console {
    padding: 12px;
    font-size: 12px;
  }

  /* --- Help --- */
  .help-tabs {
    padding: 0 16px;
  }

  .help-tab {
    padding: 10px 12px;
    font-size: 12px;
  }

  .help-content {
    padding: 20px 16px;
    height: calc(100vh - 110px);
  }

  .help-content pre {
    font-size: 11px;
    padding: 8px;
  }

  /* --- Sleeping --- */
  .sleeping-container {
    padding: 40px 16px;
  }

  /* --- Collection --- */
  .collection-container {
    padding: 20px 16px;
  }

  /* --- Mint --- */
  .mint-container {
    padding: 40px 16px;
  }

  /* --- Container (credits, generate) --- */
  .container {
    padding: 20px 16px;
  }

  .credits-section {
    padding: 14px;
  }

  .credits-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 12px;
  }

  .key-create,
  .key-login,
  .verify-payment,
  .usage-check {
    flex-direction: column;
  }

  .credits-section input[type="text"],
  .credits-section input[type="number"] {
    min-width: 0;
    width: 100%;
  }

  .input-wide {
    flex: 1;
  }

  .credits-section button {
    width: 100%;
    padding: 12px 16px;
  }

  .btn-generate {
    width: 100%;
    padding: 12px 16px;
  }

  .treasury-address {
    font-size: 11px;
    padding: 8px;
  }

  /* --- Anky detail --- */
  .anky-detail {
    padding: 20px 16px 40px;
  }

  .anky-title {
    font-size: 22px;
  }

  .anky-reflection {
    font-size: 14px;
    line-height: 1.8;
  }

  .anky-writing {
    font-size: 13px;
    line-height: 1.8;
  }

  .anky-section {
    margin-top: 24px;
    padding-top: 18px;
  }

  /* --- Notify --- */
  .notify-signup {
    padding: 16px;
  }

  .notify-input {
    width: 100%;
    min-width: 0;
  }

  .notify-btn {
    width: 100%;
    margin-left: 0;
  }
}


/* ============================================================
   RESPONSIVE — small phones (max-width: 420px)
   ============================================================ */
@media (max-width: 420px) {

  .navbar {
    padding: 10px 12px;
  }

  .nav-key-input {
    width: 120px;
    font-size: 11px;
  }

  .nav-key-prompt {
    font-size: 11px;
    padding: 2px 6px;
  }

  .gallery-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
  }

  .gallery-caption {
    padding: 6px;
  }

  .gallery-title {
    font-size: 12px;
  }

  .gallery-thinker {
    font-size: 11px;
  }

  #writing-area {
    padding: 16px 12px;
    font-size: 15px;
  }

  #response-area {
    padding: 16px 12px;
  }

  .help-tab {
    padding: 8px 10px;
    font-size: 11px;
  }

  .help-content {
    padding: 16px 12px;
    line-height: 1.8;
  }

  .container {
    padding: 16px 12px;
  }

  .sleeping-container {
    padding: 30px 12px;
  }

  .pulse-ring {
    width: 80px;
    height: 80px;
  }

  .anky-detail {
    padding: 16px 12px 30px;
  }

  .anky-title {
    font-size: 20px;
  }

  .anky-reflection {
    font-size: 13px;
  }

  .anky-moment {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }

  .anky-moment::before {
    content: "// ";
  }
}
