/* Dashboard composition on top of the shared Graphite & Berry files (tokens, fonts, motion, base, ui).
   Tokens only; no raw theme colors except the two validated chart series and the token overrides below. */

:root {
  --chart-text: #6A45E8;
  --chart-media: #E0457B;
  --chart-grid: var(--border);
  --page-max: 1120px;
  --page-pad: 40px;
  --sidebar-w: 248px;
  /* Display size for the one hero figure on Overview (between title-1 and the old 40px). */
  --text-hero: 36px;
  --leading-hero: 40px;
  /* tokens.css is shared byte-for-byte with the desktop app; the web dashboard adds CJK families
     (Linux installs Noto as "Noto Sans CJK SC") and a CJK fallback for mono. */
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", monospace;
}
/* Contrast floor (SPEC: secondary text at least 4.5:1): light text-3 #72707C is 4.42:1 on the sidebar
   and 4.16:1 on inset; #6A6874 is 4.9:1 on #F4F4F6 and 4.6:1 on #EDEDF1. Hover wash .045 -> .06. */
:root, :root[data-theme="light"] { --text-3: #6A6874; --bg-hover: rgba(24, 22, 36, .06); }
/* Dark primary hover was #EDEDF1 -> #FFFFFF (invisible); step down instead so the change reads. */
:root[data-theme="dark"] { --chart-text: #8F72FA; --chart-media: #E85A8C; --ink-hover: #D9D9E0; }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] { --chart-text: #8F72FA; --chart-media: #E85A8C; --ink-hover: #D9D9E0; } }

/* The desktop base locks the body for the Electron window; the web dashboard scrolls the document. */
html, body { height: auto; min-height: 100%; }
body { overflow: visible; min-height: 100vh; }
body.scroll-locked { overflow: hidden; }
#app { min-height: 100vh; }
.icon { flex-shrink: 0; }
.spin { animation: bramble-spin .8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 1.6s; } }
/* Body copy: no one-word last lines. */
p, .page-description, .dialog-description, .auth-sub, .section-description { text-wrap: pretty; }

/* ---------- Skip link ---------- */
.skip-link { position: fixed; top: 8px; left: 8px; z-index: var(--z-tooltip); padding: 8px 12px; border-radius: var(--radius-md); background: var(--bg-raised); color: var(--text); font-size: 13px; font-weight: 500; transform: translateY(calc(-100% - 16px)); transition: transform var(--dur-2) var(--ease-out); }
.skip-link:focus { transform: none; box-shadow: var(--shadow-pop); text-decoration: none; }

/* ---------- Boot ---------- */
.boot-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 20px; color: var(--text-3); }
.boot-screen .bramble-mark { width: 32px; height: 32px; color: var(--text); }
.boot-bar { width: 120px; }
.boot-failed { max-width: 520px; margin: 20vh auto 0; padding: 0 16px; }
.noscript { max-width: 420px; margin: 20vh auto; padding: 0 16px; text-align: center; color: var(--text-2); font: 14px/22px var(--font-sans); }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); border-radius: var(--radius-sm); }
.brand:hover { text-decoration: none; }
.brand-word { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; min-width: 0;
  background: var(--bg-sidebar); border-right: 1px solid var(--border); z-index: var(--z-chrome);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 12px 0 16px; flex-shrink: 0; }
