/* ════════════════════════════════════════════════════════════════════════
   CURSEDOWNS — OWNER CONTROL PANEL
   Design system lifted from Seb's World (same tokens, fonts, gradient, glass)
   and re-tuned for a dense, app-like control surface.
   ════════════════════════════════════════════════════════════════════════ */
:root {
  --bg-0: #07060b;
  --bg-1: #0d0b14;
  --bg-2: #14101e;
  --surface:   rgba(255,255,255,0.035);
  --surface-2: rgba(255,255,255,0.065);
  --surface-3: rgba(255,255,255,0.10);
  --border:        rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.18);

  --text:   #efecf6;
  --text-2: #b9b1c8;
  --text-3: #867e98;

  --accent:   #ff3d77;
  --accent-2: #9d6bff;
  --grad: linear-gradient(120deg, #ff3d77, #9d6bff);
  --ok:   #3ddc97;
  --warn: #ffb454;
  --bad:  #ff5d6c;

  --radius:    18px;
  --radius-sm: 11px;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --wrap: 1080px;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 65%, transparent); color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: #2a2438; border-radius: 99px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: #3a3250; }

/* ambient aurora + grain (same flavour as the store) */
body::before {
  content: ""; position: fixed; inset: -20% -10% auto -10%; height: 60vh; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 60% at 22% 20%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(38% 55% at 80% 12%, color-mix(in srgb, var(--accent-2) 28%, transparent), transparent 72%);
  filter: blur(40px); opacity: 0.55;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: clamp(16px, 4vw, 36px); position: relative; z-index: 2; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 0.92rem;
  padding: 11px 20px; border-radius: 99px; text-decoration: none; white-space: nowrap;
  transition: transform .16s, box-shadow .16s, background .16s, border-color .16s, opacity .16s;
}
.btn:active { transform: scale(.97); }
.btn.grad { background: var(--grad); color: #190d18; box-shadow: 0 6px 24px -8px color-mix(in srgb, var(--accent) 60%, transparent); }
.btn.grad:hover { box-shadow: 0 10px 32px -8px color-mix(in srgb, var(--accent) 80%, transparent); transform: translateY(-1px); }
.btn.ghost { border: 1px solid var(--border-strong); color: var(--text); background: var(--surface); }
.btn.ghost:hover { border-color: color-mix(in srgb, var(--accent-2) 60%, var(--border-strong)); background: var(--surface-2); }
.btn.sm { padding: 8px 14px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
:is(a,button,summary,input,[tabindex]):focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 8px; }

/* ════════ LOCK SCREEN (token gate) ════════ */
.lock {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 24px; background: radial-gradient(80% 80% at 50% 0%, var(--bg-2), var(--bg-0));
}
.lock[hidden] { display: none; }
.lock-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px; text-align: center;
  backdrop-filter: blur(12px); box-shadow: 0 30px 80px -30px rgba(0,0,0,.7);
}
.lock-mark { width: 54px; height: 54px; margin: 0 auto 14px; color: var(--accent); }
.lock-card h1 { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: -.01em; }
.lock-card h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lock-card p { color: var(--text-2); font-size: .92rem; margin-top: 8px; }
.field { display: flex; gap: 8px; margin-top: 20px; }
.field input {
  flex: 1; min-width: 0; background: var(--bg-0); border: 1px solid var(--border-strong);
  color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .95rem;
}
.field input::placeholder { color: var(--text-3); }
.lock-remember { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; color: var(--text-3); font-size: .82rem; }
.lock-err { color: var(--bad); font-size: .85rem; margin-top: 12px; min-height: 1.1em; }
.lock-note { color: var(--text-3); font-size: .76rem; margin-top: 18px; line-height: 1.5; }

/* ════════ HEADER ════════ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg-1) 82%, transparent);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.topbar-in { display: flex; align-items: center; gap: 14px; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; font-size: 1.06rem; text-decoration: none; }
.brand .mark { width: 26px; height: 26px; color: var(--accent); }
.brand em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spacer { flex: 1; }

.conn { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border); padding: 6px 12px; border-radius: 99px; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); box-shadow: 0 0 0 0 transparent; flex: none; }
.conn.online  .dot { background: var(--ok);  animation: pulse 2s infinite; }
.conn.offline .dot { background: var(--bad); }
.conn.stale   .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.lockpill { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600;
  font-family: var(--font-display); padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.lockpill[hidden] { display: none; }
.lockpill.on  { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--border-strong)); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.lockpill.off { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }

/* ════════ LAYOUT ════════ */
main { padding-block: 26px 64px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display);
  font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); font-weight: 600; }
.eyebrow b { color: var(--accent); }
.sec { margin-top: 30px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-head h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; letter-spacing: -.01em; }
.sec-head .hint { color: var(--text-3); font-size: .82rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }

