/* TouchUp design system.
   One button pair, one card style, one radius scale, one link look.
   Looks are token swaps on <html>: data-calm, data-dark, data-contrast, data-still. */

:root {
  color-scheme: light;
  --ground: #EEF3EF;
  --surface: #FFFFFF;
  --sunk: #E0E9E4;
  --ink: #0D2420;
  --muted: #45574F;
  --line: #C3D0C9;
  --edge: #76897F; /* form field outlines: 3:1 or better on ground and surface */
  --pine: #0F3B33;
  --on-pine: #EEF3EF;
  --pine-muted: #B9D0C6;
  --pine-surface: #18493F;
  --accent: #FF6B4A;
  --accent-lip: #C5432A;
  --on-accent: #0D2420;
  --mint: #CDE9DB;
  --stage: #FF6B4A;
  --on-stage: #0D2420;
  --r1: .75rem;
  --r2: 1.25rem;
  --r3: 2rem;
  --wrap: 75rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

html[data-calm] {
  --ground: #ECEDE7;
  --surface: #F8F8F4;
  --sunk: #DFE1DA;
  --ink: #26302D;
  --muted: #4F5955;
  --line: #C9CEC6;
  --edge: #747F79;
  --pine: #34433F;
  --on-pine: #F1F2EC;
  --pine-muted: #C5CDC8;
  --pine-surface: #40514C;
  --accent: #34433F;
  --accent-lip: transparent;
  --on-accent: #F1F2EC;
  --mint: #DCE1DA;
  --stage: #D5DAD2;
  --on-stage: #26302D;
}

html[data-dark] {
  color-scheme: dark;
  --ground: #0B1513;
  --surface: #14221F;
  --sunk: #1C2C28;
  --ink: #E7EFEA;
  --muted: #A9BBB2;
  --line: #2F423C;
  --edge: #6F857C;
  --pine: #060D0C;
  --on-pine: #E7EFEA;
  --pine-muted: #A9BBB2;
  --pine-surface: #14221F;
  --accent: #FF8163;
  --accent-lip: #A8452F;
  --on-accent: #0D2420;
  --mint: #1C3A30;
  --stage: #1B2E29;
  --on-stage: #E7EFEA;
}

html[data-dark][data-calm] {
  --ground: #121716;
  --surface: #1B2220;
  --sunk: #232B28;
  --ink: #DADFDB;
  --muted: #A3ADA8;
  --line: #363F3C;
  --edge: #77827D;
  --pine: #0C100F;
  --pine-surface: #1B2220;
  --accent: #C9D2CC;
  --accent-lip: transparent;
  --on-accent: #121716;
  --mint: #2A3330;
  --stage: #1B2220;
  --on-stage: #DADFDB;
}

html[data-contrast] { --muted: var(--ink); --line: var(--ink); --edge: var(--ink); }
html[data-contrast]:not([data-dark]) { --ink: #000; --ground: #FFF; --surface: #FFF; --sunk: #EEE; --on-accent: #000; --on-stage: #000; }
/* Calm swaps the accent for a dark slate, so with higher contrast it goes to pure black with white text. */
html[data-contrast][data-calm]:not([data-dark]) { --accent: #000; --on-accent: #FFF; }
html[data-contrast][data-dark] { --ink: #FFF; --muted: #FFF; --line: #FFF; --edge: #FFF; --ground: #000; --surface: #000; --sunk: #1A1A1A; --pine: #000; --pine-surface: #000; --on-pine: #FFF; --pine-muted: #FFF; }

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
html[data-still] { scroll-behavior: auto; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.125rem/1.55 var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, fieldset, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, .display { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; line-height: 1.02; text-wrap: balance; }
h1 { font-size: clamp(2.625rem, 5.4vw + 1rem, 5.5rem); }
h2 { font-size: clamp(1.875rem, 2.9vw + .875rem, 3.375rem); font-weight: 700; }
h3 { font-size: 1.25rem; line-height: 1.25; font-weight: 700; }
p { text-wrap: pretty; }
.lede { font-size: clamp(1.125rem, .5vw + 1rem, 1.3125rem); color: var(--muted); max-width: 34rem; }
.small { font-size: .9375rem; }
.muted { color: var(--muted); }
.num { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
strong { font-weight: 700; }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.on-pine :focus-visible { outline-color: var(--on-pine); }

.skip { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--ink); color: var(--ground); padding: .75rem 1.25rem; border-radius: 999px; font-weight: 700; }
.skip:focus { top: 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* One slim line on every page while this is a demo. Remove it at launch. */
.demo-bar { background: var(--ink); color: var(--ground); font-size: .875rem; font-weight: 700; line-height: 1.3; text-align: center; padding: .5rem var(--gutter); }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- link: one look ---------- */

a { color: inherit; }
.link {
  font-weight: 700; text-decoration: none; padding-block: .25rem;
  background: linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
  position: relative;
}
html:not([data-still]) .link { transition: background-size .25s var(--ease); }
.link:hover { background-size: 0 2px; background-position: 100% 100%; }
button.link { border: 0; background-color: transparent; border-radius: 0; }
/* Text links keep their look but get a taller tap area. */
.link::after { content: ""; position: absolute; inset: -.5rem 0; }

/* ---------- buttons: one pair ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .625rem;
  min-height: 3.25rem; padding: .5rem 1.625rem; border: 0; border-radius: 999px;
  font: 700 1.0625rem/1.2 var(--text); text-decoration: none; text-align: center;
  background: var(--accent); color: var(--on-accent);
  --lip: var(--accent-lip);
  box-shadow: 0 4px 0 var(--lip);
  -webkit-tap-highlight-color: transparent;
}
html:not([data-still]) .btn { transition: transform .12s var(--ease), box-shadow .12s var(--ease), background-color .2s; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--lip); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--lip); }
html[data-still] .btn:hover, html[data-still] .btn:active { transform: none; box-shadow: 0 4px 0 var(--lip); }
.btn .i { width: 1.25rem; height: 1.25rem; }

.btn--line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn--line:hover { background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); transform: translateY(-2px); }
.btn--line:active { transform: scale(.98); box-shadow: inset 0 0 0 2px var(--ink); }
html[data-still] .btn--line:hover, html[data-still] .btn--line:active { transform: none; box-shadow: inset 0 0 0 2px var(--ink); }
.on-pine .btn--line { color: var(--on-pine); box-shadow: inset 0 0 0 2px var(--on-pine); }
.on-pine .btn--line:hover { background: var(--pine-surface); box-shadow: inset 0 0 0 2px var(--on-pine); }
.btn--small { min-height: 2.75rem; padding-inline: 1.25rem; font-size: 1rem; }
.btn--wide { width: 100%; }
html[data-contrast] .btn:not(.btn--line) { box-shadow: inset 0 0 0 2px var(--ink), 0 4px 0 var(--ink); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%;
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--sunk); }

/* ---------- icons ---------- */

.i { width: 1.5rem; height: 1.5rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.pip { flex: none; width: 2.75rem; height: 2.75rem; }
.pip__body { fill: var(--accent); }
.pip__eye, .pip__smile { fill: var(--on-accent); }
.pip__smile { fill: none; stroke: var(--on-accent); stroke-width: 3; stroke-linecap: round; }
@keyframes pip-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
html:not([data-still]) .pip__eye { transform-box: fill-box; transform-origin: center; animation: pip-blink 3.6s infinite; }

/* ---------- wordmark ---------- */

.mark { font-family: var(--display); font-weight: 800; font-size: 1.75rem; letter-spacing: -.04em; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; min-height: 2.75rem; }
.mark i { font-style: normal; color: var(--accent); }
html[data-calm] .mark i, html[data-contrast] .mark i { color: inherit; }
.on-pine .mark { color: var(--on-pine); }

/* ---------- card: one style ---------- */

.card { background: var(--surface); border-radius: var(--r3); padding: clamp(1.25rem, 2.5vw, 2rem); }
.card--tight { border-radius: var(--r2); padding: 1rem 1.25rem; }
.on-pine .card { color: var(--ink); }
html[data-contrast] .card { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .375rem; min-height: 2rem; padding: .25rem .875rem; border-radius: 999px; background: var(--sunk); font-weight: 700; font-size: .9375rem; line-height: 1.2; }
.chip--comfort { background: var(--mint); }
.chip .i { width: 1rem; height: 1rem; stroke-width: 2.5; }
html[data-contrast] .chip { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- switch ---------- */

.switch { display: inline-flex; align-items: center; gap: .625rem; min-height: 2.75rem; padding: 0 .25rem; border: 0; background: none; font-weight: 700; font-size: 1rem; border-radius: 999px; }
.switch__track { position: relative; flex: none; width: 3.25rem; height: 1.875rem; border-radius: 999px; background: var(--line); box-shadow: inset 0 0 0 2px var(--ink); }
.switch__knob { position: absolute; left: .3125rem; top: .3125rem; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--ink); }
html:not([data-still]) .switch__knob { transition: transform .2s var(--ease); }
.switch[aria-checked="true"] .switch__track { background: var(--ink); }
.switch[aria-checked="true"] .switch__knob { transform: translateX(1.375rem); background: var(--ground); }
/* With higher contrast the line color is the ink color, so an off switch is an outline with a solid knob. */
html[data-contrast] .switch__track { background: transparent; }
.on-pine .switch { color: var(--on-pine); }
.on-pine .switch__track { box-shadow: inset 0 0 0 2px var(--on-pine); background: transparent; }
.on-pine .switch__knob { background: var(--on-pine); }
.on-pine .switch[aria-checked="true"] .switch__track { background: var(--on-pine); }
.on-pine .switch[aria-checked="true"] .switch__knob { background: var(--pine); }

/* ---------- form fields ---------- */

.field { display: flex; flex-direction: column; gap: .375rem; }
.field > label, .label { font-weight: 700; }
.field .hint { font-size: .9375rem; color: var(--muted); }
.input, .field input[type="text"], .field input[type="tel"], .field input[type="email"], .field input[type="number"], .field input[type="time"], .field select, .field textarea {
  width: 100%; min-height: 3.25rem; padding: .625rem 1rem; border: 2px solid var(--edge); border-radius: var(--r1);
  background: var(--surface); color: var(--ink);
}
.field textarea { min-height: 5.5rem; resize: vertical; }
.input:focus-visible, .field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--ink); outline-offset: 1px; }
.field .error { color: var(--ink); font-weight: 700; font-size: .9375rem; display: flex; gap: .375rem; align-items: center; }
.field .error::before { content: "!"; display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: .8125rem; flex: none; }
.field[data-invalid] input, .field[data-invalid] textarea { border-color: var(--ink); }

/* selectable row: radio or checkbox inside a label */
.picks { display: flex; flex-direction: column; gap: .5rem; }
.pick { display: flex; align-items: center; gap: .875rem; min-height: 3.5rem; padding: .75rem 1rem; border-radius: var(--r2); background: var(--surface); box-shadow: inset 0 0 0 2px transparent; cursor: pointer; }
.pick input { flex: none; width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--ink); }
.pick__text { display: flex; flex-direction: column; min-width: 0; }
.pick__text b { font-weight: 700; }
.pick__text span { font-size: .9375rem; color: var(--muted); }
.pick:hover { box-shadow: inset 0 0 0 2px var(--line); }
.pick:has(input:checked) { background: var(--mint); box-shadow: inset 0 0 0 2px var(--ink); }
.pick:has(input:checked) .pick__text span { color: var(--ink); }
.pick:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.pick input:focus-visible { outline: none; }
html[data-contrast] .pick { box-shadow: inset 0 0 0 2px var(--ink); }
html[data-contrast] .pick:has(input:checked) { box-shadow: inset 0 0 0 4px var(--ink); }

/* ---------- notes, key-value rows ---------- */

.note { display: flex; gap: .75rem; align-items: flex-start; padding: .875rem 1rem; border-radius: var(--r2); background: var(--mint); }
.note .i { margin-top: .125rem; }
.note--demo { background: var(--sunk); font-size: .9375rem; }
.note--warn { background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- shared marks: initials badge and the "done" tick ---------- */

.mono { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-family: var(--display); font-weight: 800; font-size: 1.0625rem; letter-spacing: -.02em; }
.mono--lg { width: 4.5rem; height: 4.5rem; font-size: 1.625rem; }
.badge-ok { display: grid; place-items: center; width: 3.25rem; height: 3.25rem; border-radius: 50%; background: var(--ink); color: var(--ground); }
.badge-ok .i { stroke-width: 3; }

.kv { display: flex; flex-direction: column; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; padding-block: .625rem; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 700; text-align: right; }
.kv .kv__total { border-top: 2px solid var(--ink); border-bottom: 0; margin-top: .25rem; }
.kv .kv__total dt { color: var(--ink); font-weight: 700; }
.kv .kv__total dd { font-family: var(--display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.03em; }

/* ---------- comfort sheet (dialog) ---------- */

dialog.sheet {
  width: min(100% - 1.5rem, 30rem); max-height: min(100dvh - 1.5rem, 46rem); margin: auto; padding: 0; border: 0;
  border-radius: var(--r3); background: var(--ground); color: var(--ink); overflow: auto;
}
dialog.sheet::backdrop { background: rgb(6 13 12 / .55); }
.sheet__in { display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sheet__head h2 { font-size: 1.875rem; }
.rows { background: var(--surface); border-radius: var(--r2); padding: .25rem 1.25rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; padding-block: .625rem; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row__text { display: flex; flex-direction: column; }
.row__text b { font-weight: 700; }
.row__text span { font-size: .9375rem; color: var(--muted); }
.row .switch__label { display: none; }
html[data-contrast] .rows { box-shadow: inset 0 0 0 2px var(--ink); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .375rem; padding: .375rem; border-radius: var(--r2); background: var(--surface); }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 3rem; border-radius: var(--r1); font-weight: 700; cursor: pointer; text-align: center; padding-inline: .5rem; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: var(--ground); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }

.aloud { position: fixed; left: 1rem; bottom: 1rem; z-index: 40; }
.has-tabbar .aloud { bottom: 5.5rem; }

/* ---------- Pip chat ---------- */

.chat { display: flex; flex-direction: column; gap: .75rem; min-height: 0; }
.chat__log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; padding: .25rem; }
.msg { display: flex; gap: .5rem; align-items: flex-end; max-width: 94%; }
.msg--me { align-self: flex-end; }
.msg__body { display: flex; flex-direction: column; gap: .625rem; padding: .75rem 1rem; border-radius: 1.25rem 1.25rem 1.25rem .375rem; background: var(--sunk); min-width: 0; }
.msg--me .msg__body { background: var(--ink); color: var(--ground); border-radius: 1.25rem 1.25rem .375rem 1.25rem; }
.pip--sm { width: 2rem; height: 2rem; }
.msg__card { display: flex; flex-direction: column; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.msg__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: .25rem .375rem; }
.chat__chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chat__chips:empty { display: none; }
.chat__chips .btn { text-align: left; justify-content: flex-start; border-radius: var(--r2); }
.chat__form { display: flex; gap: .5rem; align-items: center; }
.chat__form .input { flex: 1; min-width: 0; border-radius: 999px; padding-inline: 1.25rem; }
.chat__mic { background: var(--sunk); }
.chat__mic[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chat__send { background: var(--ink); color: var(--ground); }
.chat__send:hover { background: var(--ink); }
html[data-contrast] .msg__body { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---------- toast ---------- */

.toast { position: fixed; left: 50%; bottom: 1.25rem; z-index: 60; transform: translateX(-50%); max-width: min(100% - 2rem, 28rem); padding: .875rem 1.25rem; border-radius: var(--r2); background: var(--ink); color: var(--ground); font-weight: 700; text-align: center; }
.has-tabbar .toast { bottom: 5.75rem; }

/* ---------- the calm shift: colours ease once when the switch is flipped ---------- */

html.shift, html.shift body, html.shift *, html.shift *::before, html.shift *::after {
  transition: background-color .6s ease, color .6s ease, box-shadow .6s ease, border-color .6s ease, fill .6s ease, stroke .6s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
