/* A race-programme page: TriLife's three stripes, a dated course of key dates,
   phases as stages, "waiting on" and the update log beside them. */
:root {
  --bg: #f4f7f6; --surface: #ffffff; --ink: #10201f; --muted: #5a6b6b; --line: #d9e3e2;
  --accent: #1e8f8e; --accent-soft: #e2f2f1; --lime: #6d8a12; --lime-soft: #eef5d8;
  --plum: #7b4fa0; --plum-soft: #f1eaf7; --warn: #a35f00; --warn-soft: #fbefd9;
  --bad: #b3261e; --bad-soft: #fbe5e3; --stripe1: #3bbfbd; --stripe2: #b8d741; --stripe3: #7b4fa0;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #0d1615; --surface: #142120; --ink: #e5eeed; --muted: #93a7a6; --line: #253534;
  --accent: #52c8c6; --accent-soft: #163130; --lime: #b8d741; --lime-soft: #26300f;
  --plum: #b996d8; --plum-soft: #2a2036; --warn: #e6a64e; --warn-soft: #33260f;
  --bad: #f08b81; --bad-soft: #3a1d1a; color-scheme: dark } }

* { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px) }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .01em; text-wrap: balance; margin: 0 }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums }
.label { font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted) }
button { font: inherit; color: inherit }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px }
.sr { position: absolute; left: -9999px }

/* sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px 24px; display: grid; gap: 8px }
.login-card h1 { font-size: 34px; margin-top: 10px }
.login-card .sub { margin: 0 0 10px }
.login-card .btn { margin-top: 10px; padding: 10px }
.err { color: var(--bad); font-size: 13.5px; margin: 4px 0 0 }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line) }
.top .wrap { padding-block: 20px; display: grid; gap: 16px }
.stripes { display: flex; gap: 4px; height: 22px }
.stripes i { width: 5px; border-radius: 2px }
.stripes i:nth-child(1) { background: var(--stripe1) } .stripes i:nth-child(2) { background: var(--stripe2) } .stripes i:nth-child(3) { background: var(--stripe3) }
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.who-bar { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap }
.who-bar b { color: var(--ink); font-weight: 600 }
.role { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; border-radius: 4px; padding: 1px 6px; margin-left: 6px }
.role.meai { background: var(--accent-soft); color: var(--accent) } .role.trilife { background: var(--plum-soft); color: var(--plum) }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 13px }
h1 { font-size: clamp(30px, 5vw, 42px); line-height: 1 }
.sub { color: var(--muted); font-size: 13.5px; margin-top: 6px }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden }
.stat { background: var(--surface); padding: 12px 14px; min-width: 0 }
.stat b { display: block; font-family: var(--display); font-size: 24px; line-height: 1.1; margin-top: 3px }
.stat .s { color: var(--muted); font-size: 12.5px }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) } }

/* key dates */
.course { padding-block: 22px 6px }
.course-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap }
.course-head h2 { font-size: 22px }
.dates { list-style: none; margin: 0; padding: 0 0 10px; display: flex; overflow-x: auto; scrollbar-width: thin }
.dates li { flex: 0 0 168px; position: relative; padding: 18px 14px 4px 0 }
.dates li::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--line) }
.dates li::after { content: ""; position: absolute; top: 1px; left: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line) }
.dates li.done::before { background: var(--accent) }
.dates li.done::after { background: var(--accent); border-color: var(--accent) }
.dates li.next::after { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft) }
.dates .when { font-family: var(--mono); font-size: 12.5px; color: var(--muted) }
.dates li.next .when { color: var(--accent); font-weight: 500 }
.dates .what { font-size: 13.5px; line-height: 1.35; margin-top: 2px }
.dates .link { margin-top: 4px; font-size: 12px }

/* main */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; padding-block: 18px 48px; align-items: start }
@media (max-width: 960px) { .main { grid-template-columns: minmax(0, 1fr) } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center }
.tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 13.5px; font-weight: 500 }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink) }
.tab small { opacity: .7; font-weight: 400; margin-left: 4px }
.phase-note { color: var(--muted); font-size: 13.5px; margin: -4px 0 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: baseline }

.ms { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden }
.ms.attn { border-color: var(--warn) }
.ms-head { width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 16px; background: none; border: 0; text-align: left; cursor: pointer }
.ms-num { font-family: var(--display); font-size: 22px; color: var(--muted) }
.ms-title { font-weight: 600; font-size: 15.5px }
.ms-meta { color: var(--muted); font-size: 12.5px; margin-top: 1px }
.ms-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end }
.count { font-family: var(--mono); font-size: 12.5px; color: var(--muted) }
.bar { width: 74px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden }
.bar i { display: block; height: 100%; background: var(--accent) }
.ms-body { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: grid; gap: 12px }
.ms-summary { margin: 0; max-width: 70ch }
@media (max-width: 560px) { .ms-head { grid-template-columns: 26px minmax(0, 1fr) } .ms-right { grid-column: 2; justify-content: flex-start } }