.drawer-close { display: none; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; }
.ws-switcher {
  display: flex; align-items: center; gap: 10px; margin: 0 8px 8px; padding: 6px 8px; min-height: 44px; border-radius: var(--radius-md);
  text-align: left; transition: background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
  box-shadow: inset 0 0 0 1px var(--border); background: var(--bg-elevated);
}
.ws-switcher:hover, .ws-switcher[aria-expanded="true"] { background-image: var(--wash-hover); }
.ws-switcher:active { transform: scale(var(--motion-press)); }
.ws-avatar { display: grid; place-items: center; }
.ws-text { display: grid; min-width: 0; flex: 1; }
.ws-name { font-size: 13px; line-height: 18px; font-weight: 500; }
.ws-role { font-size: 12px; line-height: 16px; color: var(--text-3); }
.ws-chevron { color: var(--text-3); }
.avatar-square { border-radius: var(--radius-sm); }
.nav { display: grid; gap: 16px; }
.nav-group { display: grid; gap: 1px; }
.nav-label { padding: 6px 8px 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text-2);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.nav-item .icon { color: var(--text-3); transition: color var(--dur-1) var(--ease-out); }
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item[aria-current="page"] { background: var(--bg-active); color: var(--text); }
.nav-item[aria-current="page"] .icon { color: var(--accent-ink); }
.nav-item:focus-visible { outline-offset: -2px; }
.sidebar-foot { display: grid; gap: 4px; padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.credit-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 12px; }
.credit-line:hover { background: var(--bg-hover); text-decoration: none; color: var(--text); }
.credit-label { display: inline-flex; align-items: center; gap: 8px; }
.credit-label .icon { color: var(--text-3); }
.credit-value { font-size: 13px; font-weight: 500; color: var(--text); }
.account-trigger { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-md); text-align: left; transition: background-color var(--dur-1) var(--ease-out); }
.account-trigger:hover, .account-trigger[aria-expanded="true"] { background: var(--bg-hover); }
.account-text { display: grid; min-width: 0; flex: 1; }
.account-name { font-size: 13px; line-height: 18px; font-weight: 500; }
.account-email { font-size: 12px; line-height: 16px; color: var(--text-3); }
.account-more { color: var(--text-3); }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { flex: 1; min-width: 0; outline: none; }
.drawer-scrim { position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); background: var(--bg-overlay); animation: bramble-fade-in var(--dur-2) var(--ease-out) both; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(304px, 86vw); height: 100%; z-index: var(--z-overlay);
    transform: translateX(-102%); visibility: hidden; box-shadow: var(--shadow-dialog);
    transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease-out), visibility 0s; }
  .drawer-close { display: inline-grid; }
  .topbar {
    position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px;
    background: color-mix(in srgb, var(--bg-canvas) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .topbar-workspace { font-size: 13px; font-weight: 500; color: var(--text-2); }
  :root { --page-pad: 16px; }
}

/* ---------- Page ---------- */
/* Every page-level grid gets an explicit minmax(0, 1fr) column: an implicit auto column grows to the
   min-content width of its widest child (a toolbar, a table) and pushes the page past the viewport. */
.page { width: 100%; max-width: calc(var(--page-max) + 2 * var(--page-pad)); margin: 0 auto; padding: 28px var(--page-pad) 72px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-content: start; }
.page-enter { animation: bramble-rise var(--dur-3) var(--ease-out) both; }
.page-fade { animation: bramble-fade-in 120ms var(--ease-out) both; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-heading { display: grid; gap: 4px; min-width: 0; }
.page-title { font-size: var(--text-title-1); line-height: var(--leading-title-1); font-weight: 600; letter-spacing: var(--tracking-title-1); outline: none; }
.page-description { font-size: 13px; line-height: 20px; color: var(--text-2); max-width: 64ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.page > :empty, .page-stack > :empty { display: none; }
.section-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-width: 0; }
.section-heading { display: grid; gap: 2px; min-width: 0; }
.section-title { font-size: var(--text-title-2); line-height: var(--leading-title-2); font-weight: 600; letter-spacing: var(--tracking-title-2); }
.section-description { font-size: 13px; line-height: 20px; color: var(--text-2); }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.panel { background: var(--bg-elevated); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); min-width: 0; }
.panel-pad { padding: 20px; }
/* Same height with or without a button in it, so neighbouring panels start their rows on one line. */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-title { font-size: 13px; line-height: 18px; font-weight: 600; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.toolbar-spacer { flex: 1; }
/* Separate switch groups so two switches never read as one control. */
.toolbar-switches { gap: 24px; }
.toolbar-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.toolbar-scroll::-webkit-scrollbar { display: none; }
.switch-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; line-height: 20px; color: var(--text-2); cursor: pointer; }
.muted { color: var(--text-3); }
.t-4 { color: var(--text-4); }
.nowrap { white-space: nowrap; }
.stack-sm { display: grid; gap: 4px; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.row-center { justify-content: center; }
.grow { flex: 1; min-width: 0; }
.push-end { margin-left: auto; }
.push-start { margin-right: auto; }
.action-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cell-title { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
.cell-stack { display: grid; gap: 2px; min-width: 0; }
/* A one-line cell value that ellipsizes instead of widening the table (long workspace names). */
.cell-clip { display: block; max-width: 240px; }
/* Names and emails may be one long token (anonymised accounts); break them rather than push columns off the panel. */
.cell-person { min-width: 128px; }
.cell-person > span { overflow-wrap: anywhere; }

/* ---------- Banners, errors ---------- */
.banner { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--bg-elevated); box-shadow: var(--shadow-1); }
.banner-icon { margin-top: 2px; color: var(--text-3); }
.banner-info .banner-icon { color: var(--info); }
.banner-success .banner-icon { color: var(--success); }
.banner-warning { background: color-mix(in srgb, var(--warning-tint) 55%, var(--bg-elevated)); }
.banner-warning .banner-icon { color: var(--warning); }
.banner-danger { background: color-mix(in srgb, var(--danger-tint) 55%, var(--bg-elevated)); }
.banner-danger .banner-icon { color: var(--danger); }
.banner-text { flex: 1; min-width: 0; }
.banner-title { font-size: 13px; line-height: 20px; font-weight: 500; }
.banner-description { font-size: 13px; line-height: 20px; color: var(--text-2); }
.banner-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.error-state { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--radius-lg); background: var(--bg-elevated); box-shadow: var(--shadow-1); flex-wrap: wrap; }
.error-state-icon { color: var(--danger); display: grid; }
.error-state-text { flex: 1; min-width: 200px; }
.error-state-title { font-size: 13px; line-height: 20px; font-weight: 500; }
.error-state-message { font-size: 13px; line-height: 20px; color: var(--text-2); }
.form-error { font-size: 13px; line-height: 20px; color: var(--danger-ink); }
.form-error:empty { display: none; }
.form-note { font-size: 12px; line-height: 16px; color: var(--text-3); }
.legal-link { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.legal-link:hover { color: var(--text); text-decoration-color: currentColor; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dialog-form { display: grid; gap: 16px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field-optional { margin-left: 6px; font-weight: 400; color: var(--text-3); }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-narrow { max-width: 280px; }
.fieldset-plain { min-width: 0; margin: 0; padding: 0; border: 0; }
.legend-gap { padding: 0; margin-bottom: 8px; }
/* Grouped sheet forms (admin model editor): a floated legend becomes an ordinary grid item, so the
   heading lines up with the field labels instead of sitting in the fieldset border. */
.form-section { min-width: 0; margin: 8px 0 0; padding: 24px 0 0; border: 0; border-top: 1px solid var(--border); }
.form > .form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section-title { float: left; width: 100%; padding: 0; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); }
.input.is-readonly, .input.is-readonly:hover, .input.is-readonly:focus-within { background: var(--bg-inset); box-shadow: inset 0 0 0 1px var(--border); }
.input.is-readonly .input-control { color: var(--text-2); cursor: default; }
.inline-form { max-width: 480px; }
.input-reveal { display: grid; place-items: center; width: 24px; height: 24px; margin-right: -6px; border-radius: var(--radius-sm); color: var(--text-3); }
.input-reveal:hover { color: var(--text); background: var(--bg-hover); }
.input-lg .input-reveal { margin-right: -4px; }
.field .input { width: 100%; }
.checkbox-group { display: grid; gap: 10px; }
.btn-spinner { display: inline-grid; place-items: center; }
.btn-external { opacity: .7; }
a.btn:hover { text-decoration: none; }
.btn-accent:focus-visible, .btn-primary:focus-visible, .btn-danger:focus-visible { outline-offset: 2px; }
/* Resting destructive actions: secondary or ghost with danger text; filled red only for the final confirm. */
.btn.btn-danger-text, .btn.btn-danger-text:hover:not(:disabled) { color: var(--danger-ink); }
.btn-ghost.btn-danger-text:hover:not(:disabled) { background: var(--danger-tint); }
.dialog-close { margin-top: -2px; }
.dialog-footer { flex-wrap: wrap; }
.sheet { width: 560px; }
.sheet-lg { width: 760px; }
.sheet-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.menu-popover { position: fixed; }
.menu-popover:focus { outline: none; }
.menu-item-meta { margin-left: auto; padding-left: 12px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.menu-item .avatar { margin-top: 0; }
.toast-viewport { max-width: calc(100vw - 32px); }

/* ---------- Select (menu-based combobox; ui.css styles .select-trigger) ---------- */
.select { position: relative; display: inline-flex; min-width: 0; max-width: 100%; }
.select > .select-trigger { width: 100%; justify-content: space-between; gap: 8px; background-color: var(--bg-elevated); box-shadow: inset 0 0 0 1px var(--border-strong); cursor: pointer; }
.select > .select-trigger .select-value { flex: 1; }
.select > .select-trigger:hover:not(:disabled) { background-image: var(--wash-hover); }
.select > .select-trigger[aria-expanded="true"], .select > .select-trigger:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-tint); }
.select > .select-trigger[aria-expanded="true"] .select-chevron { transform: rotate(180deg); }
.select > .select-trigger.is-invalid { box-shadow: inset 0 0 0 1px var(--danger); }
.select > .select-trigger:disabled { opacity: 1; background: var(--bg-inset); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border); cursor: not-allowed; }
.select.is-sm > .select-trigger { height: var(--control-sm); padding: 0 6px 0 8px; gap: 6px; font-size: 12px; border-radius: var(--radius-sm); }
/* Ghost (table cells): no frame at rest; text lines up with the plain-text cells around it. */
.select.is-ghost { margin-left: -8px; }
.select.is-ghost > .select-trigger { padding-left: 8px; background: none; box-shadow: none; }
.select.is-ghost > .select-trigger:hover:not(:disabled) { background: var(--bg-hover); }
.select.is-ghost > .select-trigger[aria-expanded="true"] { background: var(--bg-active); box-shadow: none; }
.select.is-ghost > .select-trigger:focus-visible { box-shadow: 0 0 0 2px var(--border-focus); }
.select.is-ghost > .select-trigger:disabled { background: none; box-shadow: none; }
.field .select { display: flex; width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; min-width: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 18px; }
.data-table th { padding: 10px 16px; text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); white-space: nowrap; border-bottom: 1px solid var(--border); }
/* 12 + 18 + 12 = 40px single-line rows (with the 1px rule); two-line cells are 12 + 18 + 2 + 16 + 12. */
.data-table td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .align-center { text-align: center; }
.data-table td.actions { width: 1%; white-space: nowrap; text-align: right; }
.data-table td.actions .row { justify-content: flex-end; }
.data-table.is-interactive tbody tr { cursor: pointer; }
.data-table tbody tr:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.data-table .t-mono { font-size: 12px; }
/* IDs never break at hyphens ("claude-/opus-5-/5"); the table scrolls instead. */
.data-table .t-mono, .model-id { white-space: nowrap; overflow-wrap: normal; }
.data-table td.cell-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table td.cell-meta { white-space: nowrap; }
.share-bar { display: inline-block; width: 64px; height: 4px; border-radius: 2px; background: var(--bg-active); overflow: hidden; vertical-align: middle; margin-left: 8px; }
.share-bar > span { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 400ms var(--ease-out); }
.skeleton-table { display: grid; }
.skeleton-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; align-items: center; gap: 24px; height: 41px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.skeleton-row:last-child { border-bottom: 0; }
.skeleton-list-row { min-height: 56px; }
.skeleton.skeleton-fill { position: absolute; inset: 0; width: auto !important; height: auto !important; }
/* One footer row: what is shown on the left, "Load more" on the right. */
.load-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.load-more-summary { font-size: 12px; line-height: 16px; color: var(--text-3); }
.load-more-summary:empty { visibility: hidden; }
@media (max-width: 1180px) {
  .data-table .hide-md { display: none; }
  .cell-clip { max-width: 144px; }
}
@media (max-width: 720px) {
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .data-table tr { position: relative; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; min-height: 28px; }
  .data-table td::before { content: attr(data-label); flex-shrink: 0; font-size: 12px; color: var(--text-3); text-align: left; }
  .data-table td.is-primary { justify-content: flex-start; text-align: left; padding: 0 0 4px; }
  .data-table td.is-primary::before, .data-table td.actions::before, .data-table td:not([data-label])::before { content: none; }
  /* Empty cells are omitted on cards instead of printing a dash. */
  .data-table td.is-empty { display: none; }
  /* A single row action sits at the card's top-right, next to the title, not on a row of its own. */
  .data-table td.actions { width: 100%; justify-content: flex-end; padding-top: 8px; }
  .data-table td.actions:has(> :is(.btn, .icon-btn):only-child) { position: absolute; top: 10px; right: 12px; width: auto; min-height: 0; padding: 0; }
  .data-table tr:has(> td.actions > .btn:only-child) > td.is-primary { padding-right: 96px; }
  .data-table tr:has(> td.actions > .icon-btn:only-child) > td.is-primary { padding-right: 40px; }
  .data-table .hide-sm { display: none; }
  .data-table .align-right { text-align: right; }
  .data-table td.cell-amount { text-align: right; }
  /* Compact two-line rows (usage requests): title + amount, then status and time in 12px text-3. */
  .data-table.is-compact-sm tr { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 2px; }
  .data-table.is-compact-sm td { display: block; width: auto; min-height: 0; padding: 0; text-align: left; }
  .data-table.is-compact-sm td::before { content: none; }
  .data-table.is-compact-sm td.hide-sm, .data-table.is-compact-sm td.hide-md, .data-table.is-compact-sm td.is-empty { display: none; }
  .data-table.is-compact-sm td.is-primary { flex: 1 1 0; min-width: 0; padding: 0; }
  .data-table.is-compact-sm td.cell-amount { order: 1; flex: 0 0 auto; margin-left: auto; text-align: right; font-weight: 500; }
  /* A zero-height full-width item forces status and time onto the second line, always. */
  .data-table.is-compact-sm tr::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
  .data-table.is-compact-sm td.cell-meta { order: 2; font-size: 12px; line-height: 16px; color: var(--text-3); }
  .data-table.is-compact-sm td.cell-meta .badge { vertical-align: middle; }
  .skeleton-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Stats ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-strip-divided { border-top: 1px solid var(--border); }
/* Fixed rows (label, value, sub) so values share one baseline whether or not a cell has a sub-line. */
.stat { display: grid; grid-template-rows: 16px 28px minmax(16px, auto); align-content: start; gap: 4px; padding: 16px; min-width: 0; border-left: 1px solid var(--border); container-type: inline-size; }
.stat:first-child { border-left: 0; }
.stat-label { font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
/* The sub-line is the last row, so letting it wrap never moves the values off their shared baseline. */
.stat-sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
/* Long figures step down a size in narrow cells instead of breaking mid-number. */
@container (max-width: 170px) { .stat-value { font-size: 16px; } }
@media (max-width: 720px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--border); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--border); }
}

