:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --text: #14211c;
  --muted: #65756f;
  --line: #dce7e2;
  --accent: #0d7f68;
  --accent-2: #f0a43a;
  --danger: #b94b45;
  --shadow: 0 20px 70px rgba(18, 41, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(13, 127, 104, 0.13), transparent 34%),
    linear-gradient(315deg, rgba(240, 164, 58, 0.18), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-rows: auto auto minmax(520px, 1fr) auto;
  align-content: start;
  gap: 6px;
}

.workspace:has(.history-panel.is-active) {
  grid-template-rows: auto auto auto auto;
}

.topbar,
.transcript-area,
.panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 231, 226, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 96px;
  display: block;
  border-radius: 8px;
  padding: 22px 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.08;
  font-weight: 760;
}

.topbar-copy {
  width: 100%;
  min-width: 0;
}

.topbar-title-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar-title-row h1 {
  min-width: 0;
  padding-top: 2px;
}

.topbar-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.document-switch {
  width: fit-content;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(13, 127, 104, 0.18);
  border-radius: 8px;
  background: #f8fbfa;
}

.document-control-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  margin-top: 16px;
}

.document-switch-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.document-switch-link:hover,
.document-switch-link:focus-visible {
  color: var(--accent);
  outline: none;
  background: rgba(13, 127, 104, 0.08);
}

.document-switch-link.is-active {
  color: #0b6c58;
  border-color: rgba(13, 127, 104, 0.22);
  background: #e9f6f0;
  box-shadow: inset 0 0 0 1px rgba(13, 127, 104, 0.06);
}

.status {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #93a39d;
}

.status-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.status[data-state="connecting"] .status-dot {
  background: var(--accent-2);
}

.status[data-state="active"] {
  color: #075746;
}

.status[data-state="active"] .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(13, 127, 104, 0.13);
}

.status[data-state="warning"] {
  color: #9a5b00;
}

.status[data-state="warning"] .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15);
}

.status[data-state="error"] {
  color: var(--danger);
}

.status[data-state="error"] .status-dot {
  background: var(--danger);
}

.control-strip {
  flex: 0 1 auto;
  min-width: min(100%, 540px);
  min-height: 0;
  display: grid;
  grid-template-columns: auto auto auto 132px;
  align-items: center;
  justify-content: end;
  gap: 10px;
  padding: 0;
  overflow-x: auto;
}

.tabbar {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 50px;
  min-height: 50px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0;
  margin-bottom: -1px;
  padding: 0 18px;
  border: 1px solid rgba(220, 231, 226, 0.92);
  border-bottom: 1px solid rgba(220, 231, 226, 0.92);
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.history-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: clamp(720px, 72vh, 1120px);
  min-height: 0;
  align-content: start;
  gap: 14px;
  padding: 18px 18px 16px;
  border: 1px solid rgba(220, 231, 226, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(220, 231, 226, 0.7);
}

.history-header div {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.history-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  margin-left: auto;
}

.history-actions .history-demo-button {
  min-width: 96px;
  width: 132px;
}

.history-demo-button {
  width: 132px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(13, 127, 104, 0.22);
  border-radius: 8px;
  background: #f4faf7;
  color: #143b33;
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
  white-space: nowrap;
  box-shadow: none;
}

.history-secondary-button {
  border-color: rgba(13, 127, 104, 0.22);
  background: #f4faf7;
  color: #143b33;
}

.history-danger-button {
  border-color: rgba(13, 127, 104, 0.22);
  background: #f4faf7;
  color: #143b33;
}

.history-demo-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.history-demo-button:hover:not(:disabled),
.history-demo-button:focus-visible:not(:disabled) {
  outline: none;
  border-color: rgba(13, 127, 104, 0.42);
  background: #e8f5ef;
  color: #0b6c58;
}

.history-header h2 {
  font-size: 18px;
  font-weight: 820;
  white-space: nowrap;
}

#currentTaskMeta {
  display: none;
}

.history-header span,
.history-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-content: start;
  gap: 12px;
  min-height: 0;
  max-height: clamp(500px, 58vh, 860px);
  overflow-y: auto;
  padding: 2px 6px 8px 2px;
  scrollbar-gutter: stable;
}

.history-section-title {
  grid-column: 1 / -1;
  margin: 4px 0 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 820;
}

