:root {
  --bg: #0b1120;
  --bg-2: #0e1630;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf6;
  --muted: #9aa5c0;
  --gold: #e6b43c;
  --gold-soft: rgba(230, 180, 60, 0.16);
  --green: #35c98b;
  --red: #ff6b6b;
  --blue: #5aa7ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: radial-gradient(1200px 700px at 50% -10%, #16214a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- shared header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 12, 24, 0.55);
  backdrop-filter: blur(8px);
  flex: 0 0 auto;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.3px; font-size: 15px; display: flex; align-items: center; }
#logo { height: 34px; max-width: 150px; object-fit: contain; margin-right: 10px; display: none; }
.topbar .brand small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.topbar .center { text-align: center; flex: 1; }
.topbar .center .event { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; }
.topbar .center .sub { color: var(--muted); font-size: 13px; }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 75, 75, 0.12);
  border: 1px solid rgba(255, 75, 75, 0.4);
  color: #ff8f8f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}
.live-badge::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: #ff4b4b;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 75, 75, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(255, 75, 75, 0); }
}

/* ---------- stage (document) ---------- */
.stage-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  min-height: 0;
}
#stage {
  position: relative;
  border-radius: 6px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  background: #fff;
}
#doc, #ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 6px;
}
#ink { touch-action: none; cursor: crosshair; }

/* ---------- banner (display) ---------- */
.banner {
  flex: 0 0 auto;
  text-align: center;
  padding: 14px 20px;
  font-size: 22px;
  font-weight: 700;
  min-height: 58px;
  color: var(--muted);
}
.banner.active { color: var(--gold); }
.banner.done { color: var(--green); }

/* ---------- signer controls ---------- */
.controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 20px 22px;
}
.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #221a05; font-weight: 800; }
.btn.primary:hover { background: #f0c65a; }
.btn.danger { color: #ff9c9c; border-color: rgba(255, 107, 107, 0.4); }
.btn.ghost { color: var(--muted); }

/* signer hint */
.hint {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0 2px;
}
.hint.ok { color: var(--green); }
.hint.wait { color: var(--muted); }
.hint.active { color: var(--gold); font-weight: 700; }

/* ---------- operator panel ---------- */
.operator-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}
.operator-layout .stage-wrap { flex: 1 1 auto; }
.panel {
  flex: 0 0 340px;
  overflow-y: auto;
  border-left: 1px solid var(--panel-border);
  background: rgba(8, 12, 24, 0.6);
  backdrop-filter: blur(8px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel h2 { font-size: 15px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.director-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: var(--panel);
  flex-wrap: wrap;
}
.director-row.active { border-color: var(--gold); background: var(--gold-soft); }
.director-row.done { border-color: rgba(53, 201, 139, 0.4); }
.dir-num {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255,255,255,0.08);
  font-weight: 800; font-size: 14px;
}
.director-row.active .dir-num { background: var(--gold); color: #221a05; }
.director-row.done .dir-num { background: var(--green); color: #06241a; }
.dir-info { flex: 1 1 auto; min-width: 0; }
.dir-info .name { font-weight: 700; font-size: 14px; }
.dir-info .jab { color: var(--muted); font-size: 12px; }
.dir-info .state { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; }
.state.active { color: var(--gold); }
.state.done { color: var(--green); }
.state.idle { color: var(--muted); }
.dir-actions { flex: 0 0 100%; display: flex; gap: 6px; flex-wrap: wrap; }
.dir-actions .btn { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

.panel .section { display: flex; flex-direction: column; gap: 8px; }
.panel .row-btns { display: flex; gap: 8px; flex-wrap: wrap; }

input[type="file"] { color: var(--muted); font-size: 13px; }
a.download {
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
  font-size: 14px;
}
a.download:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* small screens (tablet signer) — keep stage on top, controls bottom */
@media (max-width: 760px) {
  .panel { flex-basis: 100%; border-left: none; border-top: 1px solid var(--panel-border); }
  .operator-layout { flex-direction: column; }
  .topbar .center .event { font-size: 16px; }
}
