:root {
  --bg: #000;
  --panel: #0b0b0b;
  --line: #242424;
  --line-strong: #3a3a3a;
  --text: #ececec;
  --muted: #969696;
  --red: #c9170f;
  --red-hover: #de2a22;
  --ok: #4caf6a;
  --track: rgba(255, 235, 235, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
a { color: var(--text); text-underline-offset: 3px; }
a:hover { color: #fff; }

/* ---------- controls ---------- */
button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: #6a6a6a; color: #fff; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
button.quiet { border-color: transparent; color: var(--muted); padding-left: 8px; padding-right: 8px; }
button.quiet:hover { color: var(--text); }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

input, select {
  font: inherit;
  color: var(--text);
  background: #000;
  border: 1px solid var(--line-strong);
  padding: 9px 12px;
  min-width: 0;
}
input::placeholder { color: #7d7d7d; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

/* ---------- square loader ---------- */
.square { display: block; width: 44px; height: 44px; }
.square.small { width: 22px; height: 22px; }
.square path { fill: none; stroke-width: 2; }
.square .track { stroke: var(--track); }
.square .trace {
  stroke: var(--red);
  animation-duration: 1.7s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.t1 { stroke-dasharray: 7 93;  animation-name: trace-1; }
.t2 { stroke-dasharray: 15 85; animation-name: trace-2; opacity: 0.5; }
.t3 { stroke-dasharray: 26 74; animation-name: trace-3; opacity: 0.22; }
.t4 { stroke-dasharray: 42 58; animation-name: trace-4; opacity: 0.08; }
@keyframes trace-1 { from { stroke-dashoffset: 7;  } to { stroke-dashoffset: -93; } }
@keyframes trace-2 { from { stroke-dashoffset: 15; } to { stroke-dashoffset: -85; } }
@keyframes trace-3 { from { stroke-dashoffset: 26; } to { stroke-dashoffset: -74; } }
@keyframes trace-4 { from { stroke-dashoffset: 42; } to { stroke-dashoffset: -58; } }

/* ---------- centered screens: boot and gate ---------- */
.center {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.center .logo { width: min(560px, 84vw); height: auto; display: block; user-select: none; }
.gate-form { display: flex; gap: 8px; margin-top: 4px; width: min(380px, 100%); }
.gate-form input { flex: 1; }
.gate-note { margin-top: 16px; color: var(--muted); font-size: 13px; min-height: 20px; }
.gate-note.error { color: #ff6a63; }
.gate-links { margin-top: 28px; font-size: 13px; }
.gate-links a { color: var(--muted); }
.waiting { display: flex; flex-direction: column; align-items: center; gap: 18px; }

/* ---------- app ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--line);
}
.bar img { height: 40px; width: auto; display: block; }
.bar nav { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.bar nav a { color: var(--muted); text-decoration: none; padding: 8px; }
.bar nav a:hover { color: var(--text); }

.page { max-width: 760px; margin: 0 auto; padding: 28px 20px 80px; }

.hoststate { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.dot { width: 8px; height: 8px; background: #555; flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--red); }

section { margin-top: 36px; }
section > h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
}
section > h2 button { margin-left: auto; font-size: 12px; letter-spacing: 0; text-transform: none; padding: 6px 10px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.row .who { flex: 1; min-width: 180px; }
.row .name { font-weight: 600; }
.row .meta { font-size: 13px; color: var(--muted); }
.row .actions { display: flex; gap: 8px; }
.tag { font-size: 11px; font-weight: 700; border: 1px solid var(--line-strong); padding: 1px 5px; margin-left: 6px; color: var(--muted); vertical-align: 1px; }
.empty { padding: 16px 0; color: var(--muted); font-size: 14px; }

.inline { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.inline input { flex: 1; min-width: 160px; }

.box { border: 1px solid var(--line); background: var(--panel); padding: 18px; margin-top: 14px; }
.box h3 { font-size: 15px; margin-bottom: 6px; }
.box p { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.box ol { color: var(--muted); font-size: 14px; margin: 0 0 14px 18px; }
.box ol li { margin-bottom: 4px; }

.settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.settings select { width: 100%; }
@media (max-width: 520px) { .settings { grid-template-columns: 1fr; } }

.notice { margin-top: 16px; font-size: 14px; color: var(--muted); min-height: 21px; }
.notice.error { color: #ff6a63; }

/* ---------- player ---------- */
#player { position: fixed; inset: 0; background: #000; z-index: 10; touch-action: none; user-select: none; -webkit-user-select: none; }
#player video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
#player .cover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: #000; color: var(--muted); font-size: 14px; text-align: center; padding: 24px;
}
#player .top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.72);
  font-size: 13px; color: var(--muted);
  transition: opacity 0.25s;
  z-index: 3;
}
#player .top.idle { opacity: 0; pointer-events: none; }
#player .top .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player .top button { padding: 8px 12px; font-size: 13px; background: #000; }

/* ---------- touch pad ---------- */
#pad { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#pad .pb, #pad .stick { position: absolute; pointer-events: auto; touch-action: none; }
#pad .pb {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px; font-weight: 700;
}
#pad .pb.round { border-radius: 50%; }
#pad .pb.wide { width: 62px; height: 34px; font-size: 11px; }
#pad .pb.down { background: rgba(224, 32, 27, 0.75); border-color: #fff; color: #fff; }
#pad .stick { width: 120px; height: 120px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 50%; background: rgba(0, 0, 0, 0.25); }
#pad .stick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); }

/* ---------- docs ---------- */
.doc h1 { font-size: 26px; margin-bottom: 8px; }
.doc .lead { color: var(--muted); margin-bottom: 8px; }
.doc h2 { font-size: 17px; margin: 36px 0 10px; padding-top: 20px; border-top: 1px solid var(--line); }
.doc p, .doc li { color: #c4c4c4; }
.doc p { margin-bottom: 12px; }
.doc ol, .doc ul { margin: 0 0 12px 22px; }
.doc li { margin-bottom: 6px; }
.doc code { font: 13px Consolas, "SF Mono", Menlo, monospace; background: #151515; border: 1px solid var(--line); padding: 1px 5px; }
.doc table { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 14px; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); color: #c4c4c4; }
.doc th { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  .square .trace { animation-duration: 3s; }
}
