@import url("https://fonts.googleapis.com/css2?family=Fragment+Mono:ital@0;1&family=Funnel+Display:wght@300..800&display=swap");

/* Quai — component layer. Every value comes from tokens.css; nothing here declares a token. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: var(--font-mono);
  font-size: 13px; line-height: 20px; letter-spacing: -0.03em;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }

/* ── Preview scaffolding (component cards only) ───────────────────────── */
.q-preview { padding: var(--space-5); display: flex; flex-wrap: wrap; gap: var(--space-4); align-items: flex-start; }
.q-preview.is-stack { flex-direction: column; }
.q-preview.is-flush { padding: 0; }
.q-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.q-col { display: flex; flex-direction: column; gap: var(--space-3); }
.q-muted { color: var(--fg-muted); }
.q-faint { color: var(--fg-faint); }
.q-accent { color: var(--accent); }
.q-danger { color: var(--danger); }
.q-sans { font-family: var(--font-display); letter-spacing: -0.01em; }
.q-grow { flex: 1; min-width: 0; }
.q-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Ground: dot grid and column rules ────────────────────────────────── */
.q-dotgrid {
  background-image: radial-gradient(var(--line-strong) 1px, transparent 1px);
  background-size: var(--space-5) var(--space-5);
  background-position: calc(var(--space-5) / -2) calc(var(--space-5) / -2);
}
.q-rules { position: relative; }
.q-rules::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--cols, 4)) 100%;
}

/* ── Corner brackets: the signature mark ───────────────────────────────
   Four L-shaped corners, 12px arms at rest; on hover they step in 4px and shorten to 8px. */
.q-brackets { position: relative; isolation: isolate; }
.q-brackets > .q-c { position: absolute; width: var(--bracket-size); height: var(--bracket-size);
  border: 0 solid var(--bracket); pointer-events: none; transition: all var(--dur, 180ms) var(--ease-step, cubic-bezier(.2,.7,.2,1)); }
.q-brackets > .q-c.tl { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.q-brackets > .q-c.tr { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.q-brackets > .q-c.bl { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.q-brackets > .q-c.br { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
.q-brackets:is(:hover, :focus-visible, .is-hover) > .q-c { width: var(--bracket-size-hover); height: var(--bracket-size-hover); }
.q-brackets:is(:hover, :focus-visible, .is-hover) > .q-c.tl { top: 4px; left: 4px; }
.q-brackets:is(:hover, :focus-visible, .is-hover) > .q-c.tr { top: 4px; right: 4px; }
.q-brackets:is(:hover, :focus-visible, .is-hover) > .q-c.bl { bottom: 4px; left: 4px; }
.q-brackets:is(:hover, :focus-visible, .is-hover) > .q-c.br { bottom: 4px; right: 4px; }

/* ── Button ───────────────────────────────────────────────────────────── */
.q-btn {
  --h: var(--control); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--h); padding: 0 var(--space-5); border: 0; border-radius: 0; cursor: pointer;
  background: var(--surface); color: var(--fg); font-size: 12px; line-height: 16px; white-space: nowrap;
  text-decoration: none; transition: background-color 150ms, color 150ms;
}
.q-btn:hover { background: var(--surface-2); }
.q-btn:focus-visible { outline-offset: 3px; }
.q-btn.is-primary { background: var(--accent); color: var(--on-accent); }
.q-btn.is-primary > .q-c { border-color: var(--on-accent); opacity: .5; }
.q-btn.is-primary:hover { background: var(--accent-hover); }
.q-btn.is-ghost { background: transparent; }
.q-btn.is-ghost:hover { background: var(--surface-2); }
.q-btn.is-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-btn.is-danger { background: var(--danger-dim); color: var(--danger); }
.q-btn.is-danger > .q-c { border-color: var(--danger); }
.q-btn.is-critical { background: var(--danger); color: var(--on-danger); }
.q-btn.is-critical > .q-c { border-color: var(--on-danger); opacity: .5; }
.q-btn.is-critical:hover { background: var(--danger-hover); }
.q-btn.is-critical .q-kbd { background: transparent; color: var(--on-danger); box-shadow: inset 0 0 0 1px var(--on-danger); }
.q-btn.is-link { background: none; padding: 0; height: auto; color: var(--fg); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--edge); }
.q-btn.is-link:hover { text-decoration-color: var(--accent); }
.q-btn.is-sm { --h: var(--control-sm); padding: 0 var(--space-3); font-size: 11px; }
.q-btn.is-lg { --h: var(--control-lg); padding: 0 var(--space-6); }
.q-btn.is-icon { width: var(--h); padding: 0; }
.q-btn[disabled], .q-btn.is-disabled { color: var(--fg-faint); cursor: not-allowed; background: var(--surface); }
.q-btn[disabled] > .q-c { border-color: var(--line-strong); }
.q-btn .q-kbd { margin-right: -6px; }
.q-btn svg, .q-ico { width: 14px; height: 14px; flex: none; }

.q-btngroup { display: inline-flex; }
.q-btngroup > .q-btn + .q-btn { box-shadow: inset 1px 0 0 var(--line-strong); }
.q-btngroup.is-outline { box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-btngroup.is-outline > .q-btn { background: transparent; }

/* ── Toggle ───────────────────────────────────────────────────────────── */
.q-toggle { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control); padding: 0 var(--space-3);
  border: 0; background: transparent; color: var(--fg-muted); cursor: pointer; font-size: 12px; }
.q-toggle:hover { color: var(--fg); background: var(--surface-2); }
.q-toggle[aria-pressed="true"] { color: var(--fg); background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--accent); }
.q-togglegroup { display: inline-flex; padding: 2px; gap: 2px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-togglegroup .q-toggle { height: calc(var(--control) - 4px); }
.q-togglegroup .q-toggle[aria-pressed="true"] { box-shadow: none; background: var(--surface-3); }

/* ── Kbd ──────────────────────────────────────────────────────────────── */
.q-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px;
  font: 11px/1 var(--font-mono); letter-spacing: 0; color: var(--fg-muted); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong), inset 0 -2px 0 var(--line-strong); border-radius: var(--radius-hair); }
