/* Polias UI recreations (.pui). The app's own dark tokens and component styles from
   app/src/ui/tokens.css, base.css, grid/grid.css and overlays/actions/actions.css, scoped under
   .pui so they never touch the site. A recreation is laid out at app size (the app's 13px type)
   inside .pui-stage and scaled to its frame by ui.js, so it stays vector-sharp at any width.
   FOUNDATION (run 2026-10-05-site3): scenes compose these classes, they never restyle them. */

.pui {
  --ground: #0e0f11; --panel: #17181b; --raise: #1d1e22;
  --line: rgba(255, 255, 255, 0.07); --line-2: rgba(255, 255, 255, 0.1); --hi: rgba(255, 255, 255, 0.045);
  --tile-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.22);
  --fg: #e4e5e8; --fg-2: rgba(228, 229, 232, 0.6); --fg-3: rgba(228, 229, 232, 0.38); --fg-4: rgba(228, 229, 232, 0.18);
  --hover: rgba(255, 255, 255, 0.035); --sel: rgba(255, 255, 255, 0.06);
  --accent: #6aa3d8; --accent-fg: #0d1a26;
  --t-fg: #c8cacf; --t-dim: rgba(200, 202, 207, 0.46); --t-add: #83b896; --t-del: #cf8a90;
  --t-add-bg: rgba(131, 184, 150, 0.09); --t-del-bg: rgba(207, 138, 144, 0.09);
  --s-working: #62bd8c; --s-needs: #e2a64c; --s-idle: #8d9199; --s-paused: #70a6db;
  --s-held: #a99ddf; --s-limit: #dc88ab; --s-dead: #d96d6d;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --font-ui: 'Onest', system-ui, sans-serif; --font-mono: 'Reddit Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1); --t-state: 260ms;
  --radius-tile: 8px; --radius-panel: 10px; --radius-ctl: 5px;
  font: 400 13px/1.4 var(--font-ui); color: var(--fg); -webkit-font-smoothing: antialiased;
}
.pui *, .pui *::before, .pui *::after { box-sizing: border-box; }
.pui button { font: inherit; color: inherit; }

/* frame: the box on the page; stage: the app-sized canvas inside it, scaled by ui.js */
.pui-frame { position: relative; width: 100%; overflow: hidden; border-radius: 14px; }
.pui-frame[data-ratio] { aspect-ratio: var(--ratio); }
.pui-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.st-working { --st: var(--s-working); } .st-needs { --st: var(--s-needs); } .st-idle { --st: var(--s-idle); }
.st-paused { --st: var(--s-paused); } .st-held { --st: var(--s-held); } .st-limit { --st: var(--s-limit); } .st-dead { --st: var(--s-dead); }

/* state icon (inline SVG from ui.js icon(state), 12x12 viewBox) */
.pui .ic { width: 13px; height: 13px; flex: none; color: var(--st); transition: color var(--t-state) var(--ease); }

/* window */
.pui-win {
  display: grid; grid-template-rows: 34px 1fr; width: 100%; height: 100%; overflow: hidden;
  background: var(--ground); border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
}
.pui-top { display: flex; align-items: center; gap: 10px; padding: 0 8px 0 10px; font-size: 12px; color: var(--fg-3); }
.pui-top .nm { color: var(--fg-2); font-weight: 500; }
.pui-top .sp { margin-left: auto; }
.pui-ib { width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--radius-ctl); color: var(--fg-3); }
.pui-ib.on { background: var(--sel); color: var(--fg); }
.pui-ib svg { width: 16px; height: 16px; }
.pui-new { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: var(--radius-ctl); background: var(--accent); color: var(--accent-fg); font-weight: 500; }
.pui-new svg { width: 14px; height: 14px; }
.pui-nd { display: flex; align-items: center; gap: 7px; color: var(--fg-2); font-variant-numeric: tabular-nums; padding: 0 6px; height: 26px; border-radius: var(--radius-ctl); }
.pui-nd .ic { width: 12px; height: 12px; }

