/* ================================================================
   AI2Word — modern interface
   Desktop: viewport-fitted two-pane studio.
   Mobile (≤1024px): stacked, scrollable, cards keep their height.
   ================================================================ */

/* -----------------------------------------------------------------
   Design tokens
   ----------------------------------------------------------------- */
:root {
  --bg:           #f6f7fb;
  --bg-elevated:  #ffffff;
  --bg-muted:     #eef0f6;
  --bg-header:    rgba(255,255,255,0.88);
  --bg-pane-head: linear-gradient(180deg, #ffffff 0%, #f3f5fa 100%);
  --bg-pane-foot: #f5f6fb;
  --border:       #e5e7ee;
  --border-strong:#d7dae5;
  --text:         #1a1d24;
  --text-muted:   #6b7280;
  --text-faint:   #9ca3af;
  --accent:       #6366f1;
  --accent-2:     #8b5cf6;
  --accent-soft:  #eef0ff;
  --accent-10:    rgba(99,102,241,0.10);
  --accent-30:    rgba(99,102,241,0.30);
  --danger:       #ef4444;
  --danger-10:    rgba(239,68,68,0.10);
  --danger-35:    rgba(239,68,68,0.35);
  --success:      #10b981;
  --shadow-sm:    0 1px 2px rgba(20,24,40,.04), 0 1px 3px rgba(20,24,40,.06);
  --shadow-md:    0 4px 12px rgba(20,24,40,.06), 0 2px 4px rgba(20,24,40,.04);
  --shadow-lg:    0 16px 40px rgba(20,24,40,.08), 0 4px 12px rgba(20,24,40,.05);
  --radius:       14px;
  --radius-pill:  999px;
  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

[data-bs-theme="dark"] {
  --bg:           #0d0f14;
  --bg-elevated:  #161922;
  --bg-muted:     #1c1f2a;
  --bg-header:    rgba(22,25,34,0.88);
  --bg-pane-head: linear-gradient(180deg, #161922 0%, #12151d 100%);
  --bg-pane-foot: #131722;
  --border:       #242836;
  --border-strong:#333849;
  --text:         #e6e8ee;
  --text-muted:   #9ba3b4;
  --text-faint:   #6b7280;
  --accent:       #818cf8;
  --accent-2:     #a78bfa;
  --accent-soft:  #1f2340;
  --accent-10:    rgba(129,140,248,0.10);
  --accent-30:    rgba(129,140,248,0.30);
  --danger-10:    rgba(239,68,68,0.12);
  --danger-35:    rgba(239,68,68,0.40);
  --shadow-sm:    0 1px 2px rgba(0,0,0,.30);
  --shadow-md:    0 4px 12px rgba(0,0,0,.35);
  --shadow-lg:    0 16px 40px rgba(0,0,0,.45);
}

/* -----------------------------------------------------------------
   Reset + desktop shell
   ----------------------------------------------------------------- */
* { box-sizing: border-box; }
::selection { background: var(--accent); color: #fff; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

/* -----------------------------------------------------------------
   Header
   ----------------------------------------------------------------- */
.app-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 40;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}
@supports (backdrop-filter: blur(12px)) {
  .app-header {
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 22px;
  max-width: 1800px;
  margin: 0 auto;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.app-brand:hover { color: inherit; }

.app-logo {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 18px;
  box-shadow: 0 6px 16px -6px var(--accent);
}

.app-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.app-brand-text strong { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.app-brand-text small { color: var(--text-muted); font-size: 11.5px; }

.app-header-actions { display: flex; align-items: center; gap: 8px; }

/* -----------------------------------------------------------------
   Main + grid
   ----------------------------------------------------------------- */
.app-main {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-grid {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows:    minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

/* -----------------------------------------------------------------
   Pane card
   ----------------------------------------------------------------- */
.pane-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.pane-card:hover { box-shadow: var(--shadow-md); }

/* -----------------------------------------------------------------
   Pane header
   ----------------------------------------------------------------- */
.pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-pane-head);
  min-height: 46px;
}

.pane-head-left,
.pane-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pane-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pane-dot-rose    { background: #ff5f57; }
.pane-dot-amber   { background: #febc2e; }
.pane-dot-emerald { background: #28c840; }

.pane-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 4px;
}

/* Hide the pane-header title input on phones. */
@media (max-width: 768px) {
  .title-input-header { display: none; }
}

.divider { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* -----------------------------------------------------------------
   Buttons
   ----------------------------------------------------------------- */
.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-icon:hover { border-color: var(--border-strong); background: var(--bg-muted); }

/* Anchor variant of .btn-icon (used for YouTube / website links). */
a.btn-icon {
  text-decoration: none;
  color: var(--text);
}
a.btn-icon:hover { color: var(--text); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-ghost:hover { background: var(--bg-muted); border-color: var(--border-strong); }

.btn-quiet {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-quiet:hover { background: var(--bg-muted); color: var(--text); }

.btn-primary-gradient {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px var(--accent);
  transition: transform .15s ease, box-shadow .15s ease;
}
.btn-primary-gradient:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px -8px var(--accent-2);
}
.btn-primary-gradient:active { transform: translateY(0); }
.btn-primary-gradient:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-outline-danger-soft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--danger-35);
  color: var(--danger);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-outline-danger-soft:hover { background: var(--danger-10); }

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

/* -----------------------------------------------------------------
   Editor
   ----------------------------------------------------------------- */
.editor {
  flex: 1 1 0;
  min-height: 0;
  border: none;
  outline: none;
  resize: none;
  padding: 20px 22px;
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  tab-size: 4;
  width: 100%;
}
.editor::placeholder { color: var(--text-faint); font-family: var(--font-sans); }
.editor::-webkit-scrollbar { width: 10px; }
.editor::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 10px;
  border: 3px solid var(--bg-elevated); background-clip: padding-box;
}

/* -----------------------------------------------------------------
   Pane footer
   ----------------------------------------------------------------- */
.pane-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-pane-foot);
  flex-wrap: wrap;
}

.meta-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.meta-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* -----------------------------------------------------------------
   Analysis strip
   ----------------------------------------------------------------- */
.analysis-strip {
  flex: 0 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 8px 12px;
  max-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
}
.analysis-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 12.5px;
}
.analysis-inner::-webkit-scrollbar { width: 8px; }
.analysis-inner::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 10px;
}

.muted-note { color: var(--text-muted); font-size: 12.5px; }

.analysis-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
  flex: none;
}
.analysis-chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-30);
  color: var(--accent);
}
.analysis-chip .chip-count {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.analysis-chip.is-active .chip-count { color: var(--accent); }

/* -----------------------------------------------------------------
   Preview
   ----------------------------------------------------------------- */
.preview-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(circle at 25% 0%, var(--accent-10), transparent 45%),
    var(--bg);
}
.preview-scroll::-webkit-scrollbar { width: 10px; }
.preview-scroll::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 10px;
  border: 3px solid transparent; background-clip: padding-box;
}

