/* ==========================================================================
   AI Safety and Governance — admin console stylesheet.
   Same shell system as the front end (see frontend/css/app.css) but its
   own finish: a graphite/charcoal instrument panel with warm metallic
   gold instrumentation — distinct from the front end's national-edition
   green/gold so the console always reads as "admin", regardless of
   edition. Phone-first; hard phone rules at the end of this file.
   ========================================================================== */

:root {
  --bg: #f3f1ea;
  --bg-elevated: #f2f5f3;
  --bg-sunken: #a9b5ae;
  --border: #d9d4c6;
  --border-strong: #bfb8a6;
  --text: #050605;
  --text-muted: #46506e;
  --text-faint: #5f6884;
  --accent: #050605;
  --accent-strong: #050605;
  --accent-2: #8e1b2e;
  --accent-soft: rgba(5, 6, 5, 0.08);
  --accent-contrast: #f2f5f3;
  --danger: #8e1b2e;
  --danger-soft: rgba(142, 27, 46, 0.10);
  --amber: #8a5a10;
  --amber-soft: rgba(138, 90, 16, 0.12);
  --neutral-chip: #a9b5ae;
  --panel: rgba(251, 250, 246, 0.72);
  --grid-line: rgba(5, 6, 5, 0.04);
  --glow-rgb: 11, 27, 63;
  --shadow-sm: 0 1px 2px rgba(5, 6, 5, 0.06);
  --shadow-md: 0 4px 18px rgba(5, 6, 5, 0.08);
  --shadow-lg: 0 14px 36px rgba(5, 6, 5, 0.14);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --font-mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
}

/* Dark (default): the AU palette the user app carries — formal navy ground, ivory ink, champagne hairlines, claret fills. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #050605;
    --bg-elevated: #0c0f0d;
    --bg-sunken: #000000;
    --border: #1b2d58;
    --border-strong: #2b4179;
    --text: #f2f5f3;
    --text-muted: #b4bdd3;
    --text-faint: #8b96b4;
    --accent: #2bd46b;
    --accent-strong: #5fe08e;
    --accent-2: #8e1b2e;
    --accent-soft: rgba(43, 212, 107, 0.10);
    --accent-contrast: #f2f5f3;
    --danger: #e8586b;
    --danger-soft: rgba(232, 88, 107, 0.14);
    --amber: #d8b46e;
    --amber-soft: rgba(216, 180, 110, 0.12);
    --neutral-chip: #132650;
    --panel: rgba(12, 15, 13, 0.62);
    --grid-line: rgba(43, 212, 107, 0);
    --glow-rgb: 52, 84, 160;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  --bg: #050605;
  --bg-elevated: #0c0f0d;
  --bg-sunken: #000000;
  --border: #1b2d58;
  --border-strong: #2b4179;
  --text: #f2f5f3;
  --text-muted: #b4bdd3;
  --text-faint: #8b96b4;
  --accent: #2bd46b;
  --accent-strong: #5fe08e;
  --accent-2: #8e1b2e;
  --accent-soft: rgba(43, 212, 107, 0.10);
  --accent-contrast: #f2f5f3;
  --danger: #e8586b;
  --danger-soft: rgba(232, 88, 107, 0.14);
  --amber: #d8b46e;
  --amber-soft: rgba(216, 180, 110, 0.12);
  --neutral-chip: #132650;
  --panel: rgba(12, 15, 13, 0.62);
  --grid-line: rgba(43, 212, 107, 0);
  --glow-rgb: 52, 84, 160;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1100px 560px at 100% -10%, rgba(var(--glow-rgb), 0.10), transparent 60%),
    radial-gradient(900px 520px at -10% 110%, rgba(184, 134, 44, 0.07), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  background-attachment: fixed;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { height: 100dvh; max-width: 100vw; }
[hidden] { display: none !important; }

/* ---------- buttons / switches ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--bg-elevated);
  cursor: pointer; font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: var(--accent); color: var(--accent-contrast); box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35), 0 6px 22px rgba(var(--glow-rgb), 0.22); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { background: var(--border-strong); color: var(--text-muted); cursor: not-allowed; box-shadow: none; filter: none; }
.btn-secondary { background: var(--bg-sunken); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #f2f5f3; }
.btn-danger:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: transparent; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-pill); border: none; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--bg-sunken); }

.switch { position: relative; width: 42px; height: 26px; min-width: 44px; min-height: 44px; padding: 0; border: none; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.switch::before { content: ""; position: absolute; width: 42px; height: 24px; border-radius: var(--radius-pill); background: var(--border-strong); transition: background .15s ease; }
.switch[aria-checked="true"]::before { background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 14px rgba(var(--glow-rgb), 0.45); }
.switch-thumb { position: absolute; left: calc(50% - 20px); width: 20px; height: 20px; border-radius: 50%; background: #f2f5f3; box-shadow: var(--shadow-sm); transition: transform .15s ease; }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(18px); }
.switch:disabled, .switch[aria-disabled="true"] { cursor: not-allowed; opacity: .6; }

/* ---------- brand / admin pill ---------- */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-centered { justify-content: center; margin-bottom: 20px; }
.brand-mark { color: var(--accent); flex-shrink: 0; filter: drop-shadow(0 0 6px rgba(var(--glow-rgb), 0.5)); }
.brand-word { font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand-word-short { display: none; }
.admin-pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-contrast); font-size: 10.5px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35), 0 0 14px rgba(var(--glow-rgb), 0.25);
}
.admin-pill-sm { height: 18px; padding: 0 7px; font-size: 9px; }
.wordmark-suffix { color: var(--accent); font-family: var(--font-mono); }

