:root {
  color-scheme: dark;
  --bg: #0a0e1a;
  --panel: #141827;
  --panel-2: #1a1b2e;
  --line: #2a2b3f;
  --line-hot: #7aa2f7;
  --text: #e7ecf8;
  --soft: #9aa4bf;
  --muted: #565f89;
  --green: #9ece6a;
  --blue: #7aa2f7;
  --purple: #bb9af7;
  --red: #f7768e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0a0e1a;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202338;
  color: var(--text);
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--line-hot);
}

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

.app {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  min-height: 90px;
  padding: 18px 0 22px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1.1;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--soft);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(158, 206, 106, 0.55);
}

.status.recording .status-dot {
  background: var(--red);
  box-shadow: 0 0 12px rgba(247, 118, 142, 0.55);
}

.status.error .status-dot {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 310px;
  gap: 16px;
}

.controls,
.stage,
.events {
  min-height: calc(100vh - 136px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.controls {
  padding: 16px;
}

.provider-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.provider {
  background: #101523;
}

.provider.active {
  border-color: var(--line-hot);
  background: linear-gradient(135deg, rgba(122, 162, 247, 0.24), rgba(187, 154, 247, 0.16));
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: var(--soft);
  font-size: 13px;
  font-weight: 700;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 14px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.check-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

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

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 172px;
  padding: 12px;
  line-height: 1.45;
}

#anamnesisQuestions {
  min-height: 146px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--line-hot);
}

.actions {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.9fr;
  gap: 8px;
}

.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #08101f;
  font-weight: 800;
}

.meters {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.bar {
  height: 8px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #0f1321;
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 80ms linear;
}

.stage {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.metrics div {
  min-height: 76px;
  padding: 13px;
  background: var(--panel-2);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.activity-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.activity-pill {
  display: grid;
  grid-template-columns: 12px minmax(0, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 10px 14px;
  background: #101523;
}

.activity-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.48;
  transition: background 0.25s ease, box-shadow 0.25s ease, opacity 0.7s ease, transform 0.25s ease;
}

.activity-pill strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--soft);
  font-size: 12px;
  letter-spacing: 0;
}

.activity-pill small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.activity-pill.active .activity-led {
  opacity: 1;
  transform: scale(1.35);
}

.activity-pill.start.active .activity-led {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(158, 206, 106, 0.13), 0 0 20px rgba(158, 206, 106, 0.72);
}

.activity-pill.end.active .activity-led {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(122, 162, 247, 0.13), 0 0 20px rgba(122, 162, 247, 0.72);
}

.activity-pill.fading .activity-led {
  opacity: 0.3;
  transform: scale(1);
  box-shadow: none;
}

.tool-strip {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #101523;
}

.tool-strip div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.25s ease, box-shadow 0.25s ease, opacity 0.8s ease, transform 0.25s ease;
}

.tool-strip.running .tool-led {
  background: #f2c76b;
  box-shadow: 0 0 0 5px rgba(242, 199, 107, 0.14), 0 0 24px rgba(242, 199, 107, 0.9);
  animation: toolPulse 1.05s ease-in-out infinite;
}

.tool-strip.done .tool-led {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(158, 206, 106, 0.13), 0 0 20px rgba(158, 206, 106, 0.72);
}

.tool-strip.fading .tool-led {
  background: var(--muted);
  opacity: 0.36;
  box-shadow: 0 0 0 0 rgba(158, 206, 106, 0);
  animation: none;
}

.tool-strip code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

@keyframes toolPulse {
  0%, 100% { transform: scale(1); opacity: 0.78; }
  50% { transform: scale(1.55); opacity: 1; }
}

.anamnesis-panel {
  display: grid;
  grid-template-rows: auto minmax(88px, auto);
  border-bottom: 1px solid var(--line);
  background: #0f1321;
}

.anamnesis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.anamnesis-head h2 {
  margin: 0;
  font-size: 15px;
}

.anamnesis-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(158, 206, 106, 0.45);
  border-radius: 8px;
  background: rgba(158, 206, 106, 0.12);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.anamnesis-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  padding: 12px 14px;
  overflow-y: auto;
}

.anamnesis-empty {
  color: var(--muted);
  font-size: 13px;
}

.anamnesis-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121827;
}

.anamnesis-row.followup {
  border-color: rgba(187, 154, 247, 0.42);
}

.anamnesis-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(122, 162, 247, 0.13);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.anamnesis-qa span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.anamnesis-qa p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.anamnesis-qa.answer p.pending {
  color: var(--muted);
}

.transcript {
  min-height: 420px;
  padding: 18px;
  overflow-y: auto;
}

.empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
}

.msg {
  width: min(780px, 90%);
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111624;
}

.msg.user {
  margin-left: auto;
  border-color: rgba(122, 162, 247, 0.42);
}

.msg.model {
  border-color: rgba(158, 206, 106, 0.34);
  background: #121b21;
}

.msg.system {
  width: 100%;
  color: var(--soft);
}

.role {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.text {
  white-space: pre-wrap;
  line-height: 1.45;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.events {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.events-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.events h2 {
  margin: 0;
  font-size: 15px;
}

.events-head button {
  min-height: 32px;
  padding: 0 10px;
}

#events {
  padding: 12px;
  overflow-y: auto;
  color: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.event {
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  overflow-wrap: anywhere;
}

.event.error {
  color: var(--red);
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .events {
    grid-column: 1 / -1;
    min-height: 260px;
  }
}

@media (max-width: 820px) {
  .app {
    width: min(100% - 18px, 720px);
  }

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

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

  .controls,
  .stage,
  .events {
    min-height: auto;
  }

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

  .activity-strip {
    grid-template-columns: 1fr;
  }

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

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

  .tool-strip {
    grid-template-columns: 1fr;
  }

  .anamnesis-row {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .anamnesis-qa.answer {
    grid-column: 2;
  }
}