.q-kbd.is-bracket { background: none; box-shadow: none; padding: 0; min-width: 0; color: var(--fg-muted); }
.q-kbd.is-bracket::before { content: "["; color: var(--fg-faint); }
.q-kbd.is-bracket::after { content: "]"; color: var(--fg-faint); }

/* ── Form controls ────────────────────────────────────────────────────── */
.q-label { display: block; font-size: 11px; line-height: 16px; color: var(--fg-muted); }
.q-label .q-req { color: var(--accent); }
.q-input, .q-textarea, .q-select-native {
  width: 100%; height: var(--control); padding: 0 var(--space-3); border: 0; border-radius: 0;
  background: var(--surface); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-strong);
  font-size: 12px; caret-color: var(--accent); transition: box-shadow 150ms;
}
.q-input::placeholder, .q-textarea::placeholder { color: var(--fg-muted); }
.q-input:hover, .q-textarea:hover, .q-select-native:hover { box-shadow: inset 0 0 0 1px var(--edge); }
.q-input:focus, .q-textarea:focus, .q-select-native:focus, .q-input.is-focus { outline: 0; box-shadow: inset 0 0 0 1px var(--accent); }
.q-input[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--danger); }
.q-input[disabled] { color: var(--fg-faint); background: var(--bg); cursor: not-allowed; }
.q-textarea { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); line-height: 18px; resize: vertical; }
.q-select-native { appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-muted) 50%), linear-gradient(-45deg, transparent 50%, var(--fg-muted) 50%);
  background-size: 4px 4px; background-repeat: no-repeat; background-position: calc(100% - 15px) 13px, calc(100% - 11px) 13px; }

.q-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.q-field .q-help { font-size: 11px; line-height: 16px; color: var(--fg-muted); }
.q-field .q-error { font-size: 11px; line-height: 16px; color: var(--danger); }
.q-field .q-error::before { content: "✕ "; }
.q-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.q-fieldset > legend { padding: 0; margin-bottom: var(--space-3); font-size: 11px; color: var(--fg-muted); }

.q-igroup { display: flex; align-items: stretch; height: var(--control); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-igroup:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.q-igroup > .q-addon { display: flex; align-items: center; padding: 0 var(--space-3); color: var(--fg-muted); font-size: 12px; white-space: nowrap; }
.q-igroup > .q-addon + .q-addon, .q-igroup > .q-addon.is-boxed { box-shadow: inset 1px 0 0 var(--line-strong); }
.q-igroup > .q-addon.is-boxed:first-child { box-shadow: inset -1px 0 0 var(--line-strong); }
.q-igroup > input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0 var(--space-2); outline: 0; font-size: 12px; caret-color: var(--accent); }
.q-igroup > input::placeholder { color: var(--fg-muted); }
.q-igroup > .q-btn { height: 100%; }
.q-prompt::before { content: "›"; color: var(--accent); margin-right: var(--space-2); }

