:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef1f5;
  --ink: #17202b;
  --muted: #697586;
  --line: #dfe4ea;
  --blue: #1768e5;
  --blue-soft: #eaf2ff;
  --red: #d9464e;
  --red-soft: #fff0f1;
  --green: #1d8a58;
  --green-soft: #eaf8f0;
  --amber: #a86508;
  --shadow: 0 14px 38px rgba(28, 39, 52, 0.09);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { width: min(100%, 1120px); min-height: 100vh; margin: 0 auto; padding: 0 18px calc(94px + var(--safe-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: calc(16px + env(safe-area-inset-top, 0px)) 2px 16px; }
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-mark { display: grid; place-items: center; width: 46px; height: 46px; flex: 0 0 auto; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #2d7cff, #1649ac); font-size: 18px; font-weight: 850; letter-spacing: -0.04em; box-shadow: 0 9px 20px rgba(23,104,229,.24); }
h1 { margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: -.03em; }
.connection-row { display: flex; align-items: center; gap: 5px; margin-top: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: #aab2bd; }
.connection-dot.online { background: var(--green); }
.connection-dot.offline { background: var(--red); }
.divider { opacity: .55; }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); cursor: pointer; box-shadow: 0 3px 12px rgba(29,43,62,.04); }
.icon-button:active { transform: scale(.96); }
.install-button { color: var(--blue); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.account-button { max-width: 86px; min-height: 44px; overflow: hidden; padding: 8px 11px; border: 1px solid var(--line); border-radius: 13px; color: var(--blue); background: var(--surface); box-shadow: 0 3px 12px rgba(29,43,62,.04); font-size: 14px; font-weight: 800; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.account-button.logged-in { color: var(--green); background: var(--green-soft); border-color: #cbe9d8; }
#syncButton.spinning svg { animation: spin .75s linear infinite; }

main { display: block; }
.setup-notice { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 2px 0 14px; padding: 14px; border: 1px solid #f0ca8d; border-radius: 16px; background: #fff8e8; }
.setup-notice strong { display: block; font-size: 15px; }
.setup-notice p { margin: 4px 0 0; color: #79571f; font-size: 13px; line-height: 1.45; }
.setup-actions { display: grid; flex: 0 0 auto; gap: 7px; }
.small-button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 12px; border: 0; border-radius: 10px; color: #fff; background: #9a610b; font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; cursor: pointer; }
.small-button.secondary-small { border: 1px solid #e5bd7d; color: #85570f; background: #fff; }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.summary-card { position: relative; overflow: hidden; min-width: 0; padding: 14px 13px 13px; border: 1px solid var(--line); border-top-width: 3px; border-radius: 15px; color: var(--ink); background: var(--surface); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.summary-card.waiting { border-top-color: var(--red); }
.summary-card.ready { border-top-color: var(--green); }
.summary-card.total { border-top-color: var(--blue); }
.summary-card.active { box-shadow: inset 0 0 0 2px var(--blue), 0 5px 14px rgba(23,104,229,.12); }
.summary-card.waiting.active { box-shadow: inset 0 0 0 2px var(--red), 0 5px 14px rgba(217,70,78,.12); }
.summary-card.ready.active { box-shadow: inset 0 0 0 2px var(--green), 0 5px 14px rgba(33,153,104,.12); }
.summary-card:active { transform: translateY(1px); }
.summary-label { display: block; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.summary-card strong { display: block; margin-top: 4px; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }

.controls { display: flex; gap: 9px; margin-bottom: 11px; }
.search-box { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); }
.search-box svg { width: 20px; height: 20px; flex: 0 0 auto; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 16px; }
.search-box input::placeholder { color: #9aa3af; }
.filter-strip { display: flex; gap: 8px; overflow-x: auto; margin: 0 -18px 16px; padding: 0 18px 3px; scrollbar-width: none; }
.filter-strip::-webkit-scrollbar { display: none; }
.filter-chip { min-height: 38px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.filter-chip.active { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 5px 14px rgba(23,104,229,.2); }

.boss-sections { display: grid; gap: 20px; }
.map-section { display: grid; gap: 10px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 2px; }
.section-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.section-heading span { color: var(--muted); font-size: 13px; }
.boss-grid { display: grid; gap: 10px; }
.boss-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-left: 4px solid #aeb7c3; border-radius: 17px; background: var(--surface); box-shadow: 0 4px 18px rgba(28,39,52,.045); }
.boss-card.waiting { border-left-color: var(--red); }
.boss-card.ready { border-left-color: var(--green); }
.boss-card.no-cd { border-left-color: var(--amber); }
.boss-main { padding: 15px 15px 13px; }
.boss-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.boss-name { min-width: 0; }
.map-tag { display: inline-flex; align-items: center; min-height: 23px; padding: 3px 8px; border-radius: 7px; color: #4d5a6a; background: var(--surface-soft); font-size: 12px; font-weight: 650; }
.boss-name h3 { margin: 7px 0 0; overflow-wrap: anywhere; font-size: 19px; line-height: 1.25; letter-spacing: -.02em; }
.status-pill { flex: 0 0 auto; padding: 5px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 12px; font-weight: 750; }
.waiting .status-pill { color: var(--red); background: var(--red-soft); }
.ready .status-pill { color: var(--green); background: var(--green-soft); }
.no-cd .status-pill { color: var(--amber); background: #fff5df; }
.countdown { margin: 15px 0 12px; color: #273444; font-size: clamp(24px, 7vw, 32px); font-weight: 800; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.waiting .countdown { color: var(--red); }
.ready .countdown { color: var(--green); }
.timeline { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.time-box { min-width: 0; padding: 9px 10px; border-radius: 11px; background: var(--surface-soft); }
.time-box span { display: block; color: var(--muted); font-size: 11px; }
.time-box strong { display: block; margin-top: 3px; overflow: hidden; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.updated-by { margin: 10px 1px 0; color: var(--muted); font-size: 12px; }
.boss-actions { display: grid; grid-template-columns: 1fr 54px; border-top: 1px solid var(--line); }
.boss-actions button { min-height: 48px; border: 0; background: #fff; cursor: pointer; font-size: 15px; font-weight: 750; }
.boss-actions .kill-button { color: var(--red); }
.boss-actions .more-button { display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--muted); font-size: 22px; letter-spacing: 2px; }
.boss-actions button:active { background: var(--surface-soft); }

.state-panel { display: grid; place-items: center; min-height: 280px; padding: 36px 20px; color: var(--muted); text-align: center; }
.state-panel p { margin: 8px 0 18px; max-width: 340px; line-height: 1.5; }
.state-panel strong { margin-top: 14px; color: var(--ink); font-size: 18px; }
.loader { width: 30px; height: 30px; border: 3px solid #d9e2ef; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.empty-mark { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; color: var(--blue); background: var(--blue-soft); font-weight: 850; }
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav { position: fixed; z-index: 20; bottom: 0; left: 50%; display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 1120px); min-height: calc(68px + var(--safe-bottom)); padding: 8px max(14px, env(safe-area-inset-left, 0px)) var(--safe-bottom) max(14px, env(safe-area-inset-right, 0px)); border-top: 1px solid rgba(207,214,222,.9); background: rgba(255,255,255,.94); box-shadow: 0 -12px 28px rgba(28,39,52,.07); transform: translateX(-50%); backdrop-filter: blur(18px); }
.nav-button { display: grid; place-items: center; align-content: center; gap: 3px; border: 0; background: transparent; color: #7c8796; font-size: 12px; font-weight: 700; cursor: pointer; }
.nav-button svg { width: 23px; height: 23px; }
.nav-button.active { color: var(--blue); }
.add-nav { color: var(--blue); }
.add-circle { display: grid; place-items: center; width: 38px; height: 38px; margin-top: -22px; border: 4px solid var(--bg); border-radius: 14px; color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgba(23,104,229,.25); }
.add-circle svg { width: 21px; height: 21px; }

.modal { position: fixed; z-index: 60; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(17,25,35,.48); backdrop-filter: blur(2px); cursor: default; }
.sheet-panel { position: relative; width: min(100%, 580px); max-height: min(88vh, 760px); overflow-y: auto; padding: 10px 18px calc(20px + var(--safe-bottom)); border-radius: 24px 24px 0 0; background: var(--surface); box-shadow: var(--shadow); animation: slide-up .22s ease-out; }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 15px; border-radius: 99px; background: #d6dbe1; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.sheet-heading h2 { margin: 3px 0 0; font-size: 22px; letter-spacing: -.03em; }
.eyebrow { display: block; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .05em; }
.action-list { display: grid; gap: 8px; }
.action-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; }
.action-item:active { background: var(--surface-soft); }
.action-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 12px; color: var(--blue); background: var(--blue-soft); font-size: 12px; font-weight: 850; }
.action-item strong, .action-item small { display: block; }
.action-item strong { font-size: 15px; }
.action-item small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.danger-action .action-icon { color: var(--red); background: var(--red-soft); }
.delete-action { color: var(--red); }
.delete-action .action-icon { color: var(--red); background: var(--red-soft); }

form { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; color: #4e5967; font-size: 14px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #d4dae2; border-radius: 12px; outline: 0; color: var(--ink); background: #fff; font-size: 16px; font-weight: 500; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,104,229,.12); }
.field > small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.4; }
.duration-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.duration-row label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.duration-row small { color: var(--muted); font-size: 13px; }
.time-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.time-choice label { position: relative; display: block; cursor: pointer; }
.time-choice input { position: absolute; opacity: 0; pointer-events: none; }
.time-choice span { display: block; min-height: 76px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; }
.time-choice input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.time-choice strong, .time-choice small { display: block; }
.time-choice strong { font-size: 14px; }
.time-choice small { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.result-preview { min-height: 56px; padding: 11px 13px; border-radius: 12px; color: #445164; background: var(--surface-soft); font-size: 13px; line-height: 1.5; }
.primary-button, .secondary-button { min-height: 50px; padding: 11px 18px; border-radius: 13px; font-weight: 800; cursor: pointer; }
.primary-button { border: 0; color: #fff; background: var(--blue); box-shadow: 0 7px 18px rgba(23,104,229,.2); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button.compact { min-height: 44px; padding: 9px 18px; }
.danger-primary { background: var(--red); box-shadow: 0 7px 18px rgba(217,70,78,.18); }
.secondary-button { border: 1px solid var(--line); color: var(--blue); background: #fff; }
.account-settings { display: grid; gap: 11px; }
.account-settings strong { display: block; font-size: 17px; }
.account-settings p { margin: 5px 0 2px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 16px; padding: 4px; border-radius: 13px; background: var(--surface-soft); }
.auth-tab { min-height: 40px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.auth-tab.active { color: var(--blue); background: #fff; box-shadow: 0 3px 10px rgba(28,39,52,.08); }
.auth-message { min-height: 20px; margin: -2px 0 0; color: var(--red); font-size: 13px; line-height: 1.45; }
.auth-logged-in { display: grid; justify-items: center; gap: 10px; padding: 10px 0 2px; text-align: center; }
.account-avatar { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; color: #fff; background: var(--green); font-size: 24px; font-weight: 900; }
.auth-logged-in strong { font-size: 20px; }
.auth-logged-in p { margin: 0 0 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.auth-logged-in .secondary-button { width: 100%; }
.settings-section { display: grid; gap: 11px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.settings-section-heading h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.settings-section-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.notification-status { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.notification-status.enabled { color: var(--green); font-weight: 750; }
.notification-status.blocked { color: var(--red); }
.map-manager-list { display: grid; gap: 8px; }
.map-manager-empty { margin: 0; padding: 14px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 14px; text-align: center; }
.map-manager-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 9px 10px 9px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.map-manager-copy { min-width: 0; }
.map-manager-copy strong, .map-manager-copy small { display: block; }
.map-manager-copy strong { overflow: hidden; font-size: 15px; white-space: nowrap; text-overflow: ellipsis; }
.map-manager-copy small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.map-delete-button { min-height: 38px; flex: 0 0 auto; padding: 7px 12px; border: 1px solid #f0c4c7; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 14px; font-weight: 800; cursor: pointer; }
.map-delete-button:disabled { opacity: .55; cursor: wait; }
.install-steps { display: grid; gap: 12px; margin: 0 0 18px; padding: 0; list-style: none; counter-reset: install-step; }
.install-steps li { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 11px; color: #465263; line-height: 1.45; }
.install-steps li::before { counter-increment: install-step; content: counter(install-step); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: var(--blue); background: var(--blue-soft); font-weight: 850; }

.toast-region { position: fixed; z-index: 100; left: 50%; bottom: calc(84px + var(--safe-bottom)); display: grid; gap: 8px; width: min(calc(100% - 32px), 440px); transform: translateX(-50%); pointer-events: none; }
.toast { padding: 12px 14px; border: 1px solid #2d3744; border-radius: 12px; color: #fff; background: rgba(28,37,48,.95); box-shadow: var(--shadow); font-size: 14px; line-height: 1.4; animation: toast-in .18s ease-out; }
.toast.error { border-color: #8b252c; background: rgba(139,37,44,.96); }
@keyframes slide-up { from { transform: translateY(24px); opacity: .5; } }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (min-width: 720px) {
  .app-shell { padding-inline: 28px; }
  .topbar { padding-top: 24px; }
  .summary-grid { gap: 12px; }
  .summary-card { padding: 16px; }
  .filter-strip { margin-inline: 0; padding-inline: 0; }
  .boss-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet-panel { align-self: center; border-radius: 24px; padding-bottom: 22px; }
  .modal { align-items: center; padding: 24px; }
  .account-button { max-width: 140px; padding-inline: 14px; }
}

@media (min-width: 1000px) {
  .boss-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-nav { width: min(calc(100% - 56px), 1064px); bottom: 18px; min-height: 66px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
  .app-shell { padding-bottom: 112px; }
  .toast-region { bottom: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
