/* ============================================================
   Vantulo — light mode design
   ============================================================ */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f3f1ea;
  --surface-3: #ece9e0;
  --border: #e7e3d8;
  --border-strong: #d9d4c6;

  --ink: #211f1a;
  --ink-2: #5f5b50;
  --ink-3: #928d7e;

  --accent: #0e7c6b;
  --accent-strong: #0a5f52;
  --accent-soft: #e2f1ed;
  --accent-softer: #f1f7f5;

  --danger: #b3402f;
  --danger-soft: #fbeeea;
  --amber-bg: #fdf4de;
  --amber-border: #eedfae;
  --amber-ink: #7a5c14;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(33, 31, 26, 0.06);
  --shadow-md: 0 6px 24px rgba(33, 31, 26, 0.09);

  --font-ui: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;

  --sidebar-w: 274px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: #cde8e1; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Thin warm scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* ============================== Layout ============================== */

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============================== Sidebar ============================= */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #17a189, #0a5f52);
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.01em;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 550;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
.new-chat svg { width: 15px; height: 15px; color: var(--accent); }
.new-chat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); color: var(--accent-strong); }

.convo-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.convo-label {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  padding: 4px 6px 0;
}

.convo-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px;
}

.convo-empty {
  color: var(--ink-3);
  font-size: 13px;
  padding: 8px 6px;
}

.convo-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink-2);
  transition: background 0.12s, color 0.12s;
}
.convo-item:hover { background: var(--surface-3); color: var(--ink); }
.convo-item.active { background: var(--surface); color: var(--ink); font-weight: 550; box-shadow: var(--shadow-sm); }

.convo-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
}

.convo-time {
  font-size: 11px;
  color: var(--ink-3);
  flex-shrink: 0;
}

.convo-del {
  display: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: var(--ink-3);
  align-items: center;
  justify-content: center;
}
.convo-del svg { width: 14px; height: 14px; }
.convo-item:hover .convo-time { display: none; }
.convo-item:hover .convo-del { display: flex; }
.convo-del:hover { background: var(--danger-soft); color: var(--danger); }
.convo-del.armed { display: flex; background: var(--danger); color: #fff; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 6px 0;
}

/* ============================== Top bar ============================= */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid transparent;
  min-height: 52px;
}
.topbar.scrolled { border-bottom-color: var(--border); background: rgba(250, 249, 246, 0.9); backdrop-filter: blur(6px); }

.topbar-title {
  font-size: 14px;
  font-weight: 550;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  transition: background 0.12s, color 0.12s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.sidebar-open, .sidebar-close { display: none; }

/* ============================ Key banner ============================ */

.key-banner {
  margin: 10px auto 0;
  max-width: 760px;
  width: calc(100% - 40px);
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber-ink);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13.5px;
  line-height: 1.5;
}
.key-banner code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--amber-border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ============================= Chat area ============================ */

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: auto;
}

.chat-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* ------- hero / empty state ------- */

.hero {
  margin-top: max(6vh, 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  animation: rise 0.45s ease-out both;
}

.hero-mark {
  width: 60px;
  height: 60px;
  border-radius: 17px;
  background: linear-gradient(135deg, #17a189, #0a5f52);
  color: #fff;
  font-family: var(--font-display);
  font-size: 34px;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(14, 124, 107, 0.28);
  margin-bottom: 6px;
}

.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(28px, 4.5vw, 40px);
  margin: 0;
  letter-spacing: 0.005em;
}
.hero h1 em { font-style: italic; color: var(--accent-strong); }

.hero p {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  max-width: 46ch;
  line-height: 1.55;
}

.suggestions {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 640px;
}

.suggestion {
  text-align: left;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, color 0.15s;
}
.suggestion:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: #bcd8d1;
  color: var(--ink);
}
.suggestion .s-kind {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 4px;
}

/* ------- messages ------- */