.q-otp { display: inline-flex; gap: var(--space-1); align-items: center; }
.q-otp > span { width: 32px; height: 40px; display: grid; place-items: center; font-size: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-otp > span.is-active { box-shadow: inset 0 0 0 1px var(--accent); }
.q-otp > span.is-active:empty::after { content: ""; width: 8px; height: 16px; background: var(--accent); animation: q-blink 1s steps(1) infinite; }
.q-otp > i { width: 8px; height: 1px; background: var(--edge); margin: 0 var(--space-1); }

.q-check, .q-radio { appearance: none; margin: 0; width: 14px; height: 14px; flex: none; display: inline-grid; place-items: center;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--edge); cursor: pointer; }
.q-check:checked { background: var(--accent); box-shadow: none; }
.q-check:checked::after { content: ""; width: 7px; height: 4px; margin-top: -2px; border: solid var(--on-accent); border-width: 0 0 1.5px 1.5px; transform: rotate(-45deg); }
.q-check:indeterminate { box-shadow: inset 0 0 0 1px var(--accent); }
.q-check:indeterminate::after { content: ""; width: 6px; height: 1.5px; background: var(--accent); }
.q-radio:checked { box-shadow: inset 0 0 0 1px var(--accent); }
.q-radio:checked::after { content: ""; width: 6px; height: 6px; background: var(--accent); }
.q-check[disabled], .q-radio[disabled] { box-shadow: inset 0 0 0 1px var(--line-strong); cursor: not-allowed; }
.q-choice { display: flex; gap: var(--space-2); align-items: flex-start; font-size: 12px; line-height: 16px; cursor: pointer; }
.q-choice > input { margin-top: 1px; }
.q-choice small { display: block; color: var(--fg-muted); font-size: 11px; }
.q-choice.is-card { padding: var(--space-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-choice.is-card:has(:checked) { box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-dim); }

.q-switch { appearance: none; margin: 0; position: relative; width: 30px; height: 16px; flex: none; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--edge); transition: background-color 150ms; }
.q-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; background: var(--fg-muted);
  transition: transform 160ms steps(4, end), background-color 150ms; }
.q-switch:checked { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
.q-switch:checked::after { transform: translateX(14px); background: var(--accent); }

.q-slider { appearance: none; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; --v: 50%; }
.q-slider::-webkit-slider-runnable-track { height: 4px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 4px) 0 0 / var(--v) 100% no-repeat, var(--line-strong); }
.q-slider::-moz-range-track { height: 4px; background: var(--line-strong); }
.q-slider::-moz-range-progress { height: 4px; background: var(--accent); }
.q-slider::-webkit-slider-thumb { appearance: none; width: 8px; height: 16px; margin-top: -6px; background: var(--fg); border: 0; border-radius: 0; }
.q-slider::-moz-range-thumb { width: 8px; height: 16px; background: var(--fg); border: 0; border-radius: 0; }

/* ── Select / combobox trigger + listbox ──────────────────────────────── */
.q-trigger { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: var(--control); padding: 0 var(--space-3);
  background: var(--surface); color: var(--fg); box-shadow: inset 0 0 0 1px var(--line-strong); border: 0; cursor: pointer; font-size: 12px; text-align: left; }
.q-trigger::after { content: ""; margin-left: auto; width: 0; height: 0; border: 4px solid transparent; border-top-color: var(--fg-muted); border-bottom-width: 0; }
.q-trigger[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--accent); }
.q-trigger .q-placeholder { color: var(--fg-muted); }

/* ── Popover surface: menus, listboxes, hover cards ───────────────────── */
.q-pop { background: var(--surface-3); box-shadow: var(--shadow-pop); padding: var(--space-1); min-width: 180px; font-size: 12px; }
.q-pop.is-pad { padding: var(--space-4); }
.q-menu-label { padding: 6px var(--space-2) 4px; font-size: 11px; color: var(--fg-muted); }
.q-menu-item { display: flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-2); cursor: pointer; color: var(--fg); white-space: nowrap; }
.q-menu-item:hover, .q-menu-item.is-active { background: var(--surface-2); }
.q-menu-item.is-active::before, .q-menu-item[aria-selected="true"]::before { content: "›"; color: var(--accent); width: 8px; margin-left: -2px; }
.q-menu-item:not(.is-active):not([aria-selected="true"]) { padding-left: calc(var(--space-2) + 10px); }
.q-menu-item .q-end { margin-left: auto; color: var(--fg-muted); font-size: 11px; }
.q-menu-item.is-danger { color: var(--danger); }
.q-menu-item.is-disabled { color: var(--fg-faint); cursor: default; }
.q-menu-item.is-disabled:hover { background: none; }
.q-menu-item mark { background: none; color: var(--accent); }
.q-menu-sep { height: 1px; margin: var(--space-1) calc(var(--space-1) * -1); background: var(--line); }
.q-menu-item .q-tick { width: 12px; color: var(--accent); }

