:root {
    --bg: #0f1115; --bg-2: #151820; --bg-3: #1c202a; --border: #262b36;
    --text: #e6e8ee; --text-2: #9aa3b2; --text-3: #6b7383; --accent: #d97757; --accent-soft: rgba(217,119,87,.14); --ok: #5fb87a; --danger: #e5534b; --on-fill: #fff; --on-ok: #0f1115;
    /* Type: three content sizes (meta, body, titles). 16px body: iOS zooms into smaller text fields. */
    --fs-1: 13px; --fs-2: 16px; --fs-3: 22px;
    /* Space: one scale for every padding, gap and margin. */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 16px; --sp-4: 24px; --sp-5: 32px;
    --r-1: 12px; --r-2: 16px;
    color-scheme: dark;
  }
  @media (prefers-color-scheme: light) {
    :root { --bg: #faf9f7; --bg-2: #f1efeb; --bg-3: #e8e5df; --border: #dcd8d0; --text: #1d1b18; --text-2: #4d4943; --text-3: #7a756d; --accent-soft: rgba(217,119,87,.12); --ok: #2f8a4c; --on-ok: #fff; color-scheme: light; }
  }
  * { box-sizing: border-box; }
  /* The page fills the whole screen, home-indicator area included; what shows below it is the nav's colour, never white. */
  /* Below the tab bar, down to the screen's edge, only the bar's colour, whichever of these iOS shows there
     (an installed app can get a page shorter than the screen): the root, the page's own colour (its top half is
     painted over), a band under the bar. */
  html { background: var(--bg-2); }
  html, body { margin: 0; height: 100%; height: 100dvh; }
  body { background: var(--bg-2) linear-gradient(var(--bg) 50%, transparent 50%); color: var(--text); font: var(--fs-2)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
  button { font: inherit; color: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  main { flex: 1; overflow-y: auto; background: var(--bg); padding: var(--sp-3) var(--sp-3) var(--sp-5); }
  h1 { font-size: var(--fs-3); line-height: 1.2; margin: var(--sp-2) 0 var(--sp-2); }
  p { color: var(--text-2); margin: 0 0 var(--sp-2); }
  .list { display: flex; flex-direction: column; gap: var(--sp-3); }
  .card { border: 1px solid var(--border); border-radius: var(--r-2); background: var(--bg-2); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); }
  .card.high { border-color: color-mix(in srgb, var(--danger) 60%, var(--border)); }
  .meta { font-size: var(--fs-1); color: var(--text-3); }
  .badge { font-size: var(--fs-1); font-weight: 600; letter-spacing: .04em; color: var(--danger); }
  .title { font-weight: 600; line-height: 1.3; }
  .body { color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; }
  .draft { color: var(--text-2); background: var(--bg-3); border-radius: var(--r-1); padding: var(--sp-3); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 40vh; overflow-y: auto; }
  .acts { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); flex-wrap: wrap; }
  .btn { flex: 1 1 30%; min-height: 48px; border-radius: var(--r-1); border: 1px solid var(--border); background: var(--bg-3); padding: 0 var(--sp-3); font-weight: 500; }
  .btn:active { filter: brightness(.9); }
  .btn.yes { border-color: var(--ok); background: var(--ok); color: var(--on-ok); }
  .btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-fill); }
  .btn.quiet { background: none; color: var(--text-2); }
  .note { font-size: var(--fs-1); color: var(--text-3); }
  .empty { text-align: center; color: var(--text-3); margin: var(--sp-5) 0; }
  .err { color: var(--danger); font-size: var(--fs-1); }
  /* Sign-in and enrolment: the mark and words in the middle, the button down where the thumb is. */
  .center { min-height: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-5) var(--sp-2) 0; }
  .center .mark { width: 96px; height: 96px; border-radius: 22px; margin: auto 0 var(--sp-3); }
  .cam { width: 100%; max-width: 360px; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--bg-3); }
  .center .code { font-size: var(--fs-3); letter-spacing: 0.1em; }
  .center .go { margin-top: auto; width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: max(env(safe-area-inset-bottom), var(--sp-3)); }
  .paste { width: 100%; min-height: 48px; font: inherit; color: inherit; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--r-1); padding: var(--sp-2) var(--sp-3); }
  .center .btn { flex: none; width: 100%; }
  nav { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--border); background: var(--bg-2); box-shadow: 0 64px 0 var(--bg-2), 0 128px 0 var(--bg-2); padding-bottom: max(calc(env(safe-area-inset-bottom) - var(--sp-4)), var(--sp-2)); } /* the home indicator sits in the lowest ~13px: the labels clear it, no more */
  nav button { min-height: 48px; background: none; border: 0; color: var(--text-3); font-size: var(--fs-1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); }
  nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  nav .ic { position: relative; display: flex; }
  nav button.on { color: var(--accent); }
  nav .n { position: absolute; top: -6px; left: 16px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
  [hidden] { display: none !important; }
  .card.focus { border-color: var(--accent); }
  .card.agent { display: grid; grid-template-columns: 44px 1fr; gap: var(--sp-3); align-items: center; }
  .card.agent > div { display: flex; flex-direction: column; min-width: 0; }
  .card.agent.waiting { border-color: var(--accent); }
  .aboat { width: 44px; height: 44px; overflow: visible; }
  .aboat .hull { fill: var(--text-2); }
  .aboat .sail { fill: var(--text); }
  .aboat .jib { fill: var(--accent); }
  .aboat .mast { stroke: var(--text-2); stroke-width: 2; }
  .aboat .furl { fill: var(--text-3); }
  .aboat .sea { fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linecap: round; opacity: .6; }
  .aboat .lantern { fill: var(--accent); }
  .aboat .glow { fill: var(--accent); opacity: .25; }
  .card.agent.working .ship { animation: bob 3.6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 90%; }
  @keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-2px) rotate(2deg); } }
  @media (prefers-reduced-motion: reduce) { .card.agent.working .ship { animation: none; } }
  .card.agent.idle .title { color: var(--text-2); font-weight: 500; }
  .banner { position: sticky; top: 0; z-index: 2; margin: 0 0 var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); background: var(--bg-3); color: var(--text-2); font-size: var(--fs-1); }
  /* Routes: a route as a path of islands, top to bottom. */
  .chips { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--sp-3)) var(--sp-3); padding: 0 var(--sp-3); }
  .chip { flex: none; min-height: 48px; padding: 0 var(--sp-3); border-radius: 99px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text-2); }
  .chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
  .goal { color: var(--text-2); }
  .progress { font-size: var(--fs-1); color: var(--text-3); margin-bottom: var(--sp-4); }
  .route { list-style: none; margin: 0; padding: 0; position: relative; }
  .route::before { content: ''; position: absolute; left: 19px; top: 16px; bottom: 16px; border-left: 2px dashed var(--border); }
  .step { position: relative; display: grid; grid-template-columns: 40px 1fr; gap: var(--sp-3); padding: var(--sp-2) 0; }
  .step > div { min-height: 36px; display: flex; flex-direction: column; justify-content: center; }
  .isle { width: 40px; height: 36px; z-index: 1; overflow: visible; }
  .isle path:first-child { fill: var(--bg-3); stroke: var(--border); stroke-width: 1.6; }
  .step.done .isle path:first-child { fill: color-mix(in srgb, var(--ok) 22%, var(--bg)); stroke: var(--ok); }
  .step.next .isle path:first-child { fill: color-mix(in srgb, var(--accent) 22%, var(--bg)); stroke: var(--accent); stroke-width: 2; }
  .step.locked .isle path:first-child { fill: var(--bg); stroke-dasharray: 3 3; } /* opaque: the route's dashes pass behind, not through */
  .isle .mast { stroke: var(--text-2); stroke-width: 1.4; }
  .isle .flag { fill: var(--accent); }
  .isle .boat path { fill: var(--text); }
  .isle .boat .jib { fill: var(--accent); }
  .creature { position: absolute; right: 0; top: 50%; width: 76px; height: 36px; transform: translateY(-50%); pointer-events: none; overflow: visible; }
  .creature path, .creature circle { stroke: var(--text-2); stroke-width: 1.3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
  .creature .body { fill: var(--bg-3); }
  .creature .eye { fill: var(--text-2); stroke: none; }
  .creature .ripple { stroke-opacity: 0.35; stroke-width: 1; }
  .creature .fin { stroke-opacity: 0.6; }
  .creature .bob { animation: bob 6s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
  .creature .spout { opacity: 0.4; transform-box: fill-box; transform-origin: 50% 100%; }
  .creature .spout.go { animation: spout 2.4s ease-out; }
  @keyframes bob { 50% { transform: translateY(-1.5px) rotate(-1.5deg); } }
  @keyframes spout { 0% { opacity: 0; transform: scaleY(0.2); } 25% { opacity: 1; transform: scaleY(1.25); } 100% { opacity: 0.4; transform: scaleY(1); } }
  @media (prefers-reduced-motion: reduce) { .creature .bob, .creature .spout.go { animation: none; } }
  .step:has(.creature) > div { padding-right: 84px; }
  .step.done .title { color: var(--text-2); font-weight: 500; }
  .step.locked .title { color: var(--text-3); font-weight: 400; }
  .step.next .title { color: var(--text); }
  h2.unit { font-size: var(--fs-1); font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; margin: var(--sp-4) 0 var(--sp-2); }
  h2.unit:first-child { margin-top: 0; }
  .habit { margin-bottom: var(--sp-2); }
  .card .code { font-family: ui-monospace, Menlo, monospace; font-size: var(--fs-3); letter-spacing: .08em; }
  textarea { width: 100%; min-height: 96px; margin-top: var(--sp-2); font: inherit; color: inherit; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--r-1); padding: var(--sp-3); }
  /* The chat: channels, then one conversation (its messages scroll; the composer stays at the bottom, above the tabs). */
  .chans { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-bottom: var(--sp-3); }
  .chan { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--sp-2); text-align: left; background: none; border: 0; border-bottom: 1px solid var(--border); padding: var(--sp-3) 0; min-height: 48px; }
  .chan .cn { font-weight: 600; }
  .chan .cl { grid-column: 1; color: var(--text-3); font-size: var(--fs-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .chan .ct { grid-column: 2; grid-row: 1; color: var(--text-3); font-size: var(--fs-1); }
  body.chatting main { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
  .chathead { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-2); }
  .chathead .back { width: 48px; height: 48px; margin-left: calc(-1 * var(--sp-3)); background: none; border: 0; color: var(--accent); font-size: var(--fs-3); }
  .chathead .cn { font-weight: 600; }
  .msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: var(--sp-3); }
  .msg { max-width: 82%; padding: var(--sp-2) var(--sp-3); border-radius: var(--r-2); overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
  .msg.me { align-self: flex-end; background: var(--accent); color: var(--on-fill); border-bottom-right-radius: var(--sp-1); }
  .msg.her { align-self: flex-start; background: var(--bg-3); border-bottom-left-radius: var(--sp-1); }
  .msg a { color: inherit; }
  .msg .mt { white-space: pre-wrap; }
  .msg .mm, .msg .ed { display: block; font-size: var(--fs-1); opacity: .7; text-align: right; }
  .msg .ed { display: inline; }
  .msg .opts { display: flex; flex-wrap: wrap; gap: var(--sp-1); margin-top: var(--sp-2); }
  .msg .opt { border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: var(--r-2); padding: var(--sp-1) var(--sp-2); font-size: var(--fs-1); }
  .msg button.opt { min-height: 48px; padding: 0 var(--sp-3); }
  .msg .opt.on { background: var(--accent); color: var(--on-fill); }
  .msg .hint { display: block; margin-top: var(--sp-1); }
  .day { align-self: center; font-size: var(--fs-1); color: var(--text-3); margin: var(--sp-2) 0; }
  .compose { display: flex; gap: var(--sp-2); align-items: flex-end; padding: var(--sp-2) 0; border-top: 1px solid var(--border); }
  .compose textarea { flex: 1; min-height: 48px; max-height: 160px; margin: 0; padding: var(--sp-2) var(--sp-3); resize: none; }
  .compose .btn { flex: none; }
  .hint { font-size: var(--fs-1); color: var(--text-3); margin: 0 0 var(--sp-3); }
  .setrow { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 48px; }
  .seg { display: flex; background: var(--bg-3); border-radius: var(--r-1); padding: 2px; }
  .seg button { min-height: 48px; padding: 0 var(--sp-2); border: 0; border-radius: var(--r-1); background: none; color: var(--text-2); font-size: var(--fs-1); }
  .seg button.on { background: var(--bg); color: var(--text); }
  .compose .btn.round { width: 48px; padding: 0; font-size: var(--fs-2); }
  .compose .mic { background: var(--accent); border-color: var(--accent); color: var(--on-fill); touch-action: none; }
  .attach { display: flex; gap: var(--sp-2); padding-top: var(--sp-2); }
  .rec { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-1); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-1); }
  .rec .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
  .rec .grow { flex: 1; }
  .msg .pic { display: block; padding: 0; border: 0; background: none; margin: calc(-1 * var(--sp-1)) 0 var(--sp-1); }
  .msg .pic img { display: block; max-width: 100%; max-height: 240px; min-width: 96px; min-height: 64px; border-radius: var(--r-1); background: var(--bg-3); }
  .msg .att { display: block; font-size: var(--fs-1); }
  .msg .voice { display: flex; align-items: center; gap: var(--sp-2); }
  .msg .play { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: inherit; }
  .msg.her .play { background: var(--accent-soft); color: var(--accent); }
  .msg .len { font-size: var(--fs-1); opacity: .8; }
  .msg .tr { font-style: italic; opacity: .9; margin-top: var(--sp-1); }
  .viewer { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; }
  .viewer img { max-width: 100%; max-height: 100%; }
  .card .rows { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-1) var(--sp-3); margin: 0; font-size: var(--fs-1); }
  .card .rows dt { color: var(--text-3); }
  .card .rows dd { margin: 0; color: var(--text-2); }
  .card .imp { font-weight: 600; } .card .imp.low { color: var(--ok); } .card .imp.medium { color: #d9a441; } .card .imp.high { color: var(--danger); }
  .card .rnote { color: var(--text-3); }
  .card .det summary { color: var(--text-2); font-size: var(--fs-1); min-height: 32px; }
  .filters { margin-bottom: var(--sp-3); width: max-content; max-width: 100%; overflow-x: auto; }
  .tags { display: flex; gap: var(--sp-1); }
  .badge.later { color: var(--text-3); }
  /* The chat's look: a sea chart behind the conversation (two variants: chart, paper), her compass-rose emblem. */
  .chico svg, .av svg { width: 100%; height: 100%; display: block; }
  .chico { width: 32px; height: 32px; flex: none; }
  .r1 { fill: var(--bg-3); stroke: var(--accent); stroke-width: 1.2; } .r2 { fill: var(--accent); } .r3 { fill: var(--text-3); } .r4 { stroke: var(--text-2); stroke-width: 2; fill: none; }
  .chathead .sub { margin-left: auto; font-size: var(--fs-1); color: var(--text-3); }
  .chan { grid-template-columns: 32px 1fr auto; column-gap: var(--sp-3); align-items: center; }
  .chan .chico { grid-row: span 2; }
  .chan .cn, .chan .cl { grid-column: 2; }
  .chan .ct { grid-column: 3; grid-row: 1; }
  .msgs { margin: 0 calc(-1 * var(--sp-3)); padding: var(--sp-3); border-radius: var(--r-1); }
  body.look-chart .msgs { background-color: var(--bg); background-image: linear-gradient(color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px); background-size: 40px 40px; }
  body.look-paper .msgs { background-color: color-mix(in srgb, #c9a77a 12%, var(--bg)); background-image: repeating-radial-gradient(circle at 18% 28%, transparent 0 26px, color-mix(in srgb, #c9a77a 18%, transparent) 26px 27px), repeating-radial-gradient(circle at 82% 78%, transparent 0 34px, color-mix(in srgb, #c9a77a 14%, transparent) 34px 35px); }
  .hers { display: flex; align-items: flex-end; gap: var(--sp-2); max-width: 88%; }
  .hers .msg { max-width: none; }
  .msg .who { display: block; font-size: var(--fs-1); opacity: .7; }
  .av { width: 28px; height: 28px; flex: none; }
  /* His bubbles a darker accent so white text keeps a 4.5:1 contrast; hers solid, with a hairline, over the chart. */
  .msg.me { background: color-mix(in srgb, var(--accent) 78%, #000); }
  .msg.her { background: var(--bg-2); border: 1px solid var(--border); }
  @media (prefers-contrast: more) { .msgs { background-image: none !important; } .msg.her { border-color: var(--text-2); } }
