* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink);
  font-family: var(--f-body); font-size: 16px; line-height: 1.55;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3, p, ul, ol, figure { margin: 0; }
a { color: var(--ai); }
:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--f-display); font-weight: 700; font-size: 24px; color: var(--ink); text-decoration: none; line-height: 1; }
.brand-ai { color: var(--ai); }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 10px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; }
.topnav a[aria-current='page'] { background: var(--ai-wash); color: var(--ai); }

/* layout */
.view { display: block; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px)); max-width: 760px; margin: 0 auto; outline: none; }
.screen { display: flex; flex-direction: column; gap: 18px; }
.title { font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1.2; text-wrap: balance; overflow-wrap: anywhere; }
.section { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.sub { color: var(--ink-2); font-size: 14px; }
.empty { color: var(--ink-2); }
.crumbs a { text-decoration: none; font-weight: 500; }
.booting { padding: 32px 16px; color: var(--ink-2); }

/* buttons */
.acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  font: inherit; font-size: 15px; font-weight: 700; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--sheet); color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.btn.pri { background: var(--ai); color: var(--ai-ink); border-color: var(--ai); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ai); }
.btn.danger { color: var(--risk); border-color: var(--risk); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* cards and lists */
.cards { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); color: var(--ink); text-decoration: none; }
.card .name { font-family: var(--f-display); font-weight: 700; font-size: 17px; overflow-wrap: anywhere; }
.panel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
dialog.ask { width: min(100% - 32px, 420px); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); color: var(--ink); }
dialog.ask::backdrop { background: rgb(0 0 0 / 0.45); }
dialog.ask .acts { justify-content: flex-end; }
details.archived summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; min-width: 0; }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
input, textarea, select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input[type='checkbox'], input[type='radio'] { width: 22px; height: 22px; min-height: 0; accent-color: var(--ai); }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.checks { display: flex; flex-direction: column; }
.radios { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; }
.radios legend { font-size: 14px; font-weight: 500; color: var(--ink-2); padding: 0; margin-bottom: 2px; }
.error, .errors { color: var(--risk); font-size: 14px; }
.errors { padding-left: 20px; }

/* files */
.files { display: flex; flex-direction: column; gap: 14px; }
.file-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; flex-direction: column; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sheet); color: var(--ink); text-decoration: none; }
.file-row .path { font-family: var(--f-mono); font-size: 14px; overflow-wrap: anywhere; }
.editor { font-family: var(--f-mono); font-size: 14px; line-height: 1.5; min-height: 40vh; resize: vertical; }
.preview img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); }
.history { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* trace */
.trace { list-style: none; padding: 0; display: flex; flex-direction: column; font-family: var(--f-mono); font-size: 13px; }
.trace li { border-bottom: 1px solid var(--line); padding: 6px 0; }
.trace summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.trace .k { color: var(--ai); font-weight: 500; }
.trace .d { overflow-wrap: anywhere; }
.trace pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper); padding: 10px; border-radius: 8px; margin: 6px 0 0; }
/* text to copy (a place's browser-access rules): wrapped on screen, copied as it is */
pre.code { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--paper); padding: 10px; border-radius: 8px; margin: 0; font-size: 13px; }