/* ---------- Overview ---------- */
.overview-top { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: start; }
.overview-top.has-checklist { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
/* The balance is a band, not a card: no surface, just the figure. */
.hero { display: grid; gap: 8px; align-content: start; min-width: 0; padding: 4px 0; }
.hero-head { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.hero-label { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--text-2); }
.hero-value { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.hero-figure { font-size: var(--text-hero); line-height: var(--leading-hero); font-weight: 600; letter-spacing: -0.03em; }
.hero-unit { font-size: 14px; line-height: 20px; color: var(--text-3); font-weight: 500; }
.hero-runway { font-size: 13px; line-height: 20px; color: var(--text-2); }
.hero-runway.is-warning { color: var(--warning-ink); }
.hero-runway.is-danger { color: var(--danger-ink); }
.hero-sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
.hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.checklist { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius-lg); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border); min-width: 0; }
.checklist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.checklist-title { font-size: 13px; line-height: 20px; font-weight: 600; }
.checklist-progress { font-size: 12px; line-height: 16px; color: var(--text-3); }
.checklist-steps { display: grid; margin: 0; padding: 0; list-style: none; }
.checklist-step { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 40px; padding: 8px 0; border-top: 1px solid var(--border); }
.checklist-step:first-child { border-top: 0; }
.checklist-mark { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--border-strong); background: var(--bg-elevated); }
.checklist-step.is-done .checklist-mark { background: var(--success-tint); color: var(--success-ink); box-shadow: none; }
.checklist-text { display: grid; min-width: 0; }
.checklist-step-title { font-size: 13px; line-height: 20px; font-weight: 500; }
.checklist-step.is-done .checklist-step-title { color: var(--text-3); font-weight: 400; text-decoration: line-through; text-decoration-color: var(--border-strong); }
.checklist-step-sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
.checklist-step > .btn { justify-self: end; }
/* Flat sections: hairline dividers instead of more cards; the chart is the page's one surface. */
.flat-section { display: grid; align-content: start; min-width: 0; }
.flat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.flat-title { font-size: 13px; line-height: 20px; font-weight: 600; }
.activity { display: grid; margin: 0; padding: 0; list-style: none; }
.activity-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.activity-row:last-child { border-bottom: 0; }
.activity-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--bg-subtle); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.activity-main { display: grid; gap: 2px; min-width: 0; }
.activity-title { font-size: 13px; line-height: 18px; font-weight: 500; }
.activity-meta { font-size: 12px; line-height: 16px; color: var(--text-3); }
.activity-amount { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.flat-section .list-row { min-height: 56px; }
.overview-bottom { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px; align-items: start; }
@media (max-width: 1080px) { .overview-top.has-checklist, .overview-bottom { grid-template-columns: minmax(0, 1fr); } .overview-bottom { gap: 32px; } }

/* ---------- Chart ---------- */
.chart-panel { display: grid; grid-template-columns: minmax(0, 1fr); }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 4px; flex-wrap: wrap; }
.chart-heading { display: grid; gap: 4px; }
.chart-total { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.015em; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; line-height: 16px; color: var(--text-2); flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 8px; height: 8px; border-radius: 2px; background: var(--chart-text); }
.legend-swatch.is-media { background: var(--chart-media); }
.chart-axis-caption { padding: 4px 16px 0; font-size: 12px; line-height: 16px; color: var(--text-3); }
.chart { position: relative; padding: 8px 16px 12px; outline: none; }
.chart:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -4px; border-radius: var(--radius-lg); }
.chart-svg { width: 100%; height: 220px; overflow: visible; }
.chart-svg .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .baseline { stroke: var(--border-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart-svg .tick { fill: var(--text-3); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart-svg .bar-text { fill: var(--chart-text); }
.chart-svg .bar-media { fill: var(--chart-media); }
.chart-svg .col { transition: opacity var(--dur-1) var(--ease-out); }
/* Bars rise from the baseline on first paint, 12ms apart (the delay is set per column). */
.chart-svg.is-entering .col { transform-box: fill-box; transform-origin: 50% 100%; animation: chart-rise 240ms var(--ease-out) both; }
@keyframes chart-rise { from { transform: scaleY(0); } to { transform: none; } }
.chart-svg.is-hovering .col { opacity: .45; }
.chart-svg.is-hovering .col.is-active { opacity: 1; }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg .cursor-band { fill: var(--bg-hover); }
.chart-tooltip {
  position: absolute; top: 0; left: 0; z-index: var(--z-floating); min-width: 168px; padding: 8px 12px; border-radius: var(--radius-md);
  background: var(--bg-raised); box-shadow: var(--shadow-pop); pointer-events: none; font-size: 12px; line-height: 16px;
  animation: bramble-fade-in var(--dur-1) var(--ease-out) both;
}
.chart-tooltip-date { color: var(--text-3); margin-bottom: 6px; }
.chart-tooltip-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 1px 0; }
.chart-tooltip-key { width: 8px; height: 8px; border-radius: 2px; background: var(--chart-text); }
.chart-tooltip-key.is-media { background: var(--chart-media); }
.chart-tooltip-label { color: var(--text-2); }
.chart-tooltip-value { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.chart-tooltip-total { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
.chart-empty { position: absolute; inset: 0 16px 32px; display: grid; place-items: center; align-content: center; gap: 12px; text-align: center; padding: 16px; pointer-events: none; }
.chart-empty-text { font-size: 13px; line-height: 20px; color: var(--text-2); }
.chart-empty-action { pointer-events: auto; }
.chart-table { padding: 0 0 4px; }
.chart.is-refreshing { opacity: .55; transition: opacity var(--dur-2) var(--ease-out); }
.meter-fill { transition: transform 400ms var(--ease-out); }
@media (prefers-reduced-motion: reduce) {
  .chart-svg.is-entering .col { animation: none; }
  .meter-fill, .share-bar > span { transition: none; }
  .page-fade { animation: none; }
}

/* ---------- Lists ---------- */
.list { display: grid; margin: 0; padding: 0; list-style: none; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); min-width: 0; flex-wrap: wrap; }
.list-row:last-child { border-bottom: 0; }
.list-row-flush { padding-left: 0; padding-right: 0; }
.list-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border); color: var(--text-2); flex-shrink: 0; }
.list-main { flex: 1; min-width: 160px; display: grid; gap: 2px; }
.list-title { font-size: 13px; line-height: 18px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.list-sub { font-size: 12px; line-height: 16px; color: var(--text-3); }
.list-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ---------- Billing offers ---------- */
.offer-row { flex-wrap: nowrap; gap: 16px; }
.offer-row .list-main { min-width: 0; }
.offer-row.is-current { background: color-mix(in srgb, var(--accent-tint) 45%, transparent); }
.offer-price { display: grid; gap: 2px; justify-items: end; text-align: right; min-width: 120px; flex-shrink: 0; }
.offer-row .list-actions { min-width: 96px; justify-content: flex-end; }
.stepper { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--bg-elevated); flex-shrink: 0; }
.stepper-value { min-width: 72px; text-align: center; font-size: 13px; line-height: 20px; font-weight: 500; }
@media (max-width: 640px) {
  .offer-row { flex-wrap: wrap; }
  .offer-row .list-main { flex-basis: 100%; }
  .offer-price { justify-items: start; text-align: left; min-width: 0; }
  .offer-row .list-actions { min-width: 0; }
}

/* ---------- Members / account ---------- */
.seats-panel { display: grid; gap: 12px; }
.role-text { font-size: 13px; line-height: 18px; color: var(--text); }
.impact-list { display: grid; margin: 0; padding: 0; list-style: none; border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border); }
.impact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; line-height: 20px; }
.impact-row:first-child { border-top: 0; }

