:root {
  --bg: #000000;
  --surface: #0f0f10;
  --surface-2: #18181a;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --ink: #ede9e2;
  --ink-2: #b9b5ae;
  --muted: #85817b;
  --gold: #eb974e;
  --gold-2: #ebb351;
  --gold-grad: linear-gradient(100deg, #eb974e 0%, #ebb351 100%);
  --gold-soft: rgba(235, 151, 78, 0.13);
  --gold-ink: #120a03;
  --green: #8fbf8f;
  --green-soft: rgba(143, 191, 143, 0.13);
  --amber: #e2b25c;
  --amber-soft: rgba(226, 178, 92, 0.13);
  --red: #e5978d;
  --red-soft: rgba(229, 151, 141, 0.12);
  --blue: #9fb4d6;
  --blue-soft: rgba(159, 180, 214, 0.12);
  --radius: 14px;
  --serif: Montserrat, system-ui, sans-serif;
  --sans: Montserrat, system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- layout */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 28px; height: 64px; background: rgba(12, 12, 13, 0.85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.brand img { height: 38px; width: auto; display: block; }
.brand span { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 9px; color: var(--ink-2); }
.nav a:hover { color: var(--ink); background: rgba(255, 255, 255, 0.04); }
.nav a.active { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.who { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.who .lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.who .lang button { background: none; border: 0; padding: 4px 8px; color: var(--muted); cursor: pointer; font-size: 12px; }
.who .lang button.on { color: var(--gold-ink); background: var(--gold-grad); font-weight: 700; }
main { max-width: 1240px; margin: 0 auto; padding: 40px 28px 80px; }
main.full { max-width: none; padding: 0; }

h1 { font: 700 40px/1.12 var(--serif); margin: 0 0 6px; letter-spacing: -0.005em; }
h2 { font: 700 22px/1.25 var(--serif); margin: 0 0 16px; }
h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 32px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--ink); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.head .sub { margin: 0; }
section + section { margin-top: 48px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: transparent; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: rgba(255, 255, 255, 0.05); }
.btn.gold { background: var(--gold-grad); border-color: transparent; color: var(--gold-ink); font-weight: 700; }
.btn.gold:hover { filter: brightness(1.08); }
.btn.green { background: var(--green); border-color: var(--green); color: #102010; font-weight: 600; }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.danger { color: var(--red); border-color: rgba(229, 151, 141, 0.3); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: rgba(235, 151, 78, 0.6); }
textarea { resize: vertical; min-height: 72px; }
input[type=checkbox] { accent-color: var(--gold); width: 16px; height: 16px; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); font-size: 13px; }

/* ---------- cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; transition: border-color 0.2s, transform 0.2s; display: block; }
a.card:hover { border-color: rgba(235, 151, 78, 0.4); transform: translateY(-1px); }
.card .eyebrow { color: var(--muted); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.card .title { font: 700 21px/1.25 var(--serif); margin: 8px 0 14px; }
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty { color: var(--muted); padding: 36px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.internal { color: var(--blue); background: var(--blue-soft); }
.pill.review { color: var(--amber); background: var(--amber-soft); }
.pill.changes { color: var(--red); background: var(--red-soft); }
.pill.approved { color: var(--green); background: var(--green-soft); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; color: var(--ink-2); border: 1px solid var(--line-strong); }
.tag.gold { color: var(--gold); border-color: rgba(235, 151, 78, 0.4); }

/* list rows */
.list { display: flex; flex-direction: column; }
.list a, .list .item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.list > :last-child { border-bottom: 0; }
.list a:hover { background: rgba(255, 255, 255, 0.025); }
.list .name { font-weight: 500; }
.list .where { color: var(--muted); font-size: 13px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; padding: 10px 14px; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td select { padding: 6px 8px; width: auto; }
.table-wrap { overflow-x: auto; }

/* ---------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { position: relative; overflow: hidden; background: radial-gradient(1100px 600px at 15% 115%, rgba(235, 151, 78, 0.28), transparent 60%), radial-gradient(700px 420px at 95% -10%, rgba(235, 179, 81, 0.12), transparent 60%), #050505; display: flex; flex-direction: column; justify-content: space-between; padding: 48px; border-right: 1px solid var(--line); }
.login .art .big { font: 800 60px/1.05 var(--serif); letter-spacing: -0.02em; text-transform: uppercase; max-width: 560px; }
.login .art .big i { font-style: normal; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login .art p { color: var(--ink-2); max-width: 420px; }
.login form { align-self: center; justify-self: center; width: min(380px, 88vw); display: flex; flex-direction: column; gap: 16px; }
.login form h1 { font-size: 30px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login .art { min-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); } .login .art .big { font-size: 46px; } }

/* ---------- review screen */
.reviewer { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100vh - 64px); }
.reviewer .stage { position: relative; min-width: 0; border-right: 1px solid var(--line); background: #0d0d0e; }
.reviewer .stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.reviewer aside { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.reviewer aside .top { padding: 22px 22px 16px; border-bottom: 1px solid var(--line); }
.reviewer aside .top h1 { font-size: 26px; margin-bottom: 10px; }
.reviewer aside .scroll { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 22px; }
.reviewer aside .bottom { border-top: 1px solid var(--line); padding: 14px 22px 18px; display: flex; flex-direction: column; gap: 10px; }
.versions { display: flex; flex-direction: column; gap: 6px; }
.versions a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); }
.versions a.on { border-color: rgba(235, 151, 78, 0.55); background: var(--gold-soft); }
.versions a .n { font: 700 16px/1 var(--serif); min-width: 34px; }
.versions a .d { color: var(--muted); font-size: 12px; flex: 1; }
.note { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; color: var(--ink-2); }
.warn { background: var(--amber-soft); color: var(--amber); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.warn ul, .errbox ul { margin: 6px 0 0; padding-left: 18px; }
.errbox { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg .who { display: flex; gap: 8px; align-items: baseline; font-size: 12px; color: var(--muted); }
.msg .who b { color: var(--ink); font-weight: 500; font-size: 13px; }
.msg .body { margin-top: 4px; white-space: pre-wrap; }
.msg.internal .body { border-left: 2px solid var(--blue); padding-left: 10px; color: var(--ink-2); }
.msg.event .body { color: var(--muted); font-size: 13px; }
.msg.approve .body { color: var(--green); }
.msg.changes .body { border-left: 2px solid var(--red); padding-left: 10px; }
.runtime-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.runtime-row select { width: auto; padding: 5px 8px; font-size: 12px; }
@media (max-width: 960px) {
  .reviewer { grid-template-columns: 1fr; height: auto; }
  .reviewer .stage { height: 62vh; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------- lab */
.lab { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 64px); }
.lab aside { padding: 24px; border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; gap: 18px; background: var(--surface); }
.lab .stage { position: relative; }
.lab .stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (max-width: 960px) { .lab { grid-template-columns: 1fr; height: auto; } .lab .stage { height: 62vh; } }

.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 26px 18px; text-align: center; color: var(--ink-2); transition: border-color 0.15s, background 0.15s; }
.drop.over { border-color: var(--gold); background: var(--gold-soft); }
.drop .links { margin-top: 8px; font-size: 13px; color: var(--muted); }
.drop .links button { background: none; border: 0; color: var(--gold); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.filelist { font-size: 12px; color: var(--muted); max-height: 140px; overflow-y: auto; }
.progress { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }

/* ---------- dialog */
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 18px; padding: 0; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px); }
dialog form { padding: 26px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0 0 4px; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, monospace; }
.secret code { flex: 1; user-select: all; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line-strong); padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.toast.bad { color: var(--red); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-color: var(--gold); }

@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 16px; }
  .brand span { display: none; }
  .who .name { display: none; }
  main { padding: 28px 16px 60px; }
  h1 { font-size: 34px; }
}

.login .art .logo { width: 150px; height: auto; }
.topbar { background: rgba(0, 0, 0, 0.85); }
