:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5f7080;
  --line: #d7e2e7;
  --surface: #f7fafb;
  --brand: #4f8f9f;
  --brand-deep: #285f6d;
  --accent: #9a6b3b;
  --step-bg: linear-gradient(135deg, #edf7f8 0%, #f8fbfa 54%, #f4f6f3 100%);
  --ok: #15803d;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 48px rgba(15, 63, 79, 0.13);
}

body[data-step="case"] {
  --brand: #5e9fb0;
  --brand-deep: #2f6370;
  --accent: #a67c52;
  --step-bg: linear-gradient(135deg, #eaf6f7 0%, #fbfdfc 52%, #f3f7f1 100%);
}

body[data-step="photos"] {
  --brand: #7796c8;
  --brand-deep: #405d8d;
  --accent: #6f8f88;
  --step-bg: linear-gradient(135deg, #eef4fb 0%, #f8fbff 52%, #eef8f5 100%);
}

body[data-step="exposure"] {
  --brand: #9a86c8;
  --brand-deep: #64508f;
  --accent: #b16f86;
  --step-bg: linear-gradient(135deg, #f3effb 0%, #fbf9ff 52%, #f7f0f4 100%);
}

body[data-step="symptoms"] {
  --brand: #c88391;
  --brand-deep: #86505c;
  --accent: #9a6b52;
  --step-bg: linear-gradient(135deg, #fbf0f2 0%, #fffafb 52%, #f8f1ed 100%);
}

body[data-step="risk"] {
  --brand: #c99568;
  --brand-deep: #805735;
  --accent: #a85d4f;
  --step-bg: linear-gradient(135deg, #fbf3ec 0%, #fffdf9 52%, #f9efed 100%);
}

body[data-step="clinic"] {
  --brand: #79a980;
  --brand-deep: #446e4a;
  --accent: #5f8f88;
  --step-bg: linear-gradient(135deg, #eef8f0 0%, #fbfdf9 52%, #eef8f6 100%);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--step-bg);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  font-size: 18px;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  min-width: 0;
  padding: 24px;
  background: rgba(255, 255, 255, 0.88);
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 20px rgba(23, 33, 43, 0.12);
}

.brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.35;
}

.brand span,
.section-heading p,
small {
  color: var(--muted);
}

.steps {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  min-width: 0;
}

.step span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: white;
  background: #8aa5af;
  font-weight: 800;
}

.step.is-active {
  color: var(--brand-deep);
  background: #e4f3f6;
  border-color: #b9d9e0;
  font-weight: 800;
}

.step.is-active span {
  background: var(--brand);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.top-actions,
.clinic-actions,
.symptom-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

h2 {
  margin-bottom: 8px;
  font-size: 26px;
}

h3 {
  margin-bottom: 10px;
  font-size: 20px;
}

.primary-action,
.secondary-action,
.upload-button,
.exit-action,

.ai-action,
.suggestion-action,
.next-step-action,
.delete-record,
.icon-button {
  min-height: 48px;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 800;
}

.primary-action,
.upload-button {
  border: 0;
  color: white;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(21, 94, 117, 0.2);
}

.secondary-action {
  border: 1px solid var(--line);
  color: var(--brand-deep);
  background: white;
}

.ai-action,
.suggestion-action,
.next-step-action {
  border: 0;
  color: #ffffff;
  background: linear-gradient(135deg, #e85d04, #d00000);
  box-shadow: 0 12px 26px rgba(208, 0, 0, 0.22);
}





.next-step-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.exit-action {
  border: 1px solid #f1c2c2;
  color: #7f1d1d;
  background: #fff7f7;
}

.panel {
  display: none;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-height: 560px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.panel.is-visible {
  display: block;
}

.section-heading {
  max-width: 880px;
  margin-bottom: 18px;
  line-height: 1.65;
}

.case-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.case-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--brand-deep);
  font-weight: 800;
}

.wide,
.free-text {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

input,
select {
  min-height: 48px;
  padding: 0 13px;
}

textarea {
  padding: 12px 13px;
  line-height: 1.55;
  resize: vertical;
}

.record-list,
.photo-list,
.exposure-grid,
.symptom-grid,
.guide-grid {
  display: grid;
  gap: 14px;
}

.record-list {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: center;
  justify-content: flex-end;
}

.record-list button[data-load-record] {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 4px;
  border: 0;
  background: transparent;
  text-align: left;
}

.delete-record {
  border: 1px solid #fecaca;
  color: #991b1b;
  background: #fff7f7;
}

.panel-footer {
  position: fixed;
  right: calc(24px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  margin: 0;
  pointer-events: none;
}

.panel-footer .next-step-action {
  pointer-events: auto;
  min-width: 160px;
  min-height: 52px;
  border-radius: 999px;
}

.upload-button {
  display: inline-block;
  margin-bottom: 18px;
}

.upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-button:focus-within {
  outline: 3px solid #155e75;
  outline-offset: 3px;
}

.photo-list {
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
}

.task-picker {
  display: grid;
  gap: 10px;
}

.task-picker strong {
  color: var(--brand-deep);
  font-size: 17px;
}

.task-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 9px;
  max-height: 260px;
  overflow: auto;
  padding: 2px;
}

.task-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-weight: 800;
  line-height: 1.35;
}

.task-chip input {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-height: auto;
  margin: 0;
  accent-color: #e85d04;
}

.task-chip:has(input:checked) {
  border-color: #e85d04;
  background: #fff7ed;
}

.photo-card,
.risk-card,
.guide-card,
.symptom-group,
.records-panel,
.exposure-evidence {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}


.photo-card {
  overflow: hidden;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #eef3f5;
}

.photo-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.photo-body header,
.risk-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.photo-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.analysis-status {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.photo-body header button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px 10px;
}

.chip-grid,
.exposure-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.check-chip,
.exposure-card {
  min-height: 52px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 700;
}

.check-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-chip input,
.exposure-card input {
  width: 20px;
  height: 20px;
  min-height: auto;
  accent-color: var(--brand);
}

.exposure-card {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 7px 10px;
}

.exposure-card small,
.exposure-card em {
  grid-column: 2;
}

.exposure-card em {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--brand-deep);
  background: #e4f3f6;
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.exposure-card.is-selected,
.check-chip:has(input:checked) {
  border-color: var(--brand);
  background: #f0fbfd;
}

.symptom-group {
  padding: 16px;
}

.symptom-group + .symptom-group {
  margin-top: 14px;
}

.is-redflag {
  border-color: #f1c2c2;
}

.assessment-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.score-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--brand) 26%, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand-soft) 72%, white), #ffffff);
}

.score-suggestion strong {
  display: block;
  margin-bottom: 4px;
  color: var(--brand-deep);
  font-size: 18px;
}

.score-suggestion p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.assessment-form output {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 30px;
  border-radius: 999px;
  color: white;
  background: var(--brand);
}

.risk-card,
.guide-card,
.records-panel,
.exposure-evidence {
  padding: 16px;
}

.guide-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  margin-top: 16px;
}