/* ---------- Settings layout ---------- */
.settings { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 40px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: grid; gap: 2px; }
.settings-nav a { position: relative; display: block; padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 20px; color: var(--text-2); transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.settings-nav a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.settings-nav a.is-active { color: var(--text); background: var(--bg-hover); font-weight: 500; }
.settings-nav a.is-active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: var(--accent); }
.settings-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; min-width: 0; }
.settings-body .section { scroll-margin-top: 24px; }
@media (max-width: 900px) { .settings { grid-template-columns: minmax(0, 1fr); } .settings-nav { display: none; } .settings-body .section { scroll-margin-top: 64px; } }

/* ---------- API keys ---------- */
.key-secret { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--bg-inset); box-shadow: inset 0 0 0 1px var(--border-strong); min-width: 0; }
.key-secret code { flex: 1; min-width: 0; font-size: 13px; line-height: 18px; overflow-wrap: anywhere; color: var(--text); user-select: all; }
/* "Try it" belongs to the code block under it, not to the key box above. */
.try-it { gap: 8px; margin-top: 8px; }
.try-it .code-block { margin: 0; }
.scope-list { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- Models ---------- */
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.price-unit { color: var(--text-3); font-size: 12px; }
.model-name { display: grid; gap: 2px; min-width: 0; }
.model-id { font-family: var(--font-mono); font-size: 12px; line-height: 16px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.model-sub { display: flex; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.model-sub > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.json-editor { min-height: 220px; font-size: 12px; line-height: 20px; tab-size: 2; }
.json-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.json-status.is-invalid { color: var(--danger-ink); }
.json-status.is-valid { color: var(--success-ink); }

/* ---------- Media ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
/* minmax(0, 1fr): the card's single track must not grow to a long title's min-content width. */
.media-card { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; overflow: hidden; border-radius: var(--radius-lg); background: var(--bg-elevated); box-shadow: var(--shadow-1); text-align: left; transition: box-shadow var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.media-card:hover { box-shadow: var(--shadow-pop); }
.media-card:active { transform: scale(.99); }
.media-thumb { position: relative; width: 100%; aspect-ratio: 4 / 3; background: var(--bg-inset); display: grid; place-items: center; color: var(--text-4); overflow: hidden; }
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; }
.media-thumb-kind { position: absolute; left: 8px; top: 8px; }
.media-meta { display: grid; gap: 4px; padding: 12px; min-width: 0; }
.media-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; font-size: 13px; line-height: 18px; font-weight: 500; }
.media-title > .truncate { flex: 1; }
.media-title > .badge { flex-shrink: 0; }
.media-prompt { font-size: 12px; line-height: 16px; color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; font-size: 12px; line-height: 16px; margin-top: 4px; }
.media-preview { border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-inset); }
.media-preview img, .media-preview video { width: 100%; max-height: 420px; object-fit: contain; }
.media-preview .media-placeholder { aspect-ratio: 16 / 9; }
.prompt-block { padding: 12px; border-radius: var(--radius-md); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border); font-size: 13px; line-height: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Market upload ---------- */
.dropzone { display: grid; place-items: center; gap: 8px; padding: 28px 16px; border-radius: var(--radius-lg); text-align: center; background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border-strong); transition: box-shadow var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out); }
.dropzone.is-over { background: var(--accent-tint); box-shadow: inset 0 0 0 1.5px var(--accent); }
.dropzone-icon { color: var(--text-3); }
.dropzone-title { font-size: 13px; font-weight: 500; }
.dropzone-sub { font-size: 12px; color: var(--text-3); }
.dropzone-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.file-summary { display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-md); background: var(--bg-subtle); box-shadow: inset 0 0 0 1px var(--border); font-size: 12px; }
.file-list { display: grid; gap: 2px; max-height: 140px; overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 16px; color: var(--text-2); }
.issue-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.issue { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 8px; font-size: 12px; line-height: 18px; color: var(--text-2); }
.issue .icon { margin-top: 1px; color: var(--danger); }
.issue.is-warning .icon { color: var(--warning); }
.issue-path { font-family: var(--font-mono); color: var(--text); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; }
.auth-prefs { display: flex; align-items: center; gap: 8px; }
.auth-lang-icon { color: var(--text-3); display: grid; }
.auth-stage { position: relative; display: grid; place-items: start center; padding: calc(6vh + 28px) 16px 48px; outline: none; isolation: isolate; overflow-x: clip; --vine-clear: 52px; }
/* The vine frames the card: it stays fully visible beside the card, and above it fades out 16px before
   the card's top edge so no stroke crosses into the card. */