.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; min-width: 44px; min-height: 44px;
  border-radius: 50%; border: 1px solid var(--border-strong);
  background: var(--bg-sunken); color: var(--text-muted); cursor: pointer;
  font-size: 12px; font-weight: 800; font-family: var(--font-mono); flex-shrink: 0;
}
.help-btn:hover { background: var(--bg-elevated); color: var(--text); }
.help-panel { max-width: 640px; }
.help-panel .modal-card { max-height: 80dvh; overflow-y: auto; }
.help-body h1, .help-body h2, .help-body h3 { font-size: 15px; margin: 14px 0 6px; }
.help-body h1:first-child { margin-top: 0; }
.help-body p { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.help-body code { font-family: var(--font-mono); background: var(--bg-sunken); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.help-body ul { margin: 0 0 10px; padding-left: 20px; font-size: 13px; color: var(--text-muted); }

/* ---------- login / accept ---------- */

.view-login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card { width: 100%; max-width: 440px; background: var(--panel); backdrop-filter: blur(10px) saturate(1.1); -webkit-backdrop-filter: blur(10px) saturate(1.1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: inset 0 1px 0 rgba(var(--glow-rgb), 0.10), var(--shadow-lg); padding: 28px 22px; position: relative; }
.login-card::after { content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.6), transparent); pointer-events: none; }
.login-panel { display: flex; flex-direction: column; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 12px 0 6px; }
.field-label:first-child { margin-top: 0; }
.field-input { min-height: 44px; padding: 0 14px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); width: 100%; }
.field-input:focus { border-color: var(--accent); }
.login-panel .btn-primary { margin-top: 18px; }
.preview-note { text-align: center; font-size: 12px; color: var(--text-faint); margin: 10px 0 0; }
.form-error { color: var(--danger); font-size: 12.5px; margin: 10px 0 0; }
.view-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 16px; }
.qr-wrap { display: flex; justify-content: center; padding: 14px; background: #f2f5f3; border-radius: var(--radius-md); margin-bottom: 10px; }
.otpauth-uri { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); word-break: break-all; text-align: center; margin: 0 0 6px; }
.accept-done-msg { text-align: center; font-size: 14px; }

.app-footer { text-align: center; font-size: 10.5px; color: var(--text-faint); margin: 14px 0 0; }
.app-footer-sidebar { margin: 0; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); text-align: left; }

/* ---------- shell ---------- */

.shell { height: 100dvh; display: flex; overflow: hidden; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }

.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 rgba(var(--glow-rgb), 0.08);
  z-index: 40; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidebar.is-open { transform: translateX(0); }
