:root {
  --ink: #202a28;
  --muted: #6d7773;
  --paper: #f4f2ed;
  --card: #fbfaf7;
  --line: #d9ddd7;
  --accent: #d56a4b;
  --accent-soft: #f2d8cc;
  --shadow: 0 18px 50px rgba(30, 42, 36, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 80% 0%, #fffaf2 0, transparent 34rem), var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 80px; }
.masthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 28px; margin-bottom: 36px; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { max-width: 680px; margin-bottom: 12px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 6vw, 76px); font-weight: 400; letter-spacing: -.055em; line-height: .96; }
h2 { margin-bottom: 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 400; letter-spacing: -.03em; }
h3 { margin-bottom: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.lede, .summary { max-width: 570px; color: var(--muted); font-size: 17px; line-height: 1.55; }
.debug-toggle, .section-meta { color: var(--muted); font-size: 12px; }
.debug-toggle { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.debug-toggle input { accent-color: var(--accent); }
.card { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.55); box-shadow: var(--shadow); }
.setup-card { padding: 26px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.section-heading.compact { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
label { position: relative; display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .03em; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; color: var(--ink); background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wide { grid-column: span 2; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.primary-button, .secondary-button { border: 0; border-radius: 999px; font-weight: 700; }
.primary-button { display: flex; gap: 28px; padding: 14px 18px 14px 22px; color: #fff; background: var(--ink); }
.primary-button:hover { background: var(--accent); }
.secondary-button { padding: 12px 20px; color: #fff; background: var(--accent); }
.status { min-height: 24px; padding: 12px 2px 0; color: var(--accent); font-size: 13px; }
.results { margin-top: 34px; }
.reading-intro { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin: 0 4px 18px; }
.day-shape { padding: 25px 26px; }
.weather { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 38px; }
.weather-main { display: flex; gap: 16px; align-items: center; }
.weather-icon { font-size: 48px; line-height: 1; }
.weather-label { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 26px; font-weight: 400; letter-spacing: -.02em; }
.weather-summary { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.weather-bars { display: grid; gap: 9px; align-content: center; }
.weather-bar { display: grid; grid-template-columns: 108px 1fr 84px; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; }
.bar-cue { display: inline-block; width: 22px; font-size: 15px; }
.weather-bar strong { color: var(--ink); text-align: right; }
.steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.step { height: 10px; border-radius: 3px; background: #edeae1; }
.step.filled.supportive { background: #a7ba99; }
.step.filled.challenging { background: #d6b1a6; }
.step.filled.activation { background: #9aa6b4; }
.week-day.today .step:not(.filled) { background: #e3d8cd; }
.weather-why { grid-column: 1 / -1; }
.weather-why summary { cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 700; }
.weather-areas { display: grid; gap: 4px; margin: 12px 0 10px; font-size: 14px; }
.weather-areas p { margin: 0; }
.weather-areas span { color: var(--muted); }
.indicator-caption { margin: 0; color: var(--muted); font-size: 12px; }
.areas-section { margin-top: 46px; }
.areas-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.area-card { position: relative; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.area-card:first-child { grid-column: span 2; background: #e8eee3; border-color: #ced9c8; }
.area-top { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.area-title { margin: 0 0 7px; font-size: 18px; }
.area-copy { max-width: 700px; margin: 16px 0 0; color: #4e5954; font-size: 14px; line-height: 1.6; }
.activation-chip { flex: 0 0 auto; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.day-row { margin-top: 14px; }
.headline-card { padding: 25px 26px; }
.headline-card h2 { margin: 2px 0 0; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.05; }
.headline-card .summary { margin: 14px 0 0; }
.week { padding: 25px 26px; }
.week .section-heading { margin-bottom: 10px; }
.week-days { display: grid; }
.week-day { display: grid; grid-template-columns: 74px 34px minmax(0, 1fr); gap: 10px; align-items: center; padding: 7px 8px; border-top: 1px solid var(--line); }
.week-day:first-child { border-top: 0; }
.week-day.today { border-radius: 10px; background: #f3ebe4; }
.week-day.today + .week-day { border-top-color: transparent; }
.week-name { display: grid; color: var(--ink); font-size: 14px; font-weight: 600; }
.week-name small { color: var(--muted); font-size: 11px; font-weight: 400; }
.week-icon { font-size: 24px; line-height: 1; text-align: center; }
.week-status { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; }
.quiet-card { margin-top: 14px; padding: 22px; border: 1px dashed var(--line); border-radius: 16px; background: #eeece6; color: var(--muted); }
.quiet-card .eyebrow { color: var(--muted); }
.quiet-card h3 { color: var(--muted); }
.quiet-note { margin: 6px 0 0; font-size: 13px; }
.quiet-list { margin: 12px 0 0; }
.quiet-list li { padding: 3px 0 3px 17px; border-top: 0; color: var(--muted); }
.quiet-list li::before { content: "–"; color: var(--muted); font-weight: 400; }
.area-cues { display: flex; gap: 10px; align-items: center; margin-top: 14px; color: var(--ink); font-size: 15px; font-weight: 600; }
.area-sky { font-size: 26px; line-height: 1; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.advice-card { padding: 23px; }
.advice-card h3 { margin-bottom: 14px; }
ul { margin: 0; padding: 0; list-style: none; }
li { padding: 10px 0 10px 17px; border-top: 1px solid var(--line); color: #4e5954; font-size: 14px; line-height: 1.45; }
li::before { content: "+"; margin-left: -17px; margin-right: 8px; color: var(--accent); font-weight: 800; }
.chat-card { margin-top: 14px; padding: 24px; }
.chat-log { display: grid; gap: 10px; max-height: 330px; overflow: auto; margin-bottom: 16px; }
.chat-empty { color: var(--muted); font-size: 13px; }
.chat-message { max-width: 82%; padding: 12px 15px; border-radius: 14px; color: #4e5954; font-size: 14px; line-height: 1.5; }
.chat-message.user { justify-self: end; background: var(--accent-soft); }
.chat-message.assistant { justify-self: start; background: #e8eee3; }
.chat-form { display: flex; gap: 10px; }
.chat-form input { flex: 1; }
.place-results { position: absolute; z-index: 3; top: 72px; right: 0; left: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.place-option { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 11px 13px; color: var(--ink); background: #fff; text-align: left; font-size: 12px; }
.place-option:hover { background: var(--accent-soft); }
.fold-choice { margin-top: 20px; padding: 16px 18px; border: 1px solid var(--accent-soft); border-radius: 14px; background: #fff8f4; color: var(--ink); font-size: 14px; }
.fold-choice p { margin-bottom: 12px; }
.fold-options { display: flex; flex-wrap: wrap; gap: 10px; }
.reading-place { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
.chat-message.error { background: #fbe9e3; color: var(--accent); }
.debug-status { color: var(--muted); font-size: 12px; }
.debug-status:empty { display: none; }
.debug-panel { margin-top: 22px; padding: 24px; border: 1px dashed var(--accent); border-radius: 18px; background: rgba(255,250,242,.8); }
.debug-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.debug-metric { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.debug-metric small { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.debug-metric strong { display: block; margin-top: 5px; font-size: 17px; }
.debug-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.debug-item { padding: 9px 0; border-top: 1px solid var(--line); color: #4e5954; font-size: 12px; }
.debug-item span { color: var(--muted); }
.debug-json details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.debug-json summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 700; }
pre { max-height: 440px; overflow: auto; margin: 12px 0 0; padding: 14px; border-radius: 10px; background: #232b29; color: #d9e8d7; font-size: 11px; line-height: 1.5; white-space: pre-wrap; }

/* Signed-out and loading states: only the sign-in card, or nothing, shows. */
.signin-card { display: none; }
body.signed-out .signin-card { display: block; }
body.checking .setup-card, body.checking #results,
body.signed-out .setup-card:not(.signin-card), body.signed-out #results, body.signed-out .tab-bar { display: none !important; }
.account-bar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 18px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.account-bar p { margin: 0; }
.account-bar strong { color: var(--ink); }
.account-bar .hint { flex-basis: 100%; }
.text-button { padding: 0; border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 700; }

/* Bottom tab bar: phone layout only (see the media query below). */
.tab-bar { display: none; }

@media (max-width: 760px) {
  .shell { padding-top: max(25px, env(safe-area-inset-top)); }
  /* After a reading, show only the sections of the selected tab. */
  body.has-reading .shell { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.has-reading[data-tab="home"] [data-panel]:not([data-panel="home"]),
  body.has-reading[data-tab="areas"] [data-panel]:not([data-panel="areas"]),
  body.has-reading[data-tab="chat"] [data-panel]:not([data-panel="chat"]),
  body.has-reading[data-tab="profile"] [data-panel]:not([data-panel="profile"]) { display: none !important; }
  body.has-reading .results { margin-top: 0; }
  body.has-reading .areas-section { margin-top: 0; }
  body.has-reading .two-column[data-panel="home"] { margin-top: 14px; }
  body.has-reading .tab-bar {
    position: fixed; right: 0; bottom: 0; left: 0; z-index: 20;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(251, 250, 247, .88);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  }
  .tab-bar button { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border: 0; background: none; color: var(--muted); font-size: 10px; font-weight: 600; }
  .tab-bar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .tab-bar button.selected { color: var(--accent); }
  .tab-bar button.selected svg { stroke-width: 2.1; }

  .shell { width: min(100% - 24px, 600px); padding-top: 25px; }
  .masthead { display: block; }
  .debug-toggle { margin-top: 18px; }
  .form-grid, .weather, .two-column, .debug-columns { grid-template-columns: 1fr; }
  .wide, .area-card:first-child { grid-column: auto; }
  .form-footer, .reading-intro { align-items: stretch; flex-direction: column; }
  .primary-button { justify-content: space-between; }
  .areas-list { grid-template-columns: 1fr; }
  .section-meta { display: none; }
  .debug-metrics { grid-template-columns: 1fr 1fr; }
}
