@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Work+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --paper: #EDEFE7;
  --paper-raised: #F8F9F4;
  --ink: #1E2420;
  --ink-soft: #565D52;
  --line: #D2D6C8;
  --accent: #B5722E;
  --accent-ink: #ffffff;
  --accent-soft: #F0DCC3;
  --good: #3F7A56;
  --danger: #B4483A;
  --shadow: rgba(30,36,32,0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181D;
    --paper-raised: #1D231F;
    --ink: #ECEFE8;
    --ink-soft: #A4AC9C;
    --line: #333A30;
    --accent: #E0954C;
    --accent-ink: #1B1305;
    --accent-soft: #3A2C18;
    --good: #6FBE8E;
    --danger: #E08375;
    --shadow: rgba(0,0,0,0.45);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Work Sans', -apple-system, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}
.phone {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  padding: 28px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand {
  font-family: 'Fraunces', serif;
  font-size: 15px;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

h1, h2, h3 { font-family: 'Fraunces', serif; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

.eyebrow { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }

/* ---- chat intake ---- */
.chat { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.chat-head h1 { font-size: 22px; font-weight: 500; }
.chat-head p { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.chat-thread { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding-bottom: 4px; }
.bubble { padding: 12px 15px; border-radius: 16px; font-size: 14.5px; line-height: 1.4; max-width: 88%; }
.bubble.coach { background: var(--paper-raised); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.user { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; align-self: flex-end; }
.bubble.thinking { color: var(--ink-soft); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; align-items: flex-end; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 14px; }
.chat-input-row textarea { border: none; background: transparent; padding: 6px 0; flex: 1; max-height: 90px; font-family: inherit; font-size: 15px; color: var(--ink); resize: none; }
.chat-input-row textarea:focus { outline: none; }
.chat-input-row button { flex-shrink: 0; padding: 10px 16px; }

button { font-family: 'Work Sans', sans-serif; font-weight: 600; font-size: 14.5px; border: none; border-radius: 10px; padding: 13px 18px; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }

.status-line { font-size: 13px; color: var(--ink-soft); min-height: 18px; }
.status-line.error { color: var(--danger); }

/* ---- plan ---- */
.plan { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.plan h2 { font-size: 20px; font-weight: 500; margin-top: 4px; }
.milestone-list { display: flex; flex-direction: column; gap: 8px; }
.milestone { display: flex; align-items: center; gap: 10px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.milestone .num { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--accent); width: 20px; }
.milestone.done { opacity: .55; text-decoration: line-through; }
.first-step-card { background: var(--accent-soft); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.first-step-card .tag { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.first-step-card .step-text { font-family: 'Fraunces', serif; font-size: 19px; font-weight: 500; line-height: 1.35; }

/* ---- home ---- */
.home { display: flex; flex-direction: column; gap: 20px; flex: 1; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.goal-switch-btn { background: none; border: none; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 4px; font-family: 'Fraunces', serif; font-size: 17px; font-weight: 500; color: var(--ink); text-align: left; }
.goal-switch-btn .chev { font-size: 11px; color: var(--ink-soft); font-family: 'Work Sans', sans-serif; }
.streak { font-family: 'IBM Plex Mono', monospace; font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; }
.streak b { color: var(--ink); font-size: 15px; }

.weekly-card { background: var(--paper-raised); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.weekly-card .tag { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.weekly-card p { font-size: 14px; line-height: 1.45; color: var(--ink); }
.weekly-card button { align-self: flex-start; }

.today-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 22px; padding: 26px 22px; box-shadow: 0 4px 16px var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.today-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.today-step { font-family: 'Fraunces', serif; font-size: 23px; font-weight: 500; line-height: 1.3; }
.today-why { font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }

.breakdown-btn { align-self: flex-start; padding: 8px 14px; font-size: 12.5px; }
.breakdown-btn:disabled { opacity: .5; cursor: default; }
.substeps-list { display: flex; flex-direction: column; gap: 6px; }
.substep { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.substep input[type=checkbox] { margin-top: 3px; accent-color: var(--accent); }
.substep.done { opacity: .55; text-decoration: line-through; }

.checkin-row { display: flex; gap: 8px; }
.checkin-row button { flex: 1; font-size: 13px; padding: 11px 8px; }
.btn-done { background: var(--good); color: white; }
.btn-hard { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-skip { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }

.milestones-mini { display: flex; flex-direction: column; gap: 6px; }
.milestones-mini .mtitle { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 4px; }
.history-section { display: flex; flex-direction: column; gap: 6px; }
.history-section .mtitle { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 4px; }
.history-list { display: flex; flex-direction: column; gap: 4px; }
.history-row { display: flex; align-items: baseline; gap: 8px; font-size: 13px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: none; }
.history-row .hicon { width: 14px; font-family: 'IBM Plex Mono', monospace; color: var(--good); flex-shrink: 0; }
.history-row.history-hard .hicon, .history-row.history-skip .hicon { color: var(--ink-soft); }
.history-row .hstep { flex: 1; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row .hdate { color: var(--ink-soft); font-size: 11.5px; font-family: 'IBM Plex Mono', monospace; flex-shrink: 0; }

.progress-link { text-align: center; font-size: 12.5px; color: var(--ink-soft); text-decoration: underline; cursor: pointer; margin-top: auto; }

/* ---- modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 10; }
.modal-card { background: var(--paper-raised); border-radius: 20px; padding: 24px; max-width: 360px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 30px var(--shadow); }
.modal-card h3 { font-size: 19px; font-weight: 500; margin: 6px 0 10px; }
.modal-card p { font-size: 14px; color: var(--ink-soft); line-height: 1.5; }
.modal-card button { width: 100%; margin-top: 10px; }
.stat-row { display: flex; justify-content: space-between; font-family: 'IBM Plex Mono', monospace; font-size: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat-row:last-of-type { border-bottom: none; }
.stat-row b { color: var(--ink); }

.goal-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.goal-row:last-of-type { border-bottom: none; }
.goal-row .gname.active { font-weight: 600; }
.goal-row .gstreak { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-soft); }
.goal-row .gdel { background: none; border: none; color: var(--danger); font-size: 16px; padding: 4px 6px; width: auto; margin: 0; cursor: pointer; }
