/* SHHER-ART Center · Nerve Block Reference System */
:root {
  --teal: #139BAC;
  --teal-dark: #0E7E8C;
  --teal-light: #E6F5F7;
  --teal-pale: #F3FAFB;
  --gray-900: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-400: #9ca3af;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --bg: #FFFFFF;
  --bg-soft: #F5F7F8;
  --danger: #c0392b;
  --warning-bg: #fef3c7;
  --warning-border: #f59e0b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg-soft);
  color: var(--gray-900);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--teal-dark); }
a:hover { color: var(--teal); }

/* ============ Header ============ */
.site-header {
  background: #fff;
  border-bottom: 3px solid var(--teal);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(19, 155, 172, 0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.brand-logo {
  height: 52px;
  width: auto;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-en {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--teal);
  letter-spacing: 0.5px;
}
.brand-zh {
  font-size: 0.95rem;
  color: var(--gray-900);
  font-weight: 700;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--gray-600);
  margin-top: 2px;
}

.tab-nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}
.tab {
  border: 1px solid var(--gray-200);
  background: #fff;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--gray-700);
  transition: all 0.15s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.tab:hover {
  border-color: var(--teal);
  color: var(--teal);
}
.tab.active {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
  font-weight: 700;
}
.tab-download {
  background: var(--teal-pale);
  border-color: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 600;
}
.tab-download:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

/* ============ Main / Panel ============ */
main { min-height: calc(100vh - 200px); }
.panel { display: none; }
.panel.active { display: block; }
.panel.two-col {
  display: none;
  grid-template-columns: minmax(280px, 32%) 1fr;
  gap: 1rem;
  padding: 1rem;
  max-width: 1600px;
  margin: 0 auto;
}
.panel.two-col.active { display: grid; }

.content-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  background: #fff;
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.content-wrap h2 {
  color: var(--teal-dark);
  border-left: 4px solid var(--teal);
  padding-left: 0.7rem;
  margin: 1.2rem 0 0.8rem;
  font-size: 1.35rem;
}
.content-wrap h3 {
  color: var(--gray-900);
  margin: 1.2rem 0 0.5rem;
  font-size: 1.08rem;
}
.lead { color: var(--gray-700); }

/* ============ Left column (dx list) ============ */
.left-col {
  background: #fff;
  border-radius: var(--radius);
  padding: 0.85rem;
  box-shadow: var(--shadow);
  height: calc(100vh - 130px);
  overflow-y: auto;
  position: sticky;
  top: 110px;
}
.search-wrap { margin-bottom: 0.85rem; }
#searchInput {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font: inherit;
  font-size: 0.95rem;
  background: var(--teal-pale);
  transition: border-color 0.15s, background 0.15s;
}
#searchInput:focus {
  outline: none;
  border-color: var(--teal);
  background: #fff;
}
.search-hint {
  font-size: 0.75rem;
  color: var(--gray-600);
  margin-top: 0.35rem;
  padding-left: 0.25rem;
}

.dx-group { margin-bottom: 0.75rem; }
.dx-group-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal-dark);
  letter-spacing: 1px;
  padding: 0.3rem 0.5rem;
  background: var(--teal-light);
  border-radius: 6px;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}
.dx-item {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.dx-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-200);
}
.dx-item.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}
.dx-item.active .dx-en { color: rgba(255,255,255,0.85); }
.dx-zh { font-weight: 500; font-size: 0.92rem; }
.dx-en { font-size: 0.76rem; color: var(--gray-600); margin-top: 1px; }

.dx-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.9rem;
}
.dx-empty b { color: var(--gray-700); }

/* highlight matched substring */
mark.hl {
  background: #fff3a3;
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
}

/* ============ Right column (detail) ============ */
.right-col {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  min-height: 70vh;
}
.right-col.has-decoration {
  background-image: url('../resources/decoration.png');
  background-repeat: no-repeat;
  background-position: right bottom;
  background-origin: border-box;
  background-size: 34% auto;
}

/* Welcome — "fundamental page" statement screen */
.welcome-fundamental {
  position: relative;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1.5rem;
  overflow: hidden;
}
.welcome-logo {
  height: 96px;
  margin-bottom: 2rem;
  opacity: 0.95;
}
.fundamental-quote {
  margin: 0;
  max-width: 100%;
}
.fundamental-quote .fq-en {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  font-weight: 600;
  font-size: clamp(1.1rem, 3.8vw, 2rem);
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: var(--teal-dark);
  margin: 0 0 0.6rem;
}
.fundamental-quote .fq-zh {
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--gray-700);
  margin: 0;
}

/* Diagnosis detail */
.dx-detail h1 {
  color: var(--teal-dark);
  font-size: 1.7rem;
  margin: 0 0 0.2rem;
}
.dx-detail .dx-subtitle {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}
.dx-detail .region-tag {
  display: inline-block;
  background: var(--teal-light);
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.warning-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-left: 4px solid var(--warning-border);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin: 0.75rem 0;
  font-weight: 500;
}

