:root {
  --bg: #0a0b14;
  --bg2: #10121f;
  --panel: rgba(255,255,255,.045);
  --line: rgba(255,255,255,.10);
  --ink: #e9eaf5;
  --muted: #9aa0be;
  --accent: #7c5cff;
  --accent2: #21d4a8;
  --warn: #ffb45c;
  --bad: #ff5c7a;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body { padding-bottom: 60px; }

.stars {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(124,92,255,.22), transparent 60%),
    radial-gradient(900px 500px at 92% 0%, rgba(33,212,168,.14), transparent 60%),
    radial-gradient(1px 1px at 20% 30%, #fff, transparent),
    radial-gradient(1px 1px at 70% 60%, #fff9, transparent),
    radial-gradient(1px 1px at 45% 80%, #fff7, transparent),
    radial-gradient(1px 1px at 85% 25%, #fff6, transparent),
    linear-gradient(180deg, #0a0b14, #0b0d18 60%, #090a12);
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  padding: 18px clamp(14px, 3vw, 34px) 12px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo {
  font-size: 26px; width: 48px; height: 48px; display: grid; place-items: center;
  border-radius: 14px; background: linear-gradient(140deg, rgba(124,92,255,.35), rgba(33,212,168,.25));
  border: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: .4px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.sub span:not(:empty) ~ span:not(:empty)::before { content: "· "; opacity: .5; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------- controls */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 9px 14px; border-radius: 11px; cursor: pointer; font-size: 14px;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(140deg, var(--accent), #5b3ff0); border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { border-color: rgba(255,92,122,.4); color: #ffb3c1; }

.inp {
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 11px; border-radius: 11px; font: inherit; font-size: 14px; min-width: 140px;
}
.inp:focus { outline: 2px solid rgba(124,92,255,.5); outline-offset: 1px; }
.inp.grow { flex: 1 1 260px; }
select.inp { cursor: pointer; }
option { background: #14162a; }

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 10px clamp(14px, 3vw, 34px) 16px;
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  background: linear-gradient(180deg, rgba(10,11,20,.92), rgba(10,11,20,.68));
  border-bottom: 1px solid var(--line);
}
.viewswitch { display: flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.vbtn { background: transparent; border: 0; color: var(--muted); padding: 9px 13px; cursor: pointer; font: inherit; font-size: 14px; }
.vbtn.active { background: rgba(124,92,255,.28); color: #fff; }

main { padding: 18px clamp(14px, 3vw, 34px) 40px; }

.conflict {
  border: 1px solid rgba(255,180,92,.35); background: rgba(255,180,92,.10);
  color: #ffd9a8; padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px;
}
.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ grid view */
.grid-wrap { overflow-x: auto; padding-bottom: 8px; }
.grid {
  display: grid; gap: 6px; min-width: 620px;
  grid-auto-rows: minmax(26px, auto);
}
.grid-head {
  position: sticky; top: 0; font-weight: 600; font-size: 13px; letter-spacing: .3px;
  padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.07);
  border: 1px solid var(--line); text-align: center;
}
.grid-head small { display: block; color: var(--muted); font-weight: 400; }
.time-label {
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
  padding-right: 8px; text-align: right; border-top: 1px dashed rgba(255,255,255,.07);
}
.slot-line { border-top: 1px dashed rgba(255,255,255,.055); grid-column: 2 / -1; }

.card {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: linear-gradient(140deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  border-radius: 12px; padding: 8px 10px; cursor: pointer; overflow: hidden;
  transition: transform .1s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(0,0,0,.45); border-color: rgba(255,255,255,.25); }
.card h3 { margin: 0 0 3px; font-size: 14px; line-height: 1.25; }
.card .who { color: var(--muted); font-size: 12.5px; }
.card .meta { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.card.proposed { border-left-style: dashed; opacity: .88; }
.card.cancelled { opacity: .5; }
.card.cancelled h3 { text-decoration: line-through; }
.card.clash { box-shadow: 0 0 0 1px rgba(255,180,92,.5) inset; }

.tag {
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
  background: rgba(255,255,255,.05);
}
.tag.live { border-color: rgba(33,212,168,.5); color: var(--accent2); }

.unscheduled { margin-top: 26px; }
.unscheduled h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 0 0 10px; }
.unscheduled .cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ------------------------------------------------------------ list view */
table.list { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 14px; }
table.list th {
  text-align: left; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 4px 10px; cursor: pointer; user-select: none; white-space: nowrap;
}
table.list th:hover { color: var(--ink); }
table.list td { background: rgba(255,255,255,.045); padding: 10px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table.list td:first-child { border-left: 1px solid var(--line); border-radius: 11px 0 0 11px; }
table.list td:last-child { border-right: 1px solid var(--line); border-radius: 0 11px 11px 0; }
table.list tr { cursor: pointer; }
table.list tr:hover td { background: rgba(255,255,255,.08); }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.room-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

/* --------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(4,5,12,.72); backdrop-filter: blur(6px); padding: 18px;
}
.sheet {
  width: min(680px, 100%); max-height: 86vh; overflow: auto;
  background: linear-gradient(160deg, #161930, #10121f); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet .who { color: var(--muted); margin: 0 0 12px; }
.sheet .desc { white-space: pre-wrap; margin: 12px 0; color: #d3d6ee; }
.sheet-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row .inp { flex: 1 1 160px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }
.field .inp, .field textarea { width: 100%; }
textarea.inp { min-height: 90px; resize: vertical; font: inherit; }
.att-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.att-list li {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13.5px;
}
.att-list .note { color: var(--muted); font-size: 12px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* -------------------------------------------------------------- drawer */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); z-index: 70;
  background: linear-gradient(160deg, #161930, #0e1020); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.5);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer-body { overflow: auto; padding: 16px 18px 40px; }
.drawer-body h3 { font-size: 14px; color: var(--muted); margin: 20px 0 8px; text-transform: uppercase; letter-spacing: .6px; }
.mini-list { display: grid; gap: 6px; }
.mini {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: 13.5px;
  background: rgba(255,255,255,.04);
}
.mini small { color: var(--muted); }

/* --------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 90;
  background: #1b1f39; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5); font-size: 14px;
}
.toast.bad { border-color: rgba(255,92,122,.5); }

.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 9px 14px; font-size: 12.5px; color: var(--muted);
  background: rgba(8,9,17,.82); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.foot a { color: var(--accent2); text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.dot { opacity: .5; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 1px 6px; background: rgba(255,255,255,.07); font-size: 11.5px; font-family: inherit;
}

/* ----------------------------------------------------------- easter egg */
.game { position: fixed; inset: 0; z-index: 100; background: #05060d; display: block; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.game-hud {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; padding: 12px 16px; pointer-events: none;
}
.game-hud .btn { pointer-events: auto; }
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud-badge {
  background: rgba(10,12,26,.7); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.hud-players { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.hud-players span { border-radius: 999px; padding: 3px 9px; background: rgba(10,12,26,.7); border: 1px solid var(--line); }
.game-banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  text-align: center; background: rgba(10,12,26,.85); border: 1px solid var(--line);
  padding: 26px 34px; border-radius: 18px; font-size: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.game-banner small { display: block; margin-top: 8px; font-size: 14px; color: var(--muted); }
.game-help {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: var(--muted); font-size: 12.5px; margin: 0; pointer-events: none;
}

@media (max-width: 720px) {
  .top-actions { width: 100%; }
  .top-actions .btn { flex: 1 1 auto; }
  .toolbar { position: static; }
  .game-help { display: none; }
}
