/* ============ Design tokens ============ */
:root {
  --bg: #f7fbf9;
  --surface: #ffffff;
  --text: #10322e;
  --text-muted: #5f7470;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --accent-2: #4f46e5;
  --accent-2-soft: #e0e7ff;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --border: #dcebe5;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-display: 'Sora', 'Inter', system-ui, sans-serif;

  --radius: 14px;
  --shadow: 0 1px 3px rgb(16 50 46 / .06), 0 5px 16px rgb(16 50 46 / .05);
  --shadow-lift: 0 4px 10px rgb(16 50 46 / .08), 0 12px 28px rgb(16 50 46 / .08);
  --section-pad: clamp(3rem, 7vw, 5.5rem);
  --container: 1120px;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: 1.65; font-size: 16px;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 5.5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.1rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
img, svg { max-width: 100%; }
.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--text-muted); }
.section { padding: var(--section-pad) 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .7rem 1.35rem; border-radius: 999px; border: 1px solid transparent;
  font: 600 .95rem var(--font-body); cursor: pointer; text-decoration: none;
  transition: transform .18s, box-shadow .18s, background .18s;
  min-height: 44px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .4rem .9rem; min-height: 36px; font-size: .85rem; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }

/* ============ Nav ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgb(255 255 255 / .85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; min-height: 68px; }
.brand { display: flex; align-items: center; gap: .6rem; font: 700 1.15rem var(--font-display); color: var(--text); text-decoration: none; }
.brand-badge {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.nav-links { display: none; list-style: none; margin: 0; padding: 0; gap: .25rem; }
.nav-links a {
  display: block; padding: .5rem .85rem; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--accent-soft); }
.nav-links a.active { color: var(--accent); font-weight: 600; }
.nav-toggle {
  background: none; border: 1px solid var(--border); border-radius: 10px;
  width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; color: var(--text);
}
@media (min-width: 768px) {
  .nav-links { display: flex; }
  .nav-toggle { display: none; }
}
.nav-open .nav-links {
  display: flex; flex-direction: column; position: absolute; left: 0; right: 0; top: 68px;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.25rem 1rem;
}

/* ============ Hero ============ */
.hero { position: relative; overflow: hidden; padding: var(--section-pad) 0; }
.hero-blob {
  position: absolute; width: 480px; height: 480px; border-radius: 50%;
  background: var(--accent-soft); filter: blur(90px); top: -140px; right: -120px; z-index: -1;
}
.hero-blob.two { background: var(--accent-2-soft); top: auto; bottom: -180px; left: -160px; right: auto; }
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.05fr .95fr; } }
.eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--accent-soft); color: var(--text); font-weight: 600; font-size: .85rem;
  padding: .35rem .9rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 2s infinite; }
  @keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(22 163 74 / .15); } }
}
.hero .lede { font-size: 1.15rem; color: var(--text-muted); max-width: 52ch; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.6rem; }

/* Mock server card in hero */
.server-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: 1.4rem; max-width: 420px; margin-inline: auto; width: 100%;
}
.server-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.chip { font-size: .78rem; font-weight: 600; padding: .2rem .7rem; border-radius: 999px; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.meter { margin-bottom: .9rem; }
.meter-top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .3rem; }
.bar { height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

/* ============ Cards ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.4rem; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.7rem; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.icon-chip {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 1rem;
}
.icon-chip.indigo { background: var(--accent-2-soft); color: var(--accent-2); }
.icon-chip.amber { background: var(--warn-soft); color: var(--warn); }
.icon-chip.rose { background: var(--danger-soft); color: var(--danger); }

/* ============ Service picker (user page) ============ */
.picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.2rem; }
.pick {
  position: relative; text-align: left; width: 100%;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; cursor: pointer; font: inherit; color: inherit;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.pick:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.pick[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(180deg, var(--surface), var(--accent-soft)); }
.pick[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: .8rem; right: .9rem;
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
}
.pick .muted { font-size: .9rem; margin: 0; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.7rem; margin-top: 1.6rem;
}
.panel[hidden] { display: none; }

/* File rows */
.file-row {
  display: flex; align-items: center; gap: .9rem; padding: .75rem .5rem;
  border-bottom: 1px solid var(--border);
}
.file-row:last-child { border-bottom: 0; }
.file-thumb {
  width: 42px; height: 42px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1.1rem;
}
.file-meta { min-width: 0; }
.file-meta strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta span { font-size: .82rem; color: var(--text-muted); }
.file-row .chip { margin-left: auto; flex: none; }

/* Photo grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .7rem; }
.photo {
  aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; font-size: 1.6rem;
  transition: transform .18s;
}
.photo:hover { transform: scale(1.04); }

/* ============ Dashboard (admin) ============ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.5rem; box-shadow: var(--shadow); }
.stat .label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.stat .value { font: 700 1.9rem var(--font-display); margin: .2rem 0; }
.stat .delta { font-size: .82rem; font-weight: 600; }
.up { color: var(--ok); } .down { color: var(--danger); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { text-align: left; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
tr:last-child td { border-bottom: 0; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--accent-2-soft); color: var(--accent-2); font-weight: 700; font-size: .8rem; margin-right: .6rem;
}

/* Toggle switch */
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.slider {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background .2s; pointer-events: none;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .2s; box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent); outline-offset: 2px; }

