:root {
  --ink: #1c1915;
  --muted: #5e564c;
  --paper: #f3ecdf;
  --paper-2: #e7dccb;
  --pine: #14302a;
  --pine-2: #1d4037;
  --cream: #f7f1e6;
  --copper: #b85c38;
  --copper-deep: #8c4126;
  --line: rgba(28, 25, 21, 0.12);
  --ok: #1f7a4d;
  --warn: #a15c12;
  --bad: #9b2c2c;
  --shadow: 0 24px 60px rgba(28, 25, 21, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(184, 92, 56, 0.16), transparent 55%),
    linear-gradient(180deg, #f7f1e6 0%, var(--paper) 40%, #efe4d2 100%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, .brand strong {
  font-family: "Fraunces", serif;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.eyebrow, .rail-kicker, .empty-kicker {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--copper-deep);
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.gate-card {
  width: min(460px, 100%);
  background: rgba(247, 241, 230, 0.9);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}
.gate-card h1 { margin: 8px 0 10px; font-size: 3rem; line-height: 0.95; }
.deck { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
label { display: block; margin: 12px 0 6px; font-size: 0.92rem; }
input {
  width: 100%;
  border: 1px solid rgba(28, 25, 21, 0.18);
  background: #fffdf8;
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}
input:focus { border-color: var(--copper); box-shadow: 0 0 0 4px rgba(184, 92, 56, 0.15); }
.gate-card button,
button.primary,
#empty-open {
  border: 0;
  background: var(--pine);
  color: var(--cream);
  border-radius: 999px;
  padding: 12px 16px;
}
.gate-card button { width: 100%; margin-top: 16px; }
.download {
  display: block;
  margin-top: 16px;
  text-align: center;
  color: var(--copper-deep);
  font-size: 0.92rem;
}
.gate-card button:hover,
button.primary:hover,
#empty-open:hover { background: var(--pine-2); }
.panel button {
  width: 100%;
  border: 1px solid rgba(28, 25, 21, 0.16);
  background: #fffdf8;
  border-radius: 999px;
  padding: 11px 14px;
}
.panel button.primary { border: 0; background: var(--pine); color: var(--cream); }
.panel button.danger { color: var(--bad); background: transparent; }
.pages button {
  width: auto;
  border: 1px solid rgba(28, 25, 21, 0.16);
  background: #fffdf8;
  border-radius: 999px;
  padding: 6px 10px;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.danger { color: var(--bad); }
.form-error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
.text-btn { border: 0; background: transparent; color: var(--cream); padding: 8px 0; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "rail stage panel";
}
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 22px;
  background: var(--pine);
  color: var(--cream);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .eyebrow { color: #e7b39a; }
.brand strong { display: block; font-size: 1.35rem; }
.mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 13px; background: var(--copper); color: white;
  font-family: "Fraunces", serif; font-size: 1.4rem;
}
.top-status { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.state-label, .state-message { margin: 0; }
.state-label { font-weight: 640; }
.state-message { color: rgba(247, 241, 230, 0.72); font-size: 0.88rem; max-width: 460px; }
.lamp {
  width: 12px; height: 12px; border-radius: 50%;
  background: #8d8478; box-shadow: 0 0 0 4px rgba(255,255,255,0.06);
}
.lamp[data-state="starting"] { background: var(--warn); }
.lamp[data-state="login"], .lamp[data-state="code"], .lamp[data-state="packages"] { background: #e0b15a; }
.lamp[data-state="inside"] { background: #7dcea0; }
.lamp[data-state="offline"] { background: #e07a7a; }
#logout { margin-left: 8px; }

.rail, .panel {
  background: rgba(247, 241, 230, 0.72);
  border-color: var(--line);
  border-style: solid;
  padding: 18px 16px 24px;
}
.rail { grid-area: rail; border-width: 0 1px 0 0; display: flex; flex-direction: column; min-height: 0; }
.panel { grid-area: panel; border-width: 0 0 0 1px; overflow: auto; }
.steps { list-style: none; margin: 12px 0 18px; padding: 0; display: grid; gap: 8px; }
.steps li {
  display: flex; gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 14px; color: var(--muted);
  background: rgba(255,255,255,0.35);
}
.steps li span {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); font-size: 0.8rem;
}
.steps li.on { color: var(--ink); background: white; }
.steps li.on span, .steps li.done span { background: var(--pine); color: var(--cream); border-color: var(--pine); }
.steps li.done { color: var(--ok); }
.steps li.warn { color: var(--bad); background: #fff; }
.steps li.warn span { background: var(--bad); color: white; border-color: var(--bad); }
.rail-note { color: var(--muted); line-height: 1.45; font-size: 0.92rem; margin: 0 0 16px; }
.log-wrap { margin-top: 8px; min-height: 0; display: flex; flex-direction: column; }
.log {
  list-style: none; margin: 8px 0 0; padding: 0; overflow: auto; max-height: 280px;
  font-size: 0.82rem; line-height: 1.4; color: var(--muted);
}
.log li { padding: 6px 0; border-top: 1px solid var(--line); }

.stage-wrap { grid-area: stage; padding: 16px; min-width: 0; display: flex; flex-direction: column; }
.stage-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; min-height: 32px; }
.pages { display: flex; gap: 6px; flex-wrap: wrap; }
.pages button { padding: 6px 10px; border-radius: 999px; }
.pages button.active { background: var(--pine); color: var(--cream); border-color: var(--pine); }
.url {
  margin: 0 0 0 auto; color: var(--muted); font-size: 0.8rem;
  max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage {
  position: relative; flex: 1; min-height: 520px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 30%),
    #10211c;
  border-radius: 22px; overflow: auto;
  box-shadow: var(--shadow);
  outline: none;
}
.stage:focus { box-shadow: 0 0 0 3px rgba(184, 92, 56, 0.45), var(--shadow); }
#screen { display: block; width: 100%; height: auto; }
.empty {
  position: absolute; inset: 0; display: grid; align-content: center; justify-items: start;
  padding: 48px; color: var(--cream); background: #10211c;
}
.empty h2 { margin: 8px 0; font-size: 2.4rem; line-height: 1; }
.empty p { color: rgba(247, 241, 230, 0.75); }
.empty-kicker { color: #e7b39a; }
.stage-hint { margin: 8px 2px 0; color: var(--muted); font-size: 0.85rem; }
.panel-block { margin-bottom: 16px; }
.panel-block h2 { margin: 0 0 6px; font-size: 1.28rem; }
.hint, .next-note { color: var(--muted); font-size: 0.88rem; line-height: 1.4; }
.panel .primary { margin-top: 8px; }
#close-session, #read-screen, #select-package { margin-top: 8px; }
.next-note {
  margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--copper);
  background: rgba(184, 92, 56, 0.08);
}
.client-list { max-height: 320px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; }
.client-list table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.client-list th, .client-list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.client-list th { position: sticky; top: 0; background: var(--paper); }
#download-clients { margin-top: 8px; }

@media (min-width: 1081px) {
  .app { height: 100vh; }
  .rail, .panel { overflow: auto; }
  .stage { min-height: 0; }
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "stage" "panel" "rail";
  }
  .rail, .panel { border: 0; }
  .log { max-height: 180px; }
  .state-message { display: none; }
  .url { max-width: 46%; }
  .stage { min-height: 420px; }
  .empty { padding: 28px; }
  .empty h2 { font-size: 2rem; }
}
