/* hidden 属性必须始终生效，防止 display:flex/block 等规则覆盖 */
[hidden] { display: none !important; }

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7686;
  --line: #e3e8ef;
  --brand: #2f6df0;
  --brand-d: #1f4fb0;
  --free: #ffffff;
  --free-seg: #eafaf0;
  --free-seg-b: #34c759;
  --booked: #ffe1e1;
  --booked-b: #e05555;
  --stop: #d9dde3;
  --stop-b: #8a93a3;
  --shadow: 0 6px 20px rgba(20, 40, 80, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: #e9edf3; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: #fff;
  color: var(--ink);
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  box-shadow: 0 0 36px rgba(20, 40, 80, 0.10);
  padding-bottom: 90px;
  position: relative;
}

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 16px 16px 10px;
  background: linear-gradient(135deg, #2f6df0, #4f8bff);
  color: #fff;
}
.title-wrap h1 { font-size: 20px; margin: 0; font-weight: 700; }
.subtitle { margin: 4px 0 0; font-size: 12.5px; opacity: 0.9; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions input[type="date"] {
  border: none; border-radius: 8px; padding: 7px 10px; font-size: 14px; color: var(--ink);
}
.btn-ghost {
  background: rgba(255,255,255,0.18); color: #fff; border: 1px solid rgba(255,255,255,0.5);
  border-radius: 8px; padding: 7px 12px; font-size: 14px; cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,0.3); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 10px 16px; font-size: 12.5px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg::before { content: ""; width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.lg-free::before { background: var(--free-seg); border: 1px solid var(--free-seg-b); }
.lg-booked::before { background: var(--booked); border: 1px solid var(--booked-b); }
.lg-stop::before { background: var(--stop); border: 1px solid var(--stop-b); }

.board { padding: 0 12px; }
.timeline { display: flex; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.hour-labels { width: 46px; flex: none; position: relative; border-right: 1px solid var(--line); }
.hour-labels .hl { position: absolute; left: 4px; font-size: 11px; color: var(--muted); transform: translateY(-50%); }
.hour-labels .hl.now { color: var(--brand); font-weight: 700; }
.track { position: relative; flex: 1; cursor: pointer; }
.empty-hint { position: absolute; top: 24px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 13px; }
.block {
  position: absolute; left: 6px; right: 6px; border-radius: 8px; padding: 4px 8px;
  font-size: 13px; overflow: hidden; cursor: pointer; border: 1px solid transparent;
}
.block.flow.booked { background: var(--booked); border-color: var(--booked-b); color: #9b1c1c; }
.block.flow.stop { background: var(--stop); border-color: var(--stop-b); color: #4a525f; cursor: not-allowed; }
.block.flow.free-seg { background: var(--free-seg); border-color: var(--free-seg-b); color: #1a7f37; cursor: pointer; }
.block.free-seg .free-label { color: #1a7f37; }
.block .b-name { font-weight: 700; word-break: break-all; line-height: 1.2; }
.block .b-meta { font-size: 0.85em; opacity: 0.85; margin-top: 2px; line-height: 1.3; word-break: break-all; }
.block .b-owner { position: absolute; top: 4px; right: 8px; font-size: 10px; color: var(--brand-d); font-weight: 600; }
/* 合并序列方块：顺序相接的 预约/章停用 合并为一方块，各条目竖向排成行，按内容自由撑高、完整显示 */
.block.cluster { background: var(--booked); border-color: var(--booked-b); color: #9b1c1c; display: flex; align-items: stretch; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.block.cluster .chips { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 3px; width: 100%; padding: 4px 2px; box-sizing: border-box; }
.crow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; white-space: nowrap; background: rgba(255,255,255,0.94); color: #9b1c1c; border: 1px solid var(--booked-b); border-radius: 6px; padding: 4px 8px; font-size: 12px; font-weight: 600; cursor: pointer; line-height: 1.25; }
.crow.stop { color: #4a525f; background: #eef1f5; border-color: var(--stop-b); }
.crow.mine { box-shadow: 0 0 0 2px var(--brand) inset; }
.crow .c-time { font-weight: 600; opacity: 0.92; }
.crow .c-meta { font-size: 11px; font-weight: 500; opacity: 0.82; }
.crow:active { transform: scale(0.985); }
.block .b-time { font-weight: 600; opacity: 0.92; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px;
  background: var(--brand); color: #fff; border: none; border-radius: 999px;
  padding: 14px 26px; font-size: 16px; font-weight: 600; box-shadow: 0 8px 24px rgba(47,109,240,0.4);
  cursor: pointer; z-index: 20;
}
.fab:active { background: var(--brand-d); }
.fab-stop { background: #5b6573; box-shadow: 0 8px 24px rgba(91,101,115,0.4); bottom: 78px; font-size: 14px; padding: 11px 20px; }
.fab-stop:active { background: #444c57; }

/* modals */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 25, 45, 0.45);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: #fff; width: 100%; max-width: 460px; border-radius: 16px 16px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,0.2);
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal input, .modal select {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fbfcfe;
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--brand); }
.modal .row { display: flex; gap: 12px; }
.modal .row label { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions button { flex: 1; }
.btn-primary {
  background: var(--brand); color: #fff; border: none; border-radius: 10px; padding: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary:active { background: var(--brand-d); }
.detail-body { font-size: 14.5px; line-height: 1.9; }
.detail-body .k { color: var(--muted); display: inline-block; width: 64px; }
.token-box {
  background: #f0f4ff; border: 1px dashed var(--brand); border-radius: 10px;
  padding: 12px; font-family: monospace; font-size: 15px; word-break: break-all; color: var(--brand-d); margin: 8px 0;
}
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 99;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3); max-width: 90%;
}
.toast[hidden] { display: none; }
.toast.err { background: #c0392b; }

/* desktop */
@media (min-width: 720px) {
  .modal-mask { align-items: center; }
  .modal { border-radius: 16px; }
  body { padding-bottom: 30px; }
  .fab { position: static; transform: none; display: block; margin: 16px auto; width: max-content; box-shadow: var(--shadow); }
}