.signoff { border-radius: 10px; padding: 12px 14px; background: var(--plum-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 14px }
.signoff.done { background: var(--lime-soft) }
.signoff p { margin: 0; flex: 1 1 240px }

.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor }
.st-upcoming, .st-open, .st-waiting { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line) }
.st-demo_ready, .st-built, .st-answered { background: var(--accent-soft); color: var(--accent) }
.st-in_review, .st-in_progress, .st-changes { background: var(--warn-soft); color: var(--warn) }
.st-signed_off, .st-confirmed { background: var(--plum-soft); color: var(--plum) }
.st-live, .st-received { background: var(--lime-soft); color: var(--lime) }
.chip { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px }
.chip.high { color: var(--bad); border-color: var(--bad); background: var(--bad-soft) }
.chip.ok { color: var(--plum); border-color: var(--plum) }
.chip.chg { color: var(--warn); border-color: var(--warn) }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.filter { display: flex; gap: 6px; flex-wrap: wrap }
.filter button { border: 1px solid var(--line); background: none; border-radius: 6px; padding: 3px 9px; font-size: 12.5px; cursor: pointer; color: var(--muted) }
.filter button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink) }
.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line) }
.item { border-bottom: 1px solid var(--line) }
.item-head { width: 100%; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 0; background: none; border: 0; text-align: left; cursor: pointer }
.item-n { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding-top: 2px }
.item-t { font-size: 14.5px; line-height: 1.4 }
.item-tags { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap }
.item-body { padding: 0 0 14px 40px; display: grid; gap: 10px }
@media (max-width: 560px) { .item-body { padding-left: 0 } .item-head { grid-template-columns: 26px minmax(0, 1fr) } .item-head .pill { grid-column: 2; justify-self: start } }
.side-by { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px }
@media (max-width: 700px) { .side-by { grid-template-columns: minmax(0, 1fr) } }
.say { border-radius: 8px; padding: 10px 12px; font-size: 14px; min-width: 0 }
.say p { margin: 4px 0 0; white-space: pre-line }
.say.trilife { background: var(--plum-soft) } .say.trilife .label { color: var(--plum) }
.say.meai { background: var(--accent-soft) } .say.meai .label { color: var(--accent) }
.review { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13.5px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px }
.review .lbl { font-weight: 600; margin-right: 4px }
.review .state { color: var(--muted) }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted) }
select, textarea, input[type=text], input[type=email], input[type=password], input[type=date], input[type=number] { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; max-width: 100% }
.login-card input { width: 100%; font-size: 16px }
textarea { width: 100%; min-height: 64px; resize: vertical }
.btn { border: 0; background: var(--accent); color: var(--surface); border-radius: 7px; padding: 7px 13px; font-weight: 600; font-size: 13.5px; cursor: pointer }
.btn.ghost { background: none; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line) }
.btn.ghost[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor }
.btn.ok { background: var(--plum) } .btn.ghost.ok { background: none; color: var(--plum) }
.btn.warnb { background: none; color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn) }
.btn.danger { background: none; color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad) }
.btn:disabled { opacity: .5; cursor: default }
.btn.small { padding: 4px 10px; font-size: 12.5px }
.notes { display: grid; gap: 8px }
.note { font-size: 13.5px; border-left: 2px solid var(--line); padding-left: 10px }
.who.trilife { color: var(--plum) } .who.meai { color: var(--accent) } .who.both { color: var(--ink) }
.note .who { font-weight: 600 }
.at { color: var(--muted); font-family: var(--mono); font-size: 11.5px; margin-left: 6px }
.note p { margin: 2px 0 0; white-space: pre-line }
.note .link { font-size: 12px; margin-left: 8px }
.cform { display: grid; gap: 6px }

/* aside */
aside { display: grid; gap: 22px }
.panel h2 { font-size: 21px; margin-bottom: 8px }
.panel-head { display: flex; justify-content: space-between; align-items: baseline }
.wait { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px }
.wait li { padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 14px }
.wait li:last-child { border-bottom: 0 }
.wait .due, .wait .note2 { color: var(--muted); font-size: 12.5px; grid-column: 1 / -1 }
.wait li.received .w-what { color: var(--muted) }
.wait .pill { align-self: start }
.log { list-style: none; margin: 12px 0 0; padding: 0 }
.log li { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px }
.log .d { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px }
.log .who { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase }
.log .ms-ref { color: var(--muted); font-size: 12px }
.log p { margin: 2px 0 0; white-space: pre-line }
.log .link { font-size: 12px; margin-right: 10px }
.addform { display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px }
.msg { font-size: 13px; color: var(--muted) }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 22px; color: var(--muted) }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; color: var(--muted); margin-top: 6px }
footer { color: var(--muted); font-size: 12.5px; padding-bottom: 32px }

/* modal and toast */
.modal { position: fixed; inset: 0; background: rgba(8, 16, 15, .55); display: grid; place-items: center; padding: 16px; z-index: 20 }
.modal-card { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px; padding: 20px; display: grid; gap: 12px }
.modal-card h2 { font-size: 24px }
#modal-form { display: grid; gap: 10px }
#modal-form .f { display: grid; gap: 4px }
#modal-form .f > span { font-size: 12.5px; font-weight: 600; color: var(--muted) }
#modal-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px }
#modal-form input[type=text], #modal-form select, #modal-form input[type=date], #modal-form input[type=number], #modal-form input[type=password] { width: 100% }
#modal-form .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px }
#modal-form .actions .danger { margin-right: auto }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 13.5px; z-index: 30; max-width: calc(100vw - 32px) }
@media (prefers-reduced-motion: no-preference) { .ms-body, .item-body { animation: in .18s ease-out } @keyframes in { from { opacity: .4; transform: translateY(-3px) } } }