.tip-box {
  background: var(--teal-pale);
  border-left: 4px solid var(--teal);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin: 0.75rem 0;
  font-size: 0.92rem;
}
.tip-box b { color: var(--teal-dark); }

.block-list { margin-top: 1.25rem; }
.block-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  background: #fff;
  transition: box-shadow 0.15s;
}
.block-card:hover {
  box-shadow: 0 4px 12px rgba(19,155,172,0.12);
  border-color: var(--teal-light);
}
.block-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900);
  margin-bottom: 0.35rem;
}
.block-volume {
  display: inline-block;
  background: var(--teal);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}
.block-note {
  color: var(--gray-700);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.nysora-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--teal-light);
  color: var(--teal-dark);
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.nysora-link:hover {
  background: var(--teal);
  color: #fff;
}
.nysora-link::after { content: ' ↗'; font-size: 0.85rem; }

.dx-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.dx-actions button {
  background: #fff;
  border: 1px solid var(--teal);
  color: var(--teal-dark);
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.dx-actions button:hover {
  background: var(--teal);
  color: #fff;
}

/* ============ Tables ============ */
.ref-group {
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--teal);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin: 1.25rem 0;
  background: #fff;
  box-shadow: var(--shadow);
}
.ref-group > h3 {
  margin-top: 0.25rem;
  color: var(--teal-dark);
}
.ref-group > .ref-figure:last-child { margin-bottom: 0; }

.ref-figure { margin: 1rem 0 1.5rem; text-align: center; }
.ref-figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
}
.ref-figure figcaption {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--gray-600);
}
.ref-subhead {
  font-size: 0.98rem;
  color: var(--gray-700);
  margin: 1rem 0 0.25rem;
}

.table-scroll { overflow-x: auto; }
table.drug-table, table.billing-table, table.ref-table, table.form-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}
table.drug-table th, table.drug-table td,
table.billing-table th, table.billing-table td,
table.ref-table th, table.ref-table td {
  border: 1px solid var(--gray-200);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}
table.drug-table th, table.billing-table th, table.ref-table th {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  font-size: 0.88rem;
}
table.drug-table tbody tr:nth-child(even),
table.billing-table tbody tr:nth-child(even),
table.ref-table tbody tr:nth-child(even) {
  background: var(--teal-pale);
}

table.form-table { margin-top: 0.5rem; }
table.form-table td {
  border: 1px solid var(--gray-200);
  padding: 0.5rem;
  vertical-align: middle;
}
table.form-table td:first-child {
  background: var(--gray-50);
  font-weight: 500;
  width: 30%;
}
table.form-table input {
  width: 100%;
  border: none;
  font: inherit;
  padding: 0.25rem;
  background: transparent;
}
table.form-table input.small { width: 60px; }

/* ============ Cards / Misc ============ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}
.card-grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: #fff;
}
.card h4 {
  margin: 0 0 0.4rem;
  color: var(--teal-dark);
  font-size: 1rem;
}
.card p { margin: 0.25rem 0; font-size: 0.9rem; }

.callout {
  background: var(--teal-pale);
  border: 1px solid var(--teal-light);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.92rem;
}

ul.bullet { padding-left: 1.4rem; }
ul.bullet li { margin-bottom: 0.2rem; }
ol.ordered { padding-left: 1.4rem; }
ol.ordered li { margin-bottom: 0.35rem; }

.calc-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 0.5rem 0 1rem;
}
.calc-box label { display: inline-block; margin: 0.3rem 0.6rem 0.3rem 0; }
.calc-box input, .calc-box select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font: inherit;
  font-size: 0.9rem;
}
.calc-result {
  margin-top: 0.8rem;
  padding: 0.85rem 1rem;
  background: #fff;
  border-left: 4px solid var(--teal);
  border-radius: 6px;
  font-size: 0.95rem;
}
.calc-result b { color: var(--teal-dark); }

/* ============ Record template & Checklist ============ */
.record-template {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.88rem;
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 0.5rem 0;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 18rem;
}
.copy-btn, .print-btn {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.copy-btn:hover, .print-btn:hover { background: var(--teal-dark); }
.copy-btn.copied { background: #16a34a; }
.reset-btn {
  background: #fff;
  color: var(--gray-900);
  border: 1px solid var(--gray-200);
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.reset-btn:hover { background: var(--gray-50); }

.checklist { margin-top: 0.75rem; }
.checklist-toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }
.inline-checks { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.inline-checks label { display: inline-flex; align-items: center; white-space: nowrap; }
.inline-checks input[type="checkbox"] { width: auto; margin-right: 0.35rem; transform: scale(1.15); }
.check-list { list-style: none; padding-left: 0.5rem; }
.check-list li { padding: 0.25rem 0; }
.check-list input[type="checkbox"] { margin-right: 0.5rem; transform: scale(1.15); }
.checklist textarea {
  width: 100%;
  padding: 0.55rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font: inherit;
}

/* ============ Footer ============ */
.site-footer {
  background: var(--gray-900);
  color: var(--gray-200);
  padding: 1.2rem 1.5rem;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.7;
}
.site-footer b { color: var(--teal-light); }
.footer-link {
  display: inline-block;
  color: var(--teal-light);
  text-decoration: none;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--teal);
  border-radius: 6px;
  font-weight: 500;
  transition: background 0.15s;
}
.footer-link:hover {
  background: var(--teal);
  color: #fff;
}
.footer-disclaimer {
  margin: 0.9rem auto 0;
  max-width: 760px;
  padding-top: 0.7rem;
  border-top: 1px solid var(--gray-700);
  font-size: 0.74rem;
  line-height: 1.6;
  color: var(--gray-400);
  text-align: left;
}
.footer-disclaimer b { color: var(--gray-200); }

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  html, body { overflow-x: hidden; }
  .site-header {
    padding: 0.6rem 0.9rem;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0.55rem;
  }
  .brand { gap: 0.65rem; }
  .brand-logo { height: 42px; }
  .brand-en { font-size: 1.05rem; }
  .brand-zh { font-size: 0.82rem; }
  .brand-sub { font-size: 0.7rem; }
  .tab-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: 0.4rem;
    gap: 0.4rem;
  }
  .tab-nav::-webkit-scrollbar { height: 4px; }
  .tab-nav::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }
  .tab-nav::after {
    content: '';
    flex: 0 0 0.5rem;
  }
  .tab {
    scroll-snap-align: start;
    flex: 0 0 auto;
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
  }
}