/* ── Overlays ─────────────────────────────────────────────────────────── */
.q-stage { position: relative; width: 100%; min-height: 100%; background: var(--overlay); display: grid; place-items: center; padding: var(--space-5); overflow: hidden; }
.q-stage.is-ground { background: var(--bg); }
.q-dialog { width: min(440px, 100%); background: var(--surface-3); box-shadow: var(--shadow-pop); }
.q-dialog-head { display: flex; align-items: center; gap: var(--space-2); height: 32px; padding: 0 var(--space-3); box-shadow: inset 0 -1px 0 var(--line); font-size: 11px; color: var(--fg-muted); }
.q-dialog-head .q-kbd { margin-left: auto; }
.q-dialog-body { padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.q-dialog-title { margin: 0; font: 400 20px/26px var(--font-display); letter-spacing: -0.01em; color: var(--fg); }
.q-dialog-desc { margin: 0; color: var(--fg-muted); font-size: 12px; line-height: 18px; }
.q-dialog-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-5) var(--space-5); }
.q-sheet { position: absolute; top: 0; bottom: 0; right: 0; width: min(320px, 85%); background: var(--surface-3); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.q-drawer { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface-3); box-shadow: var(--shadow-pop); }
.q-drawer-grip { display: block; margin: var(--space-2) auto 0; width: 40px; height: 4px; background: repeating-linear-gradient(90deg, var(--edge) 0 2px, transparent 2px 4px); }
.q-tooltip { display: inline-block; padding: 4px 8px; font-size: 11px; line-height: 16px; background: var(--fg); color: var(--bg); white-space: nowrap; }
.q-tooltip .q-kbd { background: transparent; color: var(--bg); box-shadow: inset 0 0 0 1px var(--fg-muted); margin-left: 6px; height: 16px; }

/* ── Command palette ──────────────────────────────────────────────────── */
.q-command { width: min(520px, 100%); background: var(--surface-3); box-shadow: var(--shadow-pop); }
.q-command-input { display: flex; align-items: center; gap: var(--space-2); height: 44px; padding: 0 var(--space-4); box-shadow: inset 0 -1px 0 var(--line); font-size: 13px; }
.q-command-input::before { content: "›"; color: var(--accent); }
.q-command-input input { flex: 1; background: none; border: 0; outline: 0; caret-color: var(--accent); }
.q-command-list { padding: var(--space-1); }
.q-command-foot { display: flex; gap: var(--space-4); padding: 8px var(--space-4); font-size: 11px; color: var(--fg-muted); box-shadow: inset 0 1px 0 var(--line); }

/* ── Menubar / navigation ─────────────────────────────────────────────── */
.q-menubar { display: inline-flex; align-items: center; height: 32px; padding: 0 var(--space-1); box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--surface); font-size: 12px; }
.q-menubar > button { height: 24px; padding: 0 var(--space-3); border: 0; background: none; cursor: pointer; color: var(--fg-muted); }
.q-menubar > button:hover, .q-menubar > button[aria-expanded="true"] { background: var(--surface-2); color: var(--fg); }
.q-nav { display: flex; gap: var(--space-5); align-items: center; font-size: 12px; }
.q-nav a { color: var(--fg-muted); text-decoration: none; }
.q-nav a:hover, .q-nav a[aria-current="page"] { color: var(--fg); }
.q-nav a[aria-current="page"]::before { content: "■ "; color: var(--accent); font-size: 8px; vertical-align: 2px; }

.q-tabs { display: flex; box-shadow: inset 0 -1px 0 var(--line); font-size: 12px; }
.q-tab { height: 34px; padding: 0 var(--space-4); border: 0; background: none; color: var(--fg-muted); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2); }
.q-tab:hover { color: var(--fg); }
.q-tab[aria-selected="true"] { color: var(--fg); box-shadow: inset 0 -1px 0 var(--accent); }
.q-tab .q-count { font-size: 11px; color: var(--fg-faint); }
.q-tabs.is-editor .q-tab { box-shadow: inset -1px 0 0 var(--line); }
.q-tabs.is-editor .q-tab[aria-selected="true"] { background: var(--bg); box-shadow: inset -1px 0 0 var(--line), inset 0 1px 0 var(--accent); }
.q-tabs.is-editor { background: var(--surface); }

.q-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-muted); }
.q-crumbs a { color: var(--fg-muted); text-decoration: none; }
.q-crumbs a:hover { color: var(--fg); }
.q-crumbs .q-sep { width: auto; height: auto; background: none; color: var(--fg-faint); }
.q-crumbs [aria-current="page"] { color: var(--fg); }

.q-pages { display: flex; align-items: center; gap: 2px; font-size: 12px; }
.q-pages a, .q-pages span { min-width: 28px; height: 28px; padding: 0 6px; display: inline-grid; place-items: center; color: var(--fg-muted); text-decoration: none; }
.q-pages a:hover { color: var(--fg); background: var(--surface-2); }
.q-pages a[aria-current="page"] { color: var(--fg); box-shadow: inset 0 0 0 1px var(--edge); }

