:root {
  --bg: #f6f8f6;
  --surface: #ffffff;
  --surface-strong: #edf3f0;
  --text: #182425;
  --muted: #5c6c6d;
  --line: #d9e1de;
  --doctor-primary: #008c95;
  --doctor-primary-dark: #007983;
  --doctor-primary-light: #e7f7f7;
  --doctor-accent-bg: #dff4f4;
  --patient-primary: #f45f52;
  --patient-primary-dark: #e64f45;
  --patient-primary-light: #fdeae7;
  --patient-accent-bg: #fde4e0;
  --teal: var(--doctor-primary);
  --teal-dark: var(--doctor-primary-dark);
  --coral: var(--patient-primary);
  --coral-dark: var(--patient-primary-dark);
  --gold: #ab7a18;
  --blue: #2f5f83;
  --shadow: 0 16px 42px rgba(34, 50, 64, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  color: white;
  background: #183234;
}

.app-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px clamp(16px, 4vw, 40px) 0;
}

.nav-item {
  min-height: 44px;
  border-radius: 8px;
  color: var(--muted);
  background: #e9efed;
  font-weight: 700;
}

.nav-item.is-active {
  color: white;
  background: var(--teal);
}

.eyebrow {
  margin: 0 0 4px;
  color: #b7d4cd;
  font-size: 13px;
}

.build-badge {
  margin-top: 6px;
  color: #d7f2ec;
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  color: #073b3d;
  background: #d7f2ec;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.muted {
  color: #263a3c;
  background: #e4e8e5;
}

.status-pill.warn {
  color: #583b00;
  background: #fff0c7;
}

.app-pages {
  padding: 18px clamp(16px, 4vw, 40px) 28px;
}

.page-section {
  display: none;
}

.page-section.is-active {
  display: block;
}

.page-section[data-page="translate"] > .setup-panel {
  display: none;
}

.setup-panel,
.translator-panel,
.records-band {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

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

.translator-focus {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  position: relative;
  max-width: 1280px;
  height: calc(100dvh - 210px);
  min-height: 620px;
  margin: 0 auto;
  padding: clamp(14px, 2vw, 22px);
}

.translator-focus > .section-heading,
.translator-focus > .prominent-log {
  display: none;
}

.records-band {
  margin: 0 0 18px;
  border-radius: 8px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

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

.hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: #324849;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfb;
  outline: 0;
}

input {
  height: 44px;
  padding: 0 12px;
}

select {
  height: 44px;
  padding: 0 12px;
}

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

.current-speech textarea {
  min-height: 84px;
  resize: none;
  padding: 0;
  border: 0;
  color: #101c1d;
  background: transparent;
  box-shadow: none;
  overflow-y: auto;
  white-space: pre-wrap;
}

.current-speech textarea:focus {
  border: 0;
  box-shadow: none;
}

.current-speech.source-primary #sourceDraft,
.current-speech.translation-primary #translationDraft {
  order: 2;
  min-height: 1.35em;
  color: #082f31;
  font-size: clamp(38px, 5vw, 68px);
  font-weight: 800;
  line-height: 1.15;
}

.current-speech.source-primary #translationDraft,
.current-speech.translation-primary #sourceDraft {
  order: 3;
  min-height: 1.25em;
  color: #5f7072;
  font-size: clamp(20px, 2.5vw, 32px);
  font-weight: 650;
  line-height: 1.22;
}

.current-speech .lyric-speaker {
  order: 1;
}

.current-speech .auto-save-note {
  order: 4;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 93, 94, 0.12);
}

.primary-command,
.secondary-command,
.text-command,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.primary-command {
  padding: 0 16px;
  color: white;
  background: var(--teal);
}

.primary-command:hover:not(:disabled) {
  background: var(--teal-dark);
}

.secondary-command {
  padding: 0 14px;
  color: var(--teal-dark);
  background: var(--surface-strong);
}

.secondary-command:hover:not(:disabled) {
  background: #dce9e4;
}

.text-command {
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  color: var(--teal);
  background: var(--surface-strong);
}

.icon-button svg,
.talk-button svg,
.turn-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.session-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.session-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfb;
  text-align: left;
}

.session-item.active {
  border-color: var(--teal);
  background: #eef8f5;
}

.session-item strong {
  font-size: 15px;
}

.session-item span {
  color: var(--muted);
  font-size: 13px;
}

.talk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.translation-stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  position: relative;
  padding: clamp(16px, 2.4vw, 28px);
  border: 1px solid #b7d8cf;
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.stage-history {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  border: 1px solid #e2e9e6;
  border-radius: 8px;
  background: #fbfcfb;
  overflow: hidden;
}