.msg { animation: rise 0.25s ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.msg.user { display: flex; justify-content: flex-end; }

.msg.user .bubble {
  max-width: 82%;
  background: var(--accent-soft);
  border: 1px solid #d3e8e2;
  color: var(--ink);
  padding: 11px 16px;
  border-radius: 18px 18px 5px 18px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.55;
}

.msg.assistant { display: flex; flex-direction: column; gap: 10px; }

.msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(135deg, #17a189, #0a5f52);
  color: #fff;
  font-family: var(--font-display);
  font-size: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.msg-name {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* ------- activity: thinking + web search ------- */

.msg-activity { display: flex; flex-direction: column; gap: 8px; }
.msg-activity:empty { display: none; }

.think {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.think-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  text-align: left;
}
.think-head:hover { background: var(--accent-softer); }
.think-head svg.spark { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.think-head .chev { width: 14px; height: 14px; margin-left: auto; color: var(--ink-3); transition: transform 0.18s; flex-shrink: 0; }
.think[data-open="1"] .chev { transform: rotate(180deg); }

.think-label.shimmer {
  background: linear-gradient(90deg, var(--ink-3) 30%, var(--accent) 50%, var(--ink-3) 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 180% 0; }
  to { background-position: -20% 0; }
}

.think-body {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--accent-softer);
}
.think[data-open="1"] .think-body { display: block; }
.think-body pre {
  margin: 0;
  padding: 11px 14px;
  max-height: 250px;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 14px 7px 11px;
  font-size: 13px;
  color: var(--ink-2);
}
.tool-chip svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.tool-chip.pending svg { animation: spin 1.4s linear infinite; }
.tool-chip.error { border-color: #ecc8c0; color: var(--danger); background: var(--danger-soft); }
.tool-chip.error svg { color: var(--danger); }
.tool-chip .q { font-weight: 550; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-chip .n { color: var(--ink-3); flex-shrink: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ------- message body / markdown ------- */

.msg-body {
  font-size: 15.5px;
  line-height: 1.65;
  overflow-wrap: break-word;
  min-width: 0;
}

.msg-body.streaming:empty::after,
.msg-body.streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.02em;
  margin-left: 3px;
  vertical-align: text-bottom;
  border-radius: 2.5px;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.msg-body p { margin: 0 0 0.85em; }
.msg-body > :first-child { margin-top: 0; }
.msg-body > :last-child { margin-bottom: 0; }

.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4, .msg-body h5, .msg-body h6 {
  font-weight: 680;
  line-height: 1.3;
  margin: 1.25em 0 0.5em;
}
.msg-body h1 { font-size: 1.35em; }
.msg-body h2 { font-size: 1.2em; }
.msg-body h3 { font-size: 1.08em; }
.msg-body h4, .msg-body h5, .msg-body h6 { font-size: 1em; }

.msg-body ul, .msg-body ol { margin: 0.2em 0 0.9em; padding-left: 1.5em; }
.msg-body li { margin: 0.3em 0; }
.msg-body li ul, .msg-body li ol { margin: 0.25em 0; }

.msg-body a { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: #9ccdc3; }
.msg-body a:hover { text-decoration-color: var(--accent-strong); }

.msg-body strong { font-weight: 680; }

.msg-body blockquote {
  margin: 0.2em 0 0.9em;
  padding: 0.45em 1.1em;
  border-left: 3px solid #a9d3ca;
  background: var(--accent-softer);
  border-radius: 0 10px 10px 0;
  color: var(--ink-2);
}
.msg-body blockquote > :last-child { margin-bottom: 0; }

.msg-body hr { border: none; border-top: 1px solid var(--border); margin: 1.3em 0; }

.msg-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08em 0.38em;
}

.codeblock {
  margin: 0.3em 0 1em;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface);
}
.codebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.codebar .lang {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: lowercase;
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--ink-3);
  padding: 4px 9px;
  border-radius: 7px;
}
.code-copy:hover { background: var(--surface-3); color: var(--ink); }
.code-copy svg { width: 12.5px; height: 12.5px; }
.code-copy .i-check { display: none; color: var(--accent); }
.code-copy.copied .i-check { display: inline; }
.code-copy.copied .i-copy { display: none; }
.code-copy.copied { color: var(--accent-strong); }

.codeblock pre {
  margin: 0;
  padding: 13px 15px;
  overflow-x: auto;
}
.codeblock pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #33312a;
}

.table-wrap { overflow-x: auto; margin: 0.3em 0 1em; }
.msg-body table {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 320px;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border);
  padding: 7px 13px;
  text-align: left;
  vertical-align: top;
}
.msg-body th { background: var(--surface-2); font-weight: 650; }
.msg-body tr:nth-child(even) td { background: #fcfbf8; }

/* ------- sources ------- */

.msg-sources { display: flex; flex-direction: column; gap: 7px; }
.msg-sources[hidden] { display: none; }
.src-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
}
.src-list { display: flex; flex-wrap: wrap; gap: 7px; }
.src {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 4px 11px 4px 5px;
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  max-width: 260px;
  transition: border-color 0.13s, color 0.13s, box-shadow 0.13s;
}
.src:hover { border-color: #a9d3ca; color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.src-n {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.src-d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------- footer actions / notes / errors ------- */

.msg-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
}
.msg.assistant.streaming .msg-foot { visibility: hidden; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-3);
  padding: 4px 9px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.msg.assistant:hover .ghost-btn, .ghost-btn:focus-visible, .ghost-btn.copied { opacity: 1; }
.ghost-btn:hover { background: var(--surface-3); color: var(--ink); }
.ghost-btn svg { width: 13px; height: 13px; }
.ghost-btn .i-check { display: none; color: var(--accent); }
.ghost-btn.copied .i-check { display: inline; }
.ghost-btn.copied .i-copy { display: none; }
.act-regen[hidden] { display: none; }

.msg-note { font-size: 12px; color: var(--ink-3); font-style: italic; margin-left: 6px; }

.err-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--danger-soft);
  border: 1px solid #ecc8c0;
  color: var(--danger);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  line-height: 1.5;
}
.err-card svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1.5px; }

