:root {
  --label: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --blue: #0071e3;
  --blue-press: #0066cc;
  --green: #248a3d;
  --orange: #c93400;
  --red: #ff3b30;
  --fill: #f2f2f7;
  --line: rgba(0, 0, 0, 0.08);
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px rgba(0, 0, 0, 0.05);
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f5f5f7;
  -webkit-font-smoothing: antialiased;
}
body { margin: 0; min-height: 100vh; background: #f5f5f7; }
button, input, select, textarea { font: inherit; color: inherit; box-sizing: border-box; }
[hidden] { display: none !important; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.22);
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand-logo {
  height: 76px;
  width: auto;
  background: transparent;
  object-fit: contain;
  display: block;
}
.eyebrow { color: var(--tertiary); font-size: 12px; font-weight: 500; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.022em; line-height: 1.15; }
.clock-block { margin-left: auto; text-align: right; }
#clock {
  display: block;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--tertiary); font-size: 12px; }
.live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c7c7cc;
}
.live.on::before { background: #34c759; box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.16); }
.live.off { color: var(--red); }
.live.off::before { background: var(--red); }
.top-actions { display: flex; gap: 8px; }

.solid, .ghost, .danger, .icon-btn {
  border-radius: 980px;
  padding: 8px 14px;
  border: 0;
  font-weight: 560;
  letter-spacing: -0.01em;
  transition: background 0.15s ease, transform 0.15s ease;
}
.solid { background: var(--blue); color: white; }
.solid:hover { background: var(--blue-press); }
.ghost { background: rgba(0, 0, 0, 0.05); color: var(--label); }
.ghost:hover { background: rgba(0, 0, 0, 0.08); }
.danger { background: transparent; color: var(--red); padding-inline: 8px; }
.danger:hover { background: rgba(255, 59, 48, 0.08); }
.icon-btn { background: transparent; color: var(--blue); font-weight: 560; }
.solid:disabled, .ghost:disabled { opacity: 0.45; cursor: wait; }

main { width: min(1120px, calc(100% - 40px)); margin: 22px auto 56px; }
.controls { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.stats {
  display: flex;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  padding: 3px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 12px;
}
.stats button {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 7px 12px;
  color: var(--label);
  font-size: 13px;
  font-weight: 560;
  white-space: nowrap;
}
.stats button.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
}
.toolbar { display: flex; gap: 8px; }
#search {
  flex: 1;
  min-width: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.05) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2386868b' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='M10.5 10.5 14 14'/%3E%3C/svg%3E") 12px 50% no-repeat;
  border-radius: 12px;
  padding: 11px 14px 11px 36px;
}
#search:focus { background-color: white; }

