/* ============ JournalPilot AI — the leather-bound diary ============
   A private Day One-style diary: warm terracotta accent on cream paper,
   Fraunces serif for the words that matter, mood as colored dots. */

:root {
  --terra: #c2410c;
  --terra-deep: #9a3412;
  --terra-soft: #fbeadd;
  --terra-ring: rgba(194, 65, 12, .14);
  --paper: #faf6ee;
  --paper-deep: #f1e9d8;
  --card: #fffdf8;
  --ink: #292019;
  --ink-soft: #5c5145;
  --muted: #9a8d78;
  --line: #e7dcc4;
  --line-soft: #f0e8d5;
  --radius: 0;
  --radius-sm: 0;
  --shadow: 0 1px 2px rgba(80, 55, 20, .06), 0 12px 30px rgba(80, 55, 20, .07);
  --shadow-sm: 0 1px 2px rgba(80, 55, 20, .08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--sans); background: var(--paper); color: var(--ink);
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
button { font-family: var(--sans); cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h2 { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.3px; margin: 0 0 16px; }
h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 28px 0 14px; }

/* ---------- topbar ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-top: 20px; padding-bottom: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-seal {
  width: 40px; height: 40px; border-radius: 50%; background: var(--terra); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(194, 65, 12, .35), inset 0 0 0 2px rgba(255,255,255,.25);
}
.brand-word { font-family: var(--serif); font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.brand-word em {
  font-style: normal; font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: 1.2px;
  color: var(--terra-deep); background: var(--terra-soft); border-radius: 0; padding: 3px 8px; margin-left: 4px;
  vertical-align: 3px;
}
.tagline { margin: 0; color: var(--muted); font-size: 14px; font-style: italic; font-family: var(--serif); font-size: 16px; }

/* ---------- streak ribbon ---------- */
.streakwrap { border-bottom: 1px solid var(--line-soft); background: var(--paper); }
.streakbar {
  max-width: 760px; margin: 0 auto; padding: 10px 24px; text-align: center;
  font-size: 13.5px; color: var(--ink-soft);
}
.streakbar strong { color: var(--terra-deep); font-variant-numeric: tabular-nums; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 8px; padding-top: 18px; padding-bottom: 4px; }
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  border-radius: 0; padding: 9px 22px; font-size: 14px; font-weight: 600;
  transition: all .15s;
}
.tab:hover { border-color: var(--terra); color: var(--terra-deep); }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fdfaf3; box-shadow: var(--shadow-sm); }

/* ---------- panes ---------- */
main.wrap { padding-top: 22px; padding-bottom: 64px; }
.pane { display: none; }
.pane.active { display: block; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px 24px; margin-bottom: 20px;
}