@media (max-width: 900px) {
  body { font-size: 14.5px; }
  .panel.two-col {
    grid-template-columns: 1fr;
    padding: 0.6rem;
    gap: 0.7rem;
  }
  .left-col {
    height: auto;
    max-height: none;
    position: static;
    padding: 0.7rem;
  }
  .right-col {
    padding: 1rem;
    min-height: auto;
  }
  .dx-item { padding: 0.7rem 0.75rem; }
  .dx-zh { font-size: 0.95rem; }
  .dx-detail h1 { font-size: 1.35rem; }
  .dx-subtitle { font-size: 0.88rem; }
  .content-wrap {
    padding: 1rem;
    margin: 0.6rem;
    border-radius: 8px;
  }
  .content-wrap h2 { font-size: 1.2rem; }
  .welcome-fundamental { padding: 2rem 1rem; min-height: 60vh; }
  .right-col.has-decoration { background-size: 48% auto; }
  .welcome-logo { height: 72px; margin-bottom: 1.5rem; }
  .fundamental-quote .fq-zh { font-size: 1rem; }
  .calc-box { padding: 0.85rem; }
  .calc-box label { display: block; margin: 0.5rem 0; }
  .calc-box input, .calc-box select { width: 100%; max-width: 280px; }
  .card-grid, .card-grid.two { grid-template-columns: 1fr; }
  table.form-table td { display: block; width: 100%; }
  table.form-table td:first-child { width: 100%; }
  .nysora-link { font-size: 0.82rem; padding: 0.5rem 0.75rem; }
}

@media (max-width: 600px) {
  body { font-size: 14px; }
  .brand-en { font-size: 0.95rem; }
  .brand-zh { font-size: 0.78rem; }
  .brand-sub { display: none; }
  .brand-logo { height: 36px; }
  .tab { font-size: 0.8rem; padding: 0.45rem 0.7rem; }
  .panel.two-col { padding: 0.4rem; gap: 0.5rem; }
  .left-col, .right-col { padding: 0.7rem; border-radius: 8px; }
  .dx-group-title { font-size: 0.72rem; }
  .dx-detail h1 { font-size: 1.2rem; }
  .dx-actions { flex-direction: column; }
  .dx-actions button { width: 100%; }
  .block-card { padding: 0.8rem; }
  .block-name { font-size: 0.98rem; }
  #searchInput { font-size: 16px; /* avoid iOS zoom */ }
  .site-footer { padding: 1rem 0.8rem; font-size: 0.78rem; }
  .content-wrap { padding: 0.8rem; }
  .content-wrap h2 { font-size: 1.1rem; }
  .content-wrap h3 { font-size: 1rem; }
}

/* ============ Print ============ */
@media print {
  .site-header, .site-footer, .tab-nav, .print-btn, .no-print-btn,
  .no-print, .checklist-toolbar { display: none !important; }
  body { background: #fff; }
  .panel { display: none !important; }
  .panel[data-panel="record"] { display: block !important; }
  .content-wrap { box-shadow: none; padding: 0; }
}
