/* ===== login ===== */
.login-page { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%);
  display: grid; gap: 16px;
  padding: 32px 28px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
  text-align: center;
  animation: rise .6s var(--ease) both;
}
.login-card .field { text-align: left; }
.login-card h1 { font-size: 20px; }
.login-logo { margin: 0 auto; border-radius: 14px; box-shadow: 0 10px 30px -10px rgba(236,72,153,.7); }
.login-error { color: var(--bad); min-height: 20px; font-size: 13px; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgba(13, 12, 18, .78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 9px; }
.brand-name { font-weight: 800; letter-spacing: -.01em; }
.brand-sub { font-size: 12.5px; font-variant-numeric: tabular-nums; }
#clock { font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 12px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line2);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.chip[data-status="connected"] .chip-dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.chip[data-status="connecting"] .chip-dot, .chip[data-status="reconnecting"] .chip-dot { background: var(--b1); animation: blink 1s infinite; }
.chip[data-status="error"] .chip-dot { background: var(--bad); }
@keyframes blink { 50% { opacity: .3; } }

/* ===== layout ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(360px, 1.2fr) minmax(300px, .95fr);
  gap: 18px;
  padding: 18px 24px 40px;
  align-items: start;
}
@media (max-width: 1180px) { .layout { grid-template-columns: 1fr 1fr; } .layout > .col:last-child { grid-column: 1 / -1; } }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; padding: 12px; } .topbar { padding: 10px 12px; flex-wrap: wrap; } }
.col { display: grid; gap: 18px; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
  animation: rise .5s var(--ease) both;
}
.col:nth-child(2) .panel { animation-delay: .06s; }
.col:nth-child(3) .panel { animation-delay: .12s; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -.005em; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* ===== live panel ===== */
.live-badge {
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--muted);
}
.live-badge.on { background: rgba(255, 77, 109, .16); color: #ff8fa3; }
.live-badge.on::before { content: "● "; animation: blink 1.2s infinite; }
.live-badge.res { background: rgba(74, 222, 128, .14); color: var(--ok); }

.live-panel { position: relative; overflow: hidden; transition: border-color .4s, box-shadow .4s; }
.live-panel.is-live { border-color: rgba(167, 139, 250, .35); box-shadow: 0 0 0 1px rgba(167,139,250,.12), 0 20px 50px -30px rgba(167,139,250,.6); }
.live-panel.is-live.blitz { border-color: rgba(250, 204, 21, .45); box-shadow: 0 0 0 1px rgba(250,204,21,.15), 0 20px 50px -30px rgba(250,204,21,.6); }

.idle { display: grid; place-items: center; gap: 6px; text-align: center; padding: 26px 8px; color: var(--muted); }
.idle-ico { font-size: 30px; opacity: .8; }
.idle strong { color: var(--text); font-size: 15px; }

.live-title { font-size: 19px; font-weight: 800; letter-spacing: -.01em; margin: 4px 0 4px; overflow-wrap: anywhere; }
.live-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.live-timer { font-size: 26px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.live-timer.urgent { color: #ff8fa3; }
.live-progress { height: 4px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; margin-bottom: 14px; }
.live-progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--a1), var(--a2)); transform-origin: left; transition: transform .25s linear; }
.blitz .live-progress > i { background: linear-gradient(90deg, var(--b1), var(--b2)); }