.stage-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.stage-history-head span {
  color: var(--text);
  font-weight: 700;
}

.live-history {
  align-content: start;
  gap: 6px;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.lyrics-flow {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vw, 20px);
  min-height: 0;
  padding: clamp(78px, 18vh, 170px) 6px clamp(160px, 45vh, 360px) 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  scroll-padding-block: 28% 45%;
}

.lyrics-flow::before {
  display: none;
}

.lyrics-flow::after {
  display: none;
}

.current-speech {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  max-height: none;
  min-height: 0;
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: visible;
}

.lyric-line {
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 8px;
}

.lyric-past,
.subtitle-line.is-past {
  color: #687778;
  background: transparent;
  opacity: 0.52;
}

.lyric-past.is-current,
.subtitle-line.is-current {
  opacity: 1;
  background: transparent;
}

.lyric-past.is-live-draft,
.subtitle-line.is-live-draft {
  opacity: 1;
  background: transparent;
  box-shadow: none;
}

.lyric-past:not(.is-current):not(.is-live-draft) .lyric-primary,
.subtitle-line.is-past .lyric-primary {
  color: #6f7d7e;
  font-size: clamp(18px, 2.4vw, 34px);
}

.lyric-past:not(.is-current):not(.is-live-draft) .lyric-secondary,
.subtitle-line.is-past .lyric-secondary {
  color: #97a3a4;
  font-size: clamp(14px, 1.7vw, 21px);
}

.lyric-speaker {
  color: #314849;
  font-size: clamp(15px, 1.8vw, 20px);
  font-weight: 800;
}

.lyric-primary {
  color: #102426;
  font-size: clamp(34px, 4.8vw, 70px);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.lyric-text-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.22em;
}

.lyric-line-label,
.patient-line-label {
  font: inherit;
  font-weight: 800;
  color: inherit;
}

.lyric-text-line .token-row {
  display: inline;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 0;
}

.lyric-secondary {
  color: #607173;
  font-size: clamp(22px, 2.8vw, 38px);
  font-weight: 650;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.lyric-primary .token,
.lyric-secondary .token {
  display: inline;
  margin: 0 0.26em 0 0;
  padding: 0;
  border-radius: 0;
  font: inherit;
  line-height: inherit;
  vertical-align: baseline;
}

.lyrics-flow .turn-actions {
  display: none;
}

.lyric-primary .token {
  color: #102426;
  background: transparent;
}

.lyric-secondary .token {
  color: #607173;
  background: transparent;
}

.talk-button {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "icon label"
    "icon hint";
  align-items: center;
  gap: 2px 10px;
  min-height: 74px;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  box-shadow: var(--shadow);
  text-align: left;
  user-select: none;
  touch-action: none;
}

.talk-button svg {
  grid-area: icon;
}

.talk-button span {
  grid-area: label;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.talk-button small {
  grid-area: hint;
  font-size: 14px;
  opacity: 0.86;
  overflow-wrap: anywhere;
}

.talk-button.doctor {
  background: var(--teal);
}

.talk-button.patient {
  background: var(--coral);
}

.talk-button.is-recording {
  transform: scale(0.985);
  box-shadow: 0 0 0 5px rgba(171, 122, 24, 0.18);
}

.live-region {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 0;
}

.live-column {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.column-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.action-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  align-items: stretch;
  gap: 10px;
  margin-top: 14px;
  position: relative;
  z-index: 2;
  padding-top: 10px;
  background: var(--surface);
}

.compact-command,
.text-command {
  align-self: center;
  min-height: 40px;
}

.hidden-control {
  display: none !important;
}

.subtitle-new-message {
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 3vh, 34px);
  z-index: 6;
  display: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: white;
  background: var(--teal);
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.subtitle-new-message.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auto-save-note {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.main-record-button {
  min-height: 104px;
  justify-content: center;
}

.main-record-button svg {
  width: 28px;
  height: 28px;
}

.confirm-translate {
  min-height: 104px;
  font-size: 22px;
  font-weight: 800;
}

.mine-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.patient-display-actions,
.device-routing-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.translator-focus > .patient-display-actions {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 4;
  opacity: 1;
}

.patient-display-actions {
  margin: -6px 0 12px;
}

.device-routing-panel {
  align-items: end;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.device-routing-panel label {
  flex: 1 1 220px;
}

.compact-metrics {
  grid-template-columns: repeat(4, minmax(100px, 1fr)) auto;
}

.manual-test-panel {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #ffdf9e;
  border-radius: 8px;
  color: #513600;
  background: #fff7df;
}

.manual-test-panel span {
  font-size: 13px;
}

.realtime-test-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr)) auto auto;
  gap: 8px;
  align-items: stretch;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-strong);
}

