/* The hub's one stylesheet: the sign-in and account pages (templates) and the
   app (crates/web). Light and dark, each its own steps. */

:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #efeeeb;
  --raised: #ffffff;
  --line: #dddcd7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #74736e;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #8a4fd1;
  --series-3: #d18a1f;
  --series-4: #1f9e8a;
  --danger: #c4312f;
  --ok: #1d7a3a;
  --warn-bg: #fff4d6;
  --user-bg: #e6eefa;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #242422;
    --raised: #2c2c29;
    --line: #34332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #a06ee6;
    --series-3: #e0a040;
    --series-4: #3bb8a2;
    --danger: #e66767;
    --ok: #5cc27a;
    --warn-bg: #3a3218;
    --user-bg: #1f2c40;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 13px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 8px; }

button {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 7px 14px;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); }
button.small { padding: 4px 10px; font-size: 13px; }
button.big { padding: 12px 24px; font-size: 16px; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button.icon { width: 34px; height: 34px; padding: 0; font-size: 20px; line-height: 1; }

input, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* phones: a field's text at 16 px — less, and Safari zooms the page in at its focus (and leaves it so) */
@media (pointer: coarse), (max-width: 820px) { input, textarea, select { font-size: 16px; } }
label { display: grid; gap: 4px; color: var(--text-2); font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 8px 12px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.warning { background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { width: auto; flex: 1; }

/* --- the pages of the templates --------------------------------------------------------- */
body.plain { padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; max-width: 640px; margin: 32px auto; }
.card.narrow { max-width: 380px; }

/* --- the app: the nav on the side, the tab beside it ------------------------------------- */
body.app { overflow: hidden; }
.shell { display: grid; grid-template-columns: 220px 1fr; height: 100dvh; }
.side { background: var(--surface-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; padding: 0 8px; min-height: 0; overflow-y: auto; }
.side-head { padding: 14px 8px 12px; }
.brand { font-weight: 600; }
.nav-item { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.nav-item:hover { background: var(--line); }
.nav-item .badge { vertical-align: middle; position: relative; top: -1px; line-height: 16px; }
.nav-item.current { background: var(--surface); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.nav-group { margin: 14px 10px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
/* the notes, under the chat: their folders, each note, one being written (greyed, a spinner) */
.notes-head { margin-top: 10px; }
.notes-head .spinner { margin-left: 6px; }
.notes-none { margin: 0 10px 4px; }
.nav-item.note { font-size: 14px; padding-top: 4px; padding-bottom: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.nav-item.note.pending { color: var(--muted); cursor: default; }
.nav-item.note.pending:hover { background: none; }
button.nav-item.note-folder { width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 14px; color: var(--text-2); padding-top: 4px; padding-bottom: 4px; cursor: pointer; }
.note-folder .fold { display: inline-block; width: 10px; color: var(--muted); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 10px; }
/* a note's page: its pictures; a paragraph of pictures alone, a mosaic */
.note-body img { display: block; max-width: 100%; max-height: 480px; margin: 8px auto; border-radius: 8px; }
.note-body .mosaic { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin: 12px 0; }
.note-body .mosaic img { width: 100%; height: 180px; max-height: none; margin: 0; object-fit: cover; }
.notes-card .handed-head .spinner { margin-left: 4px; }
.side-bottom { margin-top: auto; padding-bottom: 6px; }
.side-foot { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 14px; }
.side-foot .who { font-weight: 600; width: 100%; }
.side-foot form { display: inline; }
.scrim { display: none; }
.content { min-width: 0; min-height: 0; background: var(--bg); overflow: hidden; }

/* a tab: its header, then what it holds */
.page { height: 100%; display: flex; flex-direction: column; }
.page-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 55px; border-bottom: 1px solid var(--line); background: var(--surface); }
.page-head h1 { flex: 1; font-size: 16px; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.page-body { flex: 1; overflow-y: auto; padding: 16px; }
.page-body > * { max-width: 1100px; margin-left: auto; margin-right: auto; }
.narrow-page > * { max-width: 640px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; }
.panel h2 { margin-top: 0; }
.panel .row { margin-top: 12px; flex-wrap: wrap; }
.qr svg { width: 200px; height: 200px; background: #fff; border-radius: 8px; }
.secret { word-break: break-all; }
.menu, .back { display: none; }
.back { font-size: 24px; text-decoration: none; line-height: 1; }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--text-2); }
.badge.working, .badge.running { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.badge.failed { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--text); }
/* an app's on/off switch (the Hosted tab) */
.power { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button.switch { position: relative; width: 34px; height: 20px; min-height: 0; padding: 0; border-radius: 99px; border: 1px solid var(--line); background: var(--line); cursor: pointer; transition: background .15s; flex: none; }
button.switch .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: left .15s; }
button.switch.on { background: var(--ok); border-color: var(--ok); }
button.switch.on .knob { left: 16px; }
button.switch.busy { opacity: .6; cursor: progress; }

.badge.waiting { background: color-mix(in srgb, var(--warn-bg) 70%, var(--line)); color: var(--text); }
/* a task to review (the nav's count, a project's, a task's): blue, the user's turn */
.badge.review { background: var(--accent); color: var(--accent-ink); }
.badge.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--text); }
.badge.handed { background: var(--surface-2); }
a.button { display: inline-block; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 13px; color: var(--text); text-decoration: none; background: var(--surface); }
a.button:hover { background: var(--surface-2); }

/* --- the projects tab: a block a repository, its tasks -------------------------------------- */
.project-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-head h2 { margin: 0; font-size: 17px; flex: 1; }
.project-head h2 a { color: var(--text); text-decoration: none; }
.project-head h2 a:hover { text-decoration: underline; }
.tasks { display: grid; gap: 10px; margin-top: 12px; }
.task { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.task.review { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.task-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-head h3 { margin: 0; font-size: 15px; flex: 1; }
.task p { margin: 0; }
.review-box { display: grid; gap: 8px; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.review-box textarea { resize: vertical; }
.task-more summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.task-more h4 { margin: 12px 0 4px; font-size: 13px; color: var(--text-2); }
.task-more .plan { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--line); }
.workers, .history { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 4px; }
.history .event { white-space: pre-wrap; overflow-wrap: anywhere; }
.notice.handed { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); }
/* --- the chat tab: the user's one chat ------------------------------------------------------ */
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; background: var(--surface); }
.msg-time { font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.user .msg-time { text-align: right; }
.handover { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; background: var(--surface-2); }
.handover-task { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.handed-body { flex: 1; min-width: 0; }
.handed-head { display: flex; align-items: center; gap: 8px; }
.handed-head .ci-strip { margin: 0 0 0 auto; }
.handed-title { color: inherit; text-decoration: none; }
.handed-title:hover { text-decoration: underline; }
.task-meta { display: flex; align-items: center; gap: 12px; }
.task-meta p { flex: 1; min-width: 0; }
.task-meta .ci-strip { margin: 0; }
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); }

.log { flex: 1; overflow-y: auto; padding: 20px max(16px, calc((100% - 760px) / 2)); display: flex; flex-direction: column; }
.log-body { flex: 1 0 auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user-bg); padding: 8px 14px; border-radius: 14px; white-space: pre-wrap; max-width: 85%; }
.msg.answer > :first-child { margin-top: 0; }
.msg.answer > :last-child { margin-bottom: 0; }
.msg.answer pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow-x: auto; }
.msg.answer table { border-collapse: collapse; width: auto; }
.msg.answer th, .msg.answer td { border: 1px solid var(--line); padding: 4px 8px; }
.tool { border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.tool summary { padding: 6px 10px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool-name { font-weight: 600; }
.tool-input { font-family: var(--mono); color: var(--text-2); }
.tool.running .tool-name::after { content: " …"; }
.tool.failed { border-color: var(--danger); }
.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); max-height: 320px; overflow: auto; white-space: pre-wrap; }
.notice { color: var(--text-2); text-align: center; font-size: 14px; }
.turn-meta { font-size: 12px; margin: -6px 0 0; }
.thinking { margin: 0; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.composer { border-top: 1px solid var(--line); padding: 12px max(16px, calc((100% - 760px) / 2)) max(12px, env(safe-area-inset-bottom)); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 40vh; field-sizing: content; min-height: 44px; }
.welcome { margin: auto; text-align: center; max-width: 460px; padding: 24px; }

/* --- narrow screens: the nav slides in ------------------------------------------------------------ */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 78%; max-width: 280px; z-index: 6; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .side { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 5; background: rgb(0 0 0 / .35); }
  .menu { display: inline-block; }
  .back { display: inline; }
}

/* --- the admin page ------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tiles + .panel { margin-top: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; gap: 2px; }
.tile-label { color: var(--text-2); font-size: 13px; }
.tile-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-note { color: var(--muted); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; margin-top: 10px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.chart figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.chart-title { color: var(--text-2); }
.chart-value { color: var(--text); font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .col { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart g.hover .hit { fill: color-mix(in srgb, var(--text) 6%, transparent); }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.chart .axis { stroke: var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--text-2); font-weight: 500; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.clip { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* (relative: what is hidden for screen readers in it — .vh, absolute — stays in its box, not past the screen) */
.scroll { overflow-x: auto; position: relative; }
.narrow-form { max-width: 460px; margin-top: 16px; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.prices input { padding: 4px 6px; }
.prices input.rate { width: 6.5em; text-align: right; }
.prices td.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; justify-content: flex-end; }

/* --- a Claude account's windows: a bar each -------------------------------------------------- */
.meter { display: flex; align-items: center; gap: 6px; min-width: 120px; }
.meter-bar { flex: 1; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.meter-fill.mid { background: color-mix(in srgb, var(--accent) 40%, #d98a00); }
.meter-fill.high { background: var(--danger); }

/* --- explanations: behind an i, in the page's one box (ui.rs) ------------------------------ */
.label-row { display: inline-flex; align-items: center; gap: 6px; }
.info {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line); background: var(--raised);
  color: var(--text-2); font: italic 600 12px/1 Georgia, serif; cursor: help; user-select: none;
  text-transform: none; letter-spacing: 0;
}
.info:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.info.warn { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.tip-box {
  position: fixed; z-index: 1000; display: none; max-width: min(420px, calc(100vw - 16px));
  padding: 8px 10px; border-radius: 8px; background: var(--text); color: var(--bg);
  font: 400 12.5px/1.45 var(--font); white-space: pre-line; text-transform: none; letter-spacing: 0;
  box-shadow: 0 4px 16px rgb(0 0 0 / .18);
}
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* --- a form: a modal at its own address (ui.rs) --------------------------------------------- */
dialog.modal {
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto;
}
dialog.modal::backdrop { background: rgb(0 0 0 / .4); }
.modal-inner { padding: 14px 18px 18px; display: grid; gap: 12px; }
.modal-head { display: flex; align-items: center; gap: 8px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-inner p { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-head h2 { flex: 1; margin: 0; }
.bar { flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }
.composer-row .info { margin-bottom: 13px; }
/* (a page without the script: its i shows its text on hover or focus, drawn over the page) */
.info.nojs { position: relative; }
.info.nojs:hover::after, .info.nojs:focus::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 1000;
  width: max-content; max-width: min(420px, calc(100vw - 16px)); padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--bg); font: 400 12.5px/1.45 var(--font); white-space: pre-line;
}

/* --- the Drive tab: a folder at a time, as tiles ------------------------------------------ */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 14px; }
.crumbs a { color: var(--text); text-decoration: none; padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); }
.crumbs a:last-child { font-weight: 600; }
.crumbs .sep { color: var(--muted); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.file-tile { position: relative; display: grid; gap: 2px; padding: 8px; border-radius: var(--radius); border: 1px solid transparent; }
.file-tile:hover { background: var(--surface); border-color: var(--line); }
.tile-open { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; border-radius: 8px; background: var(--surface-2); overflow: hidden; text-decoration: none; }
.tile-open img { width: 100%; height: 100%; object-fit: cover; }
.file-tile .sign { font-size: 44px; line-height: 1; }
.file-tile.folder .tile-open { background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.file-name { font-size: 13px; font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-right: 22px; }
.file-meta { font-size: 11px; color: var(--muted); }
.file-menu { position: absolute; right: 6px; bottom: 22px; }
.file-menu summary { list-style: none; cursor: pointer; padding: 0 6px; border-radius: 6px; color: var(--text-2); }
.file-menu summary::-webkit-details-marker { display: none; }
.file-menu summary:hover { background: var(--surface-2); }
.file-menu-items { position: absolute; right: 0; top: 100%; z-index: 5; display: grid; min-width: 150px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgb(0 0 0 / .12); }
.file-menu-items a, .file-menu-items button { display: block; text-align: left; padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--text); text-decoration: none; }
.file-menu-items button.link { text-decoration: none; }
.file-menu-items button.danger { color: var(--danger); }
.file-menu-items a:hover, .file-menu-items button:hover { background: var(--surface-2); }
.drop-here { display: none; }
.dragging .drop-here { display: flex; position: fixed; inset: 16px; z-index: 50; align-items: center; justify-content: center; border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); font-weight: 600; pointer-events: none; }

/* --- files with a message ----------------------------------------------------------------- */
.attached { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip button.link { text-decoration: none; color: var(--muted); padding: 0 2px; }
.msg.user .chip { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.composer .attached { margin: 0 0 8px; }
.composer-row .attach { flex: none; margin-bottom: 5px; font-size: 18px; }
.chat-col.dragging .log { outline: 2px dashed var(--accent); outline-offset: -8px; }
.error .retry { width: 28px; height: 28px; font-size: 16px; color: var(--text-2); }
dialog.modal.wide { width: min(1100px, calc(100vw - 24px)); }
.viewer { display: flex; align-items: center; justify-content: center; min-height: 200px; max-height: calc(100dvh - 170px); overflow: auto; background: var(--surface-2); border-radius: 8px; }
.viewer img, .viewer video { max-width: 100%; max-height: calc(100dvh - 170px); object-fit: contain; display: block; }
.viewer iframe { width: 100%; height: calc(100dvh - 170px); border: 0; background: #fff; }
.viewer pre { align-self: stretch; width: 100%; margin: 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.viewer .muted { padding: 32px; }
.viewer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.viewer-bar .spacer { flex: 1; }

/* --- a browser shown to the user (live.rs) ------------------------------------------------ */
.live { display: grid; gap: 10px; outline: none; }
.live-bar { display: flex; align-items: center; gap: 8px; }
.live-address { flex: 1; }
.live-address input { padding: 6px 10px; font-family: var(--mono); font-size: 13px; }
.live-view { display: flex; justify-content: center; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.live-view img { display: block; width: 100%; max-height: calc(100dvh - 220px); object-fit: contain; cursor: pointer; user-select: none; }
.live-view .muted { padding: 120px 0; }

/* the storage bar (Drive): files, repositories, apps' data, against the room */
.storage { margin-bottom: 14px; }
.storage-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.storage-part { height: 100%; }
.storage-part + .storage-part { border-left: 2px solid var(--surface); }
.storage-part.files, .dot.files { background: var(--series-1); }
.storage-part.repos, .dot.repos { background: var(--series-2); }
.storage-part.hosted, .dot.hosted { background: var(--series-3); }
.storage-part.assets, .dot.assets { background: var(--series-4); }
.storage-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; color: var(--text-2); }
.storage-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 6px; vertical-align: 0; }

/* a hosted app's logs (Hosted) */
pre.logs { font-family: var(--mono); font-size: 12px; line-height: 1.45; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; max-height: 65vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 8px 0 0; }

/* the drive's new files: put there for the user, not opened yet (the nav's count, a tile's dot) */
.badge.new { background: var(--accent); color: var(--accent-ink); }
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; background: var(--accent); margin-right: 6px; vertical-align: 1px; }

/* the user's SSH key (Data): one line, selectable, wrapped on a small screen */
code.key { font-size: 12px; word-break: break-all; user-select: all; flex: 1; }

.project-head .project-delete { margin-left: auto; }

/* a task's CI, live (Projects): a square a run, the newest on the right, sliding in */
.ci-strip { display: flex; justify-content: flex-end; gap: 3px; overflow: hidden; margin: 6px 0 2px; max-width: 100%; }
.ci-square { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--line); animation: ci-in .35s ease-out; }
.ci-square.done { background: var(--ok); }
.ci-square.failed { background: var(--danger); }
.ci-square.running { background: var(--accent); animation: ci-in .35s ease-out, ci-pulse 1s ease-in-out infinite alternate; }
.ci-square.skipped, .ci-square.cancelled { background: var(--muted); opacity: .45; }
@keyframes ci-in { from { width: 0; opacity: 0; } to { width: 12px; opacity: 1; } }
@keyframes ci-pulse { from { opacity: 1; } to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .ci-square, .ci-square.running { animation: none; } }

/* a form for a project's secrets, in the chat */
.secrets-form { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.secrets-form input { width: 100%; }

/* links in a message (an answer, a summary, a plan): the link colour, underlined, a long address wrapped */
.msg a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg a:hover { text-decoration-thickness: 2px; }

/* a spinner in a badge: a task at work (starting, building, merging) */
.badge-spinner { width: 9px; height: 9px; border-width: 1.5px; vertical-align: -1px; }

/* the notes: a page as Notion's — a column of reading width, room above it, a large title, set in
   the system's own sans-serif as Notion's is (San Francisco, Segoe UI…); the app's bar in its own face */
.note-page { padding: 64px 24px 96px; }
.note-page > * { max-width: 708px; }
.note-body.msg { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.note-body.msg > * { margin: 0.35em 0; }
.note-body.msg h1, .note-body.msg h2, .note-body.msg h3 { font-weight: 600; line-height: 1.3; }
.note-body.msg h1 { font-size: 40px; font-weight: 700; line-height: 1.2; margin: 0 0 0.6em; }
.note-body.msg h2 { font-size: 1.5em; margin: 1.4em 0 0.25em; }
.note-body.msg h3 { font-size: 1.25em; margin: 1em 0 0.2em; }
.note-body.msg ul, .note-body.msg ol { padding-left: 1.6em; }
.note-body.msg li { margin: 0.15em 0; }
.note-body.msg blockquote { margin: 0.6em 0; padding: 0 0 0 14px; border-left: 3px solid currentColor; }
.note-body.msg hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.note-body.msg code { font-size: 0.82em; padding: 0.15em 0.35em; border-radius: 4px; background: var(--surface-2); }
.note-body.msg pre { font-size: 0.82em; padding: 14px 16px; border-radius: 6px; background: var(--surface-2); overflow-x: auto; }
.note-body.msg pre code { padding: 0; background: none; }
/* tables: the text's whole width, as a page's — light lines, the head row shaded */
.note-body.msg table { width: 100%; border-collapse: collapse; margin: 0.8em 0; font-size: 14px; line-height: 1.45; }
.note-body.msg th, .note-body.msg td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.note-body.msg th { background: var(--surface-2); font-weight: 600; }
.note-body img { border-radius: 4px; }

/* Settings' tabs: the account, the data */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs .tab { padding: 8px 14px; color: var(--text-2); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.current { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
/* the note's tools, floating in its corner: no bar on top */
.notes-page { position: relative; }
.note-tools { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; align-items: center; gap: 8px; z-index: 1; pointer-events: none; }
.note-tools > * { pointer-events: auto; }
.note-tools .grow { flex: 1; }

/* --- a phone: the same pages, made for a thumb and a narrow screen ----------------------------
   (last, to win over the rules above; the nav's drawer is with the shell's rules) */
@media (max-width: 760px) {
  /* installed as an app (viewport-fit=cover), the page goes under the notch and the home bar */
  .page-head { padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); gap: 8px; }
  .page-head h1 { font-size: 17px; }
  .page-head button:not(.icon) { white-space: nowrap; }
  .side { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .page-body { padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  /* a thumb's targets: 40 px at least */
  button.icon { width: 40px; height: 40px; }
  button { min-height: 40px; }
  button.link { min-height: 0; }
  button.small, a.button { min-height: 36px; padding: 6px 12px; }
  a.button { display: inline-flex; align-items: center; }
  .nav-item { padding: 10px 12px; }
  .nav-item.note, button.nav-item.note-folder { padding-top: 9px; padding-bottom: 9px; }
  .tabs .tab { padding: 10px 14px; }
  .file-menu summary { padding: 6px 10px; }
  .file-menu-items a, .file-menu-items button { padding: 10px 12px; font-size: 15px; }
  .crumbs a { padding: 6px 8px; }
  .task-more summary { padding: 6px 0; }
  .info { width: 22px; height: 22px; }
  /* tables: a row a line, the table scrolled sideways in its box (not the page) */
  .scroll { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .scroll th, .scroll td { white-space: nowrap; padding: 8px; }
  .scroll td.clip { max-width: 200px; }
  .msg.answer table { display: block; overflow-x: auto; }
  /* the stats: two tiles a row, the charts at the screen's width */
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .charts { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  /* a form: a sheet from the bottom, the screen's width */
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; }
  .modal-inner { padding: 14px 16px max(16px, env(safe-area-inset-bottom)); }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { flex: 1; }
  .viewer, .viewer img, .viewer video { max-height: calc(92dvh - 150px); }
  .viewer iframe { height: calc(92dvh - 150px); }
  /* the chat: the log at the screen's width, the composer above the home bar */
  .log { padding: 14px 12px; }
  .composer { padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .composer-row { gap: 6px; }
  .composer-row .attach { margin-bottom: 2px; }
  .composer-row .info { margin-bottom: 11px; }
  .msg.user { max-width: 88%; }
  /* a task, in the chat and in Projects: its CI under it rather than squeezed beside */
  .task-meta { flex-wrap: wrap; gap: 4px 12px; }
  .ci-strip { gap: 4px; }
  .ci-square { width: 14px; height: 14px; }
  @keyframes ci-in { from { width: 0; opacity: 0; } to { width: 14px; opacity: 1; } }
  /* a note: less room around it, a smaller title; its tools in its corner */
  .note-page { padding: 60px max(16px, env(safe-area-inset-right)) 64px max(16px, env(safe-area-inset-left)); }
  .note-body.msg h1 { font-size: 30px; }
  .note-body.msg h2 { font-size: 1.35em; }
  .note-body.msg table { display: block; overflow-x: auto; width: auto; max-width: 100%; }
  /* (a cell's words whole — a year, a price not cut in two: the table scrolls instead) */
  .msg th, .msg td { overflow-wrap: break-word; }
  .msg th { white-space: nowrap; }
  .note-body .mosaic { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .note-body .mosaic img { height: 140px; }
  .note-tools { top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; }
  /* long words (addresses, ids, code) wrapped, not pushing the page wider */
  code, .msg pre, .error, .notice { overflow-wrap: anywhere; }
  .msg pre code { overflow-wrap: normal; }
  .project-head h2, .task-head h3 { min-width: 0; overflow-wrap: anywhere; }
  /* the pages before signing in: the card nearly the screen's width */
  body.plain { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .card { padding: 22px 18px; margin: 12px auto; }
  .card button { min-height: 44px; }
}