.sidebar-top { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px; }
.sidebar-close-btn { flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; overflow-y: auto; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; border: none; background: transparent; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 500; cursor: pointer; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg-sunken); }
.nav-item.is-active { background: linear-gradient(90deg, rgba(var(--glow-rgb), 0.16), rgba(var(--glow-rgb), 0.02)); color: var(--accent-strong); box-shadow: inset 2px 0 0 var(--accent); }
.nav-item svg { flex-shrink: 0; }
.nav-group-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); padding: 12px 10px 4px; font-family: var(--font-mono); }

.sidebar-user { border-top: 1px solid var(--border); padding: 8px; position: relative; }
.user-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border: none; background: transparent; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.user-row:hover { background: var(--bg-sunken); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-contrast); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-name { flex: 1; text-align: left; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { position: absolute; bottom: 62px; left: 8px; right: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 10px; z-index: 45; }
.user-menu-section { margin-bottom: 8px; }
.user-menu-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); display: block; margin-bottom: 6px; font-family: var(--font-mono); }
.theme-switch { display: flex; gap: 4px; background: var(--bg-sunken); border-radius: var(--radius-pill); padding: 3px; }
.theme-opt { flex: 1; min-height: 34px; border: none; border-radius: var(--radius-pill); background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.theme-opt.is-active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-sm); }
.user-menu-item { width: 100%; text-align: left; min-height: 40px; padding: 8px 10px; border: none; background: transparent; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.user-menu-item:hover { background: var(--bg-sunken); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 8px; min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) 10px 0; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
}
.room-title { font-size: 16px; font-weight: 700; margin: 0; padding: 8px 0; flex-shrink: 0; }
.topbar-controls { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; padding: 8px 0; margin-left: auto; flex-wrap: wrap; }

.status-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--radius-pill); background: var(--neutral-chip); color: var(--text-muted); font-size: 11px; font-weight: 700; font-family: var(--font-mono); letter-spacing: .05em; }
.status-pill-on { background: var(--accent-soft); color: var(--accent-strong); box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.3); }
.status-pill-danger { background: var(--danger-soft); color: var(--danger); }

.kill-banner { padding: 10px 14px; background: var(--danger); color: #f2f5f3; font-weight: 700; font-size: 13px; text-align: center; box-shadow: 0 0 26px rgba(255,107,94,.28); }

.room-outlet { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 14px calc(20px + env(safe-area-inset-bottom)); }

/* ---------- toasts ---------- */
.toast-region { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(420px, 92vw); }
.toast { padding: 12px 16px; border-radius: var(--radius-md); background: var(--bg-elevated); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: 13px; }
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-ok { border-color: var(--accent); }

/* ---------- generic room bits ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--panel); backdrop-filter: blur(10px) saturate(1.1); -webkit-backdrop-filter: blur(10px) saturate(1.1); box-shadow: inset 0 1px 0 rgba(var(--glow-rgb), 0.10), var(--shadow-md); padding: 16px; margin-bottom: 14px; position: relative; }
.card::after { content: ""; position: absolute; left: 18px; right: 18px; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(var(--glow-rgb), 0.6), transparent); pointer-events: none; }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; font-weight: 700; margin: 0; flex: 1; }
.card-desc { font-size: 12.5px; color: var(--text-muted); margin: 0 0 10px; }
.field-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field-row label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.field-row input, .field-row select, .field-row textarea { min-height: 44px; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text); width: 100%; }
.field-row textarea { min-height: 90px; padding: 10px 12px; resize: vertical; }
.hint { font-size: 11.5px; color: var(--text-faint); margin: 4px 0 0; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th, .data-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--text-muted); font-weight: 700; font-size: 10.5px; text-transform: uppercase; font-family: var(--font-mono); }
.cell-mono { font-family: var(--font-mono); font-size: 11px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--radius-pill); background: var(--neutral-chip); color: var(--text-muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; font-family: var(--font-mono); }
.chip-role-owner { background: var(--accent-soft); color: var(--accent-strong); }
.chip-ok { background: var(--accent-soft); color: var(--accent-strong); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }

.tile-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 16px; }
@media (min-width: 560px) { .tile-grid { grid-template-columns: repeat(2, 1fr); } }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg-elevated); }
.tile-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); letter-spacing: .04em; font-family: var(--font-mono); }
.tile-value { font-size: 26px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgba(var(--glow-rgb), 0.22); }
.tile-sub { font-size: 11.5px; color: var(--text-faint); }

/* ---------- kill switch ---------- */
.kill-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 0 16px; border-radius: var(--radius-pill); border: 2px solid var(--border-strong); background: var(--bg-sunken); cursor: pointer; font-weight: 700; }
.kill-toggle-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.kill-toggle[aria-checked="true"] { border-color: var(--danger); background: var(--danger-soft); }
.kill-toggle[aria-checked="true"] .kill-toggle-thumb { background: var(--danger); }
.kill-toggle-text { color: var(--text); }
.kill-toggle[aria-checked="true"] .kill-toggle-text { color: var(--danger); }

