/* Design system.
   Plain CSS, no build step. Light and dark themes share one set of tokens. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e7ef;
  --border-strong: #cdd5e3;
  --text: #0f172a;
  --muted: #566176;
  --faint: #5f6a7f;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-contrast: #ffffff;
  --primary-soft: #eef0ff;
  --accent-text: #4f46e5;      /* primary-colored text and links: must stay readable on every surface */
  --ring: rgba(79, 70, 229, 0.35);

  --success: #047857; --success-bg: #ecfdf5; --success-border: #a7f3d0;
  --warning: #92400e; --warning-bg: #fffbeb; --warning-border: #fde68a;
  --danger:  #b91c1c; --danger-bg:  #fef2f2; --danger-border:  #fecaca;
  --info:    #1e40af; --info-bg:    #eff6ff; --info-border:    #bfdbfe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 10px 28px -14px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 18px 40px -16px rgba(15, 23, 42, 0.3);

  color-scheme: light;
  --hero-glow: rgba(99, 102, 241, 0.16);
  --tone: var(--primary);
  --radius: 16px;
  --radius-sm: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #131a2e;
  --surface-2: #1a2340;
  --border: #25304d;
  --border-strong: #35426a;
  --text: #e8ebf5;
  --muted: #a3adc2;
  --faint: #8b96b0;

  --primary: #5b5ef0;
  --primary-hover: #4e51e8;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #a5b4fc;
  --ring: rgba(129, 140, 248, 0.45);

  --success: #6ee7b7; --success-bg: rgba(16, 185, 129, 0.12); --success-border: rgba(16, 185, 129, 0.35);
  --warning: #fcd34d; --warning-bg: rgba(245, 158, 11, 0.12); --warning-border: rgba(245, 158, 11, 0.35);
  --danger:  #fca5a5; --danger-bg:  rgba(239, 68, 68, 0.12);  --danger-border:  rgba(239, 68, 68, 0.35);
  --info:    #93c5fd; --info-bg:    rgba(59, 130, 246, 0.12); --info-border:    rgba(59, 130, 246, 0.35);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 20px 44px -16px rgba(0, 0, 0, 0.7);
  --hero-glow: rgba(99, 102, 241, 0.22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1a2340;
    --border: #25304d;
    --border-strong: #35426a;
    --text: #e8ebf5;
    --muted: #a3adc2;
    --faint: #8b96b0;

    --primary: #5b5ef0;
    --primary-hover: #4e51e8;
    --primary-soft: rgba(99, 102, 241, 0.16);
    --accent-text: #a5b4fc;
    --ring: rgba(129, 140, 248, 0.45);

    --success: #6ee7b7; --success-bg: rgba(16, 185, 129, 0.12); --success-border: rgba(16, 185, 129, 0.35);
    --warning: #fcd34d; --warning-bg: rgba(245, 158, 11, 0.12); --warning-border: rgba(245, 158, 11, 0.35);
    --danger:  #fca5a5; --danger-bg:  rgba(239, 68, 68, 0.12);  --danger-border:  rgba(239, 68, 68, 0.35);
    --info:    #93c5fd; --info-bg:    rgba(59, 130, 246, 0.12); --info-border:    rgba(59, 130, 246, 0.35);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 20px 44px -16px rgba(0, 0, 0, 0.7);
    --hero-glow: rgba(99, 102, 241, 0.22);
  }
}

/* Category colors. Cards, tags and icon tiles pick one with a tone-* class.
   Dark theme uses lighter shades so text stays readable. */
