:root {
  --bg: #b8c2cc;
  --bg-dark: #9aa6b3;
  --panel: #d7dee6;
  --panel-edge: #eef2f6;
  --panel-shadow: #7f8b97;
  --frame: #5f6b77;
  --text: #1a2730;
  --muted: #53616f;
  --accent: #2d5668;
  --accent-2: #3f7389;
  --success: #2f8b55;
  --warning: #ced87c;
  --paper: #f1ead7;
  --dispatcher: #e8e1cf;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "Courier New", "Space Grotesk", monospace;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-dark) 100%);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: min(480px, 100%);
  padding: 22px;
  background: var(--panel);
  border: 2px solid var(--frame);
  box-shadow:
    inset 1px 1px 0 var(--panel-edge),
    inset -1px -1px 0 var(--panel-shadow),
    4px 4px 0 rgba(40, 50, 60, 0.25);
}

.login-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #7b8793;
  border-radius: 0;
  background: #f4f1e5;
  color: var(--text);
  font: inherit;
  outline: none;
  box-shadow: inset 1px 1px 0 #fffdf6;
}

.login-field input:focus {
  background: #fffced;
  border-color: var(--accent);
}

.login-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.login-status[data-state="error"] {
  color: #7c2f2f;
}

.app-shell {
  width: min(1600px, calc(100% - 20px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

.app-header,
.transcript-shell,
.summary-shell,
.consult-shell {
  background: var(--panel);
  border: 2px solid var(--frame);
  border-radius: 0;
  box-shadow:
    inset 1px 1px 0 var(--panel-edge),
    inset -1px -1px 0 var(--panel-shadow),
    3px 3px 0 rgba(40, 50, 60, 0.25);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
  max-width: 54rem;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--frame);
  border-radius: 0;
  background: #c7d0d8;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.session-status {
  justify-content: space-between;
}

.compact-button {
  padding: 8px 12px;
}

.status-dot,
.availability-dot {
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: #66727d;
  display: inline-block;
}

.status-dot.live,
.availability-dot {
  background: var(--success);
}

.status-dot.live {
  animation: pulse 1.2s steps(2, end) infinite;
}

.divider {
  color: #7d8a96;
}

.action-row {
  display: flex;
  gap: 10px;
}

button,
.portal-link {
  border: 2px solid var(--frame);
  border-radius: 0;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: filter 80ms ease;
  text-decoration: none;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.55),
    inset -1px -1px 0 rgba(40, 50, 60, 0.22);
}

button:hover,
.portal-link:hover {
  filter: brightness(0.98);
}

button:active,
.portal-link:active {
  box-shadow:
    inset -1px -1px 0 rgba(255, 255, 255, 0.35),
    inset 1px 1px 0 rgba(40, 50, 60, 0.26);
}

.primary {
  color: #f4f7f9;
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 100%);
}

