:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
  --navy: #08263f;
  --navy-soft: #173d5b;
  --mustard: #c48600;
  --mustard-pale: #f5e8bd;
  --paper: #f7f4ee;
  --surface: #fffdf8;
  --line: #c9c5bb;
  --muted: #626b74;
  --danger: #b6372e;
  --danger-pale: #f9e3df;
  --safe: #276148;
  --safe-pale: #e2efe7;
  --warning: #875e00;
  --warning-pale: #fff2c9;
  --shadow: 0 2px 0 rgba(8, 38, 63, 0.18);
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  background: var(--paper);
  color: var(--navy);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 14px;
  background: white;
  border: 2px solid var(--navy);
}
.skip-link:focus { transform: translateY(0); }

.app-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--navy);
  color: white;
  border-bottom: 1px solid #24445e;
}

.brand-button,
.package-trigger {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  min-height: 44px;
  cursor: pointer;
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--mustard);
  color: var(--navy);
  font-weight: 900;
}

.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 17px; letter-spacing: .12em; }
.brand-copy small { margin-top: 4px; font-size: 12px; color: #d8e2ea; }

.package-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 140px;
  padding: 5px 8px;
  border: 1px solid #6f8799;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}

.status-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6fc49a;
}
.package-trigger[data-tone="warning"] .status-dot { background: #f2c14e; }
.package-trigger[data-tone="danger"] .status-dot { background: #ff756b; }

.offline-truth-strip {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  min-height: 35px;
  padding: 8px 12px;
  background: #ece8df;
  border-bottom: 1px solid var(--line);
  color: #4d5660;
  font-size: 12px;
  line-height: 1.35;
}
.offline-truth-strip strong { color: var(--navy); white-space: nowrap; }
.boundary-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -5px;
  padding-inline: 6px;
  color: var(--navy);
  font-weight: 800;
  text-underline-offset: 3px;
}

.dial-link {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 4px;
  color: white;
  background: var(--danger);
  font-weight: 900;
  text-decoration: none;
}

.local-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.full-width { width: 100%; }

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-shell {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 16px 14px calc(94px + env(safe-area-inset-bottom));
  outline: none;
}

.route-heading { margin-bottom: 14px; }

.return-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin: -7px 0 3px -8px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--mustard);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  font-size: clamp(28px, 8vw, 34px);
  line-height: 1.18;
  letter-spacing: -.03em;
}
h2 { margin: 0; font-size: 22px; line-height: 1.3; }
h3 { margin: 0; font-size: 18px; line-height: 1.35; }

.lead {
  margin: 10px 0 0;
  color: #374956;
  font-size: 17px;
  line-height: 1.55;
}