/* ------- safety block notice ------- */

.block-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--danger-soft);
  border: 1px solid #eccabf;
  border-radius: 14px;
  padding: 14px 16px;
}
.block-ico { flex-shrink: 0; color: var(--danger); margin-top: 1px; line-height: 0; }
.block-ico svg { width: 20px; height: 20px; display: block; }
.block-main { min-width: 0; }
.block-title {
  display: block;
  font-size: 14.5px;
  font-weight: 680;
  color: var(--ink);
  margin-bottom: 4px;
}
.block-body {
  margin: 0 0 6px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.block-hint {
  margin: 0;
  font-size: 13px;
  font-weight: 550;
  color: var(--accent-strong);
}

/* ============================= Composer ============================= */

.composer-wrap {
  padding: 6px 20px calc(12px + env(safe-area-inset-bottom));
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 12px 12px 10px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px rgba(14, 124, 107, 0.12), var(--shadow-md);
}

.composer textarea {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 200px;
  padding: 2px 4px 6px 0;
}
.composer textarea::placeholder { color: var(--ink-3); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggles { display: flex; gap: 6px; flex-wrap: wrap; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5.5px 12px;
  transition: all 0.14s;
}
.toggle svg { width: 13.5px; height: 13.5px; }
.toggle:hover { border-color: var(--border-strong); color: var(--ink-2); }
.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: #b7dcd4;
  color: var(--accent-strong);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.14s, transform 0.1s;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:hover:not(:disabled) { background: var(--accent-strong); }
.send-btn:active:not(:disabled) { transform: scale(0.93); }
.send-btn:disabled { background: var(--surface-3); color: var(--ink-3); cursor: default; }
.send-btn .i-stop { display: none; }

body.streaming .send-btn { background: var(--ink); }
body.streaming .send-btn:hover { background: #000; }
body.streaming .send-btn .i-send { display: none; }
body.streaming .send-btn .i-stop { display: block; }

.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 9px 0 0;
}

/* ============================ Responsive ============================ */

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(33, 31, 26, 0.32);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.2s;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .scrim { display: block; opacity: 1; }
  .sidebar-open, .sidebar-close { display: inline-flex; }

  .suggestions { grid-template-columns: 1fr; }
  .msg.user .bubble { max-width: 90%; }
  .chat-inner { padding: 6px 14px 24px; }
  .composer-wrap { padding-left: 12px; padding-right: 12px; }
  .ghost-btn { opacity: 1; }
}

/* ========================= View switching (auth/app) ==================== */
/* Nothing shows until app.js decides which view is active — avoids flashes. */

body:not(.view-app) .app { display: none; }
body:not(.view-auth) .auth-view { display: none; }

/* ============================== Auth view =============================== */

.auth-view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(700px 340px at 50% -80px, rgba(14, 124, 107, 0.09), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  padding: 30px 30px 24px;
  animation: rise 0.4s ease-out both;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 25px;
  text-align: center;
  margin: 0 0 6px;
}

.auth-sub {
  text-align: center;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.5;
  margin: 0 0 20px;
}
.auth-sub strong { color: var(--ink); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 13px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 107, 0.12);
}

