:root {
  --bg: #0e1014;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --red: #b3403b;
  --red-dark: #7d2a27;
  --green: #2fa36b;
  --accent: #e6b85c;
  --danger: #e5645e;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 0 0 4px; }
h2 { font-size: 1.15rem; margin: 32px 0 12px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

label.field { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text] {
  width: 100%; max-width: 360px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
input[type=text]:focus-visible, button:focus-visible, .handle:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.name-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.name-row input[type=text] { flex: 1 1 200px; }
fieldset.pref { margin: 16px 0 0; min-width: 0; }
fieldset.pref legend { font-weight: 600; padding: 0 6px; margin-left: -6px; }
.pref-options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.pref-options label {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.pref-options label:has(input:checked) { border-color: var(--accent); }
.pref-options input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin: 4px 0 0; }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover, .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: #1a1405; border-color: var(--accent); font-weight: 700; }
button.danger { color: var(--danger); }
button.small { padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }

/* ---- day rows */
.day { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 14px 0; border-top: 1px solid var(--line); }
.day:first-child { border-top: 0; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.day-name { font-weight: 700; text-transform: capitalize; }
.day-summary { font-size: .9rem; font-variant-numeric: tabular-nums; }
.day-summary.off { color: #f08a85; }
.day-summary.on { color: #6fdca3; }
.day-actions { display: flex; gap: 6px; }

/* ---- range bar */
.bar { position: relative; padding: 14px 0 0; touch-action: none; user-select: none; }
.track {
  position: relative; height: 34px; border-radius: 6px; overflow: visible; cursor: pointer;
  background: repeating-linear-gradient(135deg, var(--red) 0 8px, var(--red-dark) 8px 16px);
}
.avail { position: absolute; top: 0; bottom: 0; background: var(--green); pointer-events: none; }
.tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,.32); pointer-events: none; }
.tick.hour { background: rgba(0,0,0,.6); }
.handle {
  position: absolute; top: -8px; height: 50px; width: 18px; margin-left: -9px; padding: 0;
  background: var(--text); border: 2px solid var(--bg); border-radius: 6px; cursor: ew-resize;
  touch-action: none; z-index: 2;
}
.handle::after { content: ""; position: absolute; inset: 14px 5px; border-left: 2px solid #8a8f9c; border-right: 2px solid #8a8f9c; }
.handle .tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px;
  font-size: .75rem; padding: 1px 6px; border-radius: 4px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); white-space: nowrap; display: none; pointer-events: none;
}
.handle.active .tip, .handle:focus-visible .tip { display: block; }
.hours { position: relative; height: 18px; margin-top: 6px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hours span { position: absolute; transform: translateX(-50%); }
.hours span:first-child { transform: none; }
.hours span:last-child { transform: translateX(-100%); }

.submit-row { display: flex; gap: 12px; align-items: center; margin-top: 20px; flex-wrap: wrap; }
.notice { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--green); background: rgba(47,163,107,.12); }

/* ---- admin */
.heat { display: grid; grid-template-columns: repeat(48, 1fr); height: 34px; border-radius: 6px; overflow: hidden; background: var(--red-dark); }
.heat .cell { background: var(--green); border-right: 1px solid rgba(0,0,0,.32); cursor: crosshair; }
.heat .cell:nth-child(2n) { border-right-color: rgba(0,0,0,.6); }
.heat .cell:last-child { border-right: 0; }
.heat .cell.hover { outline: 2px solid var(--text); outline-offset: -2px; }
.detail { min-height: 3.2em; font-size: .9rem; color: var(--muted); margin-top: 12px; }
.detail b { color: var(--text); }
.legend { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--red-dark), var(--green)); }

.vote { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.vote:first-child { border-top: 0; }
.vote .who { font-weight: 700; overflow-wrap: anywhere; }
.vote .when { color: var(--muted); font-size: .8rem; }
.vote .days { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: .72rem; }
.vote .days div { background: var(--panel-2); border-radius: 6px; padding: 4px 6px; min-width: 0; }
.vote .days div.off { color: var(--muted); }
.vote .days b { display: block; text-transform: capitalize; }
.vote .btns { display: flex; gap: 6px; }
.empty { color: var(--muted); padding: 12px 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
pre.json { max-height: 320px; overflow: auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: .8rem; }

@media (max-width: 640px) {
  .vote .days { grid-template-columns: repeat(2, 1fr); }
  .hours span:nth-child(even) { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: border-color .12s; }
}
