:root {
  color-scheme: dark;
  --ink: #3b281d;
  --muted-ink: #795a43;
  --paper: #ead1a3;
  --paper-light: #f5e4bd;
  --paper-dark: #cda873;
  --wood: #24150e;
  --wood-light: #55331d;
  --gold: #c89648;
  --gold-light: #f2ca77;
  --red: #a84f3b;
  --line: rgba(207, 161, 87, 0.43);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: #1d120c url("assets/backgrounds/clinic_background_v1.webp") center / cover fixed;
  color: var(--paper-light);
  font-family: "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { min-width: 760px; width: 100%; height: 100%; display: flex; flex-direction: column; background: linear-gradient(90deg, rgba(24, 12, 7, .38), rgba(24, 12, 7, .1), rgba(24, 12, 7, .52)); }
.topbar { height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: rgba(24, 13, 8, .91); border-bottom: 1px solid var(--line); }
.brand-block { min-width: 160px; }
.brand { color: var(--gold-light); font-size: 24px; letter-spacing: .18em; text-shadow: 0 2px 5px #000; }
.brand-subtitle { color: #bd9470; font-size: 11px; letter-spacing: .08em; margin-top: 1px; }
.case-status { flex: 1; color: #d9b98a; font-size: 13px; }
.patient-switcher { display: flex; align-items: center; gap: 7px; color: #cba177; font-size: 12px; }
select, .search-input { color: var(--ink); background: var(--paper-light); border: 1px solid #8d6339; border-radius: 5px; outline: none; }
.patient-switcher select { width: 150px; padding: 7px 9px; }
.topbar-button, .icon-button { color: var(--gold-light); background: transparent; border: 1px solid var(--gold); border-radius: 5px; padding: 7px 12px; }
.topbar-button:hover, .icon-button:hover { background: rgba(200, 150, 72, .2); }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 205px minmax(390px, 1fr) 342px; gap: 11px; padding: 12px 14px 14px; }
.panel-surface { background: linear-gradient(135deg, rgba(29, 15, 9, .91), rgba(45, 25, 15, .88)); border: 1px solid var(--line); box-shadow: 0 7px 22px rgba(0, 0, 0, .27), inset 0 0 0 1px rgba(255, 218, 153, .04); border-radius: 8px; }
.patient-pane { padding: 13px; min-height: 0; overflow: hidden; }
.section-kicker { color: var(--gold-light); font-size: 12px; letter-spacing: .12em; }
.portrait-frame { height: 235px; margin: 10px 0 11px; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; background: radial-gradient(ellipse at 50% 75%, rgba(224, 182, 112, .28), transparent 68%); border: 1px solid rgba(207, 161, 87, .35); border-radius: 6px; }
.portrait-frame img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
h1, h2, p { margin: 0; }
.patient-pane h1 { color: var(--paper-light); font-size: 22px; font-weight: 600; }
.patient-meta { color: #c69e73; font-size: 12px; margin-top: 4px; }
.patient-status { display: inline-block; color: #f2d49b; background: rgba(168, 79, 59, .54); border: 1px solid rgba(242, 202, 119, .4); border-radius: 4px; padding: 3px 8px; font-size: 11px; margin-top: 9px; }
.complaint-box { margin-top: 15px; padding: 10px; background: rgba(234, 209, 163, .13); border-left: 3px solid var(--gold); border-radius: 3px; }
.mini-label, .select-label { color: var(--gold-light); font-size: 11px; letter-spacing: .12em; }
.complaint-box p { color: #eed6ad; font-size: 13px; line-height: 1.55; margin-top: 5px; }
.patient-tip { color: #a98667; font-size: 11px; line-height: 1.55; margin-top: 13px; }
.dialogue-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; position: relative; }
.dialogue-pane::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 8px; background: linear-gradient(180deg, rgba(23, 12, 7, .04), rgba(23, 12, 7, .18)); }
.dialogue-pane > * { position: relative; z-index: 1; }
.dialogue-card { flex: 0 0 auto; width: 100%; min-height: 190px; max-height: 36%; overflow: hidden; display: flex; flex-direction: column; padding: 15px 22px 12px; background: linear-gradient(135deg, rgba(245, 228, 189, .88), rgba(226, 194, 139, .82)); color: var(--ink); border: 1px solid rgba(244, 201, 111, .7); border-radius: 5px; box-shadow: 0 5px 14px rgba(0, 0, 0, .22); }
.dialogue-heading, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.dialogue-card .section-kicker { color: #aa6047; }
.dialogue-card h2 { color: #5a3524; font-size: 22px; margin-top: 5px; }
.page-counter { color: #987148; font-size: 13px; padding-top: 3px; }
.dialogue-message { flex: 0 0 auto; min-height: 0; display: flex; flex-direction: column; justify-content: flex-start; padding: 9px 12px 8px; }
.speaker { color: #a84f3b; font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.message-text { color: #4c3122; font-size: clamp(18px, 1.8vw, 24px); line-height: 1.7; letter-spacing: .05em; max-width: 780px; max-height: 5.2em; overflow-y: auto; white-space: pre-wrap; scrollbar-color: #a37542 rgba(225, 193, 140, .4); }
.dialogue-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid rgba(111, 73, 39, .25); padding-top: 10px; margin-top: auto; }
.record-count { color: #97704b; font-size: 12px; }
.dialogue-actions { display: flex; align-items: center; gap: 7px; }
.primary-button, .submit-button { border: 1px solid #754527; border-radius: 5px; color: #fff0c8; background: linear-gradient(#ba6b4e, #8d3f32); box-shadow: 0 2px 0 #5b2d24; padding: 9px 16px; }
.primary-button:hover, .submit-button:hover { filter: brightness(1.1); }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: default; }
.secondary-button { border: 1px solid #916440; border-radius: 5px; color: #754b32; background: rgba(255, 239, 198, .58); padding: 9px 13px; }
.secondary-button:hover:not(:disabled) { background: rgba(255, 239, 198, .82); }
.thinking-note { flex: 0 0 42px; display: flex; align-items: center; gap: 12px; padding: 0 15px; color: #d5b184; background: rgba(29, 15, 9, .78); font-size: 12px; }
.thinking-note span { color: var(--gold-light); letter-spacing: .12em; }
.thinking-note strong { font-weight: 400; color: #f0d6aa; }
.diagnosis-pane { min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 2px; scrollbar-color: #9b6a38 rgba(30, 15, 8, .7); }
.diagnosis-pane > section { flex: 0 0 auto; }
.clue-panel, .pattern-panel, .herb-panel { padding: 12px; }
.panel-heading { align-items: center; }
.panel-heading h2 { color: var(--paper-light); font-size: 17px; font-weight: 600; }
.compact-heading { margin-bottom: 8px; }
.small-hint { color: #a98363; font-size: 11px; }
.clue-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 11px 0 8px; }
.clue-tabs button { min-width: 0; padding: 7px 2px; color: #eac98f; background: rgba(45, 24, 13, .92); border: 1px solid #85582e; border-radius: 4px; }
.clue-tabs button:hover, .clue-tabs button.active { color: #fff1c6; background: #8c4735; border-color: #e5b86c; }
.clue-detail { min-height: 54px; max-height: 84px; overflow-y: auto; padding: 9px; color: var(--ink); background: var(--paper); border-radius: 5px; font-size: 12px; line-height: 1.6; scrollbar-color: #a37542 #e1c18c; }
.clue-detail strong { display: block; color: #8b4938; margin-bottom: 3px; }
.check-label { color: #c6a073; font-size: 11px; white-space: nowrap; }
.check-label input { accent-color: var(--gold); vertical-align: -1px; }
.search-input { width: 100%; padding: 7px 9px; font-size: 12px; }
.scroll-list { overflow-y: auto; border: 1px solid rgba(207, 161, 87, .25); border-radius: 5px; margin-top: 7px; padding: 4px; scrollbar-color: #9b6a38 rgba(30, 15, 8, .7); }
.pattern-list { max-height: 136px; }
.herb-list { max-height: 116px; }
.list-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: left; color: #ead1a3; background: transparent; border: 0; border-bottom: 1px solid rgba(207, 161, 87, .16); padding: 7px 6px; font-size: 12px; }
.list-button:last-child { border-bottom: 0; }
.list-button:hover, .list-button.selected { color: #fff2c9; background: rgba(168, 79, 59, .72); }
.list-button small { flex: 0 0 auto; color: #bd9872; font-size: 10px; }
.list-empty { color: #a98767; font-size: 11px; padding: 9px 5px; }
.selection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 9px; }
.selection-field { min-width: 0; }
.selection-label-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.selection-field .select-label { margin-top: 0; margin-bottom: 4px; }
.compact-search { padding: 6px 7px; font-size: 11px; }
.select-label { display: block; margin-top: 9px; margin-bottom: 4px; }
.select-input { width: 100%; padding: 7px 9px; font-size: 12px; }
.selection-field .select-input { padding: 7px 5px; font-size: 11px; }
.basket { min-height: 35px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; margin: 8px 0; padding: 6px; border: 1px dashed rgba(207, 161, 87, .4); border-radius: 5px; }
.basket-empty { color: #9e795b; font-size: 11px; }
.herb-chip { color: #f4ddb1; background: #704032; border: 1px solid #c48b4d; border-radius: 12px; padding: 3px 8px; font-size: 11px; }
.herb-chip:hover { background: #a74e3a; }
.submit-button { width: 100%; }
.archive-dialog { width: min(500px, calc(100vw - 30px)); color: var(--ink); background: var(--paper-light); border: 2px solid #9d6a36; border-radius: 8px; padding: 18px; box-shadow: 0 15px 50px #000; }
.archive-dialog::backdrop { background: rgba(0, 0, 0, .68); }
.archive-dialog .section-kicker { color: #a84f3b; }
.archive-dialog h2 { color: #5a3524; font-size: 20px; margin-top: 5px; }
.icon-button { color: #7f4934; border-color: #9d6a36; font-size: 20px; line-height: 1; padding: 2px 8px; }
.archive-content { margin-top: 16px; color: #5b3b28; font-size: 13px; line-height: 1.7; }
.archive-item { padding: 9px 0; border-top: 1px solid rgba(125, 79, 39, .24); }
.archive-item strong { color: #9b4d3a; }
.archive-attempt { padding: 7px 0; border-top: 1px solid rgba(125, 79, 39, .16); }
.archive-attempt:first-of-type { margin-top: 5px; }
.archive-attempt strong { color: #6e3f2f; }
.archive-attempt span { color: #795a43; font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 10; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; max-width: min(680px, calc(100vw - 30px)); color: #fff0c8; background: rgba(48, 23, 14, .95); border: 1px solid #d3a25a; border-radius: 6px; padding: 12px 16px; font-size: 13px; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.portrait-warning { display: none; }

@media (max-width: 1050px) {
  .topbar { padding: 7px 10px; gap: 8px; }
  .brand-block { min-width: 135px; }
  .brand { font-size: 20px; }
  .case-status { font-size: 11px; }
  .patient-switcher span { display: none; }
  .patient-switcher select { width: 126px; }
  .workspace { grid-template-columns: 155px minmax(315px, 1fr) 280px; gap: 8px; padding: 8px; }
  .portrait-frame { height: 188px; }
  .patient-pane { padding: 10px; }
  .message-text { font-size: 20px; }
  .dialogue-card { min-height: 180px; max-height: 40%; padding: 13px 16px 10px; }
}

/* 横屏手机：保留电脑端三栏玩法，只按可用空间等比例收窄。 */
@media (orientation: landscape) and (max-width: 920px) {
  .app-shell {
    min-width: 0;
    overflow: hidden;
  }

  .topbar {
    height: 44px;
    flex-basis: 44px;
    gap: 6px;
    padding: 4px 7px;
  }

  .brand-block,
  .case-status,
  .patient-switcher {
    min-width: 0;
  }

  .brand-block { flex: 0 0 auto; }
  .brand { font-size: 16px; letter-spacing: .12em; }
  .brand-subtitle,
  .case-status,
  .patient-switcher span { display: none; }
  .patient-switcher { margin-left: auto; }
  .patient-switcher select {
    width: clamp(92px, 15vw, 120px);
    padding: 5px 6px;
    font-size: 11px;
  }
  .topbar-button {
    flex: 0 0 auto;
    padding: 5px 7px;
    font-size: 11px;
    white-space: nowrap;
  }

  .workspace {
    grid-template-columns:
      minmax(clamp(94px, 19vw, 112px), clamp(110px, 20vw, 150px))
      minmax(clamp(205px, 35vw, 235px), 1fr)
      minmax(clamp(172px, 29vw, 190px), clamp(172px, 31vw, 285px));
    gap: clamp(4px, .7vw, 6px);
    padding: clamp(4px, .7vw, 6px);
    overflow: hidden;
  }

  .patient-pane { padding: clamp(6px, .9vw, 8px); }
  .portrait-frame {
    height: clamp(90px, 30vh, 145px);
    margin: 6px 0 7px;
  }
  .patient-pane h1 { font-size: 17px; }
  .patient-meta { font-size: 10px; }
  .patient-status { margin-top: 5px; padding: 2px 5px; font-size: 10px; }
  .complaint-box { margin-top: 8px; padding: 7px; }
  .complaint-box p { font-size: 11px; line-height: 1.4; }
  .patient-tip { display: none; }

  .dialogue-pane { gap: clamp(4px, .6vw, 5px); overflow: hidden; }
  .dialogue-card {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 9px 11px 8px;
  }
  .dialogue-card h2 { font-size: 17px; margin-top: 3px; }
  .page-counter { font-size: 11px; }
  .dialogue-message { padding: 6px 8px 6px; }
  .speaker { font-size: 12px; margin-bottom: 6px; }
  .message-text {
    font-size: clamp(15px, 2.4vw, 18px);
    line-height: 1.5;
    max-height: 4.5em;
  }
  .dialogue-controls { gap: 4px; padding-top: 6px; }
  .record-count { font-size: 10px; white-space: nowrap; }
  .dialogue-actions { gap: 4px; }
  .dialogue-actions button {
    padding: 6px 7px;
    font-size: 11px;
    white-space: nowrap;
  }
  .thinking-note {
    flex-basis: 30px;
    gap: 6px;
    padding: 0 8px;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
  }

  .diagnosis-pane { gap: clamp(4px, .7vw, 6px); padding-right: 0; }
  .clue-panel, .pattern-panel, .herb-panel { padding: clamp(6px, .9vw, 8px); }
  .panel-heading h2 { font-size: 14px; }
  .small-hint, .check-label { font-size: 10px; }
  .compact-heading { margin-bottom: 5px; }
  .clue-tabs { gap: 3px; margin: 6px 0 5px; }
  .clue-tabs button { padding: 5px 1px; font-size: 11px; }
  .clue-detail {
    min-height: 36px;
    max-height: clamp(42px, 14vh, 62px);
    padding: 6px;
    font-size: 10px;
    line-height: 1.45;
  }
  .search-input { padding: 5px 6px; font-size: 10px; }
  .scroll-list { margin-top: 5px; padding: 3px; }
  .pattern-list { max-height: clamp(78px, 24vh, 108px); }
  .herb-list { max-height: clamp(68px, 20vh, 94px); }
  .list-button { gap: 4px; padding: 5px 4px; font-size: 10px; }
  .list-button small { font-size: 9px; }
  .selection-grid { gap: 5px; margin-top: 6px; }
  .selection-field .select-label { margin-bottom: 3px; }
  .compact-search { padding: 4px 5px; font-size: 10px; }
  .selection-field .select-input { padding: 5px 4px; font-size: 10px; }
  .basket { min-height: 27px; gap: 3px; margin: 5px 0; padding: 4px; }
  .basket-empty { font-size: 10px; }
  .herb-chip { padding: 2px 5px; font-size: 10px; }
  .submit-button { padding: 7px 9px; font-size: 11px; }
}

@media (orientation: portrait) {
  .app-shell { display: none; }
  .portrait-warning { display: grid; place-items: center; height: 100%; color: #f2d49b; background: #21150f; font-size: 18px; }
}