.metric-item span {
  color: var(--muted);
  font-size: 12px;
}

.metric-item strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.device-check-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.device-check-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfb;
}

.device-check-item strong {
  min-width: 108px;
  font-size: 14px;
}

.device-check-item span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.device-check-item.ok {
  border-color: #bdded4;
  background: #eef8f5;
}

.device-check-item.warn {
  border-color: #ead6a4;
  background: #fff8e7;
}

.event-log {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.prominent-log {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #d7e7e2;
  border-radius: 8px;
  color: #0a4244;
  background: #f6fbf9;
  font-weight: 600;
  font-size: 12px;
}

.turn-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.empty-state.compact {
  min-height: 72px;
}

.turn-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #fbfcfb;
}

.live-history .turn-card {
  gap: 6px;
  padding: 8px 10px;
  border-left-width: 3px;
  box-shadow: none;
}

.live-history .turn-card:last-child {
  border-color: #9bcac0;
  background: #eef8f5;
}

.live-history .turn-card.patient:last-child {
  border-color: #ddb2ad;
  background: #fff3f1;
}

.live-history .turn-meta {
  gap: 6px;
  font-size: 11px;
}

.live-history .turn-body {
  gap: 6px;
}

.live-history .turn-text h3 {
  font-size: 11px;
}

.live-history .token {
  padding: 3px 5px;
  font-size: 13px;
  line-height: 1.25;
}

.live-history .turn-actions {
  display: none;
}

.live-history .latency-badge {
  display: none;
}

.turn-card.patient {
  border-left-color: var(--coral);
}

.turn-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.risk-badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #513600;
  background: #ffedbd;
}

.latency-badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #0a4244;
  background: #d7f2ec;
}

.turn-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.turn-text {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.turn-text h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: flex-start;
}

.token {
  max-width: 100%;
  padding: 5px 7px;
  border-radius: 6px;
  color: var(--text);
  background: #eef3f1;
  overflow-wrap: anywhere;
}

.token:hover {
  background: #dbeae5;
}

.turn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.turn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--blue);
  background: #edf4f8;
}

.history-search-grid {
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(140px, 180px) minmax(130px, 160px) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.history-summary {
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.history-results {
  display: grid;
  gap: 10px;
}

.history-result {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfb;
  text-align: left;
}

.history-result.report {
  border-left-color: var(--gold);
}

.history-result:hover {
  border-color: var(--teal);
  background: #eef8f5;
}

.history-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.history-result small,
.history-result p {
  color: var(--muted);
  font-size: 13px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.backup-list {
  display: grid;
  gap: 10px;
}

.backup-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.backup-item span {
  color: var(--muted);
  font-size: 13px;
}

.backup-item a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--teal-dark);
  background: var(--surface-strong);
  text-decoration: none;
}

.glossary-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.glossary-form {
  display: grid;
  align-content: start;
  gap: 12px;
}

.glossary-form textarea {
  min-height: 96px;
}

.glossary-list {
  display: grid;
  gap: 10px;
}

.glossary-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.glossary-item.inactive {
  opacity: 0.55;
}

.glossary-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.glossary-item small {
  color: var(--muted);
}

.report-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 14px;
}

.report-form,
.report-texts {
  display: grid;
  align-content: start;
  gap: 12px;
}

.report-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

.report-thumb {
  display: grid;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.report-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.report-thumb span {
  color: var(--muted);
  font-size: 12px;
}

.report-list {
  display: grid;
  gap: 10px;
}

.report-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.report-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.report-card-header small,
.report-card p {
  color: var(--muted);
  font-size: 13px;
}

.report-image-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.report-image-strip img {
  width: 88px;
  height: 66px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.backoffice-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 14px;
}

.backoffice-search {
  display: grid;
  align-content: start;
  gap: 10px;
}

.patient-list {
  display: grid;
  gap: 8px;
}

.patient-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.patient-item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfb;
  text-align: left;
}

.patient-item:hover,
.patient-item.active {
  border-color: var(--teal);
  background: #eef8f5;
}

.keyword-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.patient-follow-up-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #143b3c;
  background: #dceee9;
  font-size: 13px;
}

.follow-up-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #263a3c;
  background: #eef3f1;
  font-size: 13px;
}