/* ── Quick actions grid ── */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.qbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  aspect-ratio: 1 / 0.82; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); transition: transform .14s, border-color .14s, background .14s, box-shadow .14s;
  text-align: center; padding: 10px;
}
.qbtn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border-strong)); background: var(--surface-3); transform: translateY(-2px); }
.qbtn:active { transform: scale(.96); }
.qbtn .emoji { font-size: 1.7rem; line-height: 1; }
.qbtn .lbl { font-family: var(--font-display); font-weight: 600; font-size: .82rem; }
.qbtn .lvl { font-size: .72rem; color: var(--accent-2); font-weight: 600; min-height: 1em; }
.qbtn.danger:hover { border-color: color-mix(in srgb, var(--bad) 70%, transparent); }

/* ── Level steppers ── */
.steppers { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.stepper { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.stepper-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stepper-top .emoji { font-size: 1.25rem; }
.stepper-top .name { font-family: var(--font-display); font-weight: 600; }
.stepper-top .now { margin-left: auto; font-size: .76rem; color: var(--accent-2); font-weight: 600; }
.pips { display: flex; flex-wrap: wrap; gap: 5px; }
.pip {
  min-width: 30px; height: 30px; padding: 0 4px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg-0); color: var(--text-2); font-size: .8rem; font-weight: 600; font-family: var(--font-display);
  transition: background .12s, color .12s, border-color .12s, transform .1s;
}
.pip:hover { border-color: var(--accent-2); color: var(--text); }
.pip:active { transform: scale(.9); }
.pip.on { background: var(--grad); color: #190d18; border-color: transparent; }

/* ── Modules accordion ── */
.modules { display: flex; flex-direction: column; gap: 10px; }
.module { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.module > summary {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; cursor: pointer; list-style: none;
  font-family: var(--font-display); font-weight: 600; user-select: none;
}
.module > summary::-webkit-details-marker { display: none; }
.module > summary .chev { margin-left: auto; transition: transform .2s; color: var(--text-3); }
.module[open] > summary .chev { transform: rotate(90deg); }
.module > summary .mstat { font-size: .74rem; color: var(--accent-2); font-weight: 600; }
.module-body { padding: 4px 16px 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.module-body .mdesc { grid-column: 1/-1; color: var(--text-3); font-size: .8rem; margin-bottom: 4px; }
.abtn {
  padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface-2);
  font-size: .84rem; font-weight: 500; text-align: left; transition: background .12s, border-color .12s, transform .1s;
  display: flex; align-items: center; gap: 7px;
}
.abtn:hover { background: var(--surface-3); border-color: color-mix(in srgb, var(--accent) 50%, var(--border-strong)); }
.abtn:active { transform: scale(.97); }
.abtn.tb::after { content: "✎"; margin-left: auto; color: var(--text-3); }
.abtn.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--border-strong)); }
.abtn.danger:hover { border-color: color-mix(in srgb, var(--bad) 75%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface-3)); }

/* ── Live status panel ── */
.status-list { display: flex; flex-direction: column; gap: 7px; }
.status-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg-0);
  border: 1px solid var(--border); border-radius: 9px; font-size: .86rem; }
.status-row .sid { color: var(--text-3); font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; min-width: 64px; }
.status-row .sline { color: var(--text); font-weight: 500; }
.empty { color: var(--text-3); font-size: .85rem; text-align: center; padding: 22px; }

/* ── Prompt (forwarded DLG/TB) ── */
.prompt-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgba(6,5,11,.7); backdrop-filter: blur(4px); }
.prompt-wrap[hidden] { display: none; }
.prompt {
  width: min(440px, 100%); background: var(--bg-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 24px; box-shadow: 0 30px 80px -30px #000;
}
.prompt .pkind { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--warn); font-weight: 600; }
.prompt .ptext { margin: 8px 0 16px; font-size: .98rem; white-space: pre-wrap; }
.prompt-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-btns .btn { flex: 1 1 30%; }

/* ── Toasts ── */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: 99px;
  padding: 9px 18px; font-size: .85rem; font-weight: 500; box-shadow: 0 12px 30px -12px #000;
  animation: rise .25s ease both; display: flex; align-items: center; gap: 8px;
}
.toast.ok  { border-color: color-mix(in srgb, var(--ok) 55%, var(--border-strong)); }
.toast.bad { border-color: color-mix(in srgb, var(--bad) 60%, var(--border-strong)); }
.toast .e { font-size: 1rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* footer line */
.foot { margin-top: 44px; text-align: center; color: var(--text-3); font-size: .76rem; line-height: 1.7; }
.foot a { color: var(--accent-2); text-decoration: none; }

@media (max-width: 560px) {
  .quick-grid { gap: 9px; }
  .qbtn .emoji { font-size: 1.45rem; }
  .topbar-in { flex-wrap: wrap; }
}