/* the data-safety warning and notices */
.risk { margin: 12px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); max-width: 728px; padding: 14px 16px; border-radius: var(--radius); background: var(--risk-wash); display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 792px) { .risk { margin-left: auto; margin-right: auto; } }
.risk strong { color: var(--risk); }
.steps { padding-left: 20px; }
.risk-note { padding: 12px 14px; border-radius: 12px; background: var(--amber-wash); color: var(--ink); font-size: 14px; }
.notices { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-direction: column; gap: 8px; padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px)); pointer-events: none; align-items: center; }
.notice, .toast { pointer-events: auto; width: min(100%, 560px); padding: 14px 16px; border-radius: var(--radius); background: var(--sheet); border: 1px solid var(--line); box-shadow: 0 12px 30px -16px var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.notice-warn { border-color: var(--amber); }
.notice-risk { border-color: var(--risk); }
.notice-ok { border-color: var(--ok); }
.toast { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.blocking { max-width: 560px; margin: 15vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 14px; }

/* Photos (§4.8, §16.2) */
.preview { display: flex; flex-direction: column; gap: 6px; }
.preview .photo { display: block; max-width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.viewer { position: fixed; inset: 0; z-index: 50; display: flex; background: #0b0c0e; }
.viewer-stage { flex: 1; overflow: hidden; touch-action: none; }
.viewer-img { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-select: none; }
.viewer-part { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); }
.viewer-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
.thumbs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs img { display: block; height: 88px; width: auto; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }

/* Settings → Models */
.role { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.role-name { font-size: 15px; font-weight: 700; margin: 0; }
.role-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.role-item { display: flex; align-items: center; gap: 2px; }
.role-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.where { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.where .sub { margin: 2px 0 0; }
textarea.mono { font-family: var(--f-mono); font-size: 13px; }
.listed { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.listed li { justify-content: space-between; }

/* Talk to your models, and test results */
.talk { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.talk-you { align-self: flex-end; max-width: 85%; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; }
.talk-model { display: flex; flex-direction: column; gap: 4px; }
.talk-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.checks-result { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.checks-result .bad { color: var(--risk); }
.shared-text { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--line); color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
/* The top bar scrolls rather than pushing the page wider on a phone. */
.topnav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { white-space: nowrap; }
/* The Plan (spec §16.2): a trip booklet's schedule page. */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.tab { flex: none; min-height: 44px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--sheet); color: var(--ink-2); font: inherit; font-size: 15px; cursor: pointer; }
.tab[aria-selected='true'] { background: var(--ai-wash); color: var(--ai); border-color: transparent; }
.timetable { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.plan-row { display: grid; grid-template-columns: 6.5em 1.2em minmax(0, 1fr); gap: 4px 8px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan-row .when { font-family: var(--f-mono); font-size: 13px; color: var(--ink-2); }
.plan-row .mark { color: var(--ai); }
.plan-row .what { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; min-height: 44px; justify-content: center; }
.plan-row .chips, .plan-row .note { grid-column: 3; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: var(--paper); color: var(--ink-2); text-decoration: none; }
a.chip { min-height: 44px; }
.chip.check { background: var(--amber-wash); color: var(--amber); }
.chip.warn { background: var(--risk-wash); color: var(--risk); }
.chip.ok { background: var(--ok-wash); color: var(--ok); }
button.chip.undo { min-height: 44px; border: 1px solid var(--line); cursor: pointer; font: inherit; font-size: 13px; }
.leg { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 6px calc(6.5em + 1.2em + 16px); color: var(--ink-2); font-size: 14px; border-bottom: 1px dashed var(--line); }
/* Now and Driving (spec §16.2) */
.now-place { font-family: var(--f-display); font-weight: 700; font-size: 20px; overflow-wrap: anywhere; }
.shiori-card { display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.shiori-card p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.route-strip { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 3px solid var(--ai); display: flex; flex-direction: column; gap: 10px; }
.route-strip li { display: flex; flex-direction: column; }
.route-strip .name { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.route-strip .you { color: var(--ai); font-weight: 700; }
.maps-card { display: flex; flex-direction: column; gap: 8px; }
.maps-card:empty, .drive-latest:empty { display: none; }
.quick-ask { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.big { min-height: 64px; font-size: 18px; border-radius: 18px; }
.sub.warn { color: var(--risk); }
.file-names { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 12px; margin: 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.original { display: flex; flex-direction: column; gap: 8px; }
/* Stamps (spec §13, §16.2): station-stamp marks for visited places. */
.trip-card { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.trip-card-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stamps { display: flex; flex: none; padding-left: 10px; }
.stamp {
  width: 40px; height: 40px; margin-left: -10px; padding: 3px; border-radius: 50%; border: 3px double var(--ai);
  background: var(--sheet); color: var(--ai); display: grid; place-items: center; text-align: center;
  font-family: var(--f-display); font-size: 9px; font-weight: 700; line-height: 1.05; overflow: hidden; word-break: keep-all;
}
.stamp.long { font-size: 7.5px; }
.stamp.longer { font-size: 6.5px; }
.stamp:nth-child(3n + 1) { transform: rotate(-9deg); }
.stamp:nth-child(3n + 2) { transform: rotate(6deg); }
.stamp:nth-child(3n) { transform: rotate(-3deg); }
.stamp.more { font-family: var(--f-mono); font-size: 11px; }
.stamps.big { flex-wrap: wrap; gap: 8px; padding-left: 0; }
.stamps.big .stamp { width: 60px; height: 60px; margin-left: 0; font-size: 11px; }
.stamps.big .stamp.long { font-size: 9.5px; }
.stamps.big .stamp.longer { font-size: 8px; }
/* Recap (spec §13) */
.recap-text { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.recap-text .md { display: flex; flex-direction: column; gap: 10px; }
.recap-text .md-h { font-family: var(--f-display); font-weight: 700; font-size: 18px; }
.sent summary { cursor: pointer; color: var(--ink-2); min-height: 44px; display: flex; align-items: center; }
.sent ul { padding-left: 20px; color: var(--ink-2); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
/* Replay (spec §13): a flat map, no tiles; strokes and geometry are attributes and these rules, never a style attribute. */
.tab[aria-current='page'] { background: var(--ai-wash); color: var(--ai); border-color: transparent; }
a.tab { display: inline-flex; align-items: center; text-decoration: none; }
.route { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.route-map { display: block; width: 100%; height: auto; max-height: 62vh; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.route-all, .route-done { fill: none; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.route-all { stroke: var(--line); }
.route-done { stroke: var(--ai); }
.route-jump { stroke: var(--ink-2); stroke-width: 4; stroke-dasharray: 12 14; }
.route-stay { fill: var(--sheet); stroke: var(--ink-2); stroke-width: 4; }
.route-stamp { fill: var(--sheet); stroke: var(--ai); stroke-width: 6; }
.route-here { fill: var(--ai); stroke: var(--sheet); stroke-width: 5; }
.replay-now { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sheet); }
.replay-time { font-family: var(--f-mono); color: var(--ink-2); }
.replay-photo { display: block; max-width: 100%; max-height: 40vh; border-radius: 10px; }
.replay-figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.replay-figure figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.replay-controls { display: flex; flex-direction: column; gap: 10px; }
/* A field fills a row; in a column it keeps its own height. */
.replay-controls .field, .simulate .field { flex: none; }
.replay-controls input[type='range'] { padding: 0; accent-color: var(--ai); }
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.replay-item { width: 100%; min-height: 44px; display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 8px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.replay-item .when { font-family: var(--f-mono); font-size: 13px; color: var(--ink-2); }
.replay-entry.kind-stay .what { font-weight: 700; }
.replay-entry.now .replay-item { background: var(--ai-wash); }
/* Simulate a trip (spec §13) */
.simulate progress { width: 100%; height: 12px; accent-color: var(--ai); }
.sim-time { font-family: var(--f-mono); }