.service-row { display: flex; align-items: center; gap: 1rem; padding: .85rem .4rem; border-bottom: 1px solid var(--border); }
.service-row:last-child { border-bottom: 0; }
.service-row .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); } .dot-off { background: var(--border); } .dot-warn { background: var(--warn); }
.service-row .grow { flex: 1; min-width: 0; }
.service-row small { color: var(--text-muted); display: block; }

/* Log */
.log { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.log li { display: flex; gap: .8rem; padding: .7rem .3rem; border-bottom: 1px dashed var(--border); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--text-muted); flex: none; font-variant-numeric: tabular-nums; }

/* Two-column dashboard layout */
.dash-grid { display: grid; gap: 1.4rem; }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: 1.15fr .85fr; } }

/* ============ Toast & misc ============ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120%);
  background: var(--text); color: #fff; padding: .8rem 1.3rem; border-radius: 12px;
  font-weight: 500; box-shadow: var(--shadow-lift); transition: transform .3s; z-index: 100; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }

.section-head { max-width: 60ch; margin-bottom: 2rem; }
.footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--text-muted); font-size: .9rem; }
.footer .container { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }

.reveal { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .5s, transform .5s; }
  .js .reveal.in { opacity: 1; transform: none; }
}

/* ============================================================
   PORTAL: password gate + launchpad (server-feel pages)
   ============================================================ */
.mono { font-family: 'JetBrains Mono', 'Consolas', monospace; }

/* Circuit-grid background shared by gate & launchpad */
.portal-bg {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--accent-soft), transparent),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px, auto;
}

/* ---------- Gate (login) ---------- */
.gate-wrap { flex: 1; display: grid; place-items: center; padding: 2rem 1.25rem; }
.gate {
  width: 100%; max-width: 460px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lift);
  overflow: hidden;
}
.gate-titlebar {
  display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem;
  background: linear-gradient(180deg, #fdfefe, var(--bg)); border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: var(--text-muted);
}
.gate-titlebar .tl-dot { width: 11px; height: 11px; border-radius: 50%; }
.gate-body { padding: 1.6rem 1.6rem 1.9rem; }
.boot-log {
  font-family: 'JetBrains Mono', monospace; font-size: .8rem; line-height: 1.8;
  color: var(--text-muted); min-height: 7.2em; margin: 0 0 1.2rem;
  white-space: pre-wrap; word-break: break-word;
}
.boot-log .ok { color: var(--ok); font-weight: 600; }
.boot-log .accent { color: var(--accent); font-weight: 600; }
.gate h1 { font-size: 1.35rem; margin-bottom: .3rem; }
.gate-form { display: flex; gap: .6rem; margin-top: 1.1rem; }
.gate-form input[type="password"] {
  flex: 1; min-width: 0; padding: .75rem 1rem; border-radius: 12px;
  border: 1px solid var(--border); font: 500 1rem 'JetBrains Mono', monospace;
  letter-spacing: .15em; background: var(--bg); color: var(--text);
}
.gate-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.gate-msg { min-height: 1.4em; font-size: .85rem; margin: .7rem 0 0; font-family: 'JetBrains Mono', monospace; }
.gate-msg.err { color: var(--danger); }
.gate-msg.good { color: var(--ok); }
@media (prefers-reduced-motion: no-preference) {
  .gate.shake { animation: shake .4s; }
  @keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
  .cursor-blink::after { content: "▊"; animation: blink 1s steps(1) infinite; color: var(--accent); }
  @keyframes blink { 50% { opacity: 0; } }
}

/* ---------- Launchpad ---------- */
.pad-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 0;
}
.pad-status {
  display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; align-items: center;
  font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: .6rem 1rem; box-shadow: var(--shadow); margin-bottom: 2rem;
}
.led { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: .4rem; }
.led-g { background: var(--ok); } .led-a { background: var(--warn); }
@media (prefers-reduced-motion: no-preference) {
  .led-g { animation: ledpulse 2.4s infinite; }
  @keyframes ledpulse { 50% { box-shadow: 0 0 0 4px rgb(22 163 74 / .15); } }
}