.bars { display: grid; gap: 7px; margin-bottom: 14px; }
.bar {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 26px 1fr auto auto; align-items: center; gap: 10px;
  min-height: 38px; padding: 6px 12px 6px 6px;
  border-radius: 11px;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
  transition: opacity .5s, transform .5s var(--spring), border-color .3s;
}
.bar-fill {
  position: absolute; inset: 0; z-index: -1; width: 0;
  background: linear-gradient(90deg, rgba(167,139,250,.45), rgba(244,114,182,.42));
  transition: width .8s var(--ease);
}
.blitz .bar-fill { background: linear-gradient(90deg, rgba(250,204,21,.45), rgba(251,146,60,.4)); }
.bar-num { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: rgba(255,255,255,.08); font-weight: 800; font-size: 13px; }
.bar-text { font-weight: 600; overflow-wrap: anywhere; }
.bar-votes { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bar-pct { font-weight: 800; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.bar.lead { border-color: rgba(167,139,250,.4); }
.blitz .bar.lead { border-color: rgba(250,204,21,.45); }
.bars.done .bar:not(.win) { opacity: .4; }
.bar.win { border-color: var(--ok); transform: scale(1.015); }
.bar.win .bar-num { background: var(--ok); color: #052e16; }

.live-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: 12px;
  background: rgba(74, 222, 128, .08);
  border: 1px solid rgba(74, 222, 128, .25);
  animation: pop .5s var(--spring);
}
.result-banner strong { font-size: 16px; overflow-wrap: anywhere; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

.challenge-text { font-size: 17px; font-weight: 700; margin-bottom: 12px; color: #fde68a; }
#challengePanel { border-color: rgba(250,204,21,.35); background: linear-gradient(180deg, rgba(250,204,21,.06), transparent 60%), var(--panel); }

/* ===== segmented & quick form ===== */
.quick { display: grid; gap: 10px; }
.seg, .durations { display: flex; gap: 6px; padding: 4px; background: var(--bg2); border-radius: 12px; border: 1px solid var(--line); }
.seg label, .durations label { flex: 1; }
.seg input, .durations input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .durations span {
  display: grid; place-items: center; text-align: center;
  height: 32px; border-radius: 9px;
  font-weight: 600; font-size: 13.5px; color: var(--muted);
  cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.seg input:checked + span, .durations input:checked + span { background: var(--panel2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 4px 12px -6px rgba(0,0,0,.6); }
.seg input[value="blitz"]:checked + span { background: rgba(250,204,21,.16); color: #fde047; }
.seg input:focus-visible + span, .durations input:focus-visible + span { outline: 2px solid var(--a1); }
.seg-lg span { height: auto; padding: 10px 8px; gap: 2px; font-size: 14.5px; }
.seg-lg small { font-weight: 500; font-size: 11.5px; color: var(--muted); }

/* ===== preview ===== */
.preview-wrap {
  position: relative; overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    repeating-conic-gradient(#1b1a23 0 25%, #15141c 0 50%) 0 0 / 22px 22px;
}
.preview-wrap iframe {
  position: absolute; top: 0; left: 0;
  width: 200%; height: 200%;
  border: 0;
  transform: scale(.5); transform-origin: 0 0;
  pointer-events: none;
}

/* ===== schedule ===== */
.grow-panel { min-height: 300px; }
.next-up {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin-bottom: 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(167,139,250,.12), rgba(244,114,182,.06));
  border: 1px solid rgba(167,139,250,.22);
}
.next-up .nu-label { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--a1); }
.next-up .nu-title { font-weight: 700; overflow-wrap: anywhere; }
.next-up .nu-in { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 18px; white-space: nowrap; }

.schedule { display: grid; gap: 18px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.group-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group-list { display: grid; gap: 6px; position: relative; }

.item {
  position: relative;
  display: grid; grid-template-columns: 20px 54px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 10px 10px 8px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  transition: border-color .2s, background .2s, transform .2s var(--ease), opacity .3s;
  animation: rise .35s var(--ease) both;
}
.item:hover { border-color: var(--line2); background: #191820; }
.item::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--a1), var(--a2));
}
.item.blitz::before { background: linear-gradient(var(--b1), var(--b2)); }
.item.blitz { background: linear-gradient(90deg, rgba(250,204,21,.05), transparent 40%), var(--bg2); }
.item.done { opacity: .55; }
.item.done:hover { opacity: .9; }
.item.missed .item-time { color: var(--bad); text-decoration: line-through; }
.item.live { border-color: rgba(255,77,109,.5); box-shadow: 0 0 0 3px rgba(255,77,109,.08); }
.item-time { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.item-time small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.item-main { min-width: 0; }
.item-title { font-weight: 650; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.item-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-tag {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(167,139,250,.14); color: #c4b5fd;
}
.type-tag.blitz { background: rgba(250,204,21,.16); color: #fde047; transform: skewX(-8deg); }
.state-tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(255,255,255,.07); color: var(--muted); }
.state-tag.live { background: rgba(255,77,109,.18); color: #ff8fa3; }
.state-tag.missed { background: rgba(251,113,133,.14); color: #fda4af; }
.state-tag.done { background: rgba(74,222,128,.12); color: var(--ok); }
.item-actions { display: flex; gap: 4px; opacity: .55; transition: opacity .2s; }
.item:hover .item-actions, .item:focus-within .item-actions { opacity: 1; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  border: 1px solid transparent; background: transparent;
  cursor: pointer; font-size: 14px; color: var(--muted);
  transition: background .15s, color .15s, transform .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.play { color: var(--ok); background: rgba(74,222,128,.1); }
.icon-btn.play:hover { background: rgba(74,222,128,.2); }
.icon-btn.danger:hover { color: var(--bad); background: rgba(251,113,133,.12); }
.overlap { color: #fdba74; font-size: 11.5px; font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; display: grid; gap: 6px; }
.empty b { color: var(--text); }

/* ===== results ===== */
.results { display: grid; gap: 10px; }
.res {
  padding: 12px 12px 10px 14px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--line);
  animation: rise .35s var(--ease) both;
}
.res.blitz { background: linear-gradient(90deg, rgba(250,204,21,.05), transparent 50%), var(--bg2); }
.res-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.res-q { font-size: 13px; color: var(--muted); margin: 4px 0 6px; overflow-wrap: anywhere; }
.res-win {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(74,222,128,.35);
  background: rgba(74,222,128,.06);
  text-align: left; cursor: copy;
  font-weight: 750; font-size: 15.5px;
  transition: background .2s, border-color .2s, transform .15s;
}
.res-win:hover { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.6); }
.res-win:active { transform: scale(.985); }
.res-win .w-text { flex: 1; overflow-wrap: anywhere; }
.res-win .w-copy { font-size: 11.5px; font-weight: 700; color: var(--ok); opacity: .8; white-space: nowrap; }
.res-win.copied { background: rgba(74,222,128,.22); }
.res-win.none { border-color: var(--line2); background: transparent; color: var(--muted); cursor: default; }
.res-mini { display: flex; height: 5px; border-radius: 4px; overflow: hidden; margin: 8px 0 8px; background: rgba(255,255,255,.05); gap: 2px; }
.res-mini i { display: block; height: 100%; background: rgba(255,255,255,.18); }
.res-mini i.w { background: var(--ok); }
.res-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.res-foot .muted { font-size: 12px; }
.res-foot .row { gap: 4px; }
.link-btn {
  background: none; border: 0; padding: 4px 6px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.link-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.link-btn.warn:hover { color: #fdba74; }

/* ===== modals ===== */
.modal {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--line2);
  border-radius: 20px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.9);
}
.modal-sm { width: min(440px, calc(100% - 24px)); }
.modal[open] { animation: modalIn .35s var(--spring); }
.modal::backdrop { background: rgba(6, 5, 10, .65); backdrop-filter: blur(4px); animation: fade .25s; }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
.modal form { display: grid; gap: 16px; padding: 20px 22px 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }
.opt-list { display: grid; gap: 6px; }
.opt-row { display: grid; grid-template-columns: 30px 1fr 32px; gap: 6px; align-items: center; animation: rise .25s var(--ease) both; }
.opt-row .n { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--panel2); font-weight: 800; font-size: 13px; color: var(--muted); }
.quick-times { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-times button { height: 28px; padding: 0 10px; border-radius: 8px; font-size: 12.5px; border: 1px solid var(--line2); background: transparent; cursor: pointer; color: var(--muted); }
.quick-times button:hover { color: var(--text); background: rgba(255,255,255,.05); }
#editor:not(.is-blitz) .blitz-only { opacity: .35; pointer-events: none; }

/* ===== toasts ===== */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast {
  padding: 11px 16px; border-radius: 12px;
  background: #24232f; border: 1px solid var(--line2);
  box-shadow: 0 16px 40px -14px rgba(0,0,0,.8);
  font-weight: 600; font-size: 13.5px;
  animation: toastIn .35s var(--spring);
  max-width: 360px;
}
.toast.err { border-color: rgba(251,113,133,.45); color: #fecdd3; }
.toast.ok { border-color: rgba(74,222,128,.4); }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.row > .input { flex: 1; width: auto; min-width: 0; }

/* ===== drag & drop reorder ===== */
.drag-handle {
  width: 20px; height: 34px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 16px; line-height: 1;
  cursor: grab; touch-action: none;
  opacity: .45;
  transition: opacity .15s, background .15s, color .15s;
}
.drag-handle.off { cursor: default; }
.item:hover .drag-handle:not(.off), .drag-handle:focus-visible { opacity: 1; color: var(--text); }
.drag-handle:not(.off):hover { background: rgba(255,255,255,.07); }
.drag-handle:focus-visible { outline: 2px solid var(--a1); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.item.dragging {
  position: fixed; z-index: 60; margin: 0;
  pointer-events: none;
  animation: none;
  background: #1f1e2a;
  border-color: rgba(167,139,250,.55);
  box-shadow: 0 24px 50px -16px rgba(0,0,0,.85), 0 0 0 1px rgba(167,139,250,.25);
  transform: scale(1.025) rotate(-.6deg);
  transition: transform .18s var(--ease), box-shadow .18s;
}
.item.dragging.blitz { border-color: rgba(250,204,21,.55); }
.item.dragging .drag-handle { opacity: 1; color: var(--text); }
.item.dragging.settling { transform: none; box-shadow: 0 6px 16px -10px rgba(0,0,0,.6); transition: top .18s var(--ease), left .18s var(--ease), transform .18s var(--ease), box-shadow .18s; }
.drag-ph {
  border-radius: 12px;
  border: 1.5px dashed rgba(167,139,250,.45);
  background: rgba(167,139,250,.06);
}
.item.retimed .t { color: var(--a1); }
.item.retimed .item-time { animation: pop .3s var(--spring); }

.range { width: 100%; accent-color: var(--a2); height: 22px; cursor: pointer; }