/* grid + tile + tabs */
.pui-grid { display: grid; gap: 10px; padding: 0 10px 10px; min-height: 0; grid-auto-rows: minmax(0, 1fr); }
.pui-tile {
  background: var(--panel); border: 2px solid color-mix(in srgb, var(--st) 38%, var(--line)); border-radius: var(--radius-tile);
  box-shadow: inset 0 1px 0 var(--hi), var(--tile-shadow); display: flex; flex-direction: column; min-width: 0; min-height: 0;
  overflow: hidden; position: relative; transition: border-color var(--t-state) var(--ease);
}
.pui-tile.st-needs { border-color: color-mix(in srgb, var(--st) 80%, transparent); }
.pui-th { display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 8px 0 12px; flex: none; }
.pui-th .repo { font-weight: 500; font-size: 12.5px; margin-right: 10px; color: var(--fg); white-space: nowrap; }
.pui-tab {
  display: flex; align-items: center; gap: 6px; height: 22px; padding: 0 7px; border-radius: 4px; font-size: 12px; color: var(--fg-3);
  position: relative; white-space: nowrap; transition: background-color var(--t-state) var(--ease), color var(--t-state) var(--ease);
}
.pui-tab::before {
  content: ''; position: absolute; left: 3px; right: 3px; top: -7px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--st); opacity: 0.6; transition: background-color var(--t-state) var(--ease), opacity var(--t-state) var(--ease);
}
.pui-tab.on { color: var(--fg); background: color-mix(in srgb, var(--st) 14%, var(--sel)); }
.pui-tab.on::before { opacity: 1; }
.pui-tab .info { width: 14px; height: 14px; border-radius: 50%; display: grid; place-items: center; font: 600 9px/1 var(--font-ui); color: var(--fg-3); border: 1px solid var(--line-2); margin-left: 2px; }
.pui-tab .sh { font: 400 10.5px var(--font-mono); color: var(--fg-3); }

/* terminal text: one div per line; spans colour it */
.pui-term { flex: 1; min-height: 0; overflow: hidden; padding: 4px 14px 12px; font: 400 12px/1.6 var(--font-mono); color: var(--t-fg); white-space: pre; position: relative; }
.pui-term > div { min-height: 1.6em; }
.pui-term .dim { color: var(--t-dim); } .pui-term .b { color: var(--fg); font-weight: 500; }
.pui-term .g { color: var(--s-working); } .pui-term .bl { color: var(--accent); } .pui-term .y { color: var(--s-needs); } .pui-term .r { color: var(--s-dead); }
.pui-term .add { color: var(--t-add); background: var(--t-add-bg); } .pui-term .del { color: var(--t-del); background: var(--t-del-bg); }
.pui-term .usr { background: rgba(255, 255, 255, 0.06); color: var(--fg); }
.pui-term .caret { display: inline-block; width: 0.6em; height: 1.15em; vertical-align: -0.2em; background: var(--t-fg); opacity: 0.8; }
.pui-term .fade { position: sticky; display: block; margin-bottom: -28px; z-index: 1; top: 0; height: 28px; background: linear-gradient(var(--panel), transparent); pointer-events: none; }

