/* TFG prototype. Paper and ink, one vermilion seal. No web fonts: nothing leaves the phone. */

:root {
  --bg: #F3EEE4;
  --card: #FBF8F2;
  --ink: #16130F;
  --ink-2: #463F35;
  --muted: #6E665A;
  --line: #DDD4C4;
  --accent: #B23A2E;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(178, 58, 46, 0.10);
  --khaki: #7A6140;
  --khaki-soft: #ECE3D2;
  --video: #1E1B17;
  --shadow: 0 1px 2px rgba(22, 19, 15, 0.05), 0 6px 20px rgba(22, 19, 15, 0.05);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11100E;
    --card: #1A1916;
    --ink: #EFE9DE;
    --ink-2: #CFC7B9;
    --muted: #9A9184;
    --line: #2E2B26;
    --accent: #E8695D;
    --accent-ink: #16130F;
    --accent-soft: rgba(232, 105, 93, 0.14);
    --khaki: #C8AE82;
    --khaki-soft: #2A2620;
    --video: #0B0A09;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11100E;
  --card: #1A1916;
  --ink: #EFE9DE;
  --ink-2: #CFC7B9;
  --muted: #9A9184;
  --line: #2E2B26;
  --accent: #E8695D;
  --accent-ink: #16130F;
  --accent-soft: rgba(232, 105, 93, 0.14);
  --khaki: #C8AE82;
  --khaki-soft: #2A2620;
  --video: #0B0A09;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* Type */
.label, .eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--khaki);
}
.display, .display-sm, .card-title, .maxim, .sheet h2, .goal-text {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.display { font-size: 40px; line-height: 1.08; margin: 12px 0 12px; }
.display-sm { font-size: 28px; line-height: 1.15; margin: 6px 0 12px; }
.lede { font-size: 18px; color: var(--ink-2); margin: 0 0 24px; }
.fine { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.muted { color: var(--muted); }

/* Header + progress */
.top { padding: 8px 2px 16px; }
.progress { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pip { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); }
.pip.on { background: var(--accent); border-color: var(--accent); }
.progress-text { font-size: 14px; color: var(--ink-2); margin-left: 4px; }
.streak {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--khaki-soft);
  color: var(--ink-2);
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 14px;
}
.card.is-done { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.meta { font-size: 13px; color: var(--muted); }
.card-title { font-size: 23px; line-height: 1.2; margin: 8px 0 2px; }
.jp { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-style: italic; }
.cue { font-family: var(--serif); font-style: italic; color: var(--ink-2); margin: 12px 0; }
.excerpt { color: var(--ink-2); margin: 0 0 14px; }
.maxim {
  margin: 10px 0 10px;
  padding: 0 0 0 14px;
  border-left: 3px solid var(--accent);
  font-size: 22px;
  line-height: 1.25;
}

/* Video placeholder */
.video {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 6px 0 4px;
  border: 0;
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 40%, rgba(178, 58, 46, 0.35), transparent 55%),
    var(--video);
  color: #EFE9DE;
}
.video-play {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid rgba(239, 233, 222, 0.7);
}
.video-play svg { width: 22px; height: 22px; fill: #EFE9DE; margin-left: 3px; }
.video-note { font-size: 12.5px; color: rgba(239, 233, 222, 0.78); padding: 0 16px; text-align: center; }

/* Buttons */
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  font-weight: 600;
  text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-link {
  border: 0;
  background: none;
  padding: 8px 4px;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
}
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.done-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent); }
.done-badge svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; }

