:root {
  --navy: #102a43;
  --navy-soft: #294860;
  --teal: #0f7c80;
  --teal-bright: #18a6a6;
  --teal-pale: #e8f7f5;
  --gold: #d8a84e;
  --gold-pale: #fff7e5;
  --ink: #182b3a;
  --muted: #667d8f;
  --line: #dce7ec;
  --surface: #ffffff;
  --background: #f4f8fa;
  --danger: #a63333;
  --shadow: 0 18px 45px rgba(16, 42, 67, 0.09);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

.skip-link { position: fixed; top: 10px; left: 10px; z-index: 1000; padding: 10px 14px; background: var(--navy); color: white; border-radius: 10px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.network-banner { position: fixed; inset: 0 0 auto 0; z-index: 1000; padding: 10px 18px; background: var(--gold-pale); border-bottom: 1px solid #ecd395; color: #654b18; text-align: center; font-size: 0.86rem; }
.network-banner:not([hidden]) ~ .app-shell .app-header { top: 39px; }
.network-banner:not([hidden]) ~ .app-shell .app-content { padding-top: 112px; }

.auth-view { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr); background: var(--surface); }
.auth-brand { position: relative; overflow: hidden; padding: clamp(48px, 8vw, 110px); display: flex; flex-direction: column; justify-content: center; background: linear-gradient(145deg, #eef9f8 0%, #f9fcfd 58%, #fff8e9 100%); }
.auth-brand::after { content: ""; position: absolute; width: 540px; height: 540px; border-radius: 50%; border: 1px solid rgba(15,124,128,.18); right: -170px; top: -120px; box-shadow: 0 0 0 70px rgba(15,124,128,.04), 0 0 0 150px rgba(216,168,78,.04); }
.brand-mark { width: 58px; height: 64px; display: flex; gap: 7px; align-items: center; margin-bottom: 26px; }
.brand-mark span { width: 7px; border-radius: 999px; background: var(--teal); display: block; }
.brand-mark span:nth-child(1) { height: 54px; }
.brand-mark span:nth-child(2) { height: 39px; background: var(--gold); }
.brand-mark span:nth-child(3) { height: 25px; background: var(--navy); }
.brand-mark.small { width: 34px; height: 38px; gap: 4px; margin: 0; }
.brand-mark.small span { width: 4px; }
.brand-mark.small span:nth-child(1) { height: 32px; }
.brand-mark.small span:nth-child(2) { height: 24px; }
.brand-mark.small span:nth-child(3) { height: 16px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.auth-brand h1 { position: relative; z-index: 1; margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: clamp(3.3rem, 7vw, 6rem); line-height: .95; }
.brand-subtitle { position: relative; z-index: 1; margin: 22px 0 42px; color: var(--navy-soft); font-size: clamp(1.1rem, 2vw, 1.45rem); }
.brand-benefits { position: relative; z-index: 1; display: grid; gap: 14px; max-width: 580px; }
.brand-benefits div { display: grid; grid-template-columns: 110px 1fr; gap: 18px; align-items: start; padding: 16px 0; border-top: 1px solid rgba(16,42,67,.12); }
.brand-benefits strong { color: var(--navy); }
.brand-benefits span { color: var(--muted); line-height: 1.5; }

.auth-card { width: min(470px, calc(100% - 48px)); margin: auto; padding: 32px; border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); background: var(--surface); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 26px; border-radius: 14px; background: #eef3f5; }
.auth-tab { padding: 11px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 700; }
.auth-tab.is-active { color: var(--navy); background: white; box-shadow: 0 5px 15px rgba(16,42,67,.08); }
.auth-form { display: grid; gap: 18px; }
.auth-form h2, .screen-intro h1, .welcome-row h1 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-weight: 700; }
.auth-form > p { margin: -8px 0 4px; color: var(--muted); }
label { display: grid; gap: 7px; color: var(--navy-soft); font-size: .9rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 48px; border: 1px solid #cbd9df; border-radius: 13px; background: white; color: var(--ink); padding: 12px 14px; outline: none; transition: border-color .2s, box-shadow .2s; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(15,124,128,.12); }
input:disabled { color: var(--muted); background: #f3f6f7; }
.primary-button, .secondary-button, .danger-button { border: 0; border-radius: 13px; min-height: 48px; padding: 12px 18px; font-weight: 800; }
.primary-button { background: var(--teal); color: white; box-shadow: 0 10px 24px rgba(15,124,128,.2); }
.primary-button:hover { background: #0b696d; }
.secondary-button { background: white; color: var(--teal); }
.danger-button { width: 100%; margin-top: 22px; color: var(--danger); background: #fff0f0; border: 1px solid #f0cccc; }
.form-hint { margin: 0 !important; color: var(--muted); font-size: .78rem; font-weight: 500; line-height: 1.5; }
.form-message { padding: 11px 13px; margin-bottom: 14px; border-radius: 11px; background: #fff0f0; color: var(--danger); font-size: .86rem; }
.form-message.success { background: var(--teal-pale); color: #075b5e; }

.app-shell { min-height: 100vh; }
.app-header { position: fixed; inset: 0 0 auto 0; z-index: 100; height: 74px; padding: 11px max(20px, calc((100vw - 1120px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(15px); }
.compact-brand { display: flex; align-items: center; gap: 13px; }
.compact-brand .eyebrow { margin-bottom: 2px; font-size: .62rem; }
.compact-brand strong { color: var(--navy); font-size: 1.05rem; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.sync-status { padding: 7px 10px; border-radius: 999px; color: #397278; background: var(--teal-pale); font-size: .72rem; font-weight: 800; }
.icon-button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); color: var(--navy); background: white; font-size: 1.2rem; }
.app-content { width: min(1120px, 100%); margin: 0 auto; padding: 98px 20px calc(105px + var(--safe-bottom)); }
.screen { animation: screen-in .24s ease; }
@keyframes screen-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.welcome-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.welcome-row h1, .screen-intro h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.05; }
.welcome-row p:not(.eyebrow), .screen-intro > p:last-child { max-width: 700px; color: var(--muted); line-height: 1.65; }
.avatar-button { flex: 0 0 auto; width: 52px; height: 52px; border: 0; border-radius: 50%; color: white; background: var(--navy); font-weight: 800; }
.hero-card { display: flex; justify-content: space-between; gap: 28px; align-items: flex-end; padding: clamp(24px, 4vw, 38px); border-radius: var(--radius); color: white; background: linear-gradient(125deg, var(--navy) 0%, #174b5d 55%, var(--teal) 100%); box-shadow: var(--shadow); }
.hero-card h2 { margin: 4px 0 8px; max-width: 650px; font-family: Georgia, serif; font-size: clamp(1.5rem, 3.4vw, 2.4rem); }
.hero-card p { max-width: 700px; margin: 0; color: #d9eef0; line-height: 1.55; }
.card-label { color: #7ce1dc !important; font-size: .69rem; letter-spacing: .14em; font-weight: 800; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 34px 0 14px; }
.section-heading h2 { margin: 0; color: var(--navy); font-family: Georgia, serif; font-size: 1.55rem; }
.text-button { border: 0; padding: 5px; color: var(--teal); background: transparent; font-weight: 800; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.summary-card { min-height: 112px; display: flex; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.summary-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--teal); background: var(--teal-pale); font-weight: 800; }
.summary-card div { display: grid; gap: 3px; }
.summary-card strong { color: var(--navy); font-size: 1.4rem; }
.summary-card span:last-child { color: var(--muted); font-size: .78rem; }
.empty-state { padding: 34px; text-align: center; border: 1px dashed #bfd2d9; border-radius: var(--radius); background: rgba(255,255,255,.65); }
.empty-state h3 { margin: 8px 0; color: var(--navy); }
.empty-state p { margin: 0 auto; max-width: 520px; color: var(--muted); }
.empty-icon { width: 48px; height: 48px; margin: auto; display: grid; place-items: center; border-radius: 16px; color: var(--teal); background: var(--teal-pale); font-size: 1.35rem; }
.screen-intro { margin-bottom: 26px; }
.capture-options { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 18px; }
.capture-option { min-height: 95px; display: grid; place-items: center; align-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 16px; color: var(--navy); background: white; }
.capture-option span { color: var(--teal); font-size: 1.25rem; }
.capture-option small { color: var(--muted); }
.capture-option.is-active { border-color: var(--teal); background: var(--teal-pale); }
.capture-option:disabled { opacity: .55; }
.capture-card, .settings-card, .ask-preview { padding: clamp(20px, 4vw, 32px); border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: 0 10px 30px rgba(16,42,67,.05); }
.capture-card label { font-size: 1.05rem; }
.capture-footer { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-top: 14px; }
.capture-footer span { color: var(--muted); font-size: .78rem; }
.memory-list { display: grid; gap: 10px; }
.memory-item { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: start; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.memory-item .memory-symbol { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--teal); background: var(--teal-pale); }
.memory-item p { margin: 0 0 6px; line-height: 1.45; }
.memory-item small { color: var(--muted); }
.status-pill { padding: 5px 8px; border-radius: 999px; color: #6f541c; background: var(--gold-pale); font-size: .68rem; font-weight: 800; }
.status-pill.synced { color: #075b5e; background: var(--teal-pale); }
.ask-preview { text-align: center; padding-top: 48px; }
.ask-orb { width: 74px; height: 74px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; color: white; background: radial-gradient(circle at 35% 35%, #34c4c0, var(--teal) 55%, var(--navy)); box-shadow: 0 15px 35px rgba(15,124,128,.25); font-size: 1.7rem; }
.ask-preview h2 { margin: 0 0 18px; color: var(--navy); font-family: Georgia, serif; }
.question-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-bottom: 24px; }
.question-chips span { padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--navy-soft); background: var(--background); font-size: .82rem; }
.ask-bar { max-width: 700px; margin: auto; display: grid; grid-template-columns: 1fr 44px; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.ask-bar input { border: 0; min-height: 44px; }
.ask-bar button { border: 0; border-radius: 12px; color: white; background: #a8b8be; }
.life-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.life-grid article { display: grid; grid-template-columns: 48px 1fr auto; gap: 14px; align-items: start; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.life-grid article > span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; color: var(--teal); background: var(--teal-pale); font-size: 1.2rem; font-weight: 800; }
.life-grid h2 { margin: 0 0 5px; color: var(--navy); font-size: 1.05rem; }
.life-grid p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.life-grid b { color: var(--muted); font-size: .8rem; }
.settings-card { display: grid; gap: 17px; max-width: 720px; }
.settings-list { display: grid; gap: 10px; margin-top: 22px; max-width: 720px; }
.settings-list article { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.settings-list article div { display: grid; gap: 5px; }
.settings-list article span { color: var(--muted); font-size: .78rem; }
.bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 100; min-height: calc(72px + var(--safe-bottom)); padding: 6px max(10px, calc((100vw - 620px) / 2)) var(--safe-bottom); display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(18px); }
.nav-item { min-height: 60px; display: grid; place-items: center; align-content: center; gap: 2px; border: 0; border-radius: 14px; color: #718794; background: transparent; }
.nav-item span { font-size: 1.12rem; }
.nav-item small { font-size: .66rem; font-weight: 800; }
.nav-item.is-active { color: var(--teal); background: var(--teal-pale); }
.toast-region { position: fixed; z-index: 2000; right: 18px; bottom: calc(90px + var(--safe-bottom)); display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 15px; border-radius: 13px; color: white; background: var(--navy); box-shadow: var(--shadow); font-size: .86rem; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; background: linear-gradient(145deg, #eef9f8, #fff); }
  .auth-brand { min-height: 340px; padding: 42px 24px 34px; }
  .auth-brand::after { width: 380px; height: 380px; }
  .brand-benefits { display: none; }
  .auth-card { margin: -30px auto 40px; position: relative; z-index: 2; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .life-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .auth-brand { min-height: 270px; }
  .auth-brand h1 { font-size: 3.5rem; }
  .brand-subtitle { margin-bottom: 4px; }
  .auth-card { width: calc(100% - 28px); padding: 22px; border-radius: 22px; }
  .app-header { height: 68px; padding: 9px 16px; }
  .app-content { padding: 86px 14px calc(94px + var(--safe-bottom)); }
  .sync-status { display: none; }
  .welcome-row h1, .screen-intro h1 { font-size: 2.05rem; }
  .hero-card { align-items: stretch; flex-direction: column; }
  .hero-card .secondary-button { align-self: flex-start; }
  .summary-grid { gap: 9px; }
  .summary-card { min-height: 96px; padding: 13px; gap: 10px; }
  .summary-icon { width: 38px; height: 38px; }
  .capture-options { grid-template-columns: repeat(5, minmax(62px, 1fr)); overflow-x: auto; padding-bottom: 3px; }
  .capture-option { min-width: 70px; min-height: 82px; font-size: .76rem; }
  .capture-footer { align-items: stretch; flex-direction: column; }
  .capture-footer .primary-button { width: 100%; }
  .memory-item { grid-template-columns: 38px 1fr; }
  .memory-item .status-pill { grid-column: 2; justify-self: start; }
  .life-grid { grid-template-columns: 1fr; }
  .bottom-nav { padding-inline: 5px; }
  .nav-item { min-height: 58px; }
  .toast-region { left: 12px; right: 12px; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* v0.1.1 secure-backend setup and password recovery */
.setup-panel {
  display: grid;
  gap: 0.9rem;
  padding: 0.25rem;
}
.setup-panel[hidden] { display: none; }
.setup-panel h2 { margin: 0; }
.setup-panel ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted, #52636d);
  display: grid;
  gap: 0.5rem;
}
.setup-panel code {
  background: #edf5f4;
  border-radius: 0.35rem;
  padding: 0.08rem 0.3rem;
}
.auth-link {
  justify-self: start;
  margin-top: -0.2rem;
}
.backend-state {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.backend-state::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #1b8a65;
}