.recovery-improving,
.due-upcoming {
  color: #0a4244;
  background: #d7f2ec;
}

.recovery-stable,
.recovery-recovered {
  color: #143b3c;
  background: #dceee9;
}

.recovery-worse,
.recovery-needs_review,
.due-overdue {
  color: #6d201f;
  background: #f5dddd;
}

.due-today {
  color: #513600;
  background: #ffedbd;
}

.keyword-button {
  cursor: pointer;
}

.keyword-button:hover {
  background: #cbe5dc;
}

.matched-keywords .keyword-chip {
  color: #513600;
  background: #ffedbd;
}

.keyword-compare-panel,
.keyword-comparison,
.comparison-list {
  display: grid;
  gap: 10px;
}

.keyword-compare-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.comparison-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.comparison-summary {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
}

.comparison-summary span,
.comparison-card small,
.comparison-note span,
.comparison-turns small {
  color: var(--muted);
  font-size: 13px;
}

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

.comparison-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.text-link {
  min-height: auto;
  padding: 0;
  color: var(--teal-dark);
  background: transparent;
  font-weight: 700;
  text-align: left;
}

.text-link:hover {
  text-decoration: underline;
}

.comparison-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.comparison-stats span {
  padding: 4px 7px;
  border-radius: 6px;
  color: #263a3c;
  background: #eef3f1;
  font-size: 12px;
}

.comparison-note,
.comparison-turns {
  display: grid;
  gap: 4px;
  padding: 9px;
  border-radius: 8px;
  background: white;
}

.comparison-actions {
  padding-top: 2px;
}

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

.patient-detail-card {
  display: grid;
  gap: 14px;
}

.patient-summary {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.patient-summary dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.patient-summary dt {
  color: var(--muted);
  font-size: 12px;
}

.patient-summary dd {
  margin: 3px 0 0;
  font-weight: 700;
}

.patient-history {
  display: grid;
  gap: 8px;
}

.history-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.history-row small {
  color: var(--muted);
}

.plan-form,
.follow-up-form,
.plan-edit-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 180px);
  gap: 10px;
}

.plan-form .wide-field,
.plan-form button,
.follow-up-form .wide-field,
.follow-up-form button,
.plan-edit-form .wide-field {
  grid-column: 1 / -1;
}

.plan-form textarea,
.follow-up-form textarea,
.plan-edit-form textarea {
  min-height: 104px;
}

.follow-up-list {
  display: grid;
  gap: 10px;
}

.follow-up-record {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fbfcfb;
}

.follow-up-record p {
  color: var(--muted);
  font-size: 13px;
}

.plan-edit-form {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.plan-edit-form [data-plan-reason] {
  min-height: 76px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions button {
  min-width: 120px;
}

.plan-list,
.plan-revision-list {
  display: grid;
  gap: 10px;
}

.patient-display-body {
  height: 100dvh;
  min-height: 100vh;
  color: #112022;
  background: #eef8f5;
  overflow: hidden;
}

.patient-display-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  height: 100dvh;
  min-height: 0;
  padding: clamp(18px, 4vw, 44px);
  overflow: hidden;
}

.patient-display-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.patient-display-header h1 {
  color: #112022;
}

.patient-display-current {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  position: relative;
  padding: clamp(20px, 4vw, 44px);
  border: 1px solid #b7d8cf;
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.patient-display-direction {
  display: none;
  color: var(--muted);
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 700;
}

.patient-display-text,
.patient-lyric-primary {
  color: #0a4244;
  font-size: clamp(42px, 6.6vw, 88px);
  font-weight: 800;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.patient-display-source,
.patient-lyric-secondary {
  color: var(--muted);
  font-size: clamp(22px, 2.8vw, 36px);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.patient-line-label {
  margin-right: 0.2em;
}

.patient-display-history-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  padding: clamp(78px, 18vh, 170px) 6px clamp(160px, 45vh, 360px) 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  scroll-padding-block: 28% 45%;
}

.patient-display-history-list::before {
  display: none;
}

.patient-display-history-list::after {
  display: none;
}

.patient-lyric-line {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  padding: 8px 0;
  color: #758384;
  opacity: 0.52;
}

.patient-lyric-line.is-current {
  opacity: 1;
}

.patient-lyric-line.is-live-draft {
  opacity: 1;
  padding-inline: 0;
  background: transparent;
  box-shadow: none;
}

.patient-lyric-line:not(.is-current) .patient-lyric-primary {
  color: #758384;
  font-size: clamp(18px, 2.6vw, 34px);
}

.patient-lyric-line:not(.is-current) .patient-lyric-secondary {
  color: #98a4a5;
  font-size: clamp(14px, 1.8vw, 22px);
}

.patient-lyric-speaker {
  color: #314849;
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: 800;
}

.patient-current-draft {
  opacity: 1;
  max-height: min(68vh, 560px);
  padding: 8px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: visible;
}

.patient-lyric-input {
  width: 100%;
  min-width: 0;
  min-height: 1.35em;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  font: inherit;
  overflow-y: auto;
}

.patient-lyric-input::placeholder {
  color: #7c8889;
}

.patient-lyric-input:focus {
  background: rgba(15, 93, 94, 0.05);
}

.patient-current-draft .patient-lyric-primary {
  min-height: 1.4em;
}

.patient-current-draft .patient-lyric-secondary {
  min-height: 1.6em;
}

.patient-action-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 280px);
  align-items: stretch;
  gap: 12px;
  position: relative;
  z-index: 3;
  padding-top: 8px;
  background: #eef8f5;
}

/* 2026-05-17 医疗小程序歌词式 UI */
body {
  background:
    radial-gradient(circle at 15% 92%, rgba(0, 140, 149, 0.08), transparent 32%),
    radial-gradient(circle at 88% 10%, rgba(244, 95, 82, 0.06), transparent 30%),
    #f7fafb;
}

body:has(.page-section[data-page="translate"].is-active) {
  height: 100dvh;
  overflow: hidden;
}

body:has(.page-section[data-page="translate"].is-active) .app-shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  min-height: 92px;
  padding: 14px clamp(16px, 4vw, 40px);
  color: #182230;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(20, 30, 40, 0.06);
  box-shadow: 0 10px 32px rgba(23, 41, 51, 0.05);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  font-size: clamp(22px, 3vw, 30px);
}