/* ---------- day navigation ---------- */
.daynav {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.daynav button {
  border: 1px solid var(--line); background: var(--card); border-radius: 0;
  min-width: 42px; height: 42px; padding: 0 14px; font-size: 15px; font-weight: 600; color: var(--ink-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.daynav button:hover { border-color: var(--terra); color: var(--terra-deep); }
#todayBtn { padding: 0 22px; }
.daynav input[type="date"] {
  border: 1px solid var(--line); border-radius: 0; background: var(--card);
  padding: 9px 16px; font-family: var(--sans); font-size: 14px; color: var(--ink-soft); width: auto;
}
.daynav input[type="date"]:focus { border-color: var(--terra); outline: none; box-shadow: 0 0 0 3px var(--terra-ring); }

/* ---------- prompt card ---------- */
.prompt { border-top: 4px solid var(--terra); }
.prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.pill {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--terra-deep); background: var(--terra-soft); border-radius: 0; padding: 5px 14px;
}
.linkbtn {
  background: none; border: none; color: var(--terra-deep); font-size: 13.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; padding: 6px 4px;
}
.linkbtn:hover { color: var(--terra); }
.prompt-text {
  font-family: var(--serif); font-size: 21px; font-style: italic; line-height: 1.55;
  margin: 0; color: var(--ink);
}

/* ---------- mood ---------- */
.lbl { display: block; font-weight: 700; font-size: 13.5px; color: var(--ink-soft); margin: 22px 0 10px; }
.lbl .muted { font-weight: 500; margin-left: 8px; }
.moodrow { display: flex; gap: 8px; flex-wrap: wrap; }
.mood {
  display: inline-flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); background: var(--card); border-radius: 0;
  padding: 9px 18px 9px 12px; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  transition: all .15s;
}
.mood:hover { border-color: var(--terra); transform: translateY(-1px); }
.mood.sel { border-color: var(--terra); background: var(--terra-soft); color: var(--terra-deep); box-shadow: var(--shadow-sm); }
.mdot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.moodtag { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.moodtag .mdot { width: 11px; height: 11px; }
.mlabel { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- diary page ---------- */
#entryText {
  width: 100%; font-family: var(--serif); font-size: 18.5px; line-height: 1.75; color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 26px; resize: vertical; min-height: 300px;
  box-shadow: var(--shadow-sm);
}
#entryText:focus { outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-ring); }
#entryText::placeholder { color: #b7a98f; font-style: italic; }
.actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.primary {
  background: var(--terra); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 12px 30px; min-height: 48px; font-size: 15px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(194, 65, 12, .32); transition: background .15s, transform .12s;
}
.primary:hover { background: var(--terra-deep); transform: translateY(-1px); }
.danger {
  background: none; border: 1px solid var(--line); color: #b91c1c;
  border-radius: var(--radius-sm); padding: 11px 20px; min-height: 46px; font-size: 14px; font-weight: 600;
}
.danger:hover { background: #fbe7e5; border-color: #efc4c1; }
#saveNote { font-size: 13.5px; }

/* ---------- entries list ---------- */
#searchBox {
  width: 100%; border: 1px solid var(--line); border-radius: 0; background: var(--card);
  padding: 12px 22px; font-size: 14.5px; margin-bottom: 18px; font-family: var(--sans); color: var(--ink);
}
#searchBox:focus { outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-ring); }
.entry-card { transition: transform .16s, box-shadow .16s; }
.entry-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.entry-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.entry-head strong { font-family: var(--serif); font-size: 17px; }
.entry-head .pill { margin-left: auto; }
.entry-prompt { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin-bottom: 8px; font-size: 15.5px; }
.entry-text { color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; margin-bottom: 10px; }

/* ---------- insights ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px; text-align: center;
}
.stat strong { display: block; font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--terra-deep); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .8px; }
.mrow { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.mlabel { min-width: 110px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.mbar { flex: 1; height: 12px; background: var(--paper-deep); border-radius: 0; overflow: hidden; }
.mfill { height: 100%; background: var(--terra); border-radius: 0; transition: width .5s ease-out; }
.mcount { min-width: 30px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ---------- footer ---------- */
footer { text-align: center; padding: 28px 20px 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .pane.active { animation: viewIn .3s ease-out; }
  @keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
  .entry-card { animation: riseIn .4s ease-out both; }
  #entryList .entry-card:nth-child(2) { animation-delay: .05s; }
  #entryList .entry-card:nth-child(3) { animation-delay: .1s; }
  @keyframes riseIn { from { opacity: 0; transform: translateY(12px); } }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 4px; }
  .prompt-text { font-size: 19px; }
  #entryText { font-size: 17px; }
  .entry-head .pill { margin-left: 0; }
  .mlabel { min-width: 92px; }
}

/* ---------- word goal ---------- */
.goalrow { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; flex-wrap: wrap; }
#wordGoal { width: 84px; }
.goalbar { flex: 1 1 160px; height: 8px; background: var(--paper-deep, #f0ebe0); }
.goalfill { height: 100%; width: 0; background: var(--terra, #b3541e); transition: width .2s; }
.goalfill.met { background: #2f7d4f; }

/* ---------- on this day ---------- */
.otd-title { margin: 30px 0 10px; }
.otd-card { margin-bottom: 12px; }

/* ---------- entries tools + tags ---------- */
.entries-tools { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.entries-tools input { flex: 1; }
.tagchips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.taglbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.tagchip {
  border: 1px solid var(--line); background: var(--card); border-radius: 0;
  padding: 5px 12px; font-size: 13px; cursor: pointer; color: var(--ink-soft);
}
.tagchip:hover { border-color: var(--terra); color: var(--terra-deep); }
.tagchip.sel { background: var(--terra-soft); border-color: var(--terra-deep); color: var(--terra-deep); font-weight: 700; }
.tcount { opacity: .65; font-size: 12px; }

/* ---------- insights calendar ---------- */
.calnav { display: flex; gap: 14px; align-items: center; margin: 6px 0 12px; }
.calgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 520px; }
.cal-h { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-d {
  border: 1px solid var(--line); background: var(--card); border-radius: 0;
  min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: default; padding: 4px 2px;
}
.cal-d.out { opacity: .35; }
.cal-d.today { border: 2px solid var(--terra-deep); }
.cal-d.has { cursor: pointer; }
.cal-d.has:hover { border-color: var(--terra-deep); }
.cal-n { font-size: 12.5px; color: var(--ink-soft); }
.cal-dot { width: 10px; height: 10px; display: block; }

/* ---------- secondary (ghost) button ---------- */
.ghost {
  background: none; border: 1px solid var(--line); color: var(--terra-deep);
  border-radius: 0; padding: 9px 18px; font-size: 14px; font-weight: 600; min-height: 42px;
}
.ghost:hover { border-color: var(--terra-deep); background: var(--terra-soft); }

/* ---------- mood trend bars (no rounded edges) ---------- */
#moodTrend { display: flex; align-items: flex-end; gap: 6px; max-width: 520px; margin: 4px 0 8px; }
.tbar { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; }
.tfill { width: 100%; min-height: 2px; background: #ccc; }
.tbar span { font-size: 10px; color: var(--muted); }
#monthRecap .stat { display: inline-block; margin-right: 18px; }

/* year recap + backup row */
.yrrow { display: flex; align-items: center; gap: 12px; margin: 6px 0 12px; }
.yrrow input[type="number"] { width: 110px; }

/* ---------- 2026 redesign: dateline masthead + relative day labels ---------- */
.dateline {
  display: block;
  font-family: var(--serif); font-size: 30px; font-weight: 600; letter-spacing: -.3px;
  color: var(--ink);
}
.dateline-sub {
  display: block;
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em; color: var(--terra);
  margin-top: 6px;
}
.relday {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--paper-deep); padding: 2px 9px; white-space: nowrap;
}
.entry-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
