/* Wayne Desktop · Apex
   Calm dark by default, light when the viewer asks for light. Dense, legible, system fonts only
   (no external font, no external anything — CSP default-src 'self'). No inline styles anywhere:
   window geometry is set through the CSSOM by wm.js, which CSP permits and markup-inline does not. */

:root {
  color-scheme: dark light;
  --bg: #0b0d12;
  --bg2: #10131b;
  --surface: #141823;
  --surface2: #1a1f2c;
  --line: #232a3a;
  --line2: #2e3750;
  --ink: #dfe5f2;
  --ink2: #9aa4bd;
  --mute: #6d778f;
  --acc: #5b9cff;
  --acc-ink: #a9c9ff;
  --acc-bg: rgba(91, 156, 255, 0.12);
  --ok: #34d399;
  --warn: #f2b134;
  --bad: #f2736b;
  --purple: #a78bfa;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.03) inset;
  --topbar-h: 44px;
  --taskbar-h: 42px;
  font-size: clamp(13px, calc(8px + 0.36vw), 18px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef1f6;
    --bg2: #e6eaf2;
    --surface: #ffffff;
    --surface2: #f5f7fb;
    --line: #d4dae6;
    --line2: #bfc7d8;
    --ink: #161b26;
    --ink2: #47506a;
    --mute: #6a7488;
    --acc: #1f5fd8;
    --acc-ink: #17408f;
    --acc-bg: rgba(31, 95, 216, 0.09);
    --ok: #0f8a5f;
    --warn: #9a6400;
    --bad: #b3251c;
    --purple: #6d43d6;
    --shadow: 0 14px 34px rgba(24, 33, 56, 0.16), 0 0 0 1px rgba(24, 33, 56, 0.04);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 0.75rem;
  background: linear-gradient(180deg, var(--surface2), var(--bg2));
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.brand .mark {
  width: 0.7rem; height: 0.7rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--acc-ink), var(--acc));
  box-shadow: 0 0 12px var(--acc-bg);
  align-self: center;
}
.brand-name { font-weight: 650; letter-spacing: 0.13em; font-size: 0.82rem; }
.brand-sub { color: var(--mute); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }

.badges { display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--mute);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.badge b { color: var(--ink); font-weight: 600; }
.light {
  display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--mute); margin-right: 0.3rem; vertical-align: baseline;
}
.light.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.light.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.light.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* ---------------------------------------------------------------- desktop + windows */

.desktop {
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(91, 156, 255, 0.07), transparent 60%),
    radial-gradient(900px 600px at 5% 110%, rgba(167, 139, 250, 0.06), transparent 60%),
    var(--bg);
}

.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  min-height: 120px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.win[hidden] { display: none !important; }
.win.focused { border-color: var(--line2); }
.win.focused .win-head { background: linear-gradient(180deg, var(--acc-bg), transparent); }

.win-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.win-head:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.win-title { margin: 0; font-size: 0.82rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.win-sub { color: var(--mute); font-size: 0.7rem; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.win-btns { display: flex; gap: 0.25rem; }
.wb {
  font: inherit; font-size: 0.7rem; line-height: 1;
  color: var(--ink2); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0.2rem 0.4rem; cursor: pointer;
}
.wb:hover { color: var(--ink); border-color: var(--line2); }
.wb:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }

.win-body { padding: 0.7rem; overflow: auto; flex: 1 1 auto; }

/* ---------------------------------------------------------------- content */

h3 { margin: 0.9rem 0 0.35rem; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--acc-ink); font-weight: 650; }
h3:first-child { margin-top: 0; }
.hint { color: var(--mute); font-size: 0.7rem; font-weight: 400; letter-spacing: 0; text-transform: none; }
.muted { color: var(--mute); }
.plain { margin: 0.2rem 0 0.6rem; padding-left: 1.1rem; color: var(--ink2); }
.plain li { margin: 0.15rem 0; }
.plain-p { margin: 0.2rem 0 0.6rem; color: var(--ink2); max-width: 78ch; }
kbd {
  font-family: var(--mono); font-size: 0.72rem;
  border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 0.25rem; background: var(--surface2); color: var(--ink);
}

form label { display: block; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--mute); margin: 0 0 0.5rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.45rem 0.6rem; }
select, input, textarea {
  display: block; width: 100%;
  font-family: var(--mono); font-size: 0.78rem;
  color: var(--ink); background: var(--bg2);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0.35rem 0.4rem; margin-top: 0.2rem;
  text-transform: none; letter-spacing: 0;
}
textarea { resize: vertical; min-height: 3.4rem; }
select:focus-visible, input:focus-visible, textarea:focus-visible, .out:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }

.btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin: 0.5rem 0; }
.act {
  font: inherit; font-size: 0.75rem; letter-spacing: 0.06em;
  color: var(--acc-ink); background: var(--acc-bg);
  border: 1px solid var(--acc); border-radius: 7px;
  padding: 0.35rem 0.7rem; cursor: pointer;
}
.act:hover { background: color-mix(in srgb, var(--acc) 22%, transparent); }
.act:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.act[disabled] { opacity: 0.45; cursor: not-allowed; }
.act.primary { color: var(--bg); background: var(--acc); font-weight: 650; }
.act.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.act.small { font-size: 0.68rem; padding: 0.22rem 0.5rem; }
.act.on { background: var(--acc); color: var(--bg); }