.auth-vine {
  position: absolute; top: calc(6vh - 40px); left: 50%; width: min(780px, 120vw); transform: translateX(-50%); z-index: -1; pointer-events: none; opacity: .9;
  --card-half: min(216px, 50vw);
  --vine-mask: linear-gradient(#000 calc(var(--vine-clear) - 12px), transparent var(--vine-clear)),
    linear-gradient(to right, #000 calc(50% - var(--card-half) - 12px), transparent calc(50% - var(--card-half)), transparent calc(50% + var(--card-half)), #000 calc(50% + var(--card-half) + 12px));
  -webkit-mask-image: var(--vine-mask);
  mask-image: var(--vine-mask);
}
.auth-card { position: relative; width: min(400px, 100%); }
.auth-panel { display: grid; gap: 20px; padding: 28px; border-radius: var(--radius-xl); background: var(--bg-elevated); box-shadow: var(--shadow-dialog); }
/* On near-black the large blurred dialog shadow bands; a hairline plus one short shadow does not. */
:root[data-theme="dark"] .auth-panel { box-shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(0, 0, 0, .35); }
@media (prefers-color-scheme: dark) { :root[data-theme="system"] .auth-panel { box-shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(0, 0, 0, .35); } }
.auth-head { display: grid; gap: 4px; text-align: center; padding-top: 4px; }
.auth-title { font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.02em; outline: none; }
.auth-sub { font-size: 13px; line-height: 20px; color: var(--text-2); }
.auth-alt { text-align: center; font-size: 13px; color: var(--text-2); }
.auth-foot { padding: 16px; text-align: center; font-size: 12px; color: var(--text-3); }
.oauth { display: grid; gap: 8px; }
.provider-mark { display: block; flex-shrink: 0; }
.provider-mark.is-github { color: var(--text); }
.auth-result { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 8px 0; }
.result-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--bg-subtle); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.result-icon.is-success { background: var(--success-tint); color: var(--success-ink); box-shadow: none; }
.result-icon.is-danger { background: var(--danger-tint); color: var(--danger-ink); box-shadow: none; }
.result-icon.is-accent { background: var(--accent-tint); color: var(--accent-ink); box-shadow: none; }
.result-actions { margin-top: 8px; }
.password-meter { display: flex; justify-content: space-between; font-size: 12px; line-height: 16px; color: var(--text-3); }
.password-meter.is-ok { color: var(--success-ink); }
/* Vine: draws once per page load, then the berries ripen (SPEC §2.4). */
.bramble-vine { width: 100%; height: auto; display: block; }
.bramble-vine.is-drawing .vine-stem, .bramble-vine.is-drawing .vine-tendril, .bramble-vine.is-drawing .vine-leaf { stroke-dasharray: 1; stroke-dashoffset: 1; animation: bramble-draw 1.4s var(--ease-in-out) forwards; }
.bramble-vine.is-drawing .vine-tendril, .bramble-vine.is-drawing .vine-leaf { animation-duration: .7s; animation-delay: var(--vine-delay, .4s); }
.bramble-vine.is-drawing .vine-berry { opacity: 0; transform: scale(.4); animation: vine-berry .5s var(--ease-out) forwards; animation-delay: var(--vine-delay, 1s); }
@keyframes vine-berry { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .bramble-vine.is-drawing .vine-stem, .bramble-vine.is-drawing .vine-tendril, .bramble-vine.is-drawing .vine-leaf { animation: none; stroke-dashoffset: 0; }
  .bramble-vine.is-drawing .vine-berry { animation: bramble-fade-in 120ms linear forwards; transform: none; }
  .page-enter { animation: bramble-fade-in 120ms linear both; }
}
@media (max-width: 520px) {
  .auth-panel { padding: 24px 16px; }
  .auth-top { padding: 12px 16px; }
  .auth-stage { --vine-clear: 36px; }
  .auth-vine { top: calc(6vh - 24px); }
}

/* ---------- Desktop approval / invitation ---------- */
.device-code { font-family: var(--font-mono); font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: .12em; text-align: center; padding: 16px; border-radius: var(--radius-lg); background: var(--bg-inset); box-shadow: inset 0 0 0 1px var(--border); }
.approve-grid { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 24px; align-items: start; }
.approve-card { display: grid; gap: 16px; padding: 24px; }
.approve-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.code-input .input-control { font-family: var(--font-mono); letter-spacing: .14em; text-transform: uppercase; font-size: 16px; }
.invite-avatar { padding-bottom: 4px; }
@media (max-width: 900px) { .approve-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Admin ---------- */
.admin-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--border); overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.admin-tabs .tab { scroll-snap-align: center; }
.admin-tabs .tabs-indicator { bottom: 0; }
.admin-tabs::-webkit-scrollbar { display: none; }
/* Narrow screens: fade the clipped edge so the bar reads as scrollable. */
@media (max-width: 1080px) {
  .admin-tabs { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
}
.metadata { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-subtle); font: 12px/16px var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); max-height: 220px; overflow: auto; }
.metadata.metadata-code { white-space: pre; overflow-wrap: normal; max-height: 320px; }
.review-files { display: grid; gap: 2px; font: 12px/16px var(--font-mono); color: var(--text-2); }
/* Review sheet: the files of the version under review, read-only. Code-running files come first, flagged. */
.review-content-files { display: grid; gap: 6px; }
.review-content-note { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 12px; line-height: 18px; }
.review-file { border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border); background: var(--bg-raised); min-width: 0; }
.review-file.is-flagged { box-shadow: inset 0 0 0 1px var(--warning), inset 3px 0 0 var(--warning); }
.review-file-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px; font-size: 12px; line-height: 16px; cursor: pointer; list-style: none; }
.review-file-head::-webkit-details-marker { display: none; }
.review-file-head::before { content: ""; width: 6px; height: 6px; flex: none; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(-45deg); transition: transform var(--dur-1) var(--ease-out); }
details.review-file[open] > .review-file-head::before { transform: rotate(45deg); }
.review-file.is-static .review-file-head { cursor: default; }
.review-file.is-static .review-file-head::before { visibility: hidden; }
.review-file-head:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; border-radius: var(--radius-md); }
.review-file-path { font-family: var(--font-mono); color: var(--text); overflow-wrap: anywhere; min-width: 0; }
.review-file-size { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-file-note { margin: 0; padding: 0 12px 8px 26px; font-size: 12px; line-height: 16px; }
.review-file-text { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--bg-subtle); font: 12px/18px var(--font-mono); color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.review-file-text:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.review-source { display: grid; justify-items: start; gap: 8px; }
.review-source p { margin: 0; }
.review-diff-wrap { overflow-x: auto; border-radius: var(--radius-md); box-shadow: inset 0 0 0 1px var(--border); }
.review-diff { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 20px; table-layout: fixed; }
.review-diff th, .review-diff td { padding: 8px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.review-diff thead th { border-top: 0; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-3); }
.review-diff thead th:first-child, .review-diff tbody th { width: 28%; }
.review-diff tbody th { font-weight: 500; color: var(--text-2); }
.review-diff tbody th .badge { margin-left: 6px; }
.review-diff-value { white-space: pre-wrap; color: var(--text); }
.review-diff tr.is-changed td:last-child { background: var(--warning-tint); }
@media (max-width: 640px) {
  .review-diff thead th:first-child, .review-diff tbody th { width: 34%; }
  .review-file-size { margin-left: 0; }
}
.t-hash { font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .page { gap: 24px; padding-top: 20px; }
  .page-actions { width: 100%; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .dialog-overlay { padding: 12px; align-items: end; }
  .dialog { max-height: calc(100vh - 24px); }
  .sheet { width: auto; left: 8px; }
  .toast-viewport { left: 16px; right: 16px; align-items: stretch; }
  .toast { width: auto; }
  .approve-actions { grid-template-columns: minmax(0, 1fr); }
  .field-narrow { max-width: none; }
  :root { --text-hero: 32px; --leading-hero: 36px; }
}

/* ---------------------------------------------------------------- small helpers used by pages */
.t-warning { color: var(--warning-ink); }
.is-positive { color: var(--success-ink); }
.result-icon.is-neutral { background: var(--bg-subtle); color: var(--text-2); }
.account-avatar { display: grid; flex-shrink: 0; }
.chart-wrap { display: grid; min-width: 0; }
.media-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--text-4); background: var(--bg-inset); }