.eyebrow {
  color: #697781;
}

.build-badge {
  color: #798892;
}

.app-nav {
  max-width: 760px;
  margin: 0 auto;
  padding-top: 14px;
}

.nav-item {
  border-radius: 18px;
  background: rgba(231, 239, 238, 0.78);
}

.nav-item.is-active {
  background: linear-gradient(135deg, var(--doctor-primary), var(--doctor-primary-dark));
  box-shadow: 0 12px 26px rgba(0, 140, 149, 0.18);
}

.page-section[data-page="translate"].is-active {
  display: grid;
  justify-items: center;
}

.translator-focus {
  --role-primary: var(--doctor-primary);
  --role-primary-dark: var(--doctor-primary-dark);
  --role-primary-light: var(--doctor-primary-light);
  --role-accent-bg: var(--doctor-accent-bg);
  grid-template-rows: 64px minmax(0, 1fr) 92px;
  width: min(100%, 760px);
  height: calc(100dvh - 220px);
  min-height: min(650px, calc(100dvh - 220px));
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(20, 30, 40, 0.06);
  border-radius: 30px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(32, 48, 62, 0.14);
}

.translation-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid rgba(20, 30, 40, 0.06);
  backdrop-filter: blur(12px);
}

.terminal-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: #182230;
  font-size: 16px;
  font-weight: 650;
}

.terminal-brand strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-wave {
  --wave-color: var(--role-primary, var(--doctor-primary));
  position: relative;
  display: inline-block;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.brand-wave::before,
.current-speech.is-current::before,
.subtitle-line.is-current::before,
.patient-lyric-line.is-current::before {
  content: "";
  display: block;
  width: 24px;
  height: 32px;
  border-radius: 8px;
  background:
    linear-gradient(var(--wave-color, var(--role-primary)) 0 0) 2px 35% / 3px 34% no-repeat,
    linear-gradient(var(--wave-color, var(--role-primary)) 0 0) 8px 18% / 3px 64% no-repeat,
    linear-gradient(var(--wave-color, var(--role-primary)) 0 0) 14px 0 / 3px 100% no-repeat,
    linear-gradient(var(--wave-color, var(--role-primary)) 0 0) 20px 22% / 3px 56% no-repeat;
}

.terminal-tools {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  flex: 0 0 auto;
}

.role-pill,
.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.doctor-role {
  color: var(--doctor-primary);
  background: var(--doctor-primary-light);
  border: 1px solid rgba(0, 140, 149, 0.22);
}

.patient-role {
  color: var(--patient-primary);
  background: var(--patient-primary-light);
  border: 1px solid rgba(244, 95, 82, 0.22);
}

.connection-pill {
  color: #66737c;
  background: #f5f7f8;
  border: 1px solid rgba(20, 30, 40, 0.08);
}

.connection-pill.warn {
  color: var(--patient-primary);
  background: var(--patient-primary-light);
}

.terminal-icon-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #75808a;
  background: transparent;
}