/* Seal: the day kept */
.sealed {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  margin: 0 0 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", var(--serif);
  font-size: 26px;
  transform: rotate(-8deg);
  animation: stamp 420ms cubic-bezier(.2, 1.4, .4, 1) both;
}
.sealed-title { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 700; }
@keyframes stamp { from { transform: scale(1.6) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(-8deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .seal { animation: none; } }

/* Vision check-in */
.goal-check { padding: 12px 0; border-top: 1px solid var(--line); }
.goal-check:first-of-type { border-top: 0; }
.goal-check p { margin: 0 0 8px; font-weight: 600; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; gap: 3px; }
.seg button {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.check-list { list-style: none; padding: 0; margin: 8px 0 4px; }
.check-list li { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; }
.check-list .mark { width: 18px; flex: none; text-align: center; font-weight: 700; color: var(--accent); }
.check-list .mark.no { color: var(--muted); }

/* Vision board */
.goal { position: relative; }
.goal-top { display: flex; justify-content: space-between; align-items: center; }
.goal-text { font-size: 21px; line-height: 1.25; margin: 10px 0 4px; }
.goal-why { margin: 0 0 10px; color: var(--ink-2); font-style: italic; font-family: var(--serif); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 12px 0 0; }
.sq {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.sq.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sq.today { border-color: var(--ink-2); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
.chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip-static {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--khaki-soft);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.idea { border-style: dashed; }

/* Forms */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin: 0 0 6px; color: var(--ink-2); }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px;
}
.field input:focus, .field select:focus { border-color: var(--ink-2); outline: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error { color: var(--accent); font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.notice {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--khaki-soft);
  color: var(--ink-2);
  font-size: 14px;
  margin: 0 0 20px;
}
.notice strong { color: var(--ink); }

/* Onboarding */
.ob { padding-top: 24px; }
.ob-welcome { min-height: calc(100vh - 140px); display: flex; flex-direction: column; justify-content: center; }
.mark { display: flex; align-items: center; gap: 14px; }
.mark svg { width: 64px; height: 64px; }
.step { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0; }
.goal-draft { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.goal-draft:first-child { border-top: 1px solid var(--line); }
.goal-draft span { font-weight: 600; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.inline-form .field { margin: 0; }
.ob-foot { margin-top: 28px; display: grid; gap: 4px; justify-items: center; }

/* Library */
.list { display: grid; gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
}
.list-item:first-child { border-top: 0; }
.num { font-family: var(--serif); font-size: 15px; color: var(--muted); width: 22px; flex: none; }
.li-main { flex: 1; min-width: 0; }
.li-title { display: block; font-weight: 600; }
.li-sub { display: block; font-size: 13px; color: var(--muted); }
.list-item .today-tag { font-size: 11px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; }
.chev { width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.lib-tabs { margin: 0 0 16px; }

/* Me */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 12px 6px; border-radius: 12px; background: var(--khaki-soft); }
.stat b { display: block; font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--ink-2); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 10px 0 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.footer-note { text-align: center; font-size: 12px; color: var(--muted); margin: 24px 0 0; }

/* Demo bar */
.demo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  margin: 0 0 8px;
  border-radius: 999px;
  border: 1px dashed var(--accent);
  font-size: 13px;
  color: var(--ink-2);
}

/* Tabs */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs[hidden] { display: none; }
.tabs a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { stroke: var(--accent); }

/* Sheet */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(10, 9, 8, 0.5); animation: fade 160ms ease both; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-width: 480px;
  max-height: 92vh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  animation: rise 220ms cubic-bezier(.2, .9, .3, 1) both;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet h2 { font-size: 26px; line-height: 1.15; margin: 4px 0 2px; }
.sheet .focus { font-size: 17px; color: var(--ink-2); margin: 10px 0 12px; }
.steps { padding-left: 22px; margin: 0 0 8px; }
.steps li { margin: 0 0 8px; }
.reading { font-family: var(--serif); font-size: 18px; line-height: 1.6; color: var(--ink); }
.practice { padding: 14px 16px; border-radius: 12px; background: var(--khaki-soft); margin: 16px 0; }
.practice p { margin: 4px 0 0; font-weight: 600; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .backdrop { animation: none; } }

/* Timer */
.timer {
  margin: 16px 0;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--video);
  color: #EFE9DE;
  text-align: center;
}
.t-label { margin: 0; font-size: 14px; font-weight: 600; color: rgba(239, 233, 222, 0.85); min-height: 21px; }
.t-time { margin: 4px 0 10px; font-family: var(--serif); font-size: 56px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.t-bar { height: 4px; border-radius: 2px; background: rgba(239, 233, 222, 0.18); overflow: hidden; }
.t-bar span { display: block; height: 100%; width: 0; background: #E8695D; }
.t-next { margin: 10px 0 14px; font-size: 13px; color: rgba(239, 233, 222, 0.7); min-height: 20px; }
.timer .btn { border-color: #EFE9DE; color: #EFE9DE; }
.timer .btn-primary { background: #E8695D; border-color: #E8695D; color: #16130F; }
.timer .btn-link { color: rgba(239, 233, 222, 0.8); }
.timer .actions { justify-content: center; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translate(-50%, 12px);
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
