:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #14202b; --muted: #5d6b78; --line: #dde3e9; --accent: #0e7c66; --accent-ink: #ffffff;
  --warn: #b45309; --bad: #b42318; --ok: #12805c; --chip: #eef2f5; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0d141b; --panel: #141e27; --ink: #e6edf3; --muted: #8b9aa8; --line: #24323f; --accent: #3fd0a4; --accent-ink: #062018; --warn: #f59e0b; --bad: #f87171; --ok: #3fd0a4; --chip: #1c2833; --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 8px; min-width: 0; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand img { width: 30px; height: 30px; }
.brand b { display: block; font-size: 15px; }
.brand span { color: var(--muted); font-size: 12px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav button { border: 0; background: transparent; padding: 6px 10px; }
nav button.on { background: var(--chip); font-weight: 600; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--bad); } .pill.warn { color: var(--warn); }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
h2 { font-size: 18px; margin: 0 0 12px; } h3 { font-size: 15px; margin: 0 0 10px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--chip); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.status { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.s-done, .s-ready, .s-running.ok { color: var(--ok); } .s-failed { color: var(--bad); } .s-queued, .s-pending, .s-booting { color: var(--warn); } .s-running { color: var(--accent); } .s-cancelled, .s-stopped { color: var(--muted); }
.lib { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.asset { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.asset .media { aspect-ratio: 1; background: repeating-conic-gradient(var(--chip) 0 25%, transparent 0 50%) 0 0 / 16px 16px; display: grid; place-items: center; cursor: pointer; }
.asset .media img, .asset .media video { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset .media .glyph { font-size: 30px; color: var(--muted); }
.asset .meta { padding: 8px 10px; font-size: 12px; display: grid; gap: 4px; }
.asset .meta .t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { border: 0; background: none; padding: 0 2px; font-size: 16px; color: var(--muted); } .star.on { color: #e3a008; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; } .chip { background: var(--chip); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
pre { background: var(--chip); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; max-height: 360px; white-space: pre-wrap; word-break: break-word; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--ink); width: min(920px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
#modalBody { padding: 18px 20px; overflow: auto; max-height: 88vh; }
#modalBody .preview img, #modalBody .preview video { max-width: 100%; max-height: 60vh; display: block; margin: 0 auto; }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.wide { grid-column: 1 / -1; }
.form label > span b { color: var(--ink); font-size: 13px; }
details summary { cursor: pointer; color: var(--muted); margin: 8px 0; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.on { opacity: .95; }
.bar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--accent); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.spark { width: 120px; height: 28px; vertical-align: middle; } .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* Tablets and phones: nothing widens the page; a wide table scrolls inside its card. */
@media (max-width: 1024px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: clip; }
  main { padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); overflow-wrap: anywhere; }
  .top { padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .card { overflow-x: auto; }
  img, video, audio, model-viewer, iframe { max-width: 100%; }
  input[type="file"] { max-width: 100%; }
  code { overflow-wrap: anywhere; }
  dialog { width: min(920px, calc(100vw - 16px)); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  #modalBody { max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
  #modalBody textarea[style*="min-height"] { min-height: 45dvh !important; }
  #toast { bottom: max(18px, env(safe-area-inset-bottom)); }
}
/* Touch screens: tap targets of 44px, and inputs at 16px so iOS doesn't zoom in on focus. */
@media (pointer: coarse) {
  button, select, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { min-height: 44px; }
  button.star { min-width: 44px; }
  input, select, textarea { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  hg-library, hg-entity, hg-slot { font-size: 16px; }
}
/* Phones. */
@media (max-width: 640px) {
  main { padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .top { gap: 8px 12px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .brand { flex: 1; min-width: 0; }
  .brand span { display: none; }
  /* The tabs: one strip under the brand that scrolls sideways. */
  nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 6px; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: none; white-space: nowrap; min-height: 44px; padding: 6px 12px; }
  .card { padding: 12px; }
  /* Toolbars: filters and actions take the full width and wrap. */
  .row.spread > .row { width: 100%; }
  .row > input:not([type="checkbox"]), .row > select { flex: 1 1 140px; }
  .form { grid-template-columns: 1fr; }
  .form input:not([type="checkbox"]), .form select, .form textarea { width: 100%; }
  .lib { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  dialog { width: calc(100vw - 16px); }
  #modalBody { padding: 14px; }
  /* Tables stack into one card per row; each cell is labelled with its column (app.js labelCells). */
  .card { overflow-x: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  td { border: 0; padding: 3px 0; width: auto !important; }
  td.num { text-align: left; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; font-weight: 600; }
  tr.click:hover td { background: none; }
  tr.click:active { background: var(--chip); }
}

/* The library's web components (clients/js/hawkesgen-ui.mjs) in the dashboard's colors, light and dark. */
hg-library, hg-entity, hg-slot { --hg-bg: var(--bg); --hg-panel: var(--panel); --hg-fg: var(--ink); --hg-muted: var(--muted); --hg-line: var(--line); --hg-accent: var(--accent); }

/* The beta lane's badge beside the name (app.js). */
.lane-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: #d97706; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; vertical-align: middle; }
