/* Mostly black, white and gray, with the logo's cyan used sparingly: the active tab dot, primary buttons, the send
   button and focus rings. Cyan is never text on white: text and icons on a cyan fill use --on-accent.
   Light is the default. Dark follows the system unless the owner picked a theme (theme.js sets data-theme). */
:root {
  color-scheme: light;
  --bg: #f5f7f7; --surface: #ffffff; --hover: #eef2f3; --text: #1b2124; --muted: #5a666b;
  --line: #e1e6e7; --line-strong: #c5ced1;
  --ink: #262c2f; --ink-text: #ffffff;
  --accent: #50e7f3; --accent-hover: #3dd8e5; --on-accent: #012423; --focus: #0b8995;
  --note: #e7f6ef; --note-text: #0f4d33; --warn-bg: #fcf1d6; --warn-text: #5f3c00;
  --shadow: 0 10px 30px rgb(16 24 28 / 0.12);
  --motion: 200ms;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141b1f; --surface: #1c252b; --hover: #253138; --text: #e6edef; --muted: #9eadb3;
    --line: #2a363d; --line-strong: #3b4a52;
    --ink: #34444d; --ink-text: #f3f7f8;
    --accent: #50e7f3; --accent-hover: #7aeef7; --on-accent: #012423; --focus: #50e7f3;
    --note: #123329; --note-text: #c6efdc; --warn-bg: #3a2d12; --warn-text: #f5dc9c;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141b1f; --surface: #1c252b; --hover: #253138; --text: #e6edef; --muted: #9eadb3;
  --line: #2a363d; --line-strong: #3b4a52;
  --ink: #34444d; --ink-text: #f3f7f8;
  --accent: #50e7f3; --accent-hover: #7aeef7; --on-accent: #012423; --focus: #50e7f3;
  --note: #123329; --note-text: #c6efdc; --warn-bg: #3a2d12; --warn-text: #f5dc9c;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
}
@media (prefers-reduced-motion: reduce) { :root { --motion: 0ms; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 720px; margin: 0 auto; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
body > main:first-child { padding-top: calc(20px + env(safe-area-inset-top)); }  /* signed out: no header */
a { color: inherit; text-underline-offset: 0.15em; }
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 16px; }
h2 { font-size: 1.1rem; font-weight: 600; margin: 32px 0 8px; }
h3.job { font-size: 0.95rem; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Header: wordmark, the Chat tab, the page's action, and the avatar menu with every other page. */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-inner { display: flex; align-items: center; gap: 16px; max-width: 720px; margin: 0 auto; padding: 10px 16px;
  min-height: 60px; }
.brand { margin-right: auto; font-size: 1.4rem; font-weight: 500; letter-spacing: -0.02em; text-decoration: none; }
.tab, .tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 8px 2px;
  color: var(--muted); text-decoration: none; font-weight: 500; transition: color var(--motion);
}
.tab:hover, .tabs a:hover { color: var(--text); }
.tab[aria-current="page"], .tabs a[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.tab[aria-current="page"]::after, .tabs a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 1px; background: var(--text);
}
.tabs { display: flex; gap: 20px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }

