:root {
  --bg: #fbfcfd;
  --panel: #ffffff;
  --ink: #0a1628;
  --ink-soft: #4a5568;
  --muted: #8a94a3;
  --line: #eef1f5;
  --line-strong: #e2e7ee;
  --blue: #4A7DFF;
  --blue-deep: #2A4A8A;
  --blue-soft: #eaf0ff;
  --shadow: 0 1px 2px rgba(10,22,40,.04), 0 8px 24px rgba(10,22,40,.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
[hidden] { display: none !important; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02","cv03","cv04";
}

/* Topbar — light, just a hairline under it */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel);
  padding: 0 28px; height: 64px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 13px; }
.wordmark {
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-weight: 400; font-size: 23px; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none; line-height: 1;
}
.wordmark .tld { font-size: 16px; color: var(--muted); }
.divider { width: 1px; height: 22px; background: var(--line-strong); }
.context { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.pipe { color: var(--line-strong); font-weight: 300; }
.partner-logo { height: 26px; width: auto; display: block; }
.user { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

/* Layout */
.layout {
  flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 300px 1fr;
  gap: 28px; padding: 28px;
}

/* Catalogue */
.cat-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 2px 14px; }
.cat-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; font-weight: 600; }
.count { font-size: 12px; color: var(--muted); font-weight: 500; }

.module-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.module {
  display: flex; align-items: center; gap: 13px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 13px 14px; cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, transform .08s ease;
}
.module:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.module:active { transform: translateY(1px); }
.module.active { border-color: var(--blue); background: var(--blue-soft); }
.module .num {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 auto;
  background: #f1f4f8; color: var(--ink-soft); font-size: 12.5px; font-weight: 600;
  display: grid; place-items: center; transition: background .16s, color .16s;
}
.module.active .num { background: var(--blue); color: #fff; }
.module .t { font-size: 13.5px; line-height: 1.35; font-weight: 500; color: var(--ink); }
.module.active .t { color: var(--blue-deep); }

/* Skeleton loaders */
.skeleton {
  height: 52px; border-radius: 12px;
  background: linear-gradient(100deg, #f3f5f8 30%, #eef1f5 50%, #f3f5f8 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.muted, .error { color: var(--muted); font-size: 13.5px; padding: 6px 2px; }
.error { color: #d4493a; }

/* Stage */
.stage { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.player-wrap {
  position: relative; background: #0f141b; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16 / 9; box-shadow: var(--shadow);
}
#player { width: 100%; height: 100%; display: block; }
.player-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  color: #6b7686; background: #0f141b; transition: opacity .25s;
}
.player-empty.hide { opacity: 0; pointer-events: none; }
.pe-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px;
  background: rgba(255,255,255,.06); color: #aeb8c6; padding-left: 4px;
}
.player-empty p { margin: 0; font-size: 14px; }

.now-playing .np-label {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; color: var(--blue);
  background: var(--blue-soft); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px;
}
.now-playing h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.02em; font-weight: 600; }
.now-playing .muted { margin: 0; padding: 0; }

/* Footer */
.footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 22px; border-top: 1px solid var(--line); margin-top: 8px;
}

/* Responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 22px; padding: 20px; }
  .stage { order: -1; }
  .module-list { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 18px; }
  .layout { padding: 16px; }
  .module-list { grid-template-columns: 1fr; }
  .now-playing h1 { font-size: 19px; }
  .divider, .pipe, .context { display: none; }
  .partner-logo { height: 22px; }
}

/* ---- Login gate ---- */
.gate {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 24px;
}
.gate-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow);
  width: 100%; max-width: 400px; padding: 38px 34px; text-align: center;
}
.gate-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 26px; }
.gate-brand .wordmark {
  font-family: "Instrument Serif", Georgia, serif; font-size: 24px; color: var(--ink); line-height: 1;
}
.gate-brand .tld { font-size: 16px; color: var(--muted); }
.gate-context {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  color: var(--blue); background: var(--blue-soft); padding: 4px 10px; border-radius: 999px;
}
.gate-title { font-size: 24px; margin: 0 0 8px; letter-spacing: -.02em; }
.gate-sub { font-size: 14px; color: var(--ink-soft); margin: 0 0 24px; line-height: 1.5; }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-input {
  width: 100%; padding: 13px 15px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: 11px; outline: none;
  text-align: center; letter-spacing: .04em; transition: border-color .15s, box-shadow .15s;
}
.gate-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.gate-btn {
  width: 100%; padding: 13px; font-size: 15px; font-weight: 600; font-family: inherit;
  color: #fff; background: var(--blue); border: 0; border-radius: 11px; cursor: pointer;
  transition: background .15s, transform .05s;
}
.gate-btn:hover { background: var(--blue-deep); }
.gate-btn:active { transform: translateY(1px); }
.gate-btn:disabled { opacity: .6; cursor: default; }
.gate-error { color: #d4493a; font-size: 13.5px; margin: 4px 0 0; line-height: 1.4; }
.gate-foot { color: var(--muted); font-size: 12px; }

/* Sign-out + site label in topbar */
.user { display: flex; align-items: center; gap: 14px; }
.site-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.logout {
  font-size: 13px; font-weight: 500; font-family: inherit; color: var(--ink-soft);
  background: transparent; border: 1px solid var(--line-strong); border-radius: 9px;
  padding: 6px 13px; cursor: pointer; transition: border-color .15s, color .15s;
}
.logout:hover { border-color: var(--blue); color: var(--blue); }