.history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 70px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--text);
  text-align: left;
}

.history-select-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.history-item-main {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 1px 2px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-delete-button {
  align-self: center;
  width: 76px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(13, 127, 104, 0.22);
  border-radius: 8px;
  background: #f4faf7;
  color: #143b33;
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
}

.history-delete-button:hover,
.history-delete-button:focus-visible {
  outline: none;
  border-color: rgba(13, 127, 104, 0.42);
  background: #e8f5ef;
  color: #0b6c58;
}

.history-item.is-active {
  border-color: rgba(13, 127, 104, 0.55);
  box-shadow: 0 0 0 3px rgba(13, 127, 104, 0.1);
}

.history-item strong,
.history-item-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
  font-size: 13px;
  font-weight: 720;
  line-height: 1.26;
}

.history-item span,
.history-item-main span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.34;
}

.tab-button {
  position: relative;
  align-self: flex-end;
  height: 50px;
  min-width: 156px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-bottom-color: transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.tab-button:hover,
.tab-button:focus-visible {
  outline: none;
  background: rgba(244, 250, 247, 0.86);
  color: #0b6c58;
}

.tab-button.is-active {
  color: #0b6c58;
  border-color: rgba(220, 231, 226, 0.92);
  border-bottom-color: #ffffff;
  background: linear-gradient(180deg, #f4faf7 0%, #ffffff 72%);
  box-shadow: none;
}

.tab-button.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: rgba(13, 127, 104, 0.68);
}

.tab-panels {
  min-height: 520px;
}

.tabbar + .tab-panels {
  margin-top: -6px;
}

.tab-panels:has(.history-panel.is-active) {
  min-height: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
}

.tab-panels > .tab-panel.is-active {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.record-panel.tab-panel:not(.is-active),
.transcript-area.tab-panel:not(.is-active),
.history-panel.tab-panel:not(.is-active) {
  display: none;
}

.primary-button,
.continue-button,
.secondary-button,
.ghost-button {
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 18px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 720;
  white-space: nowrap;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 28px rgba(13, 127, 104, 0.22);
}

.secondary-button {
  color: #ffffff;
  background: #243b34;
}

.continue-button {
  color: #ffffff;
  border-color: #d77c08;
  background: #d77c08;
  box-shadow: 0 12px 28px rgba(215, 124, 8, 0.28);
}

.continue-button .button-icon {
  color: #ffffff;
}

.ghost-button {
  color: var(--text);
  border-color: var(--line);
  background: #ffffff;
}

.mode-control {
  height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.topbar-actions .mode-control {
  height: 46px;
  min-width: 230px;
  padding: 0 14px;
  gap: 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 780;
}

.mode-control select {
  min-width: 92px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.topbar-actions .mode-control select {
  min-width: 196px;
  font-size: 16px;
  font-weight: 780;
}

.asr-service-control select {
  min-width: 150px;
}

.primary-button:hover,
.continue-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.continue-button:not(:disabled):hover {
  border-color: #bf6900;
  background: #bf6900;
  box-shadow: 0 14px 32px rgba(215, 124, 8, 0.34);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.button-icon {
  width: 18px;
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
}

.meter {
  height: 18px;
  min-width: 96px;
  width: 132px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.meter-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width 90ms linear;
}

.transcript-area {
  min-height: 520px;
  border-radius: 8px;
  padding: 20px;
  display: grid;
  grid-template-rows: minmax(150px, auto) 1fr;
  gap: 16px;
}

.transcript-header,
.panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.transcript-area .transcript-header {
  min-height: 38px;
  align-items: center;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
  font-weight: 760;
}

.transcript-area .transcript-header h2 {
  color: var(--text);
  font-size: 16px;
  font-weight: 820;
  line-height: 1.25;
}

.transcript-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.transcript-area .transcript-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.record-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.reanalyze-button,
.save-record-button,
.import-record-button {
  width: 132px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(13, 127, 104, 0.22);
  border-radius: 8px;
  background: #f4faf7;
  color: #143b33;
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
  white-space: nowrap;
  box-shadow: none;
}

.reanalyze-button:hover,
.reanalyze-button:focus-visible,
.save-record-button:hover,
.save-record-button:focus-visible,
.import-record-button:hover,
.import-record-button:focus-visible {
  outline: none;
  border-color: rgba(13, 127, 104, 0.42);
  background: #e8f5ef;
  color: #0b6c58;
}

.reanalyze-button:disabled,
.save-record-button:disabled,
.import-record-button:disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: #eef5f2;
  color: #8a9a94;
  box-shadow: none;
}

.live-zone,
.result-zone {
  display: grid;
  gap: 12px;
}

.live-zone {
  align-content: start;
}

.live-text {
  min-height: 98px;
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--accent);
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.45;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.live-text:empty::before {
  content: "说话时，实时识别文本会显示在这里。";
  color: #9aa8a3;
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 620;
}

.live-terminology-hints {
  padding: 8px 12px;
  border: 1px solid #d8e7e1;
  border-radius: 8px;
  background: #f2faf6;
  color: #2c6b52;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.live-terminology-hints[hidden] {
  display: none;
}

.result-zone {
  min-height: 330px;
  grid-template-rows: auto auto 1fr;
}

.full-audio-tools {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d9e8e2;
  border-radius: 8px;
  background: #f7fbf9;
}

.full-audio-main {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
}

.full-audio-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
  white-space: nowrap;
}

.full-audio-main audio {
  width: 100%;
  min-width: 180px;
  height: 36px;
}

.full-audio-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.full-audio-actions .load-audio-button,
.full-audio-actions .reanalyze-button {
  min-height: 34px;
  font-size: 13px;
}

.segment-list {
  min-height: 300px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fbfa;
  border: 1px solid var(--line);
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: #9aa8a3;
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 560;
  text-align: center;
}

.segment-card {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segment-card-live {
  border-color: rgba(16, 132, 103, 0.32);
  background: #f5fbf8;
}

.segment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.segment-badge {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef6f2;
  color: var(--accent);
  font-size: 13px;
  font-weight: 820;
  text-align: center;
}

.segment-badge-live {
  background: rgba(13, 127, 104, 0.12);
}

.segment-time,
.segment-range {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
  text-align: right;
  overflow-wrap: anywhere;
}

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

.segment-card p,
.segment-text {
  color: var(--text);
  font-size: 18px;
  line-height: 1.55;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.segment-raw-text {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.segment-corrections {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 6px;
  background: #f4f7fb;
  color: #356078;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.segment-audio {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segment-audio::before {
  content: "原始录音";
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.segment-card-live .segment-audio::before {
  content: "实时文本";
  color: var(--accent);
}

.segment-audio:has(audio[data-tts-pending])::before {
  content: "合成语音";
}

.segment-audio:has(audio[data-audio-pending])::before {
  content: "原始录音";
}

.segment-audio[data-loading="true"]::after,
.dialog-evidence-audio[data-loading="true"]::after {
  content: attr(data-loading-label);
  color: var(--accent);
  font-size: 12px;
  font-weight: 760;
}

.segment-audio[data-loading="true"]:not([data-loading-label])::after,
.dialog-evidence-audio[data-loading="true"]:not([data-loading-label])::after {
  content: "正在加载";
}

.segment-live-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.load-audio-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #b8d8cc;
  border-radius: 8px;
  background: #eef8f4;
  color: #08765f;
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
}

.load-audio-button:hover:not(:disabled) {
  background: #dff3ec;
  border-color: #7fc5ae;
}

.load-audio-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.segment-audio-missing {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid #dbe6e2;
  border-radius: 8px;
  background: #f6f8f7;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.segment-card audio {
  width: 100%;
  height: 36px;
}

.record-panel {
  min-height: 520px;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  padding: 20px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(220, 231, 226, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.tab-panel:not(.is-active) {
  display: none !important;
}

.analysis-status {
  display: none;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.medical-record-sheet {
  overflow-x: auto;
  overflow-y: visible;
  display: grid;
  align-content: start;
  min-height: 760px;
  padding: 18px 38px 56px;
  border: 1px solid #d7d7d7;
  border-top: 5px solid #0d0d0d;
  border-radius: 2px;
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    #ffffff;
  color: #161616;
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  box-shadow: 0 12px 36px rgba(20, 33, 28, 0.08);
}

.medical-record-title {
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: center;
  font-size: 0;
  font-weight: 700;
}

.medical-record-meta-line {
  display: grid;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid #bcbcbc;
  line-height: 1.32;
}

.medical-record-meta-line.primary {
  grid-template-columns: minmax(310px, 0.95fr) minmax(310px, 1.05fr);
  min-height: 40px;
  font-size: 21px;
  font-weight: 700;
}

.medical-record-meta-line.patient {
  grid-template-columns: minmax(150px, 1.25fr) minmax(96px, 0.75fr) minmax(82px, 0.62fr) minmax(76px, 0.58fr) minmax(148px, 1.1fr);
  min-height: 40px;
  margin-bottom: 0;
  font-size: 17px;
}

.medical-record-meta-line label {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.medical-record-meta-line label span {
  flex: 0 0 auto;
}

.medical-record-meta-line input,
.medical-record-meta-line select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #161616;
  font: inherit;
  line-height: 1.25;
  padding: 0;
}

.medical-record-meta-line input[readonly] {
  cursor: pointer;
}

.medical-record-meta-line input::placeholder,
.medical-record-meta-line select:invalid,
.record-value::placeholder {
  color: #a8a8a8;
}

.medical-record-body {
  display: grid;
  border-top: 0;
}

.medical-record-row {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
  min-height: 42px;
  border-bottom: 1px solid #bcbcbc;
  padding-right: 36px;
}

.medical-record-row.quality-defaulted {
  background: #fff8db;
  box-shadow: inset 4px 0 0 #eab308;
}

.medical-record-row.quality-missing {
  background: #fff1f0;
  box-shadow: inset 4px 0 0 #d33b32;
}

.medical-record-row.quality-warning {
  background: #fff8db;
  box-shadow: inset 4px 0 0 #eab308;
}

body[data-module="outpatient"] .medical-record-row:is(
  [data-entity="presentIllness"],
  [data-entity="pastHistory"],
  [data-entity="familyHistory"],
  [data-entity="physicalExam"],
  [data-entity="diagnosis"],
  [data-entity="followUpAdvice"]
):is(.quality-defaulted, .quality-missing, .quality-warning) {
  background: transparent;
  box-shadow: none;
}

.entity-segment-list {
  grid-column: 2 / 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  padding: 0 0 8px;
}

.entity-segment {
  display: inline-grid;
  grid-template-columns: auto auto minmax(42px, max-content);
  gap: 5px;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #d8dfdc;
  border-radius: 6px;
  background: #ffffff;
  color: #23312d;
  font: inherit;
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.entity-segment:hover {
  border-color: rgba(13, 127, 104, 0.35);
  box-shadow: 0 1px 4px rgba(28, 52, 45, 0.08);
}

.entity-segment-label {
  font-weight: 700;
}

.entity-segment-meta {
  color: #5e6b66;
  font-size: 11px;
  white-space: nowrap;
}

.entity-segment-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-segment.source-asr {
  background: #fff8db;
  border-color: #ead27a;
}

.entity-segment.source-fact {
  background: #ffffff;
  border-color: #cfd8d4;
}

.entity-segment.source-inferred {
  background: #eaf3ff;
  border-color: #b8d7ff;
}

.entity-segment.source-default,
.entity-segment.source-missing {
  background: #fff1f0;
  border-color: #f2b8b5;
}

.entity-segment.source-not_applicable {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #5f6873;
}

.entity-segment.source-low_confidence {
  background: #fff3e0;
  border-color: #f3bf75;
}

.medical-record-row.has-rich-text .record-value {
  display: none;
}

.record-rich-text {
  grid-column: 2 / 3;
  min-height: 40px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #161616;
  font: inherit;
  font-size: 17px;
  line-height: 1.72;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: text;
  content-visibility: auto;
  contain-intrinsic-size: 48px;
}

.record-rich-text:focus {
  outline: none;
  border-color: rgba(13, 127, 104, 0.45);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(13, 127, 104, 0.18);
}

.record-rich-text.is-lazy {
  color: #202826;
  background: rgba(255, 255, 255, 0.36);
}

.entity-text {
  display: inline;
  max-width: 100%;
  margin: 0 2px 0 0;
  padding: 1px 3px 2px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
  text-align: left;
  text-decoration: none;
  cursor: text;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.entity-text:hover,
.entity-text:focus-visible {
  outline: 1px solid rgba(13, 127, 104, 0.38);
  outline-offset: 1px;
}

.entity-text.tone-white {
  background: rgba(255, 255, 255, 0.72);
}

.entity-text.tone-yellow {
  background: #fff2a8;
}

.entity-text.tone-red {
  background: #ffd8d6;
}

.medical-record-row.compact {
  min-height: 42px;
}

.medical-record-row.tall {
  min-height: 78px;
}

.medical-record-row.prescription {
  min-height: 80px;
}

.medical-record-row.follow-up {
  min-height: 78px;
  margin-top: 22px;
}

.record-row-label {
  padding-top: 10px;
  color: #111111;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.record-value {
  width: 100%;
  min-height: 40px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: #161616;
  font: inherit;
  font-size: 17px;
  line-height: 1.58;
  padding: 7px 0 7px;
  overflow: hidden;
  field-sizing: content;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.medical-record-row.tall .record-value {
  min-height: 76px;
}

.medical-record-row.follow-up .record-value {
  min-height: 76px;
}

.ward-round-shell .tab-button {
  min-width: 180px;
}

.ward-round-sheet {
  min-height: 760px;
  padding: 34px 52px 42px;
  border: 1px solid #d7d7d7;
  border-radius: 2px;
  background: #fff;
  color: #111;
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  box-shadow: 0 12px 36px rgba(20, 33, 28, 0.08);
}

.ward-round-title-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(160px, 1fr);
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
  text-align: center;
}

.ward-round-title-row input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  font: inherit;
  font-size: 18px;
  text-align: right;
}

.ward-round-title-row strong {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.2;
}

.ward-round-meta-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(120px, 0.8fr));
  gap: 16px;
  min-height: 36px;
  align-items: center;
  border-bottom: 1px solid #c8c8c8;
  font-size: 16px;
}

.ward-round-meta-row label,
.ward-round-signature label {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.ward-round-meta-row input,
.ward-round-signature input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  font: inherit;
}

.ward-round-main-record {
  min-height: 260px;
  border-bottom: 1px solid #c8c8c8;
  padding: 14px 0 18px;
}

.ward-round-field-head,
.ward-round-entity header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #111;
  font-size: 16px;
  font-weight: 800;
}

.ward-round-narrative {
  min-height: 210px;
  padding: 8px 0 0;
  font-size: 19px;
  line-height: 1.72;
  text-indent: 2em;
}

.ward-round-entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid #c8c8c8;
  margin-top: 22px;
}

.ward-round-entity {
  min-height: 104px;
  border-right: 1px solid #c8c8c8;
  border-bottom: 1px solid #c8c8c8;
  padding: 10px 12px;
}

.ward-round-entity:nth-child(2n) {
  border-right: 0;
}

.ward-round-entity.span-full {
  grid-column: 1 / -1;
  border-right: 0;
}

.ward-round-entity .record-value {
  min-height: 66px;
  padding: 7px 0 0;
  font-size: 16px;
  line-height: 1.5;
}

.ward-round-signature {
  display: flex;
  justify-content: flex-end;
  margin-top: 34px;
  font-size: 18px;
}

.ward-round-signature label {
  width: 240px;
}

.surgery-record-shell .tab-button {
  min-width: 180px;
}

.surgery-record-sheet {
  min-height: 760px;
  padding: 26px 42px 42px;
  border: 1px solid #d7d7d7;
  border-radius: 2px;
  background: #fff;
  color: #111;
  font-family: "Songti SC", SimSun, "Noto Serif CJK SC", serif;
  box-shadow: 0 12px 36px rgba(20, 33, 28, 0.08);
}

.surgery-record-title-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
  text-align: center;
}

.surgery-record-title-row strong {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.surgery-record-title-row input,
.surgery-record-meta-row input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #111;
  font: inherit;
}

.surgery-record-title-row input {
  font-size: 16px;
  text-align: right;
}

.surgery-record-meta-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 12px;
  min-height: 34px;
  align-items: center;
  border-bottom: 1px solid #c8c8c8;
  font-size: 14px;
}

.surgery-record-meta-row label {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  white-space: nowrap;
}

.surgery-record-entity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid #c8c8c8;
  margin-top: 16px;
}

.surgery-record-entity,
.surgery-record-main-record {
  border-right: 1px solid #c8c8c8;
  border-bottom: 1px solid #c8c8c8;
  padding: 9px 12px;
}

.surgery-record-entity:nth-child(2n) {
  border-right: 0;
}

.surgery-record-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #111;
  font-size: 15px;
  font-weight: 800;
}

.surgery-record-entity .record-value {
  min-height: 56px;
  padding: 6px 0 0;
  font-size: 15px;
  line-height: 1.46;
}

.surgery-record-main-record {
  border-right: 0;
  margin-top: 16px;
  padding: 12px;
}

.surgery-record-narrative {
  min-height: 190px;
  padding: 8px 0 0;
  font-size: 16px;
  line-height: 1.68;
  text-indent: 2em;
}

.surgery-record-signers {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-top: 18px;
}

.entity-detail-button {
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #c8ddeb;
  border-radius: 999px;
  background: #f3f9fd;
  color: #4b7894;
  cursor: pointer;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.medical-record-row > .entity-detail-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

.entity-detail-button:hover {
  border-color: #9cc7df;
  background: #e8f5fc;
  color: #2f6f95;
}

.entity-detail-button.has-quality-note {
  min-width: 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-color: #c8ddeb;
  background: #f3f9fd;
  color: #4b7894;
  font-size: 13px;
}

.medical-record-row.quality-missing .entity-detail-button.has-quality-note {
  border-color: #c8ddeb;
  background: #f3f9fd;
  color: #4b7894;
}

.dialog-quality-card {
  border-color: rgba(214, 164, 0, 0.35);
  background: #fff8db;
  color: #4f3b00;
}

.dialog-quality-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.dialog-quality-card ul {
  margin: 0;
  padding-left: 18px;
}

.dialog-quality-card li {
  margin: 3px 0;
}

.entity-hidden-fields {
  display: none;
}

dialog:not([open]) {
  display: none;
}

.entity-dialog {
  width: min(720px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(18, 41, 34, 0.28);
}

.entity-dialog[open],
.patient-picker-dialog[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 1000;
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
}

.patient-picker-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: transparent;
}

.patient-picker-dialog::backdrop {
  background: rgba(12, 23, 20, 0.34);
  backdrop-filter: blur(3px);
}

.patient-picker-content {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(220, 231, 226, 0.96);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(18, 41, 34, 0.22);
}

.patient-picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.patient-picker-header h2 {
  font-size: 22px;
  font-weight: 800;
}

.patient-picker-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.patient-picker-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: min(62vh, 560px);
  overflow: auto;
}

.patient-picker-item {
  min-height: 92px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name tag"
    "meta meta"
    "no no";
  gap: 6px 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.patient-picker-item:hover,
.patient-picker-item:focus-visible {
  outline: none;
  border-color: rgba(13, 127, 104, 0.42);
  background: #f1f8f5;
  box-shadow: 0 8px 22px rgba(13, 127, 104, 0.12);
}

.patient-picker-main {
  grid-area: name;
  font-size: 18px;
  font-weight: 820;
}

.patient-picker-meta {
  grid-area: meta;
  color: #33423d;
  font-size: 14px;
  font-weight: 650;
}

.patient-picker-tag {
  grid-area: tag;
  align-self: start;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(13, 127, 104, 0.1);
  color: #08624f;
  font-size: 12px;
  font-weight: 760;
}

.patient-picker-no {
  grid-area: no;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.entity-dialog::backdrop {
  background: rgba(20, 33, 28, 0.36);
}

.entity-dialog-content {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.entity-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.dialog-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.entity-dialog label {
  display: grid;
  gap: 8px;
}

.entity-dialog label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.dialog-segment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2px;
}

.dialog-segment-meta-item {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbfa;
  color: #33423d;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.2;
}

.dialog-segment-meta-item.tone-white {
  background: #ffffff;
}

.dialog-segment-meta-item.tone-yellow {
  border-color: #e6cf63;
  background: #fff5bf;
}

.dialog-segment-meta-item.tone-red {
  border-color: #e6a09d;
  background: #ffe1df;
}

.entity-dialog textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fbfa;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  outline: 0;
}

.dialog-evidence-raw {
  display: none;
}

.dialog-evidence-list {
  display: grid;
  gap: 10px;
  max-height: min(42vh, 420px);
  overflow: auto;
}

.entity-dialog-content.is-entity-list label:first-of-type {
  display: none;
}

.entity-dialog-content.is-entity-list .dialog-evidence-list {
  max-height: min(66vh, 640px);
}

.entity-detail-summary {
  padding: 12px;
  border: 1px solid rgba(13, 127, 104, 0.18);
  border-radius: 8px;
  background: #f4fbf8;
}

.entity-detail-summary p {
  margin: 0;
  color: #2d3b36;
  font-size: 14px;
  line-height: 1.55;
}

.entity-inline-result {
  margin: 0;
  color: #263631;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.entity-inline-name {
  display: inline;
  color: #1f2c28;
  font-weight: 860;
}

.field-entity-detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field-entity-detail-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 104px;
  padding: 12px;
  border: 1px solid #dbe5e1;
  border-radius: 8px;
  background: #ffffff;
  content-visibility: auto;
  contain-intrinsic-size: 128px;
}

.field-entity-detail-card.status-missing {
  border-color: #efbbb5;
  background: #fff8f7;
}

.field-entity-detail-card.status-defaulted {
  border-color: #ead27a;
  background: #fffaf0;
}

.field-entity-detail-card.status-not_applicable {
  background: #f6f7f8;
  color: #5f6873;
}

.field-entity-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.field-entity-detail-header strong {
  min-width: 0;
  color: #1f2c28;
  font-size: 15px;
  font-weight: 840;
  line-height: 1.25;
}

.field-entity-detail-badges {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.field-entity-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef3f1;
  color: #4d5d57;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.field-entity-badge.status-passed,
.field-entity-badge.source-asr {
  background: #e9f7f1;
  color: #087050;
}

.field-entity-badge.status-missing {
  background: #fff1f0;
  color: #b42318;
}

.field-entity-badge.status-defaulted,
.field-entity-badge.source-default {
  background: #fff4cc;
  color: #8a5a00;
}

.field-entity-badge.status-not_applicable,
.field-entity-badge.optional {
  background: #f0f2f3;
  color: #66717a;
}

.field-entity-badge.required {
  background: #edf7ff;
  color: #16588b;
}

.field-entity-result,
.field-entity-note {
  margin: 0;
  color: #263631;
  font-size: 14px;
  font-weight: 680;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.field-entity-note {
  color: #697873;
  font-size: 12px;
  font-weight: 650;
}

.field-entity-evidence {
  display: grid;
  gap: 5px;
}

.field-entity-evidence span {
  padding: 7px 8px;
  border-radius: 6px;
  background: #f6f8f7;
  color: #566661;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.field-entity-detail-actions {
  align-self: end;
}

.field-entity-detail-actions button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(13, 127, 104, 0.24);
  border-radius: 6px;
  background: #f4fbf8;
  color: #0b6f5a;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.field-entity-detail-actions button:disabled {
  cursor: not-allowed;
  border-color: #dbe2df;
  background: #f5f7f6;
  color: #9aa6a1;
}

.dialog-evidence-card {
  content-visibility: auto;
  contain-intrinsic-size: 112px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.dialog-evidence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-evidence-header span {
  min-width: 52px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #eef6f2;
  color: var(--accent);
  font-size: 12px;
  font-weight: 820;
  text-align: center;
}

.dialog-evidence-header time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.dialog-evidence-card p {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.dialog-evidence-corrected {
  padding: 8px 10px;
  border-radius: 6px;
  background: #f4fbf8;
}

.dialog-evidence-raw-text {
  padding: 8px 10px;
  border-radius: 6px;
  background: #f7f8fa;
  color: var(--muted) !important;
}

.dialog-evidence-audio {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.dialog-evidence-audio > span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.dialog-evidence-audio audio {
  width: 100%;
  height: 34px;
}

.dialog-evidence-missing,
.dialog-evidence-empty {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.record-value:focus,
.medical-record-meta-line input:focus,
.medical-record-meta-line select:focus {
  border-color: rgba(13, 127, 104, 0.6);
  box-shadow: inset 0 -2px 0 rgba(13, 127, 104, 0.45);
}

.medical-record-meta-line label.is-required-missing {
  color: #b42318;
}

.medical-record-meta-line label.is-required-missing input,
.medical-record-meta-line label.is-required-missing select {
  box-shadow: inset 0 -2px 0 #d33b32;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1.15fr);
  gap: 18px;
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

dl {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

dl div {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: baseline;
}

dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.log-panel {
  min-height: 160px;
}

.log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.log-header h2 {
  margin-bottom: 4px;
}

.log-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.log-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.log-actions button {
  height: 30px;
  border: 1px solid rgba(46, 125, 90, 0.22);
  border-radius: 6px;
  background: #f4fbf7;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.diagnostic-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.diagnostic-summary span {
  min-width: 0;
  border: 1px solid rgba(220, 231, 226, 0.9);
  border-radius: 6px;
  background: #f8fbf9;
  padding: 7px 8px;
  color: #2d4f3d;
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diagnostic-summary span[data-level="error"] {
  border-color: rgba(183, 28, 28, 0.2);
  background: #fff6f6;
  color: var(--danger);
}

.log {
  max-height: 220px;
  overflow: auto;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.log li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(220, 231, 226, 0.7);
  overflow-wrap: anywhere;
}

.log li[data-level="error"] {
  color: var(--danger);
  font-weight: 750;
}

.log li[data-level="warn"] {
  color: #956400;
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 1120px);
    padding: 10px 0;
  }

  .workspace {
    min-height: calc(100vh - 20px);
    gap: 6px;
  }

  .topbar {
    padding: 18px;
  }

  .topbar-title-row {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .topbar-actions {
    width: 100%;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .topbar-actions .mode-control {
    flex: 1 1 auto;
    min-width: 0;
  }

  .topbar-actions .status {
    flex: 0 0 28px;
    width: 28px;
    min-width: 28px;
  }

  .document-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .document-control-row {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .document-switch-link {
    min-width: 0;
    padding: 0 8px;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .history-header {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .history-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .history-actions .history-demo-button {
    flex: 1 1 128px;
  }

  .log-header {
    flex-direction: column;
  }

  .log-actions {
    width: 100%;
  }

  .log-actions button {
    flex: 1;
  }

  .diagnostic-summary {
    grid-template-columns: 1fr;
  }

  .transcript-header,
  .panel h2 {
    align-items: flex-start;
    flex-direction: column;
  }

  .record-header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .record-header-actions .import-record-button,
  .record-header-actions .save-record-button,
  .record-header-actions .reanalyze-button {
    flex: 1 1 calc(50% - 6px);
    min-width: 132px;
  }

  .history-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .control-strip {
    width: 100%;
    min-width: 0;
    grid-template-columns: 1fr 1fr;
  }

  .medical-record-sheet {
    min-height: 680px;
    padding: 14px 16px 28px;
  }

  .medical-record-meta-line.primary,
  .medical-record-meta-line.patient {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: 0;
    padding: 8px 0;
    font-size: 17px;
  }

  .medical-record-meta-line.patient {
    font-size: 15px;
  }

  .medical-record-meta-line label {
    white-space: normal;
  }

  .medical-record-row {
    grid-template-columns: 84px minmax(0, 1fr);
    min-height: 40px;
    padding-right: 30px;
  }

  .medical-record-row.tall,
  .medical-record-row.prescription,
  .medical-record-row.follow-up {
    min-height: 86px;
  }

  .medical-record-row.follow-up {
    margin-top: 28px;
  }

  .field-entity-detail-list {
    grid-template-columns: 1fr;
  }

  .field-entity-detail-header {
    flex-direction: column;
  }

  .field-entity-detail-badges {
    justify-content: flex-start;
  }

  .record-row-label {
    padding-top: 9px;
    font-size: 16px;
  }

  .record-value {
    min-height: 38px;
    font-size: 16px;
    line-height: 1.42;
    padding-top: 8px;
  }

  .medical-record-row.tall .record-value,
  .medical-record-row.follow-up .record-value {
    min-height: 84px;
  }

  .medical-record-row > .entity-detail-button {
    top: 8px;
    right: 6px;
    width: 24px;
    min-width: 24px;
    font-size: 10px;
  }

  .tabbar {
    height: auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .tab-button {
    width: 100%;
    min-width: 0;
  }

  .segment-card {
    grid-template-columns: 1fr;
  }

  .segment-audio {
    align-items: flex-start;
    flex-direction: column;
  }

  .meter {
    grid-column: 1 / -1;
    width: 100%;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }
}