.group-title {
  margin: 22px 4px 8px;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.guest {
  display: grid;
  grid-template-columns: minmax(148px, 1.15fr) 108px minmax(150px, 1fr) minmax(210px, 1.05fr) 86px auto;
  gap: 8px 18px;
  align-items: center;
  background: var(--card);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.guest.level-important {
  background: #ff3b30;
  color: #fff;
  box-shadow: 0 12px 28px rgba(255, 59, 48, 0.28);
}
.guest.level-senior {
  background: #6ec8f5;
  color: #1d1d1f;
  box-shadow: 0 12px 28px rgba(80, 170, 220, 0.28);
}
.guest.level-normal {
  background: #fff;
  box-shadow: var(--shadow);
}
.guest.level-important .who span,
.guest.level-important .trip span,
.guest.level-important .route,
.guest.level-important .when small,
.guest.level-important .when em,
.guest.level-important .plan-time,
.guest.level-important .substatus {
  color: rgba(255, 255, 255, 0.9);
}
.guest.level-important .companion,
.guest.level-important .companion strong,
.guest.level-senior .companion,
.guest.level-senior .companion strong {
  color: #1d1d1f;
}
.guest.level-important .companion span,
.guest.level-senior .companion span { color: #6e6e73; }
.guest.level-senior .who span,
.guest.level-senior .trip span,
.guest.level-senior .route,
.guest.level-senior .when small,
.guest.level-senior .when em,
.guest.level-senior .plan-time,
.guest.level-senior .substatus {
  color: rgba(29, 29, 31, 0.72);
}
.guest.level-important .badge {
  background: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.guest.level-senior .badge {
  background: rgba(255, 255, 255, 0.62);
  color: #1d1d1f;
}
.guest.level-important .ghost { background: rgba(255, 255, 255, 0.22); color: #fff; }
.guest.level-important .ghost:hover { background: rgba(255, 255, 255, 0.34); }
.guest.level-important .solid { background: #fff; color: #d70015; }
.guest.level-important .solid:hover { background: #fff; }
.guest.level-senior .ghost { background: rgba(255, 255, 255, 0.62); color: #1d1d1f; }
.guest.level-senior .solid { background: #007aff; color: #fff; }
.guest.level-senior .solid:hover { background: #0066cc; }
.guest.level-important .details { border-top-color: rgba(255, 255, 255, 0.28); }
.guest.level-senior .details { border-top-color: rgba(0, 0, 0, 0.12); }
.guest.level-important .meta span { background: rgba(255, 255, 255, 0.2); color: #fff; }
.guest.level-senior .meta span { background: rgba(255, 255, 255, 0.45); color: #1d1d1f; }
.guest.level-important.phase-cancelled .who > strong { color: rgba(255, 255, 255, 0.72); }
.who > strong, .trip b, .when strong { display: block; }
.who > strong { display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.star { width: 18px; height: 18px; flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.16)); }
.star.sm { width: 13px; height: 13px; filter: none; }
.companions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.companion {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 3px 8px 3px 4px;
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.35;
}
.companion strong { color: var(--label); font-size: 13px; font-weight: 640; }
.host-done {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 980px;
  background: rgba(52, 199, 89, 0.18);
  color: #248a3d;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}
.guest.level-important .host-done { background: #fff; color: #248a3d; }
.pick {
  border: 0;
  border-radius: 980px;
  padding: 3px 8px;
  background: #007aff;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
}
.pick.done { background: rgba(0, 0, 0, 0.06); color: #1d1d1f; }
.separate-ops { display: flex; align-items: center; gap: 6px; justify-self: start; }
.separate-trips {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: 8px;
}
.separate {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 9px 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: #1d1d1f;
}
.separate-who, .separate-code b { display: flex; align-items: center; gap: 6px; min-width: 0; }
.separate-who strong, .separate-code b { font-size: 16px; font-weight: 680; letter-spacing: -0.02em; }
.separate-who span, .separate-code span, .separate-route, .separate-times em { color: #6e6e73; font-size: 12px; font-style: normal; }
.separate-times { display: flex; gap: 16px; align-items: baseline; font-variant-numeric: tabular-nums; }
.separate-times b { font-size: 18px; font-weight: 680; }
.mini-badge {
  justify-self: start;
  border-radius: 980px;
  padding: 4px 9px;
  background: #f2f2f7;
  color: #1d1d1f;
  font-size: 12px;
  font-weight: 700;
}
.who span, .trip span, .route, .when small, .substatus { color: var(--secondary); font-size: 13px; }
.trip b { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; }
.when strong {
  font-size: 28px;
  font-weight: 640;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.times { display: flex; align-items: flex-start; gap: 18px; }
.when.depart strong { font-size: 22px; }
.when em, .plan-time { font-style: normal; color: var(--tertiary); font-size: 12px; font-weight: 560; }
.plan-time { display: block; margin-top: 2px; }
.badge {
  justify-self: start;
  border-radius: 980px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 650;
  background: var(--fill);
  color: var(--secondary);
}
.phase-waiting .badge { background: rgba(255, 59, 48, 0.12); color: #d70015; }
.phase-delayed .badge { background: rgba(255, 149, 0, 0.16); color: var(--orange); }
.phase-enroute .badge { background: rgba(0, 122, 255, 0.12); color: #007aff; }
.phase-picked .badge { background: rgba(52, 199, 89, 0.16); color: var(--green); }
.phase-error .badge, .phase-cancelled .badge { background: rgba(255, 59, 48, 0.1); color: #d70015; }
.phase-cancelled .who > strong { color: var(--tertiary); text-decoration: line-through; }
.ops { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ops button { padding: 6px 11px; font-size: 13px; }
.details { grid-column: 1 / -1; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--secondary); font-size: 13px; margin-bottom: 12px; }
.meta span { background: var(--fill); border-radius: 980px; padding: 4px 10px; }
.stops { display: flex; gap: 0; overflow-x: auto; padding: 4px 0 6px; }
.stop { min-width: 92px; position: relative; padding-top: 16px; }
.stop::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d1d6;
  box-shadow: -46px 0 0 #e5e5ea;
}
.stop.done::before { background: #34c759; }
.stop.now::before { background: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.16); }
.stop.target b { color: var(--blue); }
.stop b, .stop span { display: block; font-size: 13px; }
.stop b { font-weight: 600; letter-spacing: -0.01em; }
.stop span { color: var(--secondary); }
.empty {
  background: var(--card);
  border-radius: 18px;
  padding: 64px 24px;
  text-align: center;
  color: var(--secondary);
  box-shadow: var(--shadow);
}
.empty strong {
  display: block;
  color: var(--label);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(92vh, 900px);
  overflow: auto;
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.2);
  color: var(--label);
}
dialog[open] { animation: sheet 0.22s ease; }
dialog::backdrop { background: rgba(0, 0, 0, 0.28); backdrop-filter: blur(6px); }
@keyframes sheet {
  from { transform: translateY(10px) scale(0.985); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.dialog-head, .dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
}
.dialog-head h2 { font-size: 20px; font-weight: 680; letter-spacing: -0.02em; }
.dialog-actions { justify-content: flex-end; }
.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px 18px;
  padding: 0 18px 8px;
}
.form-grid > label, .help { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 560; color: var(--secondary); }
.span-2 { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%;
  min-width: 0;
  border: 0;
  background: var(--fill);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--label);
}
.when-pair { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr); gap: 8px; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { background: white; }
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
}
fieldset legend { padding: 0; }
.radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--fill);
  color: var(--label);
  font-weight: 560;
}
.radio:has(input:checked) { background: white; box-shadow: 0 0 0 1.5px var(--blue); color: var(--blue); }
.companions-head { display: flex; align-items: center; justify-content: space-between; }
.companion-row {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.035);
}
.companion-main { display: grid; grid-template-columns: 1.15fr 0.9fr 108px 124px auto; gap: 8px; }
.companion-trip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.companion-trip label { display: grid; gap: 4px; min-width: 0; color: var(--secondary); font-size: 12px; font-weight: 560; }
.companion-row input, .companion-row select { box-sizing: border-box; min-width: 0; }
.companion-row input, .companion-row select {
  width: 100%;
  border: 0;
  background: white;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--label);
}
.companion-row input:focus, .companion-row select:focus { box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.22); }
.radio input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.check { display: flex; align-items: center; gap: 8px; color: var(--label); font-weight: 500; }
.preview, .form-error, .help { padding: 8px 18px 4px; }
.preview { min-height: 1.2em; color: var(--secondary); font-size: 13px; }
.form-error { color: var(--red); font-size: 13px; }
.help { line-height: 1.5; }
.help p + p { margin-top: 8px; }
.session-chip { display: flex; align-items: center; gap: 6px; color: var(--secondary); font-size: 13px; }
.session-chip .ghost, .top-actions .ghost, .top-actions .solid { white-space: nowrap; }
.gate { display: none; min-height: calc(100vh - 110px); place-items: center; padding: 28px 16px 48px; }
body:not(.authed) .gate { display: grid; }
body:not(.authed) main, body:not(.authed) .top-actions { display: none; }
.login-card {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 28px 22px 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}
.login-card h2 { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.login-card label { width: 100%; display: grid; gap: 6px; margin-top: 10px; color: var(--secondary); font-size: 13px; font-weight: 560; }
.login-card input {
  border: 0;
  background: var(--fill);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--label);
}
.login-card .solid { width: 100%; margin-top: 16px; }
.role-list { display: grid; gap: 8px; padding: 0 18px 8px; }
.role-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 36px);
  margin: 0 18px 14px;
  padding: 11px;
  border: 1.5px dashed rgba(0, 113, 227, 0.45);
  border-radius: 12px;
  background: transparent;
  color: var(--blue);
  font-weight: 650;
}
.role-add:hover { background: rgba(0, 113, 227, 0.06); }
.plus-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
#role-form h3 { margin: 2px 18px 0; font-size: 17px; font-weight: 680; letter-spacing: -0.02em; }
.role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--fill);
}
.role-row b { display: block; font-size: 14px; }
.role-row span { color: var(--secondary); font-size: 12px; }
.log-wrap { max-height: min(62vh, 560px); overflow: auto; padding: 0 18px 18px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th, .log-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table th { color: var(--secondary); font-weight: 650; position: sticky; top: 0; background: #fff; }
#log-dialog, #roles-dialog { width: min(860px, calc(100vw - 28px)); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.88);
  color: white;
  border-radius: 14px;
  padding: 12px 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

body.board main { width: min(1360px, calc(100% - 36px)); }
body.board h1 { font-size: 28px; }
body.board .guest { padding: 22px 22px; }
body.board .who > strong { font-size: 28px; }
body.board .brand-logo { height: 92px; }
body.board .star { width: 26px; height: 26px; }
body.board .star.sm { width: 16px; height: 16px; }
body.board .companion, body.board .companion strong { font-size: 16px; }
body.board .separate-who strong, body.board .separate-code b { font-size: 22px; }
body.board .separate-times b { font-size: 26px; }
body.board .companions { font-size: 16px; }
body.board .when strong { font-size: 44px; }
body.board .when.depart strong { font-size: 32px; }
body.board .trip b { font-size: 24px; }

@media (max-width: 980px) {
  .top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
    padding: max(10px, env(safe-area-inset-top)) 14px 12px;
  }
  .brand { min-width: 0; }
  .clock-block { margin: 0; text-align: right; }
  .top-actions { grid-column: 1 / -1; flex-wrap: wrap; width: 100%; }
  main { width: min(100% - 20px, 1120px); margin-top: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .companion-main, .companion-trip { grid-template-columns: 1fr; }
  dialog { width: calc(100vw - 16px); }
  .dialog-actions { flex-wrap: wrap; }
}

@media (max-width: 760px) {
  .brand-logo { height: 52px; }
  .eyebrow { font-size: 11px; }
  h1 { font-size: 18px; }
  #clock { font-size: 13px; white-space: nowrap; }
  .session-chip { flex: 1 0 100%; min-width: 0; justify-content: space-between; }
  #session-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top-actions > .ghost { flex: 1 1 0; padding: 9px 8px; text-align: center; }
  .session-chip .ghost { flex: 0 0 auto; }
  #add-btn { flex: 1 0 100%; min-height: 42px; }
  .stats { width: 100%; flex-wrap: wrap; overflow: visible; }
  .toolbar { align-items: stretch; }
  #refresh-all { flex: none; min-height: 42px; }
  .guest {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 14px;
    border-radius: 16px;
  }
  .guest .who { grid-column: 1; grid-row: 1; min-width: 0; }
  .guest .badge { grid-column: 2; grid-row: 1; align-self: start; }
  .guest .trip, .guest .route, .guest .times, .guest .ops, .separate-trips, .details { grid-column: 1 / -1; }
  .times { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .when strong, .when.depart strong { font-size: 26px; }
  .ops { gap: 8px; }
  .ops button, .pick { min-height: 40px; }
  .separate { grid-template-columns: 1fr; gap: 4px; padding: 10px 12px; }
  .separate-times { flex-wrap: wrap; gap: 8px 14px; }
  .separate-times, .separate-ops { grid-column: auto; }
  body.board h1 { font-size: 20px; }
  body.board .brand-logo { height: 56px; }
  body.board .who > strong { font-size: 22px; }
  body.board .when strong, body.board .when.depart strong { font-size: 30px; }
  body.board .trip b { font-size: 18px; }
  .toast { width: min(92vw, 420px); text-align: center; bottom: max(16px, env(safe-area-inset-bottom)); }
}