/* needs-you banner + pending card inside a tile */
.pui-wk { display: flex; align-items: center; gap: 9px; height: 28px; padding: 0 14px; font-size: 12.5px; color: var(--fg); flex: none; }
.pui-wk .r { margin-left: auto; color: var(--fg-3); font-size: 12px; }
.pui-pend { display: flex; flex-direction: column; gap: 8px; padding: 2px 14px 10px; flex: none; }
.pui-pend .tool { font-size: 12px; color: var(--fg-3); }
.pui-pend .detail { margin: 0; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-ctl); background: var(--panel); color: var(--t-fg); font: 400 12px/1.55 var(--font-mono); white-space: normal; }
.pui-pend .row { display: flex; flex-wrap: wrap; gap: 6px; }
.pui-btn { min-height: 32px; padding: 5px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-ctl); background: var(--panel); color: var(--fg-2); font-size: 12.5px; cursor: pointer; transition: filter 120ms, transform 120ms; }
.pui-btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.pui-btn:hover { color: var(--fg); background: var(--sel); }
.pui-btn.primary:hover { background: var(--accent); color: var(--accent-fg); filter: brightness(1.08); }
.pui-btn.press { transform: scale(0.97); filter: brightness(1.15); }
.pui-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* hover card, dialog, palette */
.pui-card { width: 320px; background: var(--raise); border-radius: 8px; box-shadow: var(--shadow); padding: 14px 16px 6px; font-size: 12.5px; }
.pui-card .isub { color: var(--fg-3); font-size: 12px; padding-bottom: 14px; }
.pui-kv { display: grid; grid-template-columns: 78px 1fr; row-gap: 11px; font-size: 12.5px; padding-bottom: 14px; margin: 0; }
.pui-kv dt { color: var(--fg-3); } .pui-kv dd { color: var(--fg); margin: 0; } .pui-kv dd.mono { font: 400 12px var(--font-mono); }
.pui-bar { height: 3px; border-radius: 2px; background: var(--line-2); margin-top: 7px; overflow: hidden; }
.pui-bar i { display: block; height: 100%; background: var(--fg-2); }
.pui-card .ft { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); margin: 4px -16px 0; padding: 10px 16px 6px; }
.pui-card .ft span { color: var(--fg-2); font-size: 12px; border: 1px solid var(--line-2); border-radius: var(--radius-ctl); padding: 4px 8px; }
.pui-dialog { background: var(--raise); border-radius: var(--radius-panel); box-shadow: var(--shadow); overflow: hidden; }
.pui-dialog .dh { padding: 16px 20px 4px; font: 600 14px/1.2 var(--font-ui); }
.pui-dialog .db { padding: 12px 20px 16px; }
.pui-pal .pq { display: flex; align-items: center; height: 52px; padding: 0 18px; font-size: 15px; border-bottom: 1px solid var(--line); }
.pui-pal .pq .caret { display: inline-block; width: 1.5px; height: 18px; background: var(--accent); margin-left: 1px; }
.pui-pal .pl { padding: 6px; }
.pui-pal .pg { font-size: 12px; color: var(--fg-3); padding: 10px 12px 6px; font-weight: 500; }
.pui-pal .pi { display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border-radius: 6px; font-size: 13px; color: var(--fg-2); }
.pui-pal .pi.sel { background: var(--sel); color: var(--fg); }
.pui-pal .pi mark { background: none; color: var(--fg); font-weight: 600; }
.pui-pal .pi .h { color: var(--fg-3); font-size: 12px; }
.pui-pal .pf { display: flex; align-items: center; justify-content: flex-end; gap: 16px; height: 40px; padding: 0 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--fg-3); }
.pui-kbd { font: 500 11px/1 var(--font-ui); color: var(--fg-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 3px 5px; min-width: 18px; text-align: center; display: inline-block; }
.pui-seg { display: flex; gap: 2px; background: var(--sel); border-radius: 6px; padding: 2px; }
.pui-seg span { flex: 1; text-align: center; padding: 5px 0; border-radius: 4px; font-size: 12px; color: var(--fg-2); }
.pui-seg span.on { background: var(--raise); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); }
.pui-check { width: 16px; height: 16px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--panel); display: inline-grid; place-content: center; flex: none; transition: background-color 160ms; }
.pui-check.on { background: var(--accent); border-color: var(--accent); }
.pui-check.on::after { content: ''; width: 8px; height: 4px; border: solid var(--accent-fg); border-width: 0 0 1.8px 1.8px; transform: translateY(-1px) rotate(-45deg); }
.pui-field { min-height: 30px; padding: 6px 9px; border: 1px solid var(--line-2); border-radius: var(--radius-ctl); background: var(--panel); font-size: 12.5px; color: var(--fg); }
.pui-field.focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.pui-field .ph { color: var(--fg-3); }