.menu { position: relative; margin: 0; }
.menu > summary {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--text); color: var(--text); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.03em;
}
.menu > summary::before { content: none; }
.menu[open] > summary { background: var(--hover); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 20; width: min(260px, calc(100vw - 32px));
  max-height: calc(100vh - 100px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
}
.menu-panel nav a { display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none; }
.menu-panel nav a:hover { background: var(--hover); }
.menu-panel nav a[aria-current="page"] { background: var(--hover); font-weight: 600; }
@supports (interpolate-size: allow-keywords) {
  .menu::details-content { height: auto; opacity: 1; overflow: visible; transition: none; }
}
.theme-switch { margin: 6px 0 0; padding: 10px 6px 6px; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.theme-switch legend { float: left; width: 100%; padding: 0 6px 8px; font-size: 0.85rem; }
.segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px;
  background: var(--hover); }
.segments label { position: relative; margin: 0; padding: 6px 0; border-radius: 8px; text-align: center;
  font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.segments input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segments label:has(input:checked) { background: var(--surface); color: var(--text); font-weight: 500;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.segments label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Cards and text */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.claim { margin: 0 0 6px; font-weight: 600; }
.host { color: var(--muted); font-size: 0.85rem; font-weight: 400; overflow-wrap: anywhere; }
.meta { margin: 2px 0; color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.tag { margin: 0 0 4px; font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); }
.empty { color: var(--muted); }
.note { background: var(--note); color: var(--note-text); padding: 10px 14px; border-radius: 10px; }
.warn { background: var(--warn-bg); color: var(--warn-text); padding: 10px 14px; border-radius: 10px; text-align: left; }
.center { text-align: center; padding-top: 12vh; }
.center .actions { justify-content: center; }
.status { min-height: 1.5em; color: var(--muted); }
code { overflow-wrap: anywhere; background: var(--hover); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
pre { margin: 8px 0 0; overflow-x: auto; }  /* a skill's script (Skills page) */
pre code { display: block; padding: 10px 12px; white-space: pre; overflow-wrap: normal; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Buttons and fields. A plain button is primary (cyan). .quiet is the outlined secondary. */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
button, a.button {
  font: inherit; font-weight: 500; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent); cursor: pointer;
  transition: background-color var(--motion), border-color var(--motion), transform var(--motion);
}
button:hover, a.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
a.button { display: inline-block; text-decoration: none; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
button.quiet { background: transparent; color: var(--text); border-color: var(--line-strong); }
button.quiet:hover { background: var(--hover); border-color: var(--line-strong); }
button.quiet.new-chat { padding: 7px 14px; border-color: var(--text); white-space: nowrap; }
label { display: block; font-size: 0.9rem; color: var(--muted); margin: 8px 0 4px; }
textarea, input[type="text"], input[type="number"], input[type="time"], input[type="date"], select {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
}
textarea, input[type="text"] { width: 100%; }
textarea::placeholder, input::placeholder { color: var(--muted); }

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; transition: transform var(--motion); }
details[open] > summary::before { transform: rotate(90deg); }
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  details::details-content {
    height: 0; opacity: 0; overflow: clip;
    transition: height var(--motion), opacity var(--motion), content-visibility var(--motion) allow-discrete;
  }
  details[open]::details-content { height: auto; opacity: 1; }
}

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
ol.history { padding: 0; list-style: none; }
footer { max-width: 720px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); color: var(--muted);
  font-size: 0.85rem; }
.destination { font-size: 1.1rem; overflow-wrap: anywhere; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 1rem; margin: 6px 0; }
label.check input { width: 18px; height: 18px; }
.route-svg { margin: 12px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.route-svg svg { display: block; width: 100%; height: auto; }
.walk-key { display: inline-block; width: 18px; height: 4px; background: #d9480f; border-radius: 2px; vertical-align: middle; }
ol.points, ol.steps { padding-left: 1.4em; }
ol.points li, ol.steps li { margin: 4px 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.dot.green { background: #16a34a; } .dot.amber { background: #d97706; } .dot.red { background: #dc2626; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.terms { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 4px 0; font-size: 0.92rem; }
.terms dt { color: var(--muted); }
.terms dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Chat: the owner's messages in a dark bubble on the right, replies as cards on the left. */
.chat-log { display: flex; flex-direction: column; gap: 20px; margin: 16px 0 20px; }
.msg { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.msg.owner { align-items: flex-end; }
.who { margin: 0 2px; font-size: 0.85rem; color: var(--muted); }
.bubble { max-width: 88%; padding: 12px 16px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.owner { background: var(--ink); color: var(--ink-text); }
.bubble.assistant { max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.bubble.streaming { opacity: 0.85; }
.bubble .md { white-space: normal; }
.md p { margin: 0 0 0.7em; }
.md > :last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0.2em 0 0.7em; padding-left: 1.4em; }
.md ul { list-style: circle; }
.md li { margin: 0.3em 0; }
.md .md-h { font-weight: 600; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--bg);
  padding: 0.1em 0.35em; border-radius: 6px; }
.bubble .card { white-space: normal; margin: 12px 0 0; padding: 12px 14px; background: var(--bg); border-radius: 12px; }
.bubble .card .actions { margin-top: 8px; }
.chat-form { position: sticky; bottom: 0; padding: 8px 0 calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.chat-form > label { margin: 0 2px 6px; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; }
.composer:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.composer textarea { flex: 1; min-height: 3.2em; padding: 6px 0; border: 0; border-radius: 0; background: transparent;
  resize: none; }
.composer textarea:focus-visible { outline: none; }
.send { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border-radius: 12px; }

/* Blocks (Stage 4b.3) */
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; padding: 4px 10px 8px; }
legend { font-size: 0.9rem; color: var(--muted); }
.digest { white-space: pre-wrap; }
.person-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow-y: auto; }