.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1.1rem; }
.app {
  position: relative; display: flex; flex-direction: column; gap: .65rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.25rem; text-decoration: none; color: inherit;
  box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s;
  overflow: hidden;
}
.app::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--app-c, var(--accent)); opacity: .85;
}
.app:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--app-c, var(--accent)); }
.app-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.5rem; background: color-mix(in srgb, var(--app-c, var(--accent)) 14%, white);
  color: var(--app-c, var(--accent));
}
.app h3 { margin: 0; font-size: 1.02rem; }
.app .muted { margin: 0; font-size: .82rem; }
.app-port {
  margin-top: auto; align-self: flex-start;
  font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .15rem .5rem;
}
.pad-section-title {
  font-family: 'JetBrains Mono', monospace; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--text-muted); margin: 2.2rem 0 .9rem;
  display: flex; align-items: center; gap: .8rem;
}
.pad-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Sub-pages: upload / ai / games / gamedata ---------- */
.subpage-head { display:flex; align-items:center; gap:1rem; flex-wrap:wrap; justify-content:space-between; margin-bottom:1.6rem; }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 3rem 1.5rem; text-align: center; transition: border-color .2s, background .2s; cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 2.4rem; }
.progress-row { margin-top: 1rem; }

.chat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; height: 460px; overflow: hidden;
}
.chat-log { flex: 1; overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
.bubble { max-width: 78%; padding: .65rem 1rem; border-radius: 14px; font-size: .95rem; }
.bubble.ai { background: var(--accent-2-soft); border-bottom-left-radius: 4px; align-self: flex-start; }
.bubble.me { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.chat-form { display: flex; gap: .6rem; padding: .9rem; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; min-width: 0; padding: .7rem 1rem; border-radius: 10px; border: 1px solid var(--border); font: inherit; }
.chat-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.game-shell { display: grid; place-items: center; }
#snake { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 100%; touch-action: none; }
.game-hud { display: flex; gap: 1.5rem; justify-content: center; margin: 1rem 0; font-family: 'JetBrains Mono', monospace; }

/* ============================================================
   RACK GATE — dark server-cabinet landing (body.rack-page only)
   ============================================================ */
body.rack-page {
  --rk-bg-a: #464a52; --rk-bg-b: #353941; --rk-bg-c: #262a33;
  --rk-panel: #14181f; --rk-panel-2: #1b212b; --rk-metal: #2a303b; --rk-metal-hi: #38404d;
  --rk-line: rgba(171,182,202,.22);
  --rk-text: #edf1f7; --rk-muted: #aeb8c9;
  --rk-green: #58e884; --rk-amber: #ffc861; --rk-red: #ff6b6b; --rk-blue: #6fb3ff;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: var(--rk-text);
  background:
    radial-gradient(circle at 50% 20%, rgba(197,208,224,.07), transparent 40%),
    radial-gradient(circle at 15% 85%, rgba(85,93,108,.14), transparent 35%),
    linear-gradient(145deg, var(--rk-bg-a) 0%, var(--rk-bg-b) 46%, var(--rk-bg-c) 100%);
  min-height: 100vh; display: grid; place-items: center; padding: 24px 12px;
  position: relative; overflow-x: hidden;
}
body.rack-page::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: repeating-linear-gradient(180deg,
    rgba(188,208,233,.025) 0, rgba(188,208,233,.025) 1px, transparent 1px, transparent 6px);
}
body.rack-page::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle, rgba(112,255,146,.5) 0 2px, rgba(112,255,146,0) 6px),
    radial-gradient(circle, rgba(255,96,96,.45) 0 2px, rgba(255,96,96,0) 6px),
    radial-gradient(circle, rgba(111,179,255,.4) 0 1.8px, rgba(111,179,255,0) 5px);
  background-size: 148px 64px, 178px 76px, 128px 58px;
  background-position: 0 0, 44px 22px, 90px 40px;
  mix-blend-mode: screen; opacity: .5;
}
@media (prefers-reduced-motion: no-preference) {
  body.rack-page::after { animation: rackField 1.05s steps(3, end) infinite; }
  @keyframes rackField { 0%{opacity:.15} 30%{opacity:.6} 60%{opacity:.22} 85%{opacity:.65} 100%{opacity:.25} }
}