.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 100%; max-width: 460px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 20px; }
.modal-card h2 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { font-size: 13px; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- policies room ---------- */
.policy-tiers { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.policy-tier-btn { min-height: 40px; padding: 0 14px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong); background: var(--bg-sunken); cursor: pointer; font-size: 12.5px; font-weight: 600; }
.policy-tier-btn.is-active { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.policy-file-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.policy-file-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-sunken); font-size: 12.5px; cursor: pointer; font-family: var(--font-mono); }
.policy-file-item.is-active { background: var(--accent-soft); color: var(--accent-strong); }

.code-editor-wrap { display: flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--bg-sunken); }
.code-editor-gutter { flex-shrink: 0; padding: 12px 10px; text-align: right; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--text-faint); background: var(--bg-sunken); border-right: 1px solid var(--border); user-select: none; white-space: pre; }
.code-editor-textarea { flex: 1; border: none; background: var(--bg-elevated); color: var(--text); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; padding: 12px; resize: vertical; min-height: 320px; outline: none; white-space: pre; overflow-wrap: normal; overflow-x: auto; }

.compile-errors { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.compile-error-item { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 12px; font-family: var(--font-mono); }
.compile-ok { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-strong); font-size: 12.5px; font-family: var(--font-mono); }

.tester-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tester-row input { flex: 1; min-width: 180px; }
.tester-result { margin-top: 8px; }

/* prompt-mic.js (backend/js/shared/) wraps a prompt/message field in
   .prompt-mic-wrap; inside a flex row that wrap must take over the
   field's own flex role — the Code room's Trace runner and the Policies
   room's word-rule tester both lay their prompt input out this way. */
.tester-row > .prompt-mic-wrap,
.code-panel-body [style*="display:flex"] > .prompt-mic-wrap { flex: 1; min-width: 180px; display: flex; }
.tester-row > .prompt-mic-wrap > input,
.code-panel-body [style*="display:flex"] > .prompt-mic-wrap > input { flex: 1; }

/* ---------- publish room ---------- */
.diff-block { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap; }
.diff-line-add { color: var(--accent-strong); background: rgba(var(--glow-rgb), 0.08); display: block; }
.diff-line-del { color: var(--danger); background: var(--danger-soft); display: block; }
.diff-line-ctx { color: var(--text-muted); display: block; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-sunken); font-size: 12.5px; flex-wrap: wrap; }

/* ---------- branding room ---------- */
.brand-preview { display: flex; flex-direction: column; gap: 10px; }
.brand-preview-frame { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; }
.brand-preview-frame.theme-light { background: #eef3f6; color: #0a1922; }
.brand-preview-frame.theme-dark { background: #070b10; color: #e4eef3; }
.color-swatch-row { display: flex; align-items: center; gap: 10px; }
.color-swatch { width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); flex-shrink: 0; }

/* ---------- media room ---------- */
.media-list { display: flex; flex-direction: column; gap: 8px; }
.media-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-sunken); font-size: 12.5px; flex-wrap: wrap; }

