:root {
  color-scheme: light;
  --bg-canvas: #ffefe3;
  --bg-panel: rgba(255, 255, 255, 0.88);
  --bg-panel-strong: #ffffff;
  --bg-soft: #f6f8fb;
  --bg-selected: #e6f1ff;
  --bg-hover: #f7f9fc;
  --bg-success: #eaf7ee;
  --bg-warning: #fff4df;
  --bg-danger: #fff0ef;
  --bg-disabled: #eef1f5;
  --line-soft: rgba(18, 31, 53, 0.1);
  --line-strong: rgba(18, 31, 53, 0.18);
  --text-primary: #172033;
  --text-secondary: rgba(23, 32, 51, 0.74);
  --text-muted: rgba(23, 32, 51, 0.54);
  --text-danger: #b02a37;
  --shadow-panel: 0 14px 34px rgba(52, 67, 92, 0.1);
  --shadow-card: 0 8px 22px rgba(30, 42, 64, 0.07);
  --shadow-focus: 0 0 0 4px rgba(88, 156, 255, 0.2);
  --accent: #0a6fe8;
  --accent-pressed: #075bbd;
  --green: #217a3a;
  --orange: #9a5b00;
  --red: #b02a37;
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --secondary: var(--text-secondary);
  --line: var(--line-soft);
  --fill: var(--bg-soft);
  --fill-strong: var(--bg-disabled);
  --surface: var(--bg-panel-strong);
  --shadow: var(--shadow-panel);
  --shadow-soft: 0 2px 8px rgba(41, 57, 82, 0.08);
  --stack-gap: 10px;
  --card-gap: 8px;
  --page-gutter: clamp(1.5rem, 3vw, 2rem);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang TC", "Hiragino Sans CNS", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei UI", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg-canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

button {
  cursor: pointer;
}

.site-navbar {
  min-height: 38px;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.site-navbar-inner {
  width: min(1180px, calc(100% - var(--page-gutter)));
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 3px 0;
}

.site-breadcrumb {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.38rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-breadcrumb-item {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.site-breadcrumb-current {
  flex: 1 1 auto;
}

.site-separator {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 2px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
}

.site-page-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-brand:hover {
  color: var(--accent);
}

.site-brand:focus-visible {
  outline: 0;
  box-shadow: var(--shadow-focus);
}

.app-shell {
  width: min(1180px, calc(100% - var(--page-gutter)));
  margin: 0 auto;
  padding: 12px 0 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.capsule-button,
.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.86);
  color: var(--accent);
  background: var(--bg-panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.page-action-row {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-bottom: var(--stack-gap);
}

.capsule-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.capsule-button svg,
.icon-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.capsule-button:hover,
.icon-button:hover {
  border-color: rgba(10, 111, 232, 0.18);
  background: var(--bg-hover);
}

.capsule-button:active,
.icon-button:active,
.tag-remove:active {
  transform: scale(0.97);
}

.danger-button {
  color: var(--red);
}

.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--stack-gap);
}

.column-stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px;
  backdrop-filter: blur(22px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.panel-note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: center;
}

.label {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.unit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.input,
.search-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 10px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 1px 1px rgba(0, 0, 0, 0.03);
}

.input:focus,
.search-input:focus {
  background: var(--surface);
  border-color: rgba(10, 111, 232, 0.55);
  box-shadow: var(--shadow-focus), 0 1px 1px rgba(0, 0, 0, 0.03);
}

.input::placeholder,
.search-input::placeholder {
  color: rgba(60, 60, 67, 0.52);
}

.input-error {
  color: var(--red);
  font-size: 12px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  background: rgba(245, 248, 252, 0.94);
  border: 1px solid rgba(20, 31, 56, 0.06);
  border-radius: 999px;
}

.segmented-option {
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.segmented-option.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(41, 57, 82, 0.08);
}

.search-wrap {
  position: relative;
  z-index: 5;
}

.autocomplete {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 300px;
  overflow: auto;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(30, 42, 64, 0.14);
  backdrop-filter: blur(22px);
}

.autocomplete-item {
  width: 100%;
  border: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--bg-selected);
}

.match-label {
  display: block;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.match-hint {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(221, 230, 242, 0.7);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.section-block {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.section-block:first-of-type {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.subhead {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0;
}

.empty-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.tag-list,
.driver-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reference-list {
  margin: 8px 0 0;
  padding-left: 1.15rem;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.4;
  list-style: disc;
  overflow-wrap: anywhere;
}

.tag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px 6px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
}

.ced-tag {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.tag-main {
  min-width: 0;
}

.tag-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
}

.tag-title {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tag-subtitle {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.tag-remove,
.icon-button {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0;
  padding: 0;
  flex: 0 0 28px;
  align-self: center;
}

.tag-remove {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.05);
}

.checkbox-list {
  display: grid;
  gap: 6px;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 9px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
}

.check-row > span {
  min-width: 0;
}

.check-row > input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  accent-color: var(--accent);
}

.check-title {
  display: block;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.check-note,
.footnote {
  display: block;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.dose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 7px;
  align-items: end;
  margin-top: 7px;
}

.check-row .dose-grid {
  grid-template-columns: minmax(160px, 280px);
  align-items: start;
}

.risk-card {
  border-radius: 14px;
  padding: 12px;
  background: var(--bg-panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
}

.risk-card.low {
  border-color: rgba(33, 122, 58, 0.22);
  background: var(--bg-success);
}

.risk-card.intermediate {
  border-color: rgba(154, 91, 0, 0.22);
  background: var(--bg-warning);
}

.risk-card.high {
  border-color: rgba(176, 42, 55, 0.24);
  background: var(--bg-danger);
}

.risk-card.empty-state {
  background: var(--bg-panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.92);
}

.empty-title {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.risk-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.risk-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.risk-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.risk-percent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  min-height: 24px;
  margin: 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  position: relative;
  top: -1px;
  white-space: nowrap;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--card-gap);
  margin-top: 10px;
}

.summary-item {
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  background: rgba(246, 248, 251, 0.82);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.summary-value {
  display: block;
  margin-top: 1px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.driver-list {
  margin-top: 10px;
}

.driver-item {
  padding: 8px 9px;
  border-radius: var(--radius-md);
  background: var(--bg-panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
  color: var(--secondary);
  font-size: 12px;
}

.reference-item {
  margin: 0;
  padding: 0;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.reference-item + .reference-item {
  margin-top: 0.35rem;
}

.detail-header {
  margin: -0.25rem;
}

.disclosure-button {
  width: 100%;
  min-height: 2.05rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0.25rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font-weight: 720;
  text-align: left;
}

.disclosure-title {
  min-width: 0;
  margin-right: auto;
}

.detail-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.4rem;
  padding: 0.16rem 0.58rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--secondary);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.disclosure-button:hover {
  background: var(--bg-hover);
}

.disclosure-button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.disclosure-icon {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  color: var(--secondary);
  transition: transform 160ms ease;
}

.disclosure-button[aria-expanded="true"] .disclosure-icon {
  transform: rotate(180deg);
}

.print-summary {
  display: none;
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .app-shell {
    width: min(1180px, calc(100% - var(--page-gutter)));
  }

  .app-grid {
    grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
    align-items: start;
  }

  .sticky-column {
    position: sticky;
    top: 12px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-top: 8px;
  }

  .panel {
    padding: 12px;
  }

  .field-row,
  .dose-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .risk-title {
    font-size: 25px;
  }
}

@page {
  margin: 0;
}

@media print {
  body {
    margin: 0;
    padding: 10mm;
    background: #fff;
    color: #000;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .page-action-row,
  #div-1-header,
  #div-2-demographics,
  #div-3-treatment,
  #div-6-footer {
    display: none !important;
  }

  .site-navbar {
    min-height: 0;
    display: block;
    margin-bottom: 0.4rem;
    border: 0;
    background: #fff;
    box-shadow: none;
    backdrop-filter: none;
  }

  .site-navbar-inner,
  .site-breadcrumb,
  .site-breadcrumb-current {
    width: 100%;
    display: block;
  }

  .site-brand,
  .site-separator {
    display: none !important;
  }

  .site-page-title {
    overflow: visible;
    color: #000;
    font-size: 1.6rem;
    line-height: 1.15;
    text-overflow: clip;
    white-space: normal;
  }

  .app-grid,
  .column-stack {
    display: block;
  }

  #left-column {
    display: none;
  }

  .sticky-column {
    position: static;
  }

  .panel {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0 0 16px;
    page-break-inside: avoid;
  }

  .print-summary {
    display: block;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #aaa;
  }

  .risk-card,
  .driver-item,
  .summary-item {
    background: #fff !important;
    border: 1px solid #bbb;
  }

  .detail-header {
    margin: 0 0 6px;
  }

  .disclosure-button {
    min-height: 0;
    padding: 0;
  }

  .detail-chip,
  .disclosure-icon {
    display: none !important;
  }

  .reference-list[hidden] {
    display: block !important;
  }
}