.rk-rack {
  position: relative; z-index: 1; width: 100%; max-width: 470px;
  background: linear-gradient(180deg, var(--rk-metal-hi), var(--rk-metal));
  border: 1px solid var(--rk-line); border-radius: 18px;
  padding: 16px 22px;
  box-shadow: 0 30px 70px rgba(5,8,12,.6), inset 0 1px 0 rgba(255,255,255,.06);
}
.rk-rack::before, .rk-rack::after {
  content: ""; position: absolute; top: 20px; bottom: 20px; width: 8px; border-radius: 4px;
  background: repeating-linear-gradient(180deg,
    rgba(10,13,18,.85) 0 6px, rgba(90,100,116,.5) 6px 8px, rgba(10,13,18,.85) 8px 26px);
}
.rk-rack::before { left: 7px; } .rk-rack::after { right: 7px; }

.rk-unit {
  background: linear-gradient(180deg, var(--rk-panel-2), var(--rk-panel));
  border: 1px solid var(--rk-line); border-radius: 10px;
  padding: 10px 14px; margin: 10px 0; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), inset 0 -8px 16px rgba(0,0,0,.25);
}
.rk-row { display: flex; align-items: center; gap: 10px; }
.rk-label { font-size: .62rem; letter-spacing: .16em; color: var(--rk-muted); text-transform: uppercase; }
.rk-vents { flex: 1; height: 14px; border-radius: 3px;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,.55) 0 4px, rgba(120,130,148,.25) 4px 6px); }