/* ── App shell: window frame, sidebar, status bar ─────────────────────────
   The window is a frame (native glass in the app, surface in mockups) holding one square content card. */
.q-window { min-height: 100%; display: flex; flex-direction: column; background: var(--surface); }
.q-window.is-glass { background: transparent; }
.q-window-card { flex: 1; min-height: 0; margin: 0 10px 10px; display: flex; flex-direction: column; background: var(--bg); box-shadow: var(--shadow-pop); }
.q-sidebar { width: 220px; height: 100%; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); display: flex; flex-direction: column; font-size: 12px; }
.q-sidebar-head { display: flex; align-items: center; gap: var(--space-2); height: 44px; padding: 0 var(--space-4); }
.q-sidebar-section { padding: var(--space-3) 0 var(--space-1); }
.q-sidebar-label { display: flex; justify-content: space-between; padding: 0 var(--space-4) 6px; font-size: 11px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.q-sidebar-label a { color: inherit; text-decoration: none; }
.q-sidebar-label a:hover, .q-sidebar-label a[aria-current="page"] { color: var(--fg); }
.q-sidebar-item { display: flex; align-items: center; gap: var(--space-2); height: 28px; padding: 0 var(--space-4); color: var(--fg-muted); text-decoration: none; cursor: pointer; }
.q-sidebar-item:hover { color: var(--fg); background: var(--surface-2); }
.q-sidebar-item[aria-current="page"] { color: var(--fg); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.q-sidebar-item .q-end { margin-left: auto; font-size: 11px; color: var(--fg-faint); }
.q-sidebar-foot { margin-top: auto; }

.q-statusbar { display: flex; align-items: stretch; height: 24px; font-size: 11px; line-height: 24px; color: var(--fg-muted); background: var(--surface); box-shadow: inset 0 1px 0 var(--line); }
.q-statusbar > * { padding: 0 var(--space-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.q-statusbar > .q-mode { background: var(--accent); color: var(--on-accent); }
.q-statusbar > .q-push { margin-left: auto; }
.q-statusbar > * + *:not(.q-push) { box-shadow: inset 1px 0 0 var(--line); }

/* ── Data display ─────────────────────────────────────────────────────── */
.q-card { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; min-width: 0; }
.q-card-head { padding: var(--space-4) var(--space-5) 0; display: flex; align-items: center; gap: var(--space-2); font-size: 11px; color: var(--fg-muted); }
.q-card-head .q-step { color: var(--accent); }
.q-card-head .q-dots { margin-left: auto; color: var(--accent); letter-spacing: 1px; }
.q-card-body { padding: var(--space-4) var(--space-5) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.q-card-title { margin: 0; font: 400 20px/28px var(--font-display); letter-spacing: -0.01em; color: var(--fg); }
.q-card-text { margin: 0; font-size: 12px; line-height: 20px; color: var(--fg-muted); }
.q-card-foot { margin-top: auto; padding: var(--space-3) var(--space-5); box-shadow: inset 0 1px 0 var(--line); display: flex; gap: var(--space-2); align-items: center; font-size: 11px; color: var(--fg-muted); }
.q-card-media { position: relative; aspect-ratio: 16 / 9; max-width: 100%; overflow: hidden; background: var(--bg); }

.q-eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); padding: 2px 8px; font-size: 11px; line-height: 18px; color: var(--fg-muted); background: var(--surface); }
.q-eyebrow::before { content: ""; width: 4px; height: 4px; background: var(--accent); }

.q-badge { display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 7px; font-size: 11px; line-height: 1; color: var(--fg-muted); background: var(--surface-2); white-space: nowrap; }
.q-badge::before { content: ""; width: var(--pip); height: var(--pip); background: var(--edge); }
.q-badge.is-accent::before, .q-badge.is-ok::before { background: var(--accent); }
.q-badge.is-accent { color: var(--accent); background: var(--accent-dim); }
.q-badge.is-danger { color: var(--danger); background: var(--danger-dim); }
.q-badge.is-danger::before { background: var(--danger); }
.q-badge.is-warning::before { background: var(--warning); }
.q-badge.is-info::before { background: var(--info); }
.q-badge.is-outline { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-badge.is-plain::before { display: none; }
.q-pip { display: inline-block; width: var(--pip); height: var(--pip); background: var(--accent); flex: none; }
.q-pip.is-off { background: none; box-shadow: inset 0 0 0 1px var(--edge); }
.q-pip.is-danger { background: var(--danger); }
.q-pip.is-warning { background: var(--warning); }
.q-pip.is-live { animation: q-pulse 1.6s steps(2) infinite; }

.q-avatar { position: relative; width: 32px; height: 32px; flex: none; display: inline-grid; place-items: center; overflow: hidden;
  background: var(--surface-2); color: var(--fg); font-size: 11px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.q-avatar.is-sm { width: 24px; height: 24px; font-size: 10px; }
.q-avatar.is-lg { width: 48px; height: 48px; font-size: 14px; }
.q-avatar > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.q-avatars { display: inline-flex; }
.q-avatars > .q-avatar + .q-avatar { margin-left: -6px; box-shadow: 0 0 0 2px var(--bg), inset 0 0 0 1px var(--line-strong); }

.q-table-wrap { width: 100%; overflow-x: auto; }
.q-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.q-table th { height: 32px; padding: 0 var(--space-3); text-align: left; font-weight: 400; font-size: 11px; color: var(--fg-muted); box-shadow: inset 0 -1px 0 var(--line-strong); white-space: nowrap; }
.q-table td { height: 36px; padding: 0 var(--space-3); box-shadow: inset 0 -1px 0 var(--line); white-space: nowrap; }
.q-table tbody tr:hover td { background: var(--surface); }
.q-table tr[aria-selected="true"] td { background: var(--accent-dim); }
.q-table .is-num { text-align: right; }
.q-table th[aria-sort] { cursor: pointer; color: var(--fg); }
.q-table th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.q-table th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.q-table caption { caption-side: bottom; padding-top: var(--space-2); text-align: left; font-size: 11px; color: var(--fg-muted); }
.q-toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

.q-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); box-shadow: inset 0 -1px 0 var(--line); min-width: 0; }
.q-item:hover { background: var(--surface); }
.q-item-title { font-size: 12px; color: var(--fg); }
.q-item-desc { font-size: 11px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-item.is-boxed { box-shadow: inset 0 0 0 1px var(--line); }

.q-accordion { box-shadow: inset 0 1px 0 var(--line); width: 100%; }
.q-accordion details { box-shadow: inset 0 -1px 0 var(--line); }
.q-accordion summary { list-style: none; display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: var(--space-2) 0; cursor: pointer; font: 400 16px/22px var(--font-display); letter-spacing: -0.01em; }
.q-accordion summary::-webkit-details-marker { display: none; }
.q-accordion summary::after { content: "+"; margin-left: auto; font-family: var(--font-mono); color: var(--fg-muted); }
.q-accordion details[open] summary::after { content: "−"; color: var(--accent); }
.q-accordion .q-panel { padding: 0 0 var(--space-4); font-size: 12px; line-height: 20px; color: var(--fg-muted); max-width: 60ch; }
.q-collapsible > summary { list-style: none; cursor: pointer; display: inline-flex; gap: var(--space-2); font-size: 12px; color: var(--fg-muted); }
.q-collapsible > summary::-webkit-details-marker { display: none; }
.q-collapsible > summary::before { content: "▸"; color: var(--fg-faint); transition: transform 120ms; }
.q-collapsible[open] > summary::before { transform: rotate(90deg); color: var(--accent); }

.q-sep { height: 1px; width: 100%; background: var(--line); border: 0; margin: 0; }
.q-sep.is-v { width: 1px; height: auto; align-self: stretch; }
.q-sep.is-dashed { background: repeating-linear-gradient(90deg, var(--line-strong) 0 4px, transparent 4px 8px); }
.q-sep-label { display: flex; align-items: center; gap: var(--space-3); font-size: 11px; color: var(--fg-muted); width: 100%; }
.q-sep-label::before, .q-sep-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.q-scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
.q-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.q-scroll::-webkit-scrollbar-thumb { background: var(--edge); }
.q-scroll::-webkit-scrollbar-track { background: transparent; }

.q-resizable { display: flex; width: 100%; box-shadow: inset 0 0 0 1px var(--line); }
.q-resizable > .q-pane { min-width: 0; padding: var(--space-4); }
.q-handle { width: 9px; flex: none; cursor: col-resize; display: grid; place-items: center; box-shadow: inset 4px 0 0 transparent, inset 5px 0 0 var(--line); }
.q-handle::after { content: ""; width: 3px; height: 14px; background: repeating-linear-gradient(var(--edge) 0 2px, transparent 2px 4px); }
.q-handle:hover { box-shadow: inset 5px 0 0 var(--accent); }

.q-ratio { position: relative; width: 100%; max-width: 100%; overflow: hidden; background: var(--surface); }

.q-carousel { position: relative; width: 100%; }
.q-carousel-track { display: flex; gap: var(--space-3); overflow: hidden; }
.q-carousel-slide { flex: 0 0 72%; min-width: 0; }
.q-carousel-nav { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-3); font-size: 11px; color: var(--fg-muted); }
.q-carousel-nav .q-ticks { display: flex; gap: 4px; }
.q-carousel-nav .q-ticks i { width: 12px; height: 2px; background: var(--line-strong); }
.q-carousel-nav .q-ticks i.is-on { background: var(--accent); }

/* ── Calendar ─────────────────────────────────────────────────────────── */
.q-cal { display: inline-block; padding: var(--space-3); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 12px; }
.q-cal-head { display: flex; align-items: center; justify-content: space-between; height: 28px; margin-bottom: var(--space-2); }
.q-cal-grid { display: grid; grid-template-columns: repeat(7, 30px); }
.q-cal-grid > span { height: 28px; display: grid; place-items: center; color: var(--fg); cursor: pointer; }
.q-cal-grid > span.is-dow { color: var(--fg-muted); font-size: 11px; cursor: default; }
.q-cal-grid > span.is-out { color: var(--fg-faint); }
.q-cal-grid > span:not(.is-dow):hover { background: var(--surface-2); }
.q-cal-grid > span.is-today { box-shadow: inset 0 0 0 1px var(--edge); }
.q-cal-grid > span.is-range { background: var(--accent-dim); }
.q-cal-grid > span.is-sel { background: var(--accent); color: var(--on-accent); }

/* ── Feedback ─────────────────────────────────────────────────────────── */
.q-alert { display: grid; grid-template-columns: auto 1fr; gap: 2px var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 12px; width: 100%; }
.q-alert-tag { grid-row: span 2; font-size: 11px; line-height: 20px; color: var(--fg-muted); }
.q-alert-title { color: var(--fg); }
.q-alert-text { color: var(--fg-muted); line-height: 18px; }
.q-alert.is-ok .q-alert-tag { color: var(--accent); }
.q-alert.is-warning .q-alert-tag { color: var(--warning); }
.q-alert.is-danger { box-shadow: inset 0 0 0 1px var(--danger); background: var(--danger-dim); }
.q-alert.is-danger .q-alert-tag { color: var(--danger); }
.q-alert.is-info .q-alert-tag { color: var(--info); }

.q-toast { display: flex; align-items: center; gap: var(--space-3); width: 340px; max-width: 100%; padding: var(--space-3) var(--space-4); background: var(--surface-3); box-shadow: var(--shadow-pop); font-size: 12px; }
.q-toast .q-toast-text { flex: 1; min-width: 0; }
.q-toast .q-toast-text small { display: block; color: var(--fg-muted); font-size: 11px; }
.q-toasts { display: flex; flex-direction: column; gap: var(--space-2); }
.q-toasts > .q-toast:nth-child(2) { opacity: .7; transform: scale(.97); margin-top: -36px; z-index: -1; position: relative; }

.q-progress { position: relative; height: 8px; width: 100%; background: repeating-linear-gradient(90deg, var(--line-strong) 0 3px, transparent 3px 4px); }
.q-progress > i { position: absolute; inset: 0 auto 0 0; width: var(--v, 40%); background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 4px); transition: width 200ms steps(6); }
.q-progress.is-indeterminate > i { width: 30%; animation: q-indet 1.2s steps(12) infinite; }
.q-meter { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-muted); margin-bottom: 6px; }

.q-skeleton { position: relative; overflow: hidden; background: var(--surface); }
.q-skeleton > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.q-spinner { display: inline-block; width: 1ch; color: var(--accent); font-family: var(--font-mono); }
.q-blocks { display: inline-grid; grid-template-columns: repeat(3, 4px); gap: 1px; }
.q-blocks > i { width: 4px; height: 4px; background: var(--accent); animation: q-blk 900ms steps(1) infinite; }
.q-blocks > i:nth-child(2) { animation-delay: 100ms; } .q-blocks > i:nth-child(3) { animation-delay: 200ms; }
.q-blocks > i:nth-child(6) { animation-delay: 300ms; } .q-blocks > i:nth-child(9) { animation-delay: 400ms; }
.q-blocks > i:nth-child(8) { animation-delay: 500ms; } .q-blocks > i:nth-child(7) { animation-delay: 600ms; }
.q-blocks > i:nth-child(4) { animation-delay: 700ms; } .q-blocks > i:nth-child(5) { opacity: 0; animation: none; }

.q-empty { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-6) var(--space-5); width: 100%; overflow: hidden; }
.q-empty-art { position: relative; width: 160px; height: 96px; }
.q-empty-title { margin: 0; font: 400 20px/26px var(--font-display); letter-spacing: -0.01em; }
.q-empty-text { margin: 0; font-size: 12px; color: var(--fg-muted); max-width: 40ch; }