.guide-card h3 {
  font-size: 19px;
  line-height: 1.35;
}

.guide-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 14px;
  font-weight: 900;
}

.badge.ok {
  color: #0f5132;
  background: #dcfce7;
}

.badge.warn {
  color: #7c2d12;
  background: #ffedd5;
}

.badge.danger {
  color: #7f1d1d;
  background: #fee2e2;
}

.clinic-card {
  margin-top: 16px;
}

.print-sheet {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.report-status {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-deep);
  background: #f8fbfc;
  font-weight: 800;
}

.signature-table td {
  height: 42px;
}

dialog {
  width: min(92vw, 560px);
  max-height: min(86dvh, 760px);
  border: 0;
  border-radius: 12px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.25);
  overflow: auto;
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #f0fdfa, #fff7ed);
}

.dialog-header h2 {
  margin: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
  font-size: 24px;
}









.muted {
  color: var(--muted);
}



.print-sheet table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.print-sheet th,
.print-sheet td {
  border: 1px solid #cbd5dc;
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

.print-sheet th {
  width: 120px;
  background: #f1f5f7;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b8c7ce;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbfc;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  border-radius: 8px;
  padding: 12px 16px;
  color: white;
  background: var(--brand-deep);
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  body {
    font-size: 18px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100vw;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    width: 100%;
    max-width: 100vw;
    padding: calc(8px + env(safe-area-inset-top)) 12px 10px;
    overflow: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    grid-template-columns: 54px 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand img {
    width: 54px;
    height: 54px;
  }

  .brand strong {
    font-size: 20px;
  }

  .brand span {
    font-size: 18px;
  }

  .steps {
    display: flex;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .step {
    flex: 0 0 auto;
    min-height: 40px;
    min-width: max-content;
    padding: 7px 11px;
    font-size: 15px;
    line-height: 1.25;
    white-space: nowrap;
    box-shadow: none;
  }

  .step span {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    font-size: 14px;
  }

  .workspace {
    width: 100%;
    max-width: 100vw;
    padding: 10px 12px calc(22px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .case-form,
  .assessment-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    display: block;
    margin: 0 -2px 14px;
  }

  .score-suggestion {
    align-items: stretch;
    flex-direction: column;
  }

  .case-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .panel {
    padding: 18px;
    box-shadow: 0 10px 28px rgba(15, 63, 79, 0.08);
  }

  h2 {
    font-size: 23px;
  }

  h3 {
    font-size: 19px;
  }

  .primary-action,
  .secondary-action,
  .upload-button,
  .exit-action,

  .delete-record,
  .ai-action,
  .suggestion-action {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 16px;
    white-space: nowrap;
  }

  .top-actions > button {
    flex: 0 0 auto;
    min-width: 82px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(15, 63, 79, 0.08);
  }

  .top-actions .primary-action {
    min-width: 96px;
  }

  .task-chip-grid {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: visible;
  }

  .task-chip {
    min-height: 58px;
    padding: 12px;
    font-size: 18px;
  }

  .panel-footer {
    left: calc(16px + env(safe-area-inset-left));
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
    margin: 0;
  }

  .next-step-action {
    width: 100%;
    min-height: 48px;
    font-size: 18px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 18px;
  }

  dialog {
    position: fixed;
    inset: calc(16px + env(safe-area-inset-top)) auto auto 50%;
    width: min(90vw, 420px);
    max-height: calc(100dvh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    margin: 0;
    transform: translateX(-50%);
    border-radius: 10px;
  }

  .dialog-header {
    min-height: 58px;
    padding: 12px 14px;
  }

  .dialog-header h2 {
    font-size: 20px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    flex: 0 0 42px;
  }

  

  

  .steps {
    display: flex;
  }

  .step {
    flex-basis: 122px;
    font-size: 16px;
  }

  .brand {
    grid-template-columns: 46px 1fr;
  }

  .brand img {
    width: 46px;
    height: 46px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand span {
    font-size: 16px;
  }

  .clinic-actions,
  .symptom-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .clinic-actions {
    gap: 8px;
  }

  .clinic-actions button,
  .symptom-tools button {
    min-height: 42px;
    padding: 8px 10px;
    font-size: 16px;
  }

  .record-item {
    grid-template-columns: 1fr;
  }

  .record-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-actions {
    grid-template-columns: 1fr;
  }

  .photo-list,
  .chip-grid,
  .exposure-grid,
  .record-list,
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
    font-size: 12pt;
  }

  .sidebar,
  .topbar,
  .section-heading,
  .clinic-actions,
  .clinic-card,
  .panel-footer,
  .steps,
  .panel:not(#clinic) {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .panel,
  #clinic {
    display: block !important;
    min-height: auto;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .print-sheet {
    display: block;
    border: 0;
    padding: 0;
  }
}

/* Browser report: flowing content, no fixed page height or clipping. */
.workspace { min-width: 0; padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
html { scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
.print-sheet { overflow-wrap: anywhere; }
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.print-sheet table { table-layout: fixed; }
.print-sheet th { width: auto; }
.print-sheet:focus { outline: 2px solid var(--brand); outline-offset: 3px; }
.legal-notice { margin-top: 28px; padding-top: 18px; border-top: 1px solid #cbdde2; color: var(--muted); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.legal-notice p { margin: 8px 0; }
.legal-copyright { font-weight: 600; }
.legal-notice details { margin-top: 10px; }
.legal-notice summary { cursor: pointer; padding: 10px 0; color: var(--brand); font-weight: 600; }
.legal-notice summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
@media print { .legal-notice { display: none; } }
.report-pricing { margin: 16px 0; padding: 18px; border: 1px solid #cbdde2; border-radius: 12px; background: #f2f8fa; line-height: 1.7; }
.report-pricing h3 { margin: 0 0 8px; }
.report-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 8px 0; }
.report-price strong { color: var(--brand); font-size: 22px; }
.report-price span { color: var(--muted); font-size: 14px; }
.report-pricing ul { padding-left: 22px; margin: 8px 0; }
@media print { .report-pricing { display: none; } }
.storage-note { color: var(--muted); font-size: 14px; line-height: 1.6; }
.topbar { flex-wrap: wrap; justify-content: flex-start; align-items: flex-end; gap: 12px; }
.case-selector { display: grid; gap: 6px; flex: 0 1 420px; width: min(100%, 420px); min-width: 0; }
.case-selector select { width: 100%; min-width: 0; min-height: 48px; }
.top-actions { flex: 0 0 auto; }
#caseSaveStatus { margin: 0 0 16px; }
@media (max-width: 560px) {
  .case-selector { width: 100%; margin-bottom: 10px; }
  .top-actions { flex-wrap: wrap; overflow-x: visible; }
  .print-sheet { padding: 12px; font-size: 15px; }
  .print-sheet th, .print-sheet td { padding: 6px; }
}