.preview-paper {
  background: #ffffff;
  color: #1a1d24;
  border-radius: 6px;
  padding: 40px 44px;
  box-shadow:
    0 1px 2px rgba(20,24,40,.08),
    0 12px 32px rgba(20,24,40,.10);
  max-width: 820px;
  margin: 0 auto;
}

.preview {
  font-family: "Calibri", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1d24;
  word-wrap: break-word;
}
.preview * { color: inherit; }
.preview h1, .preview h2, .preview h3,
.preview h4, .preview h5, .preview h6 {
  font-family: inherit; font-weight: 700; color: #0f1117;
  line-height: 1.3; margin: 1.2em 0 .5em;
}
.preview h1 { font-size: 1.7em; }
.preview h2 { font-size: 1.4em; }
.preview h3 { font-size: 1.2em; }
.preview h4 { font-size: 1.05em; }
.preview h5 { font-size: .98em; }
.preview h6 { font-size: .92em; color: #4b5563; }
.preview h1:first-child, .preview h2:first-child, .preview h3:first-child { margin-top: 0; }
.preview p { margin: 0 0 .9em; }
.preview ul, .preview ol { padding-left: 1.6em; margin: 0 0 .9em; }
.preview li { margin: .15em 0; }
.preview blockquote {
  margin: 1em 0; padding: .4em 1em;
  border-left: 3px solid #c7c9d1; color: #4b5563; font-style: italic;
}
.preview hr { border: none; border-top: 1px solid #d9dbe3; margin: 1.4em 0; }
.preview a {
  color: #2563eb; text-decoration: none;
  border-bottom: 1px solid rgba(37,99,235,.35);
}
.preview a:hover { border-bottom-color: #2563eb; }
.preview code {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: .9em; background: #f3f4f8; color: #1a1d24;
  padding: .15em .4em; border-radius: 4px; border: 1px solid #e5e7ee;
}
.preview .code, .preview pre {
  background: #f7f8fb; border: 1px solid #e5e7ee; border-radius: 8px;
  padding: 14px 16px; margin: 1em 0; overflow-x: auto;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px; line-height: 1.6;
}
.preview pre code { background: transparent; border: none; padding: 0; font-size: inherit; }
.preview table { border-collapse: collapse; margin: 1em 0; width: 100%; font-size: .95em; }
.preview table th, .preview table td {
  border: 1px solid #c9cbd4; padding: 8px 12px;
  text-align: left; vertical-align: top;
}
.preview table th { background: #f3f4f8; font-weight: 600; }
.preview img { max-width: 100%; border-radius: 4px; }
.preview .math-display {
  display: block; text-align: center; margin: 1em 0; overflow-x: auto;
}
.preview .math-inline-fb,
.preview .math-display-fb {
  font-family: "Cambria Math", "STIX Two Math", "Latin Modern Math", Georgia, serif;
}
.preview .math-display-fb {
  display: block; text-align: center; padding: .4em 0; font-size: 1.1em;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  gap: 12px; padding: 80px 20px; color: #b6bac4; text-align: center;
}
.empty-state i { font-size: 42px; opacity: .5; }
.empty-state p { margin: 0; font-size: 14px; }

/* -----------------------------------------------------------------
   Toast
   ----------------------------------------------------------------- */
.toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; font-weight: 500; color: var(--text);
  max-width: 380px;
  opacity: 0; transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: auto;
}
.toast-item.show { opacity: 1; transform: translateY(0); }
.toast-item i { font-size: 16px; flex: none; }
.toast-info    { border-left: 3px solid var(--accent); }
.toast-info i    { color: var(--accent); }
.toast-success { border-left: 3px solid var(--success); }
.toast-success i { color: var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-error i   { color: var(--danger); }
.toast-warn    { border-left: 3px solid #f59e0b; }
.toast-warn i    { color: #f59e0b; }

/* -----------------------------------------------------------------
   Focus
   ----------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =================================================================
   MOBILE / NARROW — stack the panes, let the page scroll.
   ================================================================= */
@media (max-width: 1024px) {

  html {
    height: auto;
    overflow: auto;
  }
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
    display: block;
  }

  .app-header {
    position: sticky;
    top: 0;
    flex: none;
  }
  .app-header-inner {
    padding: 10px 14px;
  }

  .app-main {
    display: block;
    min-height: 0;
    padding: 14px 14px 40px;
    overflow: visible;
    max-width: none;
  }

  .app-grid {
    display: block;
    min-height: 0;
    overflow: visible;
  }

  .pane {
    display: block;
    min-height: 0;
    margin-bottom: 14px;
    overflow: visible;
  }
  .pane:last-child { margin-bottom: 0; }

  .pane-editor .pane-card,
  .pane-preview .pane-card {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    height: 520px;
    overflow: hidden;
  }

  .analysis-strip {
    max-height: none;
    height: auto;
  }
  .analysis-inner {
    flex-wrap: wrap;
    overflow: visible;
  }
}

/* -----------------------------------------------------------------
   Small phones
   ----------------------------------------------------------------- */
@media (max-width: 600px) {
  .app-brand-text small { display: none; }
  .preview-paper { padding: 22px 20px; }
  .pane-head { padding: 8px 10px; }
  .pane-foot { padding: 8px 10px; }
  .meta-right .btn { padding: 6px 10px; font-size: 12px; }
  .toast-host { left: 12px; right: 12px; bottom: 12px; }
  .toast-item { max-width: none; }

  .pane-editor .pane-card,
  .pane-preview .pane-card {
    height: 460px;
  }
}

/* =================================================================
   Settings drawer (right slide-out)
   ================================================================= */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,12,20,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 100;
}
.settings-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
@supports (backdrop-filter: blur(2px)) {
  .settings-backdrop {
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 380px;
  max-width: 92vw;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(20,24,40,.18);
  z-index: 101;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  display: flex;
  flex-direction: column;
}
.settings-drawer.open {
  transform: translateX(0);
}

.settings-drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-pane-head);
}
.settings-drawer-head strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.settings-drawer-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 16px 28px;
}
.settings-drawer-body::-webkit-scrollbar { width: 10px; }
.settings-drawer-body::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 10px;
  border: 3px solid var(--bg-elevated); background-clip: padding-box;
}

.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-child { border-bottom: none; }

.settings-section h6 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}
.settings-note strong {
  color: var(--text);
  font-weight: 600;
}