.form-error {
  min-height: 18px;
  margin: 2px 0 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--danger);
}
.form-error:empty { margin: 0 0 6px; }

.btn-primary {
  width: 100%;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  border-radius: 11px;
  transition: background 0.14s, transform 0.1s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:active:not(:disabled) { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.auth-alt {
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  margin: 16px 0 0;
}

.link-btn {
  color: var(--accent-strong);
  font-weight: 600;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: #9ccdc3;
}
.link-btn:hover { text-decoration-color: var(--accent-strong); }
.link-btn:disabled { color: var(--ink-3); text-decoration: none; cursor: default; }

.otp-row { display: flex; gap: 8px; justify-content: center; margin: 4px 0 10px; }
.otp-d {
  width: 46px;
  height: 56px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 23px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.otp-d:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 107, 0.12);
}

.auth-foot { color: var(--ink-3); font-size: 12px; margin: 0; }

/* ====================== Sidebar account & upgrade ======================= */

.upgrade-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 13px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #11907c, #0a5f52);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.upgrade-btn svg { width: 14px; height: 14px; }
.upgrade-btn:hover { filter: brightness(1.07); box-shadow: var(--shadow-md); transform: translateY(-1px); }

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 2px 10px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #17a189, #0a5f52);
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-email {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout-btn { width: 30px; height: 30px; flex-shrink: 0; }
.signout-btn svg { width: 15px; height: 15px; }
.signout-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* ================================ Modal ================================= */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(33, 31, 26, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-scrim[hidden] { display: none; }

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(33, 31, 26, 0.25);
  padding: 30px 28px 22px;
  animation: pop 0.22s ease-out both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.modal-close { position: absolute; top: 12px; right: 12px; }

.pro-modal { text-align: center; }

.pro-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 15px;
  background: linear-gradient(135deg, #17a189, #0a5f52);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(14, 124, 107, 0.3);
}
.pro-badge svg { width: 26px; height: 26px; }

.pro-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 25px;
  margin: 0 0 4px;
}
.pro-title em { font-style: italic; color: var(--accent-strong); }

.pro-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 18px; }

.pro-perks {
  list-style: none;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: var(--accent-softer);
  border: 1px solid #d9ebe6;
  border-radius: 13px;
  text-align: left;
}
.pro-perks li {
  position: relative;
  padding-left: 24px;
  font-size: 13.5px;
  line-height: 1.45;
  margin: 7px 0;
  color: var(--ink);
}
.pro-perks li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  -webkit-mask: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M20 6L9 17l-5-5"/%3E%3C/svg%3E') center / 100% no-repeat, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3.4" stroke-linecap="round" stroke-linejoin="round"%3E%3Cpath d="M20 6L9 17l-5-5"/%3E%3C/svg%3E') center / 100% no-repeat, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.pro-price { font-family: var(--font-display); font-size: 34px; margin-bottom: 14px; }
.pro-price span { font-family: var(--font-ui); font-size: 13px; color: var(--ink-3); }

.pro-cta {
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, #11907c, #0a5f52);
  color: #fff;
  font-weight: 650;
  font-size: 15px;
  border-radius: 12px;
  transition: filter 0.13s, transform 0.1s;
}
.pro-cta:hover:not(:disabled) { filter: brightness(1.07); }
.pro-cta:active:not(:disabled) { transform: scale(0.985); }
.pro-cta:disabled { opacity: 0.65; cursor: default; }

.pro-msg { min-height: 17px; font-size: 12.5px; color: var(--danger); margin: 10px 0 0; }
.pro-fine { font-size: 11.5px; color: var(--ink-3); margin: 6px 0 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