.tone-career    { --tone: #225bd8; }
.tone-content   { --tone: #bc2266; }
.tone-marketing { --tone: #9b4e08; }
.tone-work      { --tone: #047854; }
.tone-writing   { --tone: #0a766d; }
.tone-documents { --tone: #7c3aed; }
:root[data-theme="dark"] .tone-career    { --tone: #7ab0ff; }
:root[data-theme="dark"] .tone-content   { --tone: #f58ac0; }
:root[data-theme="dark"] .tone-marketing { --tone: #fbb454; }
:root[data-theme="dark"] .tone-work      { --tone: #4fd8a4; }
:root[data-theme="dark"] .tone-writing   { --tone: #5eead4; }
:root[data-theme="dark"] .tone-documents { --tone: #b79cff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tone-career    { --tone: #7ab0ff; }
  :root:not([data-theme="light"]) .tone-content   { --tone: #f58ac0; }
  :root:not([data-theme="light"]) .tone-marketing { --tone: #fbb454; }
  :root:not([data-theme="light"]) .tone-work      { --tone: #4fd8a4; }
  :root:not([data-theme="light"]) .tone-writing   { --tone: #5eead4; }
  :root:not([data-theme="light"]) .tone-documents { --tone: #b79cff; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { flex-shrink: 0; }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--primary); color: var(--primary-contrast);
  padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600;
  transition: top 0.15s;
}
.skip-link:focus { top: 12px; }
.main:focus { outline: none; }

.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.main { flex: 1; padding-block: 32px 72px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.08rem; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #ec4899 100%);
  box-shadow: 0 4px 12px -4px rgba(99, 102, 241, 0.6);
}
.nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  padding: 8px 14px; border-radius: 999px; font-size: 0.93rem; font-weight: 500; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { color: var(--accent-text); background: var(--primary-soft); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Flash messages ---------- */
.flashes { display: grid; gap: 10px; margin-bottom: 20px; }
.flash {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--info-border); border-radius: var(--radius-sm);
  background: var(--info-bg); color: var(--info); font-size: 0.95rem; line-height: 1.5;
}
.flash svg { margin-top: 2px; }
.flash-text { flex: 1; }
.flash-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.flash-error   { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
.flash-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.flash-close { border: 0; background: transparent; color: inherit; opacity: 0.7; padding: 2px; border-radius: 6px; line-height: 0; }
.flash-close:hover { opacity: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 0.95rem; box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--accent-text); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: 1rem; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.86rem; gap: 6px; }
.btn[disabled] { opacity: 0.75; cursor: progress; }
.btn-icon { display: inline-flex; align-items: center; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .btn-icon { display: none; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Home: hero ---------- */
.hero { position: relative; text-align: center; padding: 28px 0 8px; }
.hero::before {
  content: ""; position: absolute; inset: -40px 0 auto; height: 360px; z-index: -1;
  background: radial-gradient(60% 70% at 50% 0%, var(--hero-glow), transparent 70%);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--primary-soft); color: var(--accent-text); font-size: 0.82rem; font-weight: 600;
}
.hero h1 {
  margin: 18px auto 0; max-width: 18ch; font-size: clamp(2rem, 5.2vw, 3.3rem);
  line-height: 1.1; letter-spacing: -0.03em; font-weight: 800;
}
.gradient-text {
  background: linear-gradient(120deg, #4f46e5, #9333ea 55%, #db2777);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { margin: 16px auto 0; max-width: 56ch; font-size: 1.1rem; color: var(--muted); }
.hero-points { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; margin-top: 22px; color: var(--muted); font-size: 0.92rem; }
.hero-points li { display: inline-flex; align-items: center; gap: 7px; }
.hero-points svg { color: var(--success); }

/* ---------- Home: toolbar and grid ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; margin: 40px 0 22px; }
.search { position: relative; flex: 1 1 280px; max-width: 420px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input {
  width: 100%; height: 46px; padding: 0 44px 0 42px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--ring); }
.kbd {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px;
  padding: 0 7px; font-size: 0.75rem; color: var(--faint); background: var(--surface-2);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--muted); font-size: 0.9rem; font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--accent-text); color: var(--primary-contrast); }

.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card-link {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--tone) 45%, var(--border)); }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.tile {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; font-size: 1.5rem; line-height: 1;
  background: color-mix(in srgb, var(--tone) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tone) 22%, var(--surface));
}
.tag {
  padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, var(--surface));
}
.card-link :is(h2, h3) { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; }
.card-link p { color: var(--muted); font-size: 0.93rem; flex: 1; }
.card-cta { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--tone); }
.card-cta svg { transition: transform 0.2s; }
.card-link:hover .card-cta svg { transform: translateX(4px); }
.results-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; }
.empty { text-align: center; padding: 56px 20px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------- Inner pages ---------- */
.breadcrumb { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; font-size: 0.9rem; color: var(--faint); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent-text); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--text); font-weight: 500; }

.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(1.5rem, 3.4vw, 2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.page-head .lead { color: var(--muted); margin-top: 4px; }
.page-head .tile { width: 56px; height: 56px; font-size: 1.75rem; border-radius: 16px; }
.page-head-main { flex: 1; min-width: 0; }

.layout { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.layout-result { grid-template-columns: 300px minmax(0, 1fr); }
.stack { display: grid; gap: 18px; }
.sticky { position: sticky; top: 88px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 26px; }
.card-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 700; margin-bottom: 14px; }

/* ---------- Form ---------- */
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.field { grid-column: 1 / -1; margin-bottom: 22px; }
.field.is-half { grid-column: auto; }
@media (max-width: 560px) { .field.is-half { grid-column: 1 / -1; } }
.field label { display: flex; align-items: baseline; gap: 8px; font-weight: 600; font-size: 0.93rem; margin-bottom: 7px; }
.req { color: var(--danger); }
.opt { font-weight: 500; font-size: 0.78rem; color: var(--faint); }
.input {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.55; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--ring); }
.input:user-invalid { border-color: var(--danger); }
option, optgroup { background-color: var(--surface); color: var(--text); }
/* Dropdown: custom arrow drawn with gradients so it follows the theme colors */
select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 15px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 0.82rem; color: var(--faint); }
.counter { white-space: nowrap; }
.counter.is-near { color: var(--warning); font-weight: 600; }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 6px; }
.form-note { color: var(--faint); font-size: 0.85rem; }

/* File picker */
.file-input { padding: 9px 12px; cursor: pointer; }
.file-input::file-selector-button {
  margin-right: 14px; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--primary-soft); border-color: var(--accent-text); color: var(--accent-text); }
.privacy-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 18px; font-size: 0.82rem; color: var(--faint); line-height: 1.5; }
.privacy-note svg { margin-top: 2px; }

/* ---------- Sidebar cards ---------- */
.steps { display: grid; gap: 14px; counter-reset: step; }
.steps li { position: relative; padding-left: 38px; font-size: 0.93rem; color: var(--muted); counter-increment: step; }
.steps li strong { display: block; color: var(--text); font-size: 0.95rem; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.8rem; font-weight: 700;
  background: var(--primary-soft); color: var(--accent-text);
}
.usage-text { display: flex; justify-content: space-between; font-size: 0.93rem; margin-bottom: 10px; }
.usage-text strong { font-weight: 700; }
.segments { display: flex; gap: 5px; }
.segment { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.segment.is-used { background: var(--primary); border-color: var(--accent-text); }
.usage-hint { margin-top: 10px; font-size: 0.82rem; color: var(--faint); }

/* ---------- Result ---------- */
.inputs { display: grid; gap: 14px; }
.inputs dt { font-size: 0.78rem; font-weight: 600; color: var(--faint); margin-bottom: 2px; }
.inputs dd { font-size: 0.93rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.inputs .is-empty { color: var(--faint); }
.output-card { overflow: hidden; }
.output-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.output-meta { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.95rem; }
.output-stats { font-weight: 500; font-size: 0.82rem; color: var(--faint); }
.output-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.output {
  padding: 26px; font-size: 1.02rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font); max-height: none;
}
.result-actions { display: grid; gap: 10px; }
.result-actions .btn { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ---------- Chat with PDF ---------- */
.layout-chat { grid-template-columns: 300px minmax(0, 1fr); }
.doc-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.doc-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, var(--surface)); }
.doc-name { font-weight: 600; font-size: 0.95rem; overflow-wrap: anywhere; line-height: 1.35; }
.doc-meta { display: grid; gap: 8px; margin-bottom: 16px; font-size: 0.88rem; }
.doc-meta div { display: flex; justify-content: space-between; gap: 12px; }
.doc-meta dt { color: var(--faint); }
.doc-meta dd { font-weight: 600; margin: 0; }
.doc-new { width: 100%; }
.col-doc { position: sticky; top: 88px; }

.chat { display: flex; flex-direction: column; min-height: 560px; }
.chat-log { flex: 1; min-height: 320px; max-height: min(62vh, 640px); overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-bubble { max-width: min(82%, 640px); padding: 11px 15px; border-radius: 16px; line-height: 1.6; font-size: 0.97rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-assistant .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg-user .msg-bubble { background: var(--primary); color: var(--primary-contrast); border-bottom-right-radius: 5px; }
.msg-error .msg-bubble { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.is-typing .msg-bubble { display: flex; gap: 5px; align-items: center; padding: 15px 16px; }
.is-typing .msg-bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite ease-in-out; }
.is-typing .msg-bubble span:nth-child(2) { animation-delay: 0.2s; }
.is-typing .msg-bubble span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 22px 14px; }
.chat-form { display: flex; align-items: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
textarea.chat-input { flex: 1; min-height: 46px; max-height: 160px; height: 46px; resize: none; padding: 11px 14px; line-height: 1.5; }
.chat-form .btn { min-height: 46px; }
.chat-hint { padding: 10px 22px 16px; font-size: 0.8rem; color: var(--faint); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.chat-form + .chat-hint { margin-top: -1px; }

/* ---------- Sections, landing content and articles ---------- */
.section { margin-top: 56px; }
.section h2, .prose h2 { font-size: clamp(1.3rem, 2.6vw, 1.6rem); letter-spacing: -0.02em; line-height: 1.25; font-weight: 700; margin-bottom: 14px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin-bottom: 0; }
.section-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.92rem; color: var(--accent-text); }
.section-link:hover { text-decoration: underline; }
.section-note { color: var(--muted); font-size: 0.93rem; margin: -6px 0 14px; }
.home-section { margin-top: 72px; }
.landing { margin-top: 24px; border-top: 1px solid var(--border); }
.two-col { display: grid; gap: 40px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.checklist { display: grid; gap: 12px; }
.checklist li { position: relative; padding-left: 30px; color: var(--muted); }
.checklist li::before {
  content: ""; position: absolute; left: 0; top: 0.35em; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 12.5 10.5 17 18 8'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.numbered { display: grid; gap: 14px; counter-reset: n; }
.numbered li { position: relative; padding-left: 38px; color: var(--muted); counter-increment: n; }
.numbered li::before { content: counter(n); position: absolute; left: 0; top: 0.1em; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; background: var(--primary); color: var(--primary-contrast); }
.example { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 0; overflow: hidden; }
.example-in { padding: 22px; background: var(--surface-2); border-right: 1px solid var(--border); }
.example-out { padding: 22px; }
.example-output { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; font-size: 0.97rem; }
.example-chat { grid-column: 1 / -1; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.faq { display: grid; gap: 10px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.faq summary { cursor: pointer; padding: 16px 18px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--accent-text); flex: none; }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { padding: 0 18px 18px; color: var(--muted); }
.how-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.how-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); }
.how-num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--primary-contrast); font-weight: 700; margin-bottom: 14px; }
.how-step h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.how-step p { color: var(--muted); font-size: 0.93rem; }
.meta-small { font-size: 0.8rem; color: var(--faint); }
.guide-card .tag { background: color-mix(in srgb, var(--tone) 12%, var(--surface)); }
.tone-ai-tips { --tone: #066b84; }
:root[data-theme="dark"] .tone-ai-tips { --tone: #67e8f9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tone-ai-tips { --tone: #67e8f9; } }

.page-intro { max-width: 720px; margin-bottom: 8px; }
.page-intro h1, .article-head h1 { font-size: clamp(1.9rem, 4.4vw, 2.6rem); line-height: 1.15; letter-spacing: -0.03em; font-weight: 800; }
.page-intro .lead, .article-head .lead { margin-top: 12px; color: var(--muted); font-size: 1.1rem; }
.article-head { max-width: 760px; margin-bottom: 28px; }
.article-head .tag { display: inline-block; margin-bottom: 12px; color: var(--tone); }
.article-meta { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; color: var(--faint); font-size: 0.88rem; }
.article-layout { display: grid; gap: 40px; grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
.page-article .article-layout, .page-article { max-width: 760px; }
.toc { position: sticky; top: 88px; }
.toc ol { display: grid; gap: 10px; font-size: 0.9rem; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent-text); text-decoration: underline; }
.prose { max-width: 70ch; font-size: 1.06rem; line-height: 1.8; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 2em; scroll-margin-top: 88px; }
.prose h3 { margin-top: 1.6em; font-size: 1.15rem; font-weight: 700; scroll-margin-top: 88px; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.4em; display: grid; gap: 0.5em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li::marker { color: var(--faint); }
.prose a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose strong { font-weight: 700; }
.prose blockquote { margin-left: 0; padding: 4px 0 4px 18px; border-left: 4px solid var(--primary-soft); color: var(--muted); }
.prose code { padding: 2px 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.9em; }
.prose pre { padding: 16px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; white-space: pre-wrap; }
.prose pre code { padding: 0; border: 0; background: none; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th { font-weight: 700; background: var(--surface-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin-block: 2em; }
.cta-box { margin-top: 48px; padding: 26px; border-radius: var(--radius); background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 40%, var(--surface))); border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border)); }
.cta-box h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.cta-box p { color: var(--muted); margin-bottom: 16px; }
.cta-links { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Error pages ---------- */
.error-page { max-width: 560px; margin: 40px auto 0; text-align: center; }
.error-code { font-size: clamp(4.5rem, 16vw, 7.5rem); line-height: 1; font-weight: 800; letter-spacing: -0.04em; margin-bottom: 8px; }
.error-page h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; letter-spacing: -0.02em; }
.error-page .lead { margin-top: 12px; color: var(--muted); font-size: 1.05rem; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 28px; }
.error-ref { margin-top: 28px; font-size: 0.85rem; color: var(--faint); }
.error-ref code { padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); user-select: all; }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed; z-index: 200; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: grid; gap: 10px; width: min(92vw, 380px); pointer-events: none;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 0.93rem; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease-out;
}
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-grid { display: grid; gap: 32px; grid-template-columns: 1.6fr repeat(3, 1fr); padding-block: 44px 28px; }
.footer-about p { margin-top: 12px; max-width: 34ch; color: var(--muted); font-size: 0.92rem; }
.footer-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 700; margin-bottom: 12px; }
.site-footer ul li { margin-bottom: 8px; }
.site-footer ul a { color: var(--muted); font-size: 0.92rem; }
.site-footer ul a:hover { color: var(--accent-text); text-decoration: underline; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 20px 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.86rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .toc { position: static; }
  .two-col { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .how-grid { grid-template-columns: minmax(0, 1fr); }
  .example { grid-template-columns: minmax(0, 1fr); }
  .example-in { border-right: 0; border-bottom: 1px solid var(--border); }
  .layout, .layout-result, .layout-chat { grid-template-columns: minmax(0, 1fr); }
  .col-doc { position: static; order: 2; }
  .sticky { position: static; }
  .layout-result .col-inputs { order: 2; }
}
@media (max-width: 560px) {
  .footer-grid { grid-template-columns: minmax(0, 1fr); padding-block: 32px 16px; }
  .section { margin-top: 44px; }
  .brand-name { font-size: 1rem; }
  .nav-link { padding: 8px 10px; }
  .main { padding-block: 22px 56px; }
  .card-pad { padding: 20px; }
  .page-head { align-items: flex-start; }
  .page-head .tile { width: 48px; height: 48px; font-size: 1.5rem; }
  .output { padding: 20px; }
  .chat-log { padding: 16px; }
  .chat-suggest { padding-inline: 16px; }
  .msg-bubble { max-width: 92%; }
  .chat-send-label { display: none; }
  .kbd { display: none; }
  .search input { padding-right: 16px; }
  .hero-points { flex-direction: column; align-items: center; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