.rk-led { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.rk-g { background: var(--rk-green); box-shadow: 0 0 8px var(--rk-green); }
.rk-a { background: var(--rk-amber); box-shadow: 0 0 8px var(--rk-amber); }
.rk-r { background: var(--rk-red); box-shadow: 0 0 8px var(--rk-red); }
.rk-b { background: var(--rk-blue); box-shadow: 0 0 8px var(--rk-blue); }
@media (prefers-reduced-motion: no-preference) {
  .rk-blink   { animation: rkBlink 1.2s steps(2) infinite; }
  .rk-blink-2 { animation: rkBlink 1.7s steps(2) .4s infinite; }
  .rk-blink-3 { animation: rkBlink .9s steps(2) .2s infinite; }
  .rk-blink-4 { animation: rkBlink 2.1s steps(2) .7s infinite; }
  @keyframes rkBlink { 50% { opacity: .15; box-shadow: none; } }
}

.rk-plate { display: flex; align-items: center; justify-content: space-between; }
.rk-plate .rk-name { font: 700 .95rem 'Sora', sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.rk-plate .rk-name span { color: var(--rk-green); }
.rk-plate .rk-tag { font-size: .6rem; color: var(--rk-muted); letter-spacing: .12em; }

.rk-disks { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-top: 8px; }
.rk-disk { height: 34px; border-radius: 5px; border: 1px solid rgba(171,182,202,.18);
  background: linear-gradient(180deg, #232a35, #171d26);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; }
.rk-disk .rk-led { width: 5px; height: 5px; }

/* fans */
.rk-fans { display: flex; gap: 14px; align-items: center; margin-top: 8px; }
.rk-fan {
  width: 52px; height: 52px; border-radius: 50%; flex: none; position: relative;
  border: 2px solid rgba(171,182,202,.28);
  background: radial-gradient(circle at 50% 50%, #0d1218 30%, #1a212b 70%);
  display: grid; place-items: center; overflow: hidden;
}
.rk-blades {
  width: 40px; height: 40px; color: #8b97aa;
}
@media (prefers-reduced-motion: no-preference) {
  .rk-blades { animation: rkSpin 1.6s linear infinite; }
  .rack-alert .rk-blades { animation-duration: .4s; }
  @keyframes rkSpin { to { transform: rotate(360deg); } }
}
.rk-fan::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: #2c3542; border: 1px solid rgba(171,182,202,.35); }
.rk-temp { font-size: .72rem; color: var(--rk-muted); line-height: 1.7; }
.rk-temp strong { color: var(--rk-text); font-size: .95rem; }

.rk-ports { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; margin-top: 8px; }
.rk-port { height: 16px; border-radius: 3px; border: 1px solid rgba(171,182,202,.2);
  background: #10151d; display: grid; place-items: center; }
.rk-port .rk-led { width: 4px; height: 4px; }

.rk-console {
  border-radius: 8px; border: 1px solid rgba(111,179,255,.25);
  background: radial-gradient(ellipse at 50% 0%, rgba(111,179,255,.08), transparent 60%), #0b0f15;
  padding: 14px 16px; margin-top: 8px;
  box-shadow: inset 0 0 30px rgba(0,0,0,.6), 0 0 0 3px rgba(0,0,0,.3);
}
.rk-console-head { display: flex; justify-content: space-between; align-items: center;
  font-size: .6rem; letter-spacing: .14em; color: var(--rk-blue); margin-bottom: 8px; }
body.rack-page .boot-log { color: var(--rk-muted); min-height: 8.5em; font-size: .72rem; line-height: 1.85; }
body.rack-page .boot-log .ok { color: var(--rk-green); }
body.rack-page .boot-log .accent { color: var(--rk-amber); }
body.rack-page .boot-log .err { color: var(--rk-red); font-weight: 700; }

body.rack-page .gate-form { margin-top: 10px; }
body.rack-page .gate-form input[type="password"] {
  background: #060a0f; color: var(--rk-green);
  border: 1px solid rgba(88,232,132,.35); border-radius: 6px;
  letter-spacing: .25em; caret-color: var(--rk-green); font-weight: 600;
}
body.rack-page .gate-form input:focus {
  border-color: var(--rk-green);
  box-shadow: 0 0 0 3px rgba(88,232,132,.15), 0 0 14px rgba(88,232,132,.2);
}
body.rack-page .gate-form .btn {
  font: 700 .78rem 'JetBrains Mono', monospace; letter-spacing: .12em; text-transform: uppercase;
  background: linear-gradient(180deg, #1d5a34, #123c22); color: #b8ffd0;
  border: 1px solid rgba(88,232,132,.5); border-radius: 6px;
}
body.rack-page .gate-form .btn:hover { box-shadow: 0 0 16px rgba(88,232,132,.35); transform: translateY(-1px); }
body.rack-page .gate-msg { font-size: .78rem; }
body.rack-page .gate-msg.err { color: var(--rk-red); }
body.rack-page .gate-msg.good { color: var(--rk-green); }

/* alarm state: everything goes red */
.rack-alert .rk-led { background: var(--rk-red) !important; box-shadow: 0 0 8px var(--rk-red) !important; }
@media (prefers-reduced-motion: no-preference) {
  .rk-rack.shake { animation: rkShake .45s; }
  @keyframes rkShake { 20%,60% { transform: translateX(-9px); } 40%,80% { transform: translateX(9px); } }
}
.rk-foot { position: relative; z-index: 1; margin-top: 14px; text-align: center;
  font-size: .62rem; color: var(--rk-muted); letter-spacing: .1em; }
@media (max-width: 420px) {
  .rk-rack { padding: 12px 16px; }
  .rk-ports { grid-template-columns: repeat(8, 1fr); }
  .rk-ports .rk-port:nth-child(n+9) { display: none; }
}

/* ============================================================
   RACK LAUNCHPAD — home.html as a server room
   ============================================================ */
body.rack-page.pad { display: block; padding: 0 0 70px; }
.rkp-wrap { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* top bar as a rack crown */
.rkp-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, var(--rk-metal-hi), var(--rk-metal));
  border: 1px solid var(--rk-line); border-radius: 0 0 16px 16px; border-top: 0;
  padding: 12px 18px; margin-bottom: 18px;
  box-shadow: 0 16px 40px rgba(5,8,12,.45);
}
.rkp-top .rk-name { font: 700 1rem 'Sora', sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.rkp-top .rk-name span { color: var(--rk-green); }
.rkp-logout {
  font: 700 .7rem 'JetBrains Mono', monospace; letter-spacing: .12em; text-transform: uppercase;
  background: linear-gradient(180deg, #5a1d1d, #3c1212); color: #ffc9c9;
  border: 1px solid rgba(255,107,107,.5); border-radius: 6px; padding: 9px 14px; cursor: pointer;
  transition: box-shadow .2s, transform .15s; min-height: 40px;
}
.rkp-logout:hover { box-shadow: 0 0 16px rgba(255,107,107,.4); transform: translateY(-1px); }

/* telemetry strip */
.rkp-telemetry {
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
  background: linear-gradient(180deg, var(--rk-panel-2), var(--rk-panel));
  border: 1px solid var(--rk-line); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 26px;
  font-family: 'JetBrains Mono', monospace; font-size: .74rem; color: var(--rk-muted);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), inset 0 -8px 16px rgba(0,0,0,.25);
}
.rkp-telemetry strong { color: var(--rk-text); font-weight: 600; }

/* rack section = a cabinet holding blades */
.rkp-cab {
  background: linear-gradient(180deg, var(--rk-metal-hi), var(--rk-metal));
  border: 1px solid var(--rk-line); border-radius: 14px;
  padding: 12px 18px 16px; margin-bottom: 22px; position: relative;
  box-shadow: 0 20px 50px rgba(5,8,12,.4), inset 0 1px 0 rgba(255,255,255,.05);
}
.rkp-cab::before, .rkp-cab::after {
  content: ""; position: absolute; top: 14px; bottom: 14px; width: 7px; border-radius: 4px;
  background: repeating-linear-gradient(180deg,
    rgba(10,13,18,.85) 0 6px, rgba(90,100,116,.5) 6px 8px, rgba(10,13,18,.85) 8px 24px);
}
.rkp-cab::before { left: 6px; } .rkp-cab::after { right: 6px; }
.rkp-cab-title {
  font-family: 'JetBrains Mono', monospace; font-size: .68rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--rk-muted); margin: 2px 4px 10px;
  display: flex; align-items: center; gap: 10px;
}
.rkp-cab-title::after { content: ""; flex: 1; height: 1px; background: var(--rk-line); }

.rkp-blades { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rk-blade {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--rk-text);
  background: linear-gradient(180deg, var(--rk-panel-2), var(--rk-panel));
  border: 1px solid var(--rk-line); border-left: 4px solid var(--bl-c, var(--rk-green));
  border-radius: 9px; padding: 12px 14px; position: relative; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), inset 0 -8px 16px rgba(0,0,0,.25);
  transition: transform .18s, box-shadow .2s, border-color .2s;
}
.rk-blade:hover {
  transform: translateX(6px);
  border-color: var(--bl-c, var(--rk-green));
  box-shadow: 0 0 22px color-mix(in srgb, var(--bl-c, var(--rk-green)) 25%, transparent),
              inset 0 1px 0 rgba(255,255,255,.05);
}
.rk-blade .bl-screen {
  width: 52px; height: 52px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 1.45rem; background: #0b0f15; border: 1px solid rgba(111,179,255,.2);
  box-shadow: inset 0 0 14px rgba(0,0,0,.7);
}
.rk-blade .bl-body { min-width: 0; flex: 1; }
.rk-blade h3 { margin: 0 0 2px; font: 600 .95rem 'Sora', sans-serif; letter-spacing: .04em; }
.rk-blade p { margin: 0; font-size: .76rem; color: var(--rk-muted); line-height: 1.45;
  font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-blade .bl-io { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.rk-blade .bl-port {
  font-family: 'JetBrains Mono', monospace; font-size: .66rem; color: var(--rk-muted);
  background: #10151d; border: 1px solid rgba(171,182,202,.22); border-radius: 5px; padding: 2px 7px;
}
@media (max-width: 560px) { .rk-blade p { white-space: normal; } }

/* activity ticker */
.rkp-ticker {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: rgba(11,15,21,.92); border-top: 1px solid var(--rk-line);
  backdrop-filter: blur(8px);
  font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: var(--rk-muted);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; overflow: hidden;
}
.rkp-ticker .tk-label { color: var(--rk-green); font-weight: 700; letter-spacing: .12em; flex: none; }
.rkp-ticker .tk-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   NO-SCROLL LAUNCHPAD — fill exactly one screen
   ============================================================ */
@media (min-width: 951px) and (min-height: 601px) {
  body[data-theme="server"].rack-page.pad { height: 100vh; overflow: hidden; padding: 0; display: flex; flex-direction: column; }
  body[data-theme="server"].rack-page.pad .rkp-wrap {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    max-width: 1500px; width: 100%; padding-bottom: 46px; /* room for syslog ticker */
  }
  body[data-theme="server"].rack-page.pad .rkp-top { margin-bottom: 10px; flex: none; }
  body[data-theme="server"].rack-page.pad .rkp-telemetry { margin-bottom: 12px; flex: none; }
  body[data-theme="server"].rack-page.pad .rk-foot { display: none; }

  body[data-theme="server"] .rkp-grid {
    flex: 1; min-height: 0;
    display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr;
    gap: 12px;
  }
  body[data-theme="server"] .rkp-grid .rkp-cab { margin-bottom: 0; display: flex; flex-direction: column; min-height: 0; }
  body[data-theme="server"] .rkp-grid .rkp-cab-title { flex: none; }
  body[data-theme="server"] .rkp-grid .rkp-blades {
    flex: 1; min-height: 0;
    display: grid; grid-template-columns: 1fr; grid-auto-rows: 1fr; gap: 8px;
  }
  /* bigger blades */
  body[data-theme="server"] .rkp-grid .rk-blade { padding: 12px 18px; min-height: 0; }
  body[data-theme="server"] .rkp-grid .rk-blade .bl-screen { width: 58px; height: 58px; font-size: 1.6rem; }
  body[data-theme="server"] .rkp-grid .rk-blade h3 { font-size: 1.08rem; }
  body[data-theme="server"] .rkp-grid .rk-blade p { font-size: .8rem; }
  body[data-theme="server"] .rkp-grid .rk-blade:hover { transform: translateX(8px); }
}
/* wide screens: 3-column blade rows inside each cabinet for even bigger tiles */
@media (min-width: 1350px) and (min-height: 601px) {
  body[data-theme="server"] .rkp-grid .rkp-blades { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-rows: 1fr; grid-auto-flow: column; }
  body[data-theme="server"] .rkp-grid .rk-blade { flex-direction: column; text-align: center; justify-content: center; gap: 10px; padding: 16px; }
  body[data-theme="server"] .rkp-grid .rk-blade .bl-body { flex: none; }
  body[data-theme="server"] .rkp-grid .rk-blade .bl-screen { width: 64px; height: 64px; font-size: 1.8rem; }
  body[data-theme="server"] .rkp-grid .rk-blade .bl-io { flex-direction: row; align-items: center; }
  body[data-theme="server"] .rkp-grid .rk-blade p { white-space: normal; }
  body[data-theme="server"] .rkp-grid .rk-blade:hover { transform: translateY(-5px); }
}

/* ============================================================
   ADMIN PANEL
   ============================================================ */
body.rack-page.adm { display: block; padding: 0 0 40px; overflow-y: auto; }
.adm-wrap { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.adm-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .adm-grid { grid-template-columns: 1.05fr .95fr; align-items: start; } }
.adm-card {
  background: linear-gradient(180deg, var(--rk-panel-2, #1b212b), var(--rk-panel, #14181f));
  border: 1px solid var(--rk-line, rgba(171,182,202,.22)); border-radius: 12px;
  padding: 18px; margin-bottom: 16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 14px 34px rgba(5,8,12,.35);
}
.adm-card h2 { font: 600 1rem 'Sora', sans-serif; margin: 0 0 4px; letter-spacing: .04em; }
.adm-card .hint { font-size: .76rem; opacity: .7; margin: 0 0 14px; }
.adm-field { margin-bottom: 12px; }
.adm-field label { display: block; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; opacity: .7; margin-bottom: 5px; }
.adm-field input, .adm-field select {
  width: 100%; padding: 10px 12px; border-radius: 8px; font: 500 .92rem 'Inter', sans-serif;
  background: rgba(0,0,0,.35); color: inherit; border: 1px solid var(--rk-line, rgba(171,182,202,.25));
}
.adm-field input:focus, .adm-field select:focus { outline: none; border-color: var(--rk-green, #58e884); box-shadow: 0 0 0 3px rgba(88,232,132,.15); }
.adm-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adm-btn {
  font: 700 .76rem 'JetBrains Mono', monospace; letter-spacing: .1em; text-transform: uppercase;
  background: linear-gradient(180deg, #1d5a34, #123c22); color: #b8ffd0;
  border: 1px solid rgba(88,232,132,.5); border-radius: 7px; padding: 11px 18px; cursor: pointer; min-height: 44px;
  transition: box-shadow .2s, transform .15s;
}
.adm-btn:hover { box-shadow: 0 0 16px rgba(88,232,132,.3); transform: translateY(-1px); }
.adm-btn.ghost { background: transparent; color: inherit; border-color: var(--rk-line, rgba(171,182,202,.35)); }
.adm-btn.danger { background: linear-gradient(180deg, #5a1d1d, #3c1212); color: #ffc9c9; border-color: rgba(255,107,107,.5); }
.adm-btn.sm { padding: 7px 12px; min-height: 34px; font-size: .68rem; }

.adm-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.adm-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  background: rgba(0,0,0,.25); border: 1px solid var(--rk-line, rgba(171,182,202,.18));
  border-left: 4px solid var(--it-c, #58e884);
}
.adm-item .ic { font-size: 1.25rem; flex: none; }
.adm-item .tx { flex: 1; min-width: 0; }
.adm-item .tx b { display: block; font-size: .92rem; }
.adm-item .tx small { opacity: .65; font-size: .74rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-item.off { opacity: .42; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-card {
  text-align: left; cursor: pointer; padding: 12px; border-radius: 10px; font: inherit; color: inherit;
  background: rgba(0,0,0,.25); border: 2px solid var(--rk-line, rgba(171,182,202,.2)); transition: transform .15s, border-color .2s;
}
.theme-card:hover { transform: translateY(-2px); }
.theme-card[aria-pressed="true"] { border-color: var(--rk-green, #58e884); box-shadow: 0 0 14px rgba(88,232,132,.25); }
.theme-card b { display: block; font-size: .88rem; margin-bottom: 3px; }
.theme-card small { font-size: .7rem; opacity: .65; line-height: 1.35; display: block; }
.theme-swatch { height: 34px; border-radius: 6px; margin-bottom: 8px; border: 1px solid rgba(255,255,255,.15); }
.adm-badge { font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  background: rgba(88,232,132,.15); color: #58e884; border: 1px solid rgba(88,232,132,.4); }

/* icon picker */
.icon-pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px;
  max-height: 148px; overflow-y: auto; padding: 8px; border-radius: 9px;
  background: rgba(0,0,0,.28); border: 1px solid var(--rk-line, rgba(171,182,202,.22));
}
.icon-pick button {
  aspect-ratio: 1; font-size: 1.2rem; line-height: 1; cursor: pointer;
  background: transparent; border: 2px solid transparent; border-radius: 8px; color: inherit;
  transition: background .15s, border-color .15s;
}
.icon-pick button:hover { background: rgba(255,255,255,.08); }
.icon-pick button[aria-pressed="true"] { border-color: var(--rk-green, #58e884); background: rgba(88,232,132,.16); }
.edit-mode { border-color: var(--rk-amber, #ffc861) !important; box-shadow: 0 0 0 3px rgba(255,200,97,.15) !important; }

/* console log: fixed window, content scrolls up inside it */
body.rack-page .boot-log {
  height: 8.6em; min-height: 0 !important; overflow-y: auto; scrollbar-width: thin;
}
body.rack-page .boot-log::-webkit-scrollbar { width: 4px; }
body.rack-page .boot-log::-webkit-scrollbar-thumb { background: rgba(160,180,200,.3); border-radius: 4px; }