/* -----------------------------------------------------------------
   Full-row toggle with title + description
   ----------------------------------------------------------------- */
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 10px;
  margin: 2px -10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.toggle-row:hover { background: var(--bg-muted); }

.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-row .toggle-track {
  flex: none;
  margin-top: 3px;
}

.toggle-row .toggle-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1 1 auto;
}

.toggle-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.toggle-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.toggle-desc code {
  font-family: var(--font-mono);
  font-size: .9em;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--bg-muted);
  color: var(--text);
}

/* -----------------------------------------------------------------
   Toggle switch — base track + thumb
   (Applies to both .toggle and .toggle-row contexts)
   ----------------------------------------------------------------- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
  -webkit-user-select: none;
  transition: color .15s ease;
}
.toggle:hover { color: var(--text); }

.toggle input,
.toggle-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--bg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  flex: none;
  transition: background .15s ease, border-color .15s ease;
}
.toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s ease;
}

/* Checked state — accent track + thumb slid to the right. */
.toggle input:checked + .toggle-track,
.toggle-row input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-track .toggle-thumb,
.toggle-row input:checked + .toggle-track .toggle-thumb {
  transform: translateX(14px);
}

/* Title color feedback when the switch is on. */
.toggle input:checked ~ .toggle-label {
  color: var(--text);
  font-weight: 500;
}
.toggle-row input:checked ~ .toggle-text .toggle-title {
  color: var(--accent);
  font-weight: 600;
}