/* ── Terminal / code ──────────────────────────────────────────────────── */
.q-term { background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 12px; line-height: 20px; width: 100%; min-width: 0; }
.q-term-head { display: flex; align-items: center; gap: var(--space-2); height: 30px; padding: 0 var(--space-3); font-size: 11px; color: var(--fg-muted); box-shadow: inset 0 -1px 0 var(--line); }
.q-term-head .q-btn { margin-left: auto; }
.q-term pre { margin: 0; padding: var(--space-3) var(--space-4); overflow-x: auto; font: inherit; letter-spacing: 0; }
.q-term .q-ps { color: var(--accent); user-select: none; }
.q-term .q-out { color: var(--fg-muted); }
.q-term .q-ok { color: var(--accent); }
.q-term .q-err { color: var(--danger); }
.q-caret::after { content: ""; display: inline-block; width: .6em; height: 1.1em; vertical-align: -.2em; background: var(--accent); margin-left: 2px; animation: q-blink 1s steps(1) infinite; }

/* ── Pixel icons: projects (seed), services (monogram), pictograms (glyph) ── */
.q-icon { position: relative; flex: none; width: 32px; height: 32px; display: inline-grid; place-items: center; overflow: hidden;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-strong); vertical-align: middle; }
.q-icon > canvas.q-icv { display: block; image-rendering: pixelated; }
.q-icon.is-xs { width: 18px; height: 18px; background: none; box-shadow: none; }
.q-icon.is-sm { width: 24px; height: 24px; }
.q-icon.is-lg { width: 48px; height: 48px; }
.q-icon.is-xl { width: 72px; height: 72px; }
.q-icon.is-plain { background: none; box-shadow: none; }
.q-icon.is-selected { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
button.q-icon { border: 0; padding: 0; cursor: pointer; }
button.q-icon:hover { box-shadow: inset 0 0 0 1px var(--edge); }

/* ── Sheen: a frame of random mint dither around a black inner card, behind a hovered card or row (drawn by bundle.js) ── */
.q-sheen { --q-sheen-frame: 10px; position: relative; isolation: isolate; }
.q-sheen-cell { position: relative; }
.q-sheen-fx { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }

/* ── Effects ──────────────────────────────────────────────────────────── */
.q-dither { position: relative; overflow: hidden; background: var(--bg); }
.q-dither > canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.q-dither-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 8px 14px; background: var(--bg); color: var(--accent); font-size: 12px; white-space: nowrap; box-shadow: inset 0 0 0 1px var(--line); }
.q-glyph { display: inline-block; }
.q-reveal .q-ch { display: inline-block; white-space: pre; filter: blur(8px); opacity: 0; transform: translateY(4px);
  transition: filter 600ms cubic-bezier(.2,.7,.2,1), opacity 600ms, transform 600ms; transition-delay: calc(var(--i) * 18ms); }