.out {
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.4;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 7px;
  padding: 0.5rem; margin: 0.2rem 0 0;
  white-space: pre-wrap; word-break: break-word;
  max-height: 16rem; overflow: auto;
}
.out-block { margin-top: 0.6rem; }
.code { font-family: var(--mono); font-size: 1.3rem; letter-spacing: 0.32em; color: var(--acc-ink); }

.claim { margin: 0 0 0.5rem; padding: 0.4rem 0.55rem; border-left: 3px solid var(--line2); background: var(--surface2); border-radius: 0 6px 6px 0; color: var(--ink2); font-size: 0.78rem; }
.claim.warn { border-left-color: var(--warn); }

/* the ask is the loudest thing on the surface: a refusal that cannot name its question is a defect */
.ask {
  margin: 0.6rem 0;
  border: 1px solid var(--warn);
  border-left-width: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  padding: 0.55rem 0.7rem;
}
.ask-label { font-size: 0.64rem; letter-spacing: 0.22em; color: var(--warn); font-weight: 700; }
.ask-q { margin: 0.2rem 0 0.35rem; font-size: 1.02rem; line-height: 1.3; color: var(--ink); font-weight: 600; max-width: 70ch; }
.ask-next, .ask-unlocks { margin: 0.1rem 0; font-size: 0.76rem; color: var(--ink2); max-width: 80ch; }
.ask-next::before { content: "next: "; color: var(--mute); }
.ask-unlocks::before { content: "unlocks: "; color: var(--mute); }

.ruling { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; }
.ruling.VERIFIED { color: var(--ok); }
.ruling.REFUSED { color: var(--bad); }
.ruling.NO_SIGNAL { color: var(--warn); }
.ruling.NEEDS_HUMAN { color: var(--purple); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.74rem; font-family: var(--mono); }
th, td { text-align: left; padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--mute); font-weight: 500; font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; position: sticky; top: 0; background: var(--surface); }
td.ok { color: var(--ok); }
td.bad { color: var(--bad); }
td.wrap { white-space: normal; max-width: 42ch; }

.kv { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: 0.2rem 0.7rem; margin: 0.2rem 0 0.5rem; font-size: 0.78rem; }
.kv dt { color: var(--mute); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }

/* ---------------------------------------------------------------- taskbar */

.taskbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 0.5rem;
  height: var(--taskbar-h);
  padding: 0 0.6rem calc(env(safe-area-inset-bottom, 0px) / 2);
  background: linear-gradient(0deg, var(--surface2), var(--bg2));
  border-top: 1px solid var(--line);
  overflow-x: auto;
}
.tb-label { color: var(--mute); font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; }
.tb-buttons { display: flex; gap: 0.3rem; flex: 1 1 auto; }
.tb-right { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; }
.tb-status { font-family: var(--mono); font-size: 0.68rem; color: var(--mute); white-space: nowrap; }

.noscript { padding: 1rem; color: var(--warn); font-family: var(--mono); }

/* ---------------------------------------------------------------- narrow: windows stack, no dragging */

@media (max-width: 720px) {
  body { overflow: auto; }
  .desktop { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.6rem; overflow: visible; }
  .win {
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-height: none;
    left: auto !important; top: auto !important;
  }
  .win-head { cursor: default; }
  .win-body { max-height: 60vh; }
  .topbar { height: auto; padding: 0.4rem 0.6rem; }
  .badges { font-size: 0.9em; }
}

@media (prefers-reduced-motion: no-preference) {
  .win { transition: box-shadow 120ms ease, border-color 120ms ease; }
}


/* ---------------------------------------------------------------- window roles */

.win[data-chrome="quick"] {
  border-color: var(--acc);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--acc-bg);
}
.win[data-chrome="quick"] .win-head { background: var(--acc-bg); }
.win[data-chrome="quick"] .win-title::before {
  content: "\2022 "; color: var(--acc); /* a panel, not a place to live */
}
.win[data-chrome="hud"] .win-head { border-bottom-width: 2px; }

/* ---------------------------------------------------------------- skins */

.skin-list { display: grid; gap: 0.4rem; margin: 0.5rem 0; }
.skin {
  display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.6rem; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface2); padding: 0.45rem 0.6rem;
}
.skin.active { border-color: var(--acc); background: var(--acc-bg); }
.skin-name { font-weight: 650; font-size: 0.82rem; }
.skin-id { font-family: var(--mono); font-size: 0.68rem; color: var(--mute); }
.skin-desc { grid-column: 1 / -1; font-size: 0.74rem; color: var(--ink2); }
label.inline { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-size: 0.68rem; }
label.inline select, label.inline input { width: auto; min-width: 9rem; margin-top: 0; }
code { font-family: var(--mono); font-size: 0.92em; }
