:root {
  color-scheme: light;
  --navy: #08263f;
  --navy-2: #123d5c;
  --mustard: #bd7e00;
  --mustard-pale: #fff4cf;
  --danger: #c53b34;
  --danger-pale: #fff0ed;
  --safe: #26734d;
  --safe-pale: #e9f5ee;
  --paper: #f7f5f0;
  --surface: #ffffff;
  --soft: #e8edf0;
  --line: #b9c0c5;
  --muted: #5d6870;
  --ink: #12212c;
  --shadow: 0 2px 0 rgba(8, 38, 63, 0.14);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: #dce2e5;
  color: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

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

button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 50;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  background: var(--surface);
  border: 2px solid var(--navy);
  color: var(--navy);
  padding: 10px 12px;
  font-weight: 800;
}

.skip-link:focus { transform: translateY(0); }

.app-bar {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  background: var(--navy);
  color: white;
  border-bottom: 1px solid #061b2c;
}

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

.brand-button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px 7px 14px;
  text-align: left;
}

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

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: 0.09em;
  line-height: 1.1;
}

.brand-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #d9e3ea;
  font-size: 11px;
}

.package-trigger {
  width: 103px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 9px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 11px;
  line-height: 1.25;
  text-align: left;
}

.status-dot {
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #77c394;
}