.state-strip,
.warning-block,
.info-block,
.failure-block {
  margin: 12px 0;
  padding: 11px 12px;
  border-left: 5px solid var(--mustard);
  background: var(--mustard-pale);
  color: #4a3b17;
  font-size: 14px;
  line-height: 1.5;
}
.state-strip { display: flex; align-items: flex-start; gap: 9px; }
.state-strip strong { color: var(--navy); }
.state-strip[data-tone="safe"] { border-color: var(--safe); background: var(--safe-pale); color: #244b39; }
.state-strip[data-tone="danger"],
.failure-block[data-tone="danger"] { border-color: var(--danger); background: var(--danger-pale); color: #6c2822; }
.state-strip[data-tone="neutral"] { border-color: #64727d; background: #e8edf0; color: #3d4a54; }

.action-list {
  margin: 14px 0;
  padding: 0;
  list-style: none;
  counter-reset: action;
  border-top: 1px solid var(--line);
}
.action-list li {
  counter-increment: action;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: #30424f;
  font-size: 15px;
  line-height: 1.45;
}
.action-list li::before {
  content: counter(action);
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  font-weight: 800;
  font-size: 13px;
}

.media-group {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.media-slot {
  overflow: hidden;
  border: 1px solid #aaa79f;
  border-left: 4px solid var(--mustard);
  background: #fbfaf6;
}

.media-slot-heading,
.media-slot summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 10px 12px;
}

.media-slot-heading > span,
.media-slot summary small {
  color: var(--mustard);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
}

.media-slot-heading > strong {
  flex: 1;
  font-size: 15px;
  line-height: 1.35;
}

.media-slot summary {
  cursor: pointer;
  list-style: none;
}

.media-slot summary::-webkit-details-marker { display: none; }
.media-slot summary > span:first-child { display: grid; gap: 3px; }
.media-slot summary strong { font-size: 16px; line-height: 1.35; }
.media-summary-action { color: var(--navy); font-size: 13px; font-weight: 800; white-space: nowrap; }
.media-slot[open] .media-summary-action::after { content: "收起"; }
.media-slot:not([open]) .media-summary-action::after { content: "圖解"; }
.media-summary-action { font-size: 0; }
.media-summary-action::after { font-size: 13px; }

.media-viewer {
  padding: 0 12px 12px;
  border-top: 1px solid #dedbd3;
}

.media-viewer picture { display: block; margin: 12px 0 0; }
.media-viewer img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 12px;
  border: 1px solid #d4d0c7;
  background: var(--surface);
}
.media-loading { margin: 0; padding: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.media-fallback {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 0 12px 10px;
  color: #4f5961;
}

.media-fallback-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px dashed #898e91;
  border-radius: 50%;
  color: #67717a;
  font-size: 12px;
  font-weight: 800;
}

.media-fallback strong,
.media-fallback small { display: block; }
.media-fallback strong { font-size: 14px; line-height: 1.3; }
.media-fallback small { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.media-fallback-answer,
.media-caption {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid #e2ded6;
  color: #30424f;
  font-size: 14px;
  line-height: 1.5;
}
.media-fallback-answer strong,
.media-caption strong { color: var(--navy); }
.media-viewer .media-fallback { padding-top: 12px; }
.media-viewer .media-fallback-answer { padding-inline: 0; }
.media-caption { padding-inline: 0; }
.media-boundary { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.media-slot[data-media-state="load_failed"] { border-color: var(--warning); }
.media-description { margin-top: 10px; border-top: 1px solid #dedbd3; }
.media-description summary { min-height: 44px; padding: 8px 0; color: var(--navy); font-size: 13px; font-weight: 800; cursor: pointer; }
.media-description p { margin: 0 0 8px; color: #3b4d59; font-size: 13px; line-height: 1.6; white-space: pre-line; }

.choice-group {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.choice-button,
.plain-button,
.state-choice,
.failure-row,
.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--navy);
  border-radius: 4px;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
}

.choice-button {
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: 8px;
  padding: 13px 12px;
  text-align: left;
  font-weight: 750;
  line-height: 1.38;
  box-shadow: var(--shadow);
}
.choice-button::after { content: "›"; font-size: 27px; line-height: 1; color: var(--mustard); }
.choice-button[data-urgent="true"] { border-color: var(--danger); background: #fff9f8; }
.choice-button[data-urgent="true"]::after { color: var(--danger); }

.warning-block { margin-top: 16px; }
.warning-block strong { display: block; margin-bottom: 3px; color: var(--warning); }

.supplement-panel,
.tool-panel,
.status-panel,
.directory-panel {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 2px solid var(--navy);
}
.panel-heading { margin-bottom: 10px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.segmented-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.state-choice { min-width: 0; padding: 10px 8px; font-size: 14px; line-height: 1.3; }
.state-choice[aria-pressed="true"] { background: var(--navy); color: white; }

.data-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.data-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: #edf1f3;
  border-bottom: 1px solid var(--line);
}
.data-card-header span { color: var(--muted); font-size: 12px; text-align: right; }
.data-list { margin: 0; }
.data-list div {
  display: grid;
  grid-template-columns: minmax(92px, .8fr) minmax(0, 1.3fr);
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid #e4e1da;
}
.data-list div:last-child { border-bottom: 0; }
.data-list dt { color: var(--muted); font-size: 13px; }
.data-list dd { min-width: 0; margin: 0; font-size: 14px; font-weight: 700; text-align: right; overflow-wrap: anywhere; }

.field-grid { display: grid; gap: 12px; margin-top: 12px; }
.field-grid label { display: grid; gap: 5px; color: #384955; font-size: 14px; font-weight: 700; }
.field-grid input,
.field-grid textarea,
.field-grid select {
  width: 100%;
  min-height: 48px;
  padding: 10px 11px;
  border: 1px solid #83909a;
  border-radius: 3px;
  background: white;
  color: var(--navy);
  font-size: 16px;
}
.field-grid textarea { min-height: 78px; resize: vertical; }
.field-grid small { color: var(--muted); font-weight: 400; line-height: 1.4; }

.button-row { display: grid; gap: 8px; margin-top: 12px; }

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.qa-disclosure {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.qa-disclosure summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 750;
  cursor: pointer;
}

.qa-disclosure p {
  color: var(--muted);
  line-height: 1.55;
}

.failure-block ul {
  margin: 10px 0 0;
  padding-left: 20px;
  overflow-wrap: anywhere;
}
.primary-button,
.secondary-button,
.danger-button,
.plain-button { padding: 11px 13px; font-weight: 800; }
.primary-button { background: var(--navy); color: white; }
.secondary-button { background: var(--surface); }
.danger-button { border-color: var(--danger); background: var(--danger-pale); color: #7a2822; }
.plain-button { background: var(--surface); text-align: left; }
.app-shell > .primary-button { margin-top: 12px; }

.rescue-card-text {
  margin: 0;
  padding: 12px;
  color: var(--navy);
  font: inherit;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.delivery-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.delivery-status span { color: var(--muted); font-size: 13px; }
.delivery-status strong { text-align: right; }

.failure-list,
.directory-list { display: grid; margin-top: 12px; border-top: 1px solid var(--line); }
.failure-row,
.directory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px 4px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.failure-row::after,
.directory-row::after { content: "›"; color: var(--mustard); font-size: 25px; text-align: center; }
.failure-row strong,
.directory-row strong { display: block; font-size: 15px; line-height: 1.35; }
.failure-row small,
.directory-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.module-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

.bottom-nav {
  position: fixed;
  z-index: 25;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 68px;
  padding: 4px max(6px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  border-top: 1px solid #9ca4aa;
  background: rgba(255, 253, 248, .98);
}
.bottom-nav button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 56px;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: #52606b;
  font-size: 11px;
  cursor: pointer;
}
.bottom-nav button > span:first-child { font-size: 20px; line-height: 1; }
.bottom-nav button[aria-current="page"] { color: var(--navy); font-weight: 800; }

.toast {
  position: fixed;
  z-index: 40;
  right: 12px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 12px;
  max-width: 456px;
  margin: auto;
  padding: 11px 13px;
  border-radius: 4px;
  background: var(--navy);
  color: white;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 5px 16px rgba(8, 38, 63, .26);
}

.error-screen { text-align: left; }
.error-screen .primary-button { margin-top: 12px; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid #f1b82d;
  outline-offset: 2px;
}

@media (min-width: 520px) {
  .app-shell { border-right: 1px solid #ddd8ce; border-left: 1px solid #ddd8ce; background: var(--surface); }
  .bottom-nav { right: 50%; left: 50%; width: 480px; transform: translateX(-50%); border-right: 1px solid #9ca4aa; border-left: 1px solid #9ca4aa; }
}

@media (max-width: 519px) {
  .offline-truth-strip { align-items: flex-start; flex-wrap: wrap; justify-content: flex-start; }
  .offline-truth-strip > span { flex-basis: 100%; }
}

@media (max-width: 370px) {
  .brand-copy small { display: none; }
  .package-trigger { max-width: 128px; font-size: 11px; }
  .offline-truth-strip { align-items: flex-start; flex-direction: column; gap: 1px; }
  .app-shell { padding-right: 12px; padding-left: 12px; }
  h1 { font-size: 28px; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .14s ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