/* Keyboard focus ring on the visible track. */
.toggle input:focus-visible + .toggle-track,
.toggle-row input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dark-theme thumb tuning. */
[data-bs-theme="dark"] .toggle-thumb {
  background: #cfd2da;
}
[data-bs-theme="dark"] .toggle input:checked + .toggle-track .toggle-thumb,
[data-bs-theme="dark"] .toggle-row input:checked + .toggle-track .toggle-thumb {
  background: #ffffff;
}

/* -----------------------------------------------------------------
   Title input (pane header + drawer)
   ----------------------------------------------------------------- */
.title-input {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  width: 130px;
  outline: none;
  transition: background .15s ease;
}
.title-input:hover  { background: var(--bg-muted); }
.title-input:focus  { background: var(--bg-muted); }
.title-input::placeholder { color: var(--text-faint); }


/* -----------------------------------------------------------------
   Drawer fields (labelled text inputs and selects)
   ----------------------------------------------------------------- */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input::placeholder { color: var(--text-faint); }
.field-input:hover  { border-color: var(--border-strong); }
.field-input:focus  {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-10);
}

.field-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-faint);
}

.field-group { margin-top: 8px; }

.is-hidden { display: none !important; }

select.field-input {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 34px;
  cursor: pointer;
}
[data-bs-theme="dark"] select.field-input {
  background-image:
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239ba3b4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
}
select.field-input option {
  background: var(--bg-elevated);
  color: var(--text);
}

