/* Triumph brand: navy bar, steel neutrals, accent blue. Built for a phone in one hand. */
:root {
  --navy: #0A2E45; --navy-deep: #061e2e; --accent: #126194; --accent-hover: #0d4a72;
  --bg: #F4F7F9; --card: #FFFFFF; --ink: #17252E; --muted: #55707F; --line: #DCE4E9; --line-strong: #8FA3B0;
  --accent-soft: #e2eef6;
  --good: #1b7a45; --good-soft: #e2f3e9; --warn: #9a5a00; --warn-soft: #fcefd9; --bad: #b42318; --bad-soft: #fde6e4;
  --f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1820; --card: #12232e; --ink: #e6eef3; --muted: #93a9b6; --line: #22394a; --line-strong: #3d5a6d;
    --accent: #4f9fd6; --accent-hover: #6cb2e2; --accent-soft: #15324a;
    --good: #5cc98a; --good-soft: #143322; --warn: #f0b25a; --warn-soft: #3a2a10; --bad: #f07a6e; --bad-soft: #3d1a16;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 var(--f-body); min-height: 100dvh }
[hidden] { display: none !important }
button, input, textarea { font: inherit; color: inherit }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px }

/* Top bar */
.bar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top, 0px) }
.bar-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px)); position: relative }
.logo { height: 30px; width: auto; display: block }
.who { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: .9rem; font-weight: 600; cursor: pointer }
.menu { position: absolute; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(100% - 4px); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); overflow: hidden }
.menu button { display: block; width: 100%; padding: 12px 20px; background: none; border: 0; text-align: left; cursor: pointer; color: var(--ink) }

main { max-width: 560px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(40px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
h1 { font-family: var(--f-display); font-weight: 700; font-size: 1.9rem; line-height: 1.1; margin: 0; letter-spacing: .005em }
h2 { font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; margin: 0 0 8px }
.lede { color: var(--muted); margin: 6px 0 0 }
.lede.small { font-size: .9rem; margin-top: 18px }

/* Login */
.login { padding-top: 8vh; display: grid; gap: 20px }
.login form { display: grid; gap: 14px; margin-top: 8px }
.fld { display: grid; gap: 6px }
.fld > span { font-weight: 600; font-size: .92rem }
.fld.inline { grid-template-columns: auto 1fr; align-items: center; gap: 12px }
input[type=text], input[type=password], input[type=date], textarea {
  width: 100%; background: var(--card); border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 50px; font-size: 16px }
textarea { resize: vertical; min-height: 0; line-height: 1.45 }
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft) }

/* Buttons */
.btn { border: 0; border-radius: 12px; padding: 14px 20px; font-weight: 600; cursor: pointer; min-height: 52px; background: var(--card); border: 1.5px solid var(--line) }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff }
.btn.primary:active { background: var(--accent-hover) }
.btn.big { width: 100%; font-family: var(--f-display); font-size: 1.25rem; letter-spacing: .02em; min-height: 58px }
.btn.small { min-height: 46px; padding: 10px 16px }
.btn:disabled { opacity: .6 }

/* Header row on the form */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px }
.date-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .92rem; white-space: nowrap; cursor: pointer }
.date-chip::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px) }
.date-chip input { position: absolute; inset: 0; opacity: 0; width: 100%; min-height: 0; cursor: pointer }
.date-chip.past { border-color: var(--warn); color: var(--warn); background: var(--warn-soft) }
.sent-note { background: var(--good-soft); color: var(--good); border-radius: 10px; padding: 10px 14px; font-size: .92rem; font-weight: 500; margin: 0 0 14px }

/* Cards */
#f { display: grid; gap: 12px }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 0; display: grid; gap: 12px; min-width: 0 }
legend { float: left; width: 100%; padding: 0; font-family: var(--f-display); font-weight: 600; font-size: 1.15rem; display: flex; justify-content: space-between; align-items: baseline; gap: 8px }
legend + * { clear: both }
.hint { color: var(--muted); font-family: var(--f-body); font-weight: 400; font-size: .8rem; font-style: normal }

.chips { display: flex; flex-wrap: wrap; gap: 8px }
.chips:empty { display: none }
.chip { border: 1.5px solid var(--line); background: var(--bg); border-radius: 999px; padding: 9px 15px; min-height: 44px; font-size: .95rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600 }
.chip[aria-pressed="true"]::before { content: ""; width: 10px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translateY(-2px) }
.chip.me { cursor: default }
.chip.add { border-style: dashed; color: var(--muted); background: transparent }
.add-row { display: flex; gap: 8px }
.add-row input { flex: 1; min-width: 0 }

.seg { display: grid; gap: 8px }
.seg.three { grid-template-columns: repeat(3, 1fr) }
.seg.two { grid-template-columns: 1fr 1fr }
.seg button { border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; min-height: 52px; font-weight: 600; cursor: pointer }
.seg button[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent) }
#f-status button[aria-checked="true"][data-v="on-track"] { background: var(--good-soft); border-color: var(--good); color: var(--good) }
#f-status button[aria-checked="true"][data-v="behind"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn) }
#f-status button[aria-checked="true"][data-v="blocked"] { background: var(--bad-soft); border-color: var(--bad); color: var(--bad) }
.reveal { display: grid; gap: 10px }

.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 14px; margin: 0; font-size: .95rem }
.submit-bar { position: sticky; bottom: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 70%, transparent) }

/* Recent */
.recent { margin-top: 28px }
.recent ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; font-size: .92rem }
.recent li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500 }
.recent li span:last-child { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--good) }
.dot.behind { background: var(--warn) } .dot.blocked { background: var(--bad) }

/* Done */
.done { text-align: center; padding-top: 10vh; display: grid; gap: 10px; justify-items: center }
.done .btn { margin-top: 18px; min-width: 240px }
.check svg { width: 84px; height: 84px; fill: none; stroke: var(--good); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round }
.check circle { stroke-dasharray: 152; stroke-dashoffset: 152; animation: draw .5s ease-out forwards }
.check path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s .4s ease-out forwards }
@keyframes draw { to { stroke-dashoffset: 0 } }

.center { display: grid; place-items: center; min-height: 50vh }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }
@media (prefers-reduced-motion: reduce) { .check circle, .check path { animation: none; stroke-dashoffset: 0 } .spinner { animation-duration: 3s } }