.package-trigger[data-tone="warning"] .status-dot { background: #f0bd42; }
.package-trigger[data-tone="danger"] .status-dot { background: #ff766d; }

.prototype-boundary {
  min-height: 42px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid #d2c9ad;
  background: var(--mustard-pale);
  color: #5e460d;
  font-size: 12px;
  line-height: 1.35;
}

.prototype-boundary strong { white-space: nowrap; }
.prototype-boundary a {
  grid-column: 1 / -1;
  justify-content: center;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #8a6718;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.58);
  font-weight: 800;
  text-decoration: none;
}

.app-shell {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 18px 14px 30px;
  outline: none;
}

.route-view { min-width: 0; }

.return-button {
  min-height: 44px;
  margin: -6px 0 9px -7px;
  padding: 7px;
  border: 0;
  background: transparent;
  color: var(--navy);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.eyebrow {
  margin: 0 0 6px;
  color: #8a5c00;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

h1, h2, h3, p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(27px, 8vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0;
  color: var(--navy);
  font-size: 21px;
  line-height: 1.3;
}

h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.section-heading {
  margin: 22px 0 9px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.scenario-list,
.branch-list,
.failure-list,
.button-stack {
  display: grid;
  gap: 9px;
  margin-top: 15px;
}

.scenario-button,
.branch-button,
.failure-button,
.choice-button,
.primary-button,
.secondary-button,
.danger-button,
.quiet-button,
.call-button,
.nav-row {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
}

.scenario-button,
.branch-button,
.failure-button,
.nav-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 38px 12px 13px;
}

.scenario-button::after,
.branch-button::after,
.failure-button::after,
.nav-row::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mustard);
  font-size: 25px;
  line-height: 1;
}

.scenario-button strong,
.branch-button strong,
.failure-button strong,
.nav-row strong {
  display: block;
  color: var(--navy);
  font-size: 16px;
  line-height: 1.35;
}

.scenario-button small,
.branch-button small,
.failure-button small,
.nav-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.scenario-button[data-urgent="true"] { border-left: 4px solid var(--danger); }

.answer-block,
.action-block,
.call-panel,
.state-panel,
.warning-block,
.uncertain-block,
.blocked-block,
.minimum-shell,
.confirmation-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 13px;
}

.answer-block {
  border-left: 4px solid var(--mustard);
}

.answer-block p,
.action-block p,
.call-panel p,
.state-panel p,
.warning-block p,
.uncertain-block p,
.blocked-block p,
.confirmation-panel p {
  margin: 5px 0 0;
  font-size: 15px;
  line-height: 1.55;
}

.answer-block strong,
.action-block strong,
.call-panel strong,
.state-panel strong,
.warning-block strong,
.uncertain-block strong,
.blocked-block strong,
.confirmation-panel strong {
  display: block;
  color: var(--navy);
  font-size: 14px;
}

.action-block { border-left: 4px solid var(--danger); }
.action-block .main-action { color: #8f2924; font-weight: 900; }

.warning-block {
  border-color: #d0ab52;
  background: var(--mustard-pale);
  color: #5f480f;
}

.uncertain-block {
  border-color: #91a2ae;
  background: #eef3f6;
}

.blocked-block {
  border-color: #9eabb4;
  background: #f0f2f3;
}

.blocked-block code {
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.media-stack {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.media-card {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid #aeb8be;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.media-heading {
  display: grid;
  gap: 2px;
  padding: 11px 12px;
  border-bottom: 1px solid #d2d8dc;
  background: #eef3f6;
}

.media-heading span {
  color: #8a5c00;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.media-heading strong {
  color: var(--navy);
  font-size: 16px;
  line-height: 1.35;
}

.media-card picture,
.media-card img {
  display: block;
  width: 100%;
}

.media-card img {
  height: auto;
  background: #fbfaf6;
}

.media-card figcaption {
  padding: 10px 12px;
  border-top: 1px solid #d7dcdf;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.media-transcript {
  border-top: 1px solid #d7dcdf;
  color: var(--navy);
}

.media-transcript summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.media-transcript p {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-line;
}

.call-panel {
  border-color: var(--danger);
  background: var(--danger-pale);
}

.call-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.call-button,
.primary-button,
.secondary-button,
.danger-button,
.quiet-button,
.choice-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 13px;
  text-align: center;
  font-weight: 900;
  text-decoration: none;
}

.runtime-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  margin-top: 8px;
  border-radius: 999px;
  background: #e6f3ea;
  color: #175c37;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.runtime-badge[data-tone="warning"] { background: var(--mustard-pale); color: #684d0b; }
.runtime-badge[data-tone="danger"] { background: var(--danger-pale); color: #8f2924; }

.qa-only {
  margin-top: 18px;
  border-top: 1px dashed #9aa7af;
  padding-top: 16px;
}

.qa-only[hidden] { display: none; }

.phone-fallback {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.call-button,
.danger-button {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.primary-button {
  border-color: var(--navy);
  background: var(--navy);
  color: white;
}

.secondary-button { border-color: var(--navy); color: var(--navy); }
.quiet-button { background: #eef1f2; color: var(--navy); }
.choice-button { justify-content: flex-start; }
.choice-button[aria-pressed="true"] { background: var(--navy); color: white; }

.call-state {
  margin-top: 14px;
  border-top: 5px solid var(--mustard);
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.call-state[data-tone="safe"] { border-top-color: var(--safe); }
.call-state[data-tone="danger"] { border-top-color: var(--danger); }

.status-label {
  display: inline-block;
  margin-bottom: 7px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
}

.call-number {
  margin: 4px 0;
  color: var(--navy);
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
}

.script-box {
  margin-top: 12px;
  padding: 11px;
  border-left: 3px solid var(--navy);
  background: #eef3f6;
  font-size: 14px;
  line-height: 1.55;
}

.meta-list {
  display: grid;
  gap: 0;
  margin: 14px 0 0;
  border-top: 1px solid var(--line);
}

.meta-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.4;
}

.meta-row dt { color: var(--muted); }
.meta-row dd { min-width: 0; margin: 0; color: var(--navy); font-weight: 800; }

.state-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.state-panel[data-tone="safe"] { border-left: 4px solid var(--safe); }
.state-panel[data-tone="warning"] { border-left: 4px solid var(--mustard); }
.state-panel[data-tone="danger"] { border-left: 4px solid var(--danger); }

.minimum-shell {
  border: 2px solid var(--danger);
  background: #fffafa;
}

.minimum-shell .scenario-button { box-shadow: none; }

.confirmation-panel { border-color: var(--danger); }

.history-list {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  margin-top: 14px;
  padding: 18px 14px;
  border: 1px dashed #8a979f;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #9ca7ae;
  background: rgba(255, 255, 255, 0.98);
}

.bottom-nav button {
  min-width: 0;
  min-height: 62px;
  padding: 6px 3px;
  border: 0;
  border-right: 1px solid #d5dadd;
  background: transparent;
  color: #4c5962;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.bottom-nav button:last-child { border-right: 0; }
.bottom-nav button[aria-current="page"] { background: #e8eef2; color: var(--navy); }

.toast {
  position: fixed;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.error-screen { padding-top: 18px; }

body[data-low-power="true"] * { box-shadow: none !important; }
body[data-low-power="true"] .prototype-boundary,
body[data-low-power="true"] .warning-block { background: #f1f1f1; }
body[data-low-power="true"] .media-stack { display: none; }

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

@media (min-width: 520px) {
  body { border-right: 1px solid #c4cbd0; border-left: 1px solid #c4cbd0; }
  .app-bar, .prototype-boundary, .bottom-nav { max-width: 460px; margin-right: auto; margin-left: auto; }
  .bottom-nav { left: 50%; right: auto; width: 460px; transform: translateX(-50%); }
}

@media (max-width: 370px) {
  .app-shell { padding-right: 11px; padding-left: 11px; }
  .package-trigger { width: 94px; font-size: 10px; }
  .brand-copy strong { font-size: 16px; }
  .prototype-boundary { font-size: 11px; }
  h1 { font-size: 27px; }
  .meta-row { grid-template-columns: 98px minmax(0, 1fr); }
  .bottom-nav button { font-size: 11px; }
}

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

@media (forced-colors: active) {
  .status-dot {
    border: 2px solid ButtonText;
    background: ButtonText;
  }

  .scenario-button,
  .branch-button,
  .failure-button,
  .primary-button,
  .secondary-button,
  .quiet-button,
  .danger-button,
  .choice-button,
  .call-button,
  .state-panel,
  .call-state,
  .warning-block,
  .blocked-block,
  .minimum-shell {
    border: 2px solid ButtonText;
  }

  .scenario-button,
  .branch-button,
  .failure-button,
  .state-panel,
  .call-state,
  .warning-block,
  .blocked-block,
  .minimum-shell {
    background: Canvas;
    color: CanvasText;
  }

  .primary-button,
  .danger-button,
  .call-button {
    background: ButtonFace;
    color: ButtonText;
  }

  .choice-button[aria-pressed="true"] {
    background: Highlight;
    color: HighlightText;
  }

  a,
  .return-button,
  .secondary-button,
  .quiet-button {
    color: LinkText;
  }
}