/* Small phones: full-width drawer */
@media (max-width: 480px) {
  .settings-drawer { width: 100vw; max-width: 100vw; }
}

/* -----------------------------------------------------------------
   About links (settings drawer)
   ----------------------------------------------------------------- */
.about-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.about-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.about-link:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
}
.about-link > i:first-child {
  font-size: 16px;
  color: var(--accent);
  flex: none;
}
.about-link .about-link-ext {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: auto;
  flex: none;
}
.about-link:hover .about-link-ext { color: var(--text-muted); }

/* =================================================================
   Header nav (Home / Features / How it works)
   ================================================================= */
.app-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.app-nav-link:hover {
  background: var(--bg-muted);
  color: var(--text);
}
.app-nav-link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Hide primary nav under 720px; brand link still goes home. */
@media (max-width: 720px) {
  .app-nav { display: none; }
}

/* =================================================================
   Static content pages (Features, How it works)
   ================================================================= */
.page-main {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  width: 100%;
  background: var(--bg);
}
.page-main::-webkit-scrollbar { width: 10px; }
.page-main::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 10px;
  border: 3px solid transparent; background-clip: padding-box;
}

.page-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 22px 96px;
}

.page-hero {
  text-align: center;
  padding: 24px 0 40px;
}

.page-hero .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid var(--accent-30);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.page-hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 18px;
  color: var(--text);
}

.page-hero .lede {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
}
.page-hero .lede code {
  font-family: var(--font-mono);
  font-size: .9em;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text);
}

.page-section {
  margin-top: 56px;
}

.page-section h2 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--text);
}

.page-section .section-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 24px;
  max-width: 640px;
}

/* -----------------------------------------------------------------
   Feature grid
   ----------------------------------------------------------------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, border-color .2s ease, transform .15s ease;
}
.feature-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
  flex: none;
}

.feature-card h3 {
  font-size: 0.98rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.005em;
}

.feature-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}

.feature-card code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

/* -----------------------------------------------------------------
   Pipeline diagram (How it works)
   ----------------------------------------------------------------- */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 18px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.pipeline-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  flex: none;
}
.pipeline-step .num {
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}

.pipeline-arrow {
  color: var(--text-faint);
  font-size: 12px;
  flex: none;
  padding: 0 2px;
}

/* -----------------------------------------------------------------
   Numbered step cards
   ----------------------------------------------------------------- */
.steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 18px;
  padding: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 6px 14px -6px var(--accent);
  flex: none;
}

.step-body h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.005em;
}

.step-body .what {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

.step-body .why {
  margin: 0;
  padding: 11px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-muted);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.step-body .why strong {
  color: var(--accent);
  font-weight: 600;
  margin-right: 4px;
}

.step-body code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.step-body .why code {
  background: var(--bg-elevated);
}

/* -----------------------------------------------------------------
   Closing CTA
   ----------------------------------------------------------------- */
.page-cta {
  margin-top: 64px;
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.page-cta h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.page-cta p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.page-cta .btn-primary-gradient {
  padding: 10px 22px;
  font-size: 14px;
  text-decoration: none;
}

/* -----------------------------------------------------------------
   Static pages — mobile
   ----------------------------------------------------------------- */
@media (max-width: 1024px) {
  .page-main {
    flex: none;
    min-height: 0;
    overflow: visible;
  }
  .page-inner {
    padding: 24px 16px 60px;
  }
  .page-hero { padding: 8px 0 24px; }
  .page-section { margin-top: 40px; }
  .page-cta { margin-top: 40px; padding: 28px 18px; }
}

@media (max-width: 600px) {
  .step {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px;
  }
  .pipeline { padding: 14px; }
}

/* =================================================================
   Changelog page
   ================================================================= */
.release-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.release {
  padding: 22px 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.release-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.release-head h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
  color: var(--text);
}
.release-head time {
  font-size: 12.5px;
  color: var(--text-muted);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.release-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.release-list-items li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.release-list-items code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
}
.release-list-items a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-30);
}