.terminal-icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.patient-display-actions {
  position: absolute;
  top: 76px;
  right: 18px;
  z-index: 4;
  display: flex;
  gap: 8px;
}

.patient-display-actions .secondary-command {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--doctor-primary);
  background: rgba(231, 247, 247, 0.86);
  box-shadow: none;
}

.translation-stage,
.patient-display-current {
  min-height: 0;
  padding: 0 20px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(70% 30% at 50% 100%, rgba(0, 140, 149, 0.08), transparent 68%),
    #ffffff;
  box-shadow: none;
  overflow: hidden;
}

.lyrics-flow,
.patient-display-history-list {
  gap: 0;
  height: 100%;
  padding: 26px 16px 104px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 132, 142, 0.42) transparent;
  scroll-padding-block: 12% 26%;
}

.translator-focus .lyrics-flow {
  padding: clamp(78px, 18vh, 170px) 16px clamp(180px, 45vh, 360px) 6px;
  scroll-padding-block: 28% 45%;
}

.patient-display-body .patient-display-history-list {
  padding: clamp(78px, 18vh, 170px) 16px clamp(180px, 45vh, 360px) 6px;
  scroll-padding-block: 28% 45%;
}

.lyrics-flow::-webkit-scrollbar,
.patient-display-history-list::-webkit-scrollbar {
  width: 4px;
}

.lyrics-flow::-webkit-scrollbar-thumb,
.patient-display-history-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(120, 132, 142, 0.42);
}

.subtitle-line.is-past,
.patient-lyric-line.is-past {
  position: relative;
  margin: 0 0 22px 16px;
  padding: 0 0 0 28px;
  color: #687682;
  border-radius: 0;
  opacity: 0.78;
}

.subtitle-line.is-past::before,
.patient-lyric-line.is-past::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid #b7c0c8;
  border-radius: 50%;
  background: #ffffff;
}

.subtitle-line.is-past::after,
.patient-lyric-line.is-past::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 20px;
  bottom: -20px;
  width: 1px;
  background: rgba(160, 170, 180, 0.34);
}

.subtitle-line.is-past .lyric-primary,
.patient-lyric-line:not(.is-current) .patient-lyric-primary {
  color: #5f6b76;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

.subtitle-line.is-past .lyric-secondary,
.patient-lyric-line:not(.is-current) .patient-lyric-secondary {
  color: #7d8995;
  font-size: 14px;
  font-weight: 450;
  line-height: 1.55;
}

.subtitle-line.is-past .lyric-line-label,
.patient-lyric-line.is-past .patient-line-label {
  flex-basis: 100%;
  margin-bottom: 5px;
  color: #7a8794;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}

.subtitle-line.is-past .lyric-secondary .lyric-line-label,
.patient-lyric-line.is-past .patient-lyric-secondary .patient-line-label {
  display: none;
}

.subtitle-line.is-current,
.current-speech.is-current,
.patient-lyric-line.is-current {
  --wave-color: var(--role-primary);
  position: relative;
  display: grid;
  gap: 8px;
  margin: 48px 0 0;
  padding: 6px 6px 22px 48px;
  border-radius: 0;
  color: #111827;
  background: transparent;
  opacity: 1;
}

.subtitle-line.is-current::before,
.current-speech.is-current::before,
.patient-lyric-line.is-current::before {
  position: absolute;
  left: 6px;
  top: 14px;
}

.lyric-speaker,
.patient-lyric-speaker {
  color: #7a8794;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
}

.subtitle-line.is-current .lyric-line-label,
.current-speech.is-current .lyric-speaker,
.patient-lyric-line.is-current .patient-line-label,
.patient-current-draft.is-current .patient-lyric-speaker {
  display: block;
  margin: 0 0 2px;
  color: #7a8794;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
}

.subtitle-line.is-current .lyric-primary .lyric-line-label,
.patient-lyric-line.is-current .patient-lyric-primary .patient-line-label {
  flex-basis: 100%;
}

.subtitle-line.is-current .lyric-secondary .lyric-line-label,
.patient-lyric-line.is-current .patient-lyric-secondary .patient-line-label {
  display: none;
}

.lyric-primary,
.patient-display-text,
.patient-lyric-primary,
.current-speech.source-primary #sourceDraft,
.current-speech.translation-primary #translationDraft {
  color: #111827;
  font-size: clamp(25px, 4.1vw, 31px);
  font-weight: 760;
  line-height: 1.35;
}

.current-speech.source-primary #translationDraft,
.current-speech.translation-primary #sourceDraft,
.lyric-secondary,
.patient-display-source,
.patient-lyric-secondary {
  color: var(--role-primary, var(--doctor-primary));
  font-size: clamp(16px, 2.5vw, 20px);
  font-weight: 560;
  line-height: 1.55;
}

.current-speech.is-past #sourceDraft,
.current-speech.is-past #translationDraft {
  color: #5f6b76;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
}