.q-reveal.is-in .q-ch { filter: blur(0); opacity: 1; transform: none; }
.q-blurred { filter: blur(6px); opacity: .6; transition: filter 600ms, opacity 600ms; }
.q-blurred.is-in { filter: none; opacity: 1; }
.q-fadeup { opacity: 0; transform: translateY(12px); transition: opacity 500ms, transform 500ms cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0ms); }
.q-fadeup.is-in { opacity: 1; transform: none; }

/* ── Type helpers (the scale lives in tokens; these are composed roles) ── */
.q-h1 { margin: 0; font: 400 44px/48px var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
.q-h2 { margin: 0; font: 400 26px/36px var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.q-h3 { margin: 0; font: 400 20px/28px var(--font-display); letter-spacing: -0.01em; }
.q-lead { margin: 0; font-size: 14px; line-height: 20px; color: var(--fg-muted); max-width: 52ch; }
.q-p { margin: 0; font-size: 13px; line-height: 20px; color: var(--fg-muted); max-width: 65ch; }
.q-over { font-size: 11px; line-height: 20px; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-muted); }
.q-code { font-size: 12px; padding: 1px 5px; background: var(--surface-2); color: var(--fg); }
.q-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--space-2); font-size: 12px; }
.q-list > li::before { content: "+"; color: var(--fg-muted); margin-right: var(--space-3); }

@keyframes q-blink { 50% { opacity: 0; } }
@keyframes q-pulse { 50% { opacity: .35; } }
@keyframes q-blk { 0%, 100% { opacity: 1; } 50% { opacity: .15; } }
@keyframes q-indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .q-reveal .q-ch, .q-blurred, .q-fadeup { filter: none; opacity: 1; transform: none; }
}

/* Any element can carry a dither field; its canvas sits under the content. */
[data-dither] { position: relative; overflow: hidden; }
[data-dither] > canvas.q-dcv { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; z-index: 0; }
[data-dither] > :not(canvas) { position: relative; z-index: 1; }
[data-dither] > .q-dither-label { position: absolute; }