.tag {
  display: inline-block;
  flex: none;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}
.tag-new  { background: var(--accent-soft); color: var(--accent); }
.tag-fix  { background: rgba(239,68,68,.12); color: #ef4444; }
.tag-perf { background: rgba(16,185,129,.14); color: #059669; }

/* =================================================================
   Prose (About, Privacy)
   ================================================================= */
.prose {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-muted);
  margin: 0 0 14px;
  max-width: 720px;
}
.prose code,
.prose-list code,
.prose-note code {
  font-family: var(--font-mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.prose-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
}
.prose-list li {
  position: relative;
  padding-left: 22px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}
.prose-list li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .55;
}

.prose-note {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-faint);
  max-width: 720px;
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}
.prose-note a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-30);
}

/* =================================================================
   Profile card (About)
   ================================================================= */
.profile-card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 22px;
  align-items: start;
  padding: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  max-width: 720px;
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 72px; height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 28px;
  box-shadow: 0 10px 24px -10px var(--accent);
}

.profile-body h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.005em;
}
.profile-body p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.profile-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.profile-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.profile-links a:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.profile-links a i { color: var(--accent); }

/* =================================================================
   404 page
   ================================================================= */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px 40px;
}

.error-code {
  font-size: clamp(4rem, 12vw, 7rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

.error-page h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.error-page .lede {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 0 28px;
}

.error-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.error-actions .btn-ghost,
.error-actions .btn-primary-gradient {
  text-decoration: none;
}

/* =================================================================
   Responsive — About profile & 404
   ================================================================= */
@media (max-width: 600px) {
  .profile-card {
    grid-template-columns: 1fr;
    gap: 16px;
    text-align: center;
    padding: 20px;
  }
  .profile-avatar { margin: 0 auto; }
  .profile-links { justify-content: center; }

  .release { padding: 18px; }
  .release-head { flex-direction: column; gap: 4px; }
}

/* =================================================================
   App footer
   Compact single-row footer shown on every page.
   Fits below the app studio without stealing meaningful height.
   ================================================================= */
.app-footer {
  flex: 0 0 auto;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

.app-footer-inner {
  max-width: 1800px;
  margin: 0 auto;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.app-footer-copy {
  white-space: nowrap;
  color: var(--text-faint);
}

.app-footer-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.app-footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color .15s ease, background .15s ease;
}
.app-footer-nav a:hover {
  color: var(--text);
  background: var(--bg-muted);
}

.app-footer-sep {
  color: var(--text-faint);
  opacity: .55;
  user-select: none;
  -webkit-user-select: none;
}

.app-footer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.app-footer-version {
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-size: 11.5px;
  line-height: 1.5;
}

.app-footer-social {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: color .15s ease, background .15s ease;
}
.app-footer-social:hover {
  color: var(--text);
  background: var(--bg-muted);
}

/* -----------------------------------------------------------------
   Footer — mobile
   Stack the three groups and center-align everything.
   ----------------------------------------------------------------- */
@media (max-width: 768px) {
  .app-footer-inner {
    padding: 12px 14px;
    justify-content: center;
    text-align: center;
    gap: 10px;
  }
  .app-footer-copy,
  .app-footer-meta {
    justify-content: center;
    width: 100%;
  }
  .app-footer-nav {
    justify-content: center;
    width: 100%;
    order: -1;         /* nav first on narrow screens */
  }
}