.current-speech textarea,
.patient-lyric-input {
  min-height: 1.35em;
  max-height: 7.8em;
  padding: 0;
  color: inherit;
}

.current-speech textarea::placeholder,
.patient-lyric-input::placeholder {
  color: rgba(107, 119, 128, 0.58);
}

.current-speech .auto-save-note {
  display: none;
}

.current-speech .auto-save-note.is-visible {
  display: block;
  order: 4;
  color: #6d7a83;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.current-speech .auto-save-note.is-warning {
  color: #b95a18;
}

.translator-focus .current-speech .auto-save-note,
.translator-focus .current-speech .auto-save-note.is-visible {
  display: none !important;
}

.translator-focus .current-speech textarea {
  max-height: min(42vh, 440px);
}

.current-speech.is-past .auto-save-note {
  display: none !important;
}

.translator-focus .lyrics-flow .subtitle-line.is-past {
  margin-bottom: 28px;
}

.translator-focus .lyrics-flow .subtitle-line.is-current {
  gap: 8px;
  margin-top: 48px;
  padding-bottom: 22px;
}

.translator-focus .lyrics-flow .subtitle-line.is-current.patient {
  gap: 8px;
  margin-top: 48px;
  padding-bottom: 22px;
}

.translator-focus .lyrics-flow .subtitle-line.is-current .lyric-text-line {
  display: block;
  max-width: 100%;
}

.translator-focus .lyrics-flow .subtitle-line.is-current .lyric-line-label {
  display: block;
  margin: 0 0 8px;
}

.translator-focus .lyrics-flow .subtitle-line.is-current .lyric-secondary .lyric-line-label {
  display: none;
}

.translator-focus .lyrics-flow .subtitle-line.is-current .token-row {
  display: inline;
  min-height: 0;
}

.translator-focus .lyrics-flow .subtitle-line.is-current .token {
  margin-right: 0.28em;
}

.patient-token-row {
  display: inline;
  min-width: 0;
  min-height: 0;
}

.patient-token {
  display: inline;
  margin: 0 0.26em 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: inherit;
  text-align: left;
  vertical-align: baseline;
}

.patient-token:hover,
.patient-token:focus-visible {
  color: var(--role-primary, var(--patient-primary));
  background: transparent;
  outline: none;
}

.patient-display-body {
  --role-primary: var(--patient-primary);
  --role-primary-dark: var(--patient-primary-dark);
  --role-primary-light: var(--patient-primary-light);
  --role-accent-bg: var(--patient-accent-bg);
  background:
    radial-gradient(circle at 92% 92%, rgba(244, 95, 82, 0.08), transparent 32%),
    #f9fbfc;
}

.patient-display-shell {
  grid-template-rows: 64px minmax(0, 1fr) 92px;
  gap: 0;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: clamp(12px, 2.2vw, 22px);
}

.patient-display-header {
  display: flex;
}

.patient-display-current {
  background:
    radial-gradient(70% 30% at 50% 100%, rgba(244, 95, 82, 0.08), transparent 68%),
    #ffffff;
  border-inline: 1px solid rgba(244, 95, 82, 0.12);
}

.patient-display-direction {
  display: none;
}

.patient-display-body .patient-lyric-line.is-current .patient-lyric-primary,
.patient-display-body .patient-current-draft.is-current .patient-lyric-primary {
  color: var(--patient-primary);
}

.patient-display-body .patient-lyric-line.is-current.is-long-current .patient-lyric-primary,
.patient-display-body .patient-current-draft.is-current.is-long-current .patient-lyric-primary {
  font-size: clamp(21px, 3.1vw, 25px);
  line-height: 1.26;
}

.patient-display-body .patient-lyric-line.is-current.is-long-current .patient-lyric-secondary,
.patient-display-body .patient-current-draft.is-current.is-long-current .patient-lyric-secondary {
  font-size: clamp(14px, 1.9vw, 17px);
  line-height: 1.42;
}

