/* Underverket admin and login pages. One deliberate dark look taken from the office:
   near-black steel, the mauve wall, copper pipes. Pixel type for headings and buttons. */
:root {
  --bg: #141317;
  --panel: #1f1d23;
  --panel-2: #29262e;
  --field: #111014;
  --line: #3b3741;
  --text: #f2ede7;
  --muted: #a99fa7;
  --mauve: #8a6c72;
  --copper: #d58b52;
  --copper-hi: #e8a46f;
  --ok: #8fd09a;
  --warn: #f0c46a;
  --err: #f08a7c;
  --shadow: #000;
  --font-display: 'Pixelify Sans', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'VT323', ui-monospace, 'Courier New', monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font-body);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; margin-top: 1.5rem; }
p { margin: 0; }
a { color: var(--copper-hi); }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 1.2em; letter-spacing: .02em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--copper-hi); outline-offset: 2px; }

/* ---------- layout ---------- */
.main {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 48px;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page { display: flex; flex-direction: column; gap: 24px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 2px solid var(--line);
  background: var(--panel);
}
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.nav a, .linklike {
  font-family: var(--font-display); font-size: 1rem; color: var(--muted); text-decoration: none;
  background: none; border: 0; padding: 4px 0; cursor: pointer;
}
.nav a:hover, .linklike:hover, .nav a[aria-current="page"] { color: var(--text); }
.nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--copper); }
.nav form { margin: 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 1rem; line-height: 1;
  color: var(--text); background: var(--panel-2); text-decoration: none;
  border: 2px solid var(--shadow); box-shadow: 3px 3px 0 var(--shadow);
  padding: 12px 16px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #332f39; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--copper); color: #1b120c; }
.btn.primary:hover { background: var(--copper-hi); }
.btn.danger { color: var(--err); }
.btn.small { padding: 8px 12px; font-size: .9rem; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label, legend { font-family: var(--font-display); font-weight: 500; font-size: .95rem; color: var(--muted); }
input[type="text"], input[type="password"], input:not([type]) {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--field); border: 2px solid var(--line); padding: 11px 12px;
}
input:focus { border-color: var(--copper); outline: none; }
input[readonly] { color: var(--muted); }
.help { color: var(--muted); font-size: .9rem; }
.help.warn { color: var(--warn); }
.hint { color: var(--muted); font-size: .92rem; }

.alert { padding: 12px 14px; border: 2px solid currentColor; background: var(--panel); }
.alert.ok { color: var(--ok); }
.alert.error { color: var(--err); }

.card { background: var(--panel); border: 2px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- login / setup / messages ---------- */
body.auth .main { min-height: 100vh; justify-content: center; align-items: center; padding-block: 32px; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 16px;
}
.auth-card .lede { color: var(--muted); }

/* ---------- admin ---------- */
.add-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.copyrow { display: flex; gap: 8px; flex-wrap: wrap; }
.copyrow input { flex: 1 1 260px; font-family: var(--font-mono); font-size: 1.15rem; }
.linkbox { border-color: var(--copper); }
.section-title { margin-bottom: 12px; }

.members { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.member {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: 10px 14px; background: var(--panel); border: 2px solid var(--line);
}
.member.state-off { opacity: .6; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { font-family: var(--font-display); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 1rem; }
.pill {
  font-family: var(--font-mono); font-size: 1.1rem; line-height: 1; white-space: nowrap;
  padding: 4px 8px 2px; border: 2px solid currentColor; text-transform: uppercase; letter-spacing: .04em;
}
.pill-on { color: var(--ok); }
.pill-pending { color: var(--warn); }
.pill-off { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.scenes { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.scene {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px; background: var(--panel-2); border: 2px solid var(--line);
}
.scene.is-active { border-color: var(--ok); }
.scene img { width: 90px; height: 160px; image-rendering: pixelated; border: 2px solid var(--line); }
.scene strong { font-family: var(--font-display); font-weight: 600; }
.scene img.sprite { width: 100%; max-width: 160px; height: auto; border: 0; margin-block: auto; }
#kalender form + form { margin-top: 10px; }
.actions form { margin: 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  h1 { font-size: 1.6rem; }
  .topbar { padding-block: 10px; gap: 10px; }
  .wordmark { font-size: 1.05rem; }
  .nav { gap: 12px; }
  .nav a, .linklike { font-size: .9rem; }
  .add-form { grid-template-columns: minmax(0, 1fr); }
  .member { grid-template-columns: minmax(0, 1fr) auto; }
  .member .actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active { transform: none; }
}