/* ---------- code room (VS Code style) ---------- */
.code-room { display: flex; flex-direction: column; height: 100%; min-height: 0; gap: 0; }
.code-room-note { padding: 8px 12px; background: var(--amber-soft); color: var(--amber); font-size: 12px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.code-toolbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.code-body { display: flex; flex: 1; min-height: 420px; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.code-explorer { width: 220px; flex-shrink: 0; overflow-y: auto; background: var(--bg-sunken); border-right: 1px solid var(--border); padding: 6px; }
.code-explorer-item { padding: 5px 8px; font-size: 12px; font-family: var(--font-mono); cursor: pointer; border-radius: var(--radius-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-explorer-item:hover { background: var(--bg-elevated); }
.code-explorer-item.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.code-explorer-dir { font-weight: 700; color: var(--text-muted); padding-top: 8px; }
.code-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.code-tabs { display: flex; overflow-x: auto; background: var(--bg-sunken); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.code-tab { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 12px; font-family: var(--font-mono); border-right: 1px solid var(--border); cursor: pointer; white-space: nowrap; color: var(--text-muted); }
.code-tab.is-active { background: var(--bg-elevated); color: var(--text); }
.code-tab-close { cursor: pointer; opacity: .6; }
.code-tab-close:hover { opacity: 1; }
.code-editor-host { flex: 1; min-height: 320px; }
.code-panels { display: flex; flex-direction: column; border-top: 1px solid var(--border); max-height: 260px; }
.code-panel-tabs { display: flex; gap: 4px; padding: 6px 8px; background: var(--bg-sunken); }
.code-panel-tab { min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill); border: none; background: transparent; font-size: 11.5px; font-weight: 700; cursor: pointer; color: var(--text-muted); }
.code-panel-tab.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.code-panel-body { flex: 1; overflow-y: auto; padding: 10px; font-family: var(--font-mono); font-size: 11.5px; background: var(--bg-sunken); }
.code-output-line { white-space: pre-wrap; word-break: break-word; }
.code-problem-item { padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 4px; }
.code-problem-item:hover { background: var(--bg-elevated); }
.code-problem-item.sev-error { color: var(--danger); }
.code-problem-item.sev-warning { color: var(--amber); }
.trace-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.trace-table th, .trace-table td { text-align: left; padding: 6px; border-bottom: 1px solid var(--border); }
.code-mobile-note { display: none; padding: 24px 16px; text-align: center; color: var(--text-faint); background: var(--bg-elevated); border: 1px dashed var(--border-strong); border-radius: var(--radius-md); font-size: 13px; }

/* ---------- audit ---------- */
.audit-table-wrap { position: relative; overflow-x: auto; }
.ledger-badge { display: inline-flex; align-items: center; gap: 8px; width: fit-content; padding: 6px 12px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: 12.5px; box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35), 0 0 18px rgba(var(--glow-rgb), 0.18); }
.ledger-badge.is-broken { background: var(--danger-soft); color: var(--danger); box-shadow: none; }

/* ---------- reviews ---------- */
.review-item { padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg-elevated); margin-bottom: 10px; font-size: 12.5px; }
.review-item-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- print PDF button ---------- */
.print-btn { display: inline-flex; align-items: center; gap: 6px; }

/* ==========================================================================
   PHONE OVERRIDES (measured at 375x812 and 768x1024)
   ========================================================================== */

@media (min-width: 900px) {
  .sidebar { position: sticky; transform: none; width: var(--sidebar-w); flex-shrink: 0; }
  .drawer-scrim { display: none !important; }
  .sidebar-close-btn { display: none; }
  #hamburger-btn { display: none; }
  .shell { flex-direction: row; }
  .login-card { padding: 36px 32px; }
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 767.98px) {
  .code-body { flex-direction: column; }
  .code-explorer { width: 100%; max-height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
  .code-mobile-note { display: block; margin-bottom: 8px; }
}

@media (max-width: 480px) {
  .brand-word-full { display: none; }
  .brand-word-short { display: inline; }
  .room-title { font-size: 14px; }
  .tile-value { font-size: 22px; }
  .data-table { font-size: 11.5px; }
}
