:root {
  --bg: #f5f0e8;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --ink: #2d2926;
  --muted: #6e655e;
  --line: rgba(67, 54, 42, 0.14);
  --accent: #8d694c;
  --accent-strong: #62462f;
  --danger: #8a3f34;
  --safe: #416a59;
  --shadow: 0 24px 80px rgba(72, 52, 37, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(141, 105, 76, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.86), transparent 28rem),
    linear-gradient(135deg, #f5efe6 0%, #efe2d2 48%, #e8d7c5 100%);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: none; box-shadow: var(--focus); }

.app-shell { display: grid; grid-template-columns: 320px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.74);
  backdrop-filter: blur(18px);
  display: flex; flex-direction: column; gap: 26px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 16px;
  display: grid; place-items: center; color: var(--accent-strong); font-size: 26px;
  background: linear-gradient(145deg, #fff, #efe2d2);
}
.brand h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.nav-list { display: grid; gap: 8px; }
.nav-link {
  border: 1px solid transparent; background: transparent; color: var(--muted); text-align: left;
  padding: 12px 14px; border-radius: 14px; transition: 0.16s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.58); color: var(--ink); }
.nav-link.active { background: var(--surface-strong); border-color: var(--line); color: var(--ink); box-shadow: 0 10px 26px rgba(72,52,37,0.08); }
.sidebar-card { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,0.48); }
.sidebar-card.push { margin-top: auto; }
.sidebar-card p { color: var(--muted); font-size: 13px; margin: 4px 0 12px; line-height: 1.45; }
.sidebar-footer { font-size: 12px; color: var(--muted); line-height: 1.4; }
.sidebar-footer p { margin: 0 0 5px; }
.switch-row, .consent-box { display: flex; gap: 10px; align-items: flex-start; line-height: 1.45; }
.switch-row input, .consent-box input { margin-top: 3px; accent-color: var(--accent); }
.main { padding: 54px; overflow: auto; }
.view { display: none; animation: fadeIn 0.22s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }
.glass, .panel, .narrow-card { border: 1px solid var(--line); background: rgba(255,250,242,0.78); box-shadow: var(--shadow); border-radius: var(--radius-lg); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) 440px; gap: 28px; align-items: stretch; }
.hero-card, .narrow-card, .summary-card, .door-card { padding: clamp(28px, 4vw, 54px); }
.narrow-card { max-width: 980px; margin: 0 auto; }
.panel { padding: 24px; }
.stack { display: grid; gap: 16px; align-content: center; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-strong); font-size: 12px; font-weight: 700; margin: 0 0 12px; }
h2 { margin: 0 0 18px; font-size: clamp(34px, 6vw, 68px); line-height: 0.95; letter-spacing: -0.055em; }
.narrow-card h2, .page-header h2, .summary-card h2, .door-card h2 { font-size: clamp(30px, 4vw, 48px); }
h3 { margin: 0 0 10px; font-size: 18px; }
p { line-height: 1.6; }
.lead { color: var(--muted); font-size: 20px; max-width: 72ch; }
.lead.small { font-size: 16px; }
.notice { margin: 22px 0; padding: 16px 18px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,0.64); color: var(--muted); line-height: 1.55; }
.notice.soft { border-color: rgba(65, 106, 89, 0.18); }
.notice.risk { border-color: rgba(138,63,52,0.28); background: rgba(255,239,236,0.68); color: #5e3029; }
.notice.safe { border-color: rgba(65,106,89,0.24); background: rgba(237,248,243,0.68); color: #315244; }
.button-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.button-row.compact { margin-top: 12px; gap: 8px; }
.button-row.compact .secondary, .button-row.compact .ghost { padding: 9px 12px; font-size: 13px; }
.primary, .secondary, .ghost, .text-button {
  border: 1px solid var(--line); border-radius: 999px; padding: 13px 18px; transition: 0.16s ease; font-weight: 650;
}
.primary { background: var(--accent-strong); color: #fff7ed; border-color: var(--accent-strong); }
.primary:hover { transform: translateY(-1px); background: #4f3724; }
.secondary { background: rgba(255,255,255,0.7); color: var(--ink); }
.secondary:hover, .ghost:hover { background: var(--surface-strong); transform: translateY(-1px); }
.secondary.danger { color: var(--danger); }
.ghost, .text-button { background: transparent; color: var(--muted); }
.text-button { border: 0; padding: 6px 0; border-radius: 6px; }
.mini-step { display: grid; grid-template-columns: 42px 1fr; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,0.42); }
.mini-step.current { background: rgba(255,255,255,0.78); }
.mini-step span { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: var(--accent-strong); background: #f4e8da; font-weight: 800; }
.mini-step p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 26px 0; }
.check-list, .x-list { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.8; }
.consent-box { border: 1px solid var(--line); background: rgba(255,255,255,0.55); padding: 16px; border-radius: 16px; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 26px; }
.choice-card { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.56); border-radius: 20px; padding: 20px; min-height: 140px; transition: 0.16s ease; }
.choice-card:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 15px 35px rgba(72,52,37,0.1); }
.choice-card strong { display: block; font-size: 18px; margin-bottom: 8px; }
.choice-card span { display: block; color: var(--muted); line-height: 1.45; }
.progress-row, .page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.progress-track { height: 8px; border-radius: 99px; background: rgba(255,255,255,0.6); overflow: hidden; margin: 8px 0 28px; }
.progress-track div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: inherit; transition: width 0.18s ease; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: rgba(255,255,255,0.78); color: var(--ink); line-height: 1.5; }
.quick-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.quick-tag { border: 1px solid var(--line); background: rgba(255,255,255,0.64); border-radius: 999px; padding: 8px 12px; color: var(--muted); }
.quick-tag.selected { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.summary-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 0.9fr); gap: 26px; align-items: start; }
.summary-list { display: grid; gap: 12px; margin-top: 20px; }
.summary-item { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,0.52); }
.summary-item strong { display: block; margin-bottom: 4px; }
.summary-item p { margin: 0; color: var(--muted); }
.door-card { position: sticky; top: 32px; }
.door-type { display: inline-flex; border: 1px solid var(--line); color: var(--accent-strong); background: rgba(255,255,255,0.62); border-radius: 999px; padding: 7px 11px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800; margin-bottom: 18px; }
.door-card h3 { font-size: 32px; line-height: 1.05; letter-spacing: -0.035em; margin-bottom: 16px; }
.door-meta { display: grid; gap: 12px; margin-top: 18px; }
.door-meta div { border-top: 1px solid var(--line); padding-top: 12px; }
.door-meta strong { display: block; margin-bottom: 4px; }
.door-meta p { margin: 0; color: var(--muted); }
.reflection-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.reflection-choice { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,0.6); border-radius: 16px; padding: 16px; color: var(--ink); }
.reflection-choice.selected { border-color: var(--accent-strong); background: rgba(255,255,255,0.92); box-shadow: var(--focus); }
.search { width: min(320px, 100%); border: 1px solid var(--line); border-radius: 999px; padding: 13px 16px; background: rgba(255,255,255,0.7); }
.library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 24px; }
.library-card, .history-card { border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: rgba(255,250,242,0.74); box-shadow: 0 10px 32px rgba(72,52,37,0.08); }
.library-card h3, .history-card h3 { font-size: 20px; line-height: 1.15; margin: 6px 0 10px; }
.library-card p, .history-card p { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.history-list { display: grid; gap: 14px; margin-top: 24px; }
.empty-state { padding: 36px; border: 1px dashed var(--line); border-radius: 24px; text-align: center; color: var(--muted); background: rgba(255,255,255,0.35); }
.prose p { color: var(--muted); }
.prose h3 { margin-top: 28px; }
.tag { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #f0e1d1; color: var(--accent-strong); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
body.discreet #brandTitle::after { content: ""; }
body.discreet .brand-mark { display: none; }
body.discreet { --accent: #68717a; --accent-strong: #424a52; }
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .hero-grid, .summary-layout, .two-column { grid-template-columns: 1fr; }
  .door-card { position: relative; top: 0; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .main, .sidebar { padding: 22px; }
  .choice-grid, .reflection-options, .library-grid { grid-template-columns: 1fr; }
  h2 { font-size: 38px; }
}

.auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; margin-top: 24px; }
.auth-card { padding: 28px; display: grid; gap: 16px; }
.auth-card h3 { font-size: 28px; letter-spacing: -0.035em; margin-bottom: 4px; }
.auth-card label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; }
.auth-card input[type="email"], .auth-card input[type="password"], .auth-card input[type="text"] {
  width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px;
  background: rgba(255,255,255,0.76); color: var(--ink); font-weight: 500;
}
.auth-check { font-weight: 500 !important; }
.account-status-card .button-row { margin-top: 8px; }
#authMessage:empty { display: none; }
@media (max-width: 900px) { .auth-grid { grid-template-columns: 1fr; } }

.auth-grid.three-card { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.field-hint { min-height: 17px; color: var(--muted); font-size: 12px; font-weight: 500; }
.field-hint.error { color: var(--danger); }
.text-button.left { justify-self: start; text-align: left; }
.reset-form { display: grid; gap: 16px; margin-top: 18px; }
.reset-token-box { border: 1px solid rgba(65,106,89,0.24); background: rgba(237,248,243,0.68); border-radius: 16px; padding: 14px; word-break: break-word; }
.reset-token-box p { margin: 0 0 8px; color: var(--muted); }
.reset-token-box a { color: var(--safe); font-weight: 700; }
.small-muted { font-size: 12px; color: var(--muted); }
@media (max-width: 1180px) { .auth-grid.three-card { grid-template-columns: 1fr; } }

/* v0.10 admin panel */
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.admin-status-grid { display: grid; gap: 10px; }
.connect-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: rgba(255,255,255,0.55); display: grid; gap: 3px; }
.connect-card strong { font-size: 15px; }
.connect-card span { font-weight: 800; }
.connect-card small { color: var(--muted); word-break: break-word; }
.connect-card.ok { border-color: rgba(65,106,89,0.32); background: rgba(237,248,243,0.62); }
.connect-card.warn { border-color: rgba(143,57,47,0.28); background: rgba(255,240,235,0.62); }
.admin-overview { display: grid; gap: 18px; margin-top: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px; }
.stat-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: rgba(255,255,255,0.58); }
.stat-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; }
.stat-card strong { display: block; font-size: 30px; margin-top: 6px; }
.admin-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.admin-table-card { padding: 20px; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; }
.admin-json { padding: 18px; }
.admin-json pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--muted); }
.page-header.tight { margin-top: 28px; }
.ghost.danger { color: var(--danger); }
@media (max-width: 1200px) {
  .admin-grid, .admin-two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