.danger {
  color: #fff6f6;
  background: linear-gradient(180deg, #8d3e3e 0%, #6d2f2f 100%);
}

.secondary {
  color: #f4f7f9;
  background: linear-gradient(180deg, #53798c 0%, #35586a 100%);
}

.ghost,
.portal-link {
  color: var(--text);
  background: linear-gradient(180deg, #dfe5ea 0%, #bcc6d0 100%);
}

.wide-button {
  width: 100%;
  justify-content: center;
}

kbd {
  padding: 0.12rem 0.38rem;
  border: 1px solid var(--frame);
  border-radius: 0;
  background: #e2e7ec;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.75),
    inset -1px -1px 0 rgba(40, 50, 60, 0.18);
  font: inherit;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.78fr) minmax(360px, 0.92fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.transcript-shell,
.summary-shell,
.consult-shell {
  padding: 14px;
}

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

.transcript-toolbar {
  padding: 4px 2px 12px;
  border-bottom: 2px solid #a1acb7;
}

.panel-header {
  padding: 2px 2px 0;
}

.toolbar-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-shell,
.consult-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 76vh;
}

.physician-card,
.consultation-composer {
  border: 2px solid #8d98a3;
  border-radius: 0;
  background: #dfe5eb;
  box-shadow:
    inset 1px 1px 0 #f4f7fa,
    inset -1px -1px 0 #909ca8;
}

.physician-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.physician-avatar {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border: 2px solid var(--frame);
  border-radius: 0;
  background: linear-gradient(180deg, #dde4eb 0%, #b6c1cc 100%);
  color: var(--accent);
  font-weight: 700;
}

.physician-identity p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.summary-box,
.consultation-input {
  width: 100%;
  padding: 14px;
  border: 2px solid #7b8793;
  border-radius: 0;
  background: #f4f1e5;
  color: var(--text);
  font: inherit;
  font-size: 0.96rem;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  box-shadow: inset 1px 1px 0 #fffdf6;
}

.summary-box {
  min-height: 62vh;
  margin-top: 2px;
}

.summary-box:focus,
.consultation-input:focus {
  background: #fffced;
  border-color: var(--accent);
}

.consultation-feed,
.transcript-stream {
  overflow-y: auto;
}

.consultation-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 44vh;
  padding-right: 2px;
}

.consultation-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.consultation-message.dispatcher {
  align-items: flex-end;
}

.consultation-message.physician,
.consultation-message.system {
  align-items: flex-start;
}

.consultation-bubble {
  max-width: 96%;
  padding: 12px 14px;
  border: 2px solid #8c98a4;
  border-radius: 0;
  font-size: 0.94rem;
  line-height: 1.45;
  white-space: pre-wrap;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.65);
}

.consultation-bubble.dispatcher {
  background: var(--dispatcher);
}

.consultation-bubble.physician {
  background: var(--paper);
}

.consultation-bubble.summary {
  background: #e0e8ef;
}

.consultation-meta {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.consultation-composer {
  margin-top: auto;
  padding: 10px;
}

.consultation-actions {
  margin-top: 8px;
}

.icon-button {
  min-width: 52px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #dfe5ea 0%, #bcc6d0 100%);
  color: var(--text);
}

.transcript-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 68vh;
  max-height: 76vh;
  padding: 16px 4px 4px;
}

.empty-state {
  padding: 22px;
  border: 2px dashed #8995a1;
  border-radius: 0;
  color: var(--muted);
  text-align: center;
  background: #dfe6eb;
}

.message-row {
  display: grid;
  grid-template-columns: minmax(84px, 0.82fr) minmax(0, 0.18fr);
  align-items: start;
  gap: 10px;
  width: 100%;
  padding: 12px 4px;
  border-bottom: 1px solid #a9b4bf;
}

.message-row:last-of-type {
  border-bottom: 0;
}

.bubble-edit {
  margin: 0;
  width: 100%;
  min-height: 56px;
  padding: 0;
  border-radius: 0;
  outline: none;
  border: 0;
  background: transparent;
  font-size: clamp(0.98rem, 1.5vw, 1.05rem);
  line-height: 1.55;
  cursor: text;
  white-space: pre-wrap;
}

.bubble-edit.patient {
  color: var(--text);
}

.bubble-edit.dispatcher {
  color: var(--accent);
}

.bubble-edit.live {
  background: linear-gradient(90deg, rgba(90, 115, 130, 0.14), transparent 38%);
}

.bubble-edit:focus {
  background: rgba(90, 115, 130, 0.1);
}

.message-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.timestamp {
  font-variant-numeric: tabular-nums;
}

.role-live {
  color: var(--accent);
  font-weight: 700;
}

.speaker-label {
  color: var(--text);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.switch-note {
  margin: 2px 0 4px 0;
  padding-left: 194px;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: normal;
  text-align: left;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal-open {
  overflow: hidden;
}

.modal-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(54, 63, 72, 0.68);
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(760px, 100%);
  background: var(--panel);
  border: 2px solid var(--frame);
  border-radius: 0;
  box-shadow:
    inset 1px 1px 0 var(--panel-edge),
    inset -1px -1px 0 var(--panel-shadow),
    4px 4px 0 rgba(40, 50, 60, 0.3);
  padding: 14px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-copy {
  margin: 12px 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-summary-box {
  min-height: 260px;
  margin: 0;
}

.modal-actions {
  margin-top: 12px;
}

.modal-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@media (max-width: 1220px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.8fr);
  }

  .consult-shell {
    grid-column: 1 / -1;
    min-height: auto;
  }

  .consultation-feed {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 12px, 1600px);
  }

  .app-header,
  .transcript-toolbar,
  .panel-header,
  .consultation-actions,
  .modal-header,
  .modal-actions {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .header-actions,
  .action-row {
    width: 100%;
    align-items: stretch;
  }

  .header-status,
  .primary,
  .secondary,
  .ghost,
  .portal-link,
  .icon-button {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .message-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .switch-note {
    padding-left: 0;
  }

  .summary-shell,
  .consult-shell {
    min-height: auto;
  }

  .summary-box {
    min-height: 280px;
  }
}
