:root {
  --bg: #0b1017;
  --panel: #141b25;
  --panel-2: #1a2331;
  --line: #253143;
  --text: #e6edf6;
  --muted: #8ea0b8;
  --accent: #2dd4bf;
  --mine: #22c55e;
  --car: #60a5fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16233a 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 14px/1.5 "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 23, .85);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand::before {
  content: "◤◢";
  color: var(--accent);
  margin-right: 8px;
  letter-spacing: -2px;
}

.me { display: flex; align-items: center; gap: 10px; }
.me-label { color: var(--muted); }
.me-label.on { color: var(--mine); font-weight: 700; }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px 0;
}

.group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }

.btn {
  font: inherit;
  color: #06121a;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: filter .15s, background .15s;
}

.btn:hover { filter: brightness(1.08); }

.btn.ghost {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

.btn.ghost:hover { background: var(--panel-2); }

.btn.date { padding: 6px 8px; color-scheme: dark; }

.hint {
  color: var(--muted);
  margin: 12px 18px 0;
  font-size: 13px;
}

.wrap { padding: 12px 18px 40px; }

.grid-shell {
  overflow: auto;
  max-height: calc(100vh - 210px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

table { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; min-width: 620px; }

th, td { border-bottom: 1px solid var(--line); }

thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--panel-2);
  padding: 8px 6px;
  font-weight: 600;
  white-space: nowrap;
}

thead th .dow { color: var(--muted); font-size: 12px; font-weight: 400; }
thead th.today { color: var(--accent); }
thead th.today .dow { color: var(--accent); }

th.time, td.time {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 6px 10px;
  width: 62px;
  white-space: nowrap;
  font-size: 12px;
}

thead th.time { z-index: 4; }

td.cell {
  position: relative;
  height: 36px;
  padding: 3px 4px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background .1s;
  vertical-align: top;
}

td.cell:hover { background: #1b2634; }
td.cell.past { opacity: .45; }

td.cell:not(.past):hover::after {
  content: "+";
  position: absolute;
  right: 4px;
  bottom: 1px;
  color: #46566d;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

.blocks { display: flex; flex-direction: column; gap: 2px; }

.blk {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  font-size: 11px;
  line-height: 16px;
  padding: 0 4px;
  border-radius: 4px;
  border-left: 3px solid var(--car);
  background: rgba(96, 165, 250, .18);
  white-space: nowrap;
  overflow: hidden;
}

.blk b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.blk i { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 4px; }
.blk.cont { padding: 0; height: 6px; background: rgba(96, 165, 250, .26); }
.blk.full { border-left-color: var(--mine); background: rgba(34, 197, 94, .2); }
.blk.full i { color: #9ff0bb; }
.blk.mine { border-left-color: var(--accent); background: rgba(45, 212, 191, .24); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-car { background: rgba(96, 165, 250, .85); }
.dot-mine { background: var(--accent); }
.dot-full { background: var(--mine); }
.dot-past { background: #47556b; }

.dlg {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  width: min(520px, 94vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}

.dlg::backdrop { background: rgba(3, 7, 12, .7); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 16px; }
.dlg-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input {
  font: inherit;
  color: var(--text);
  background: #0e1520;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
}
.field input:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.err { color: #f87171; margin: 0; min-height: 18px; font-size: 13px; }

.tag {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 400;
  color: #05201c;
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  vertical-align: 1px;
}

.cars { display: flex; flex-direction: column; gap: 10px; }
.car {
  border: 1px solid var(--line);
  border-left: 3px solid var(--car);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.car.full { border-left-color: var(--mine); }
.car.joined { border-left-color: var(--accent); background: #182433; }
.car-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.car-title { font-weight: 700; }
.car-note { color: var(--muted); font-size: 13px; }
.car-sub { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.new-car { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.new-car .board-sub { margin: 0; }
.form-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-row input, .form-row select {
  font: inherit;
  color: var(--text);
  background: #0e1520;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
}
.form-row input { flex: 1 1 200px; min-width: 0; }
.inline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: #0f1723;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
  z-index: 99;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.board { margin-top: 26px; }
.board-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.board-head h2 { margin: 0; font-size: 16px; }
.board-sub { margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cars-board-outer { display: flex; flex-direction: column; gap: 8px; }
.cars-board { display: flex; flex-direction: column; gap: 8px; }

.board-car {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-left: 3px solid var(--car);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 14px;
}

.board-car.full { border-left-color: var(--mine); }
.board-car.joined { background: #182433; border-left-color: var(--accent); }
.bc-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bc-when { font-weight: 700; font-variant-numeric: tabular-nums; }
.bc-owner, .bc-need { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.board-car.full .bc-need { color: var(--mine); }
.bc-note { font-size: 13px; }
.bc-members { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.bc-actions { display: flex; gap: 8px; margin-left: auto; }

@media (max-width: 640px) {
  .hint { display: none; }
  .grid-shell { max-height: none; }
  th.time, td.time { width: 52px; padding: 6px; }
  td.cell { height: 30px; padding: 2px 3px; }
  .blk { font-size: 10px; line-height: 14px; }
}