/* settings panel: nav + content */
.pui-set { display: grid; grid-template-columns: 180px 1fr; height: 100%; background: var(--raise); border-radius: var(--radius-panel); overflow: hidden; box-shadow: var(--shadow); }
.pui-set nav { padding: 16px 10px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.pui-set nav b { font-weight: 600; font-size: 13px; padding: 0 8px 10px; }
.pui-set nav span { padding: 6px 8px; border-radius: 5px; color: var(--fg-2); }
.pui-set nav span.on { background: var(--sel); color: var(--fg); }
.pui-set section { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; font-size: 12.5px; }
.pui-set h4 { margin: 0; font: 600 14px var(--font-ui); }
.pui-rule { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.pui-rule .n { color: var(--fg); } .pui-rule .w { color: var(--fg-3); grid-column: 1; }
.pui-rule.hit { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 6px; padding: 10px; }
.pui-tag { display: inline-block; font-size: 11px; color: var(--fg-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }

/* phone: a plain device body with the app's mobile queue inside */
.pui-phone { width: 300px; height: 640px; border-radius: 44px; background: #050506; padding: 10px; box-shadow: 0 40px 90px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.12); position: relative; }
.pui-phone .scr { width: 100%; height: 100%; border-radius: 35px; background: var(--ground); overflow: hidden; position: relative; display: flex; flex-direction: column; }
.pui-phone .isl { position: absolute; top: 10px; left: 50%; width: 92px; height: 26px; margin-left: -46px; border-radius: 13px; background: #000; z-index: 3; }
.pui-phone .hd { padding: 52px 18px 10px; font: 600 20px var(--font-ui); display: flex; align-items: baseline; gap: 8px; }
.pui-phone .hd small { font: 400 14px var(--font-ui); color: var(--fg-3); }
.pui-phone .bd { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.pui-phone .tb { display: flex; justify-content: space-around; padding: 14px 8px 24px; border-top: 1px solid var(--line); font-size: 12px; color: var(--fg-3); }
.pui-phone .tb .on { color: var(--fg); font-weight: 500; }
.pui-mq { border-radius: 14px; padding: 12px 12px 12px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; transition: opacity 300ms var(--ease), transform 300ms var(--ease); }
.pui-mq.on { border: 2px solid color-mix(in srgb, var(--s-needs) 80%, transparent); }
.pui-mq .r1 { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.pui-mq .r1 .g { color: var(--fg); font-weight: 500; } .pui-mq .r1 .n { color: var(--fg-3); } .pui-mq .r1 .t { margin-left: auto; color: var(--fg-3); font-size: 12px; }
.pui-mq .q { font-size: 13px; line-height: 1.45; color: var(--fg-2); padding-left: 21px; }
.pui-mq .pui-btn { min-height: 40px; border-radius: 10px; font-size: 13px; }
.pui-mq.gone { opacity: 0; transform: translateX(40px); }
.pui-push { position: absolute; left: 10px; right: 10px; top: 44px; z-index: 4; border-radius: 18px; padding: 10px 12px; background: rgba(40, 41, 45, 0.94); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); display: flex; gap: 10px; align-items: center; font-size: 12.5px; transform: translateY(-140%); transition: transform 500ms var(--ease); }
.pui-push.in { transform: none; }
.pui-push .ap { width: 30px; height: 30px; border-radius: 8px; background: #2a2c31; display: grid; place-items: center; flex: none; }
.pui-push b { display: block; font-weight: 500; color: var(--fg); } .pui-push span { color: var(--fg-2); }

/* the drawn pointer scenes use for a click */
.pui-ptr { position: absolute; left: 0; top: 0; width: 22px; height: 22px; z-index: 20; pointer-events: none; opacity: 0; transition: opacity 200ms; }
.pui-ptr.on { opacity: 1; }
.pui-ptr svg { display: block; transition: transform 120ms; transform-origin: 3px 2px; }
.pui-ptr.down svg { transform: scale(0.82); }

/* things that fade or slide in when a scene says so */
.pui [data-in] { transition: opacity 400ms var(--ease), transform 400ms var(--ease); }
.pui [data-in='hidden'] { opacity: 0; transform: translateY(6px); }
.pui [hidden] { display: none !important; }
.pui .pop { animation: pui-pop 420ms var(--ease); }
@keyframes pui-pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .pui *, .pui *::before, .pui *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