.patient-display-body .patient-lyric-line.is-current.is-very-long-current .patient-lyric-primary,
.patient-display-body .patient-current-draft.is-current.is-very-long-current .patient-lyric-primary {
  font-size: clamp(18px, 2.5vw, 21px);
  line-height: 1.22;
}

.patient-display-body .patient-lyric-line.is-current.is-very-long-current .patient-lyric-secondary,
.patient-display-body .patient-current-draft.is-current.is-very-long-current .patient-lyric-secondary {
  font-size: clamp(13px, 1.65vw, 15px);
  line-height: 1.38;
}

.patient-display-body .patient-lyric-line.is-current.is-extra-long-current .patient-lyric-primary,
.patient-display-body .patient-current-draft.is-current.is-extra-long-current .patient-lyric-primary {
  font-size: clamp(16px, 2.05vw, 18px);
  line-height: 1.18;
}

.patient-display-body .patient-lyric-line.is-current.is-extra-long-current .patient-lyric-secondary,
.patient-display-body .patient-current-draft.is-current.is-extra-long-current .patient-lyric-secondary {
  font-size: clamp(12px, 1.45vw, 13px);
  line-height: 1.32;
}

.patient-display-body .patient-current-draft.is-current .patient-lyric-input {
  max-height: none;
  overflow-y: hidden;
}

.action-row,
.patient-action-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 92px;
  margin: 0;
  padding: 14px 20px 20px;
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid rgba(20, 30, 40, 0.06);
  backdrop-filter: blur(14px);
}

.talk-button {
  justify-content: center;
  min-height: 56px;
  padding: 0 16px;
  border-radius: 18px;
  box-shadow: none;
  text-align: center;
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.talk-button:active,
.confirm-translate:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.talk-button.doctor {
  color: var(--doctor-primary);
  background: var(--doctor-primary-light);
}

.talk-button.patient {
  color: var(--patient-primary);
  background: var(--patient-accent-bg);
}

.talk-button span {
  font-size: 16px;
  font-weight: 700;
}

.talk-button small {
  display: none;
}

.confirm-translate {
  min-height: 56px;
  border-radius: 18px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 16px 30px rgba(0, 140, 149, 0.2);
}

.translator-focus .confirm-translate {
  background: linear-gradient(135deg, var(--doctor-primary), var(--doctor-primary-dark));
}

.patient-action-row .confirm-translate {
  background: linear-gradient(135deg, #ff766b, var(--patient-primary));
  box-shadow: 0 16px 30px rgba(244, 95, 82, 0.2);
}

.confirm-translate::before {
  content: "✓";
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  margin-right: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.pulse-display .patient-display-current {
  animation: displayPulse 0.45s ease-out;
}

.patient-display-body.pulse-display .patient-display-current {
  animation: none;
}

@keyframes displayPulse {
  from {
    box-shadow: 0 0 0 8px rgba(15, 93, 94, 0.16);
  }
  to {
    box-shadow: var(--shadow);
  }
}

.plan-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #fbfcfb;
}

.plan-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.plan-card small,
.plan-card p,
.plan-card summary {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 920px) {
  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    justify-content: flex-start;
  }

  .status-cluster {
    justify-content: flex-start;
  }

  .live-region,
  .realtime-test-panel,
  .turn-body,
    .history-search-grid,
    .backoffice-grid,
    .glossary-grid,
    .comparison-filters,
    .plan-form,
    .follow-up-form,
    .patient-filters,
    .plan-edit-form,
    .report-grid {
    grid-template-columns: 1fr;
  }

  .translator-focus {
    min-height: auto;
  }

  .translation-stage {
    grid-template-rows: minmax(0, 1fr);
    min-height: 58vh;
  }

  .plan-form .wide-field,
  .plan-form button,
  .follow-up-form .wide-field,
  .follow-up-form button,
  .plan-edit-form .wide-field {
    grid-column: auto;
  }

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

  .form-grid.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .nav-item {
    min-height: 40px;
    font-size: 14px;
  }

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

  .talk-button {
    min-height: 68px;
  }

  .current-speech textarea {
    min-height: 1.35em;
    font-size: clamp(25px, 8vw, 31px);
  }

  .action-row > button {
    width: 100%;
  }

  .patient-display-shell {
    padding: 16px;
  }

  .patient-display-current {
    min-height: 0;
  }

  .patient-action-row > button {
    width: 100%;
  }

  .device-check-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .device-check-item span {
    text-align: left;
  }
}
