:root {
  --bg: #eff1f7;
  --card: #ffffff;
  --text: #1c1f2a;
  --muted: #8a90a2;
  --line: #e4e7ef;
  --blue: #4d9bf5;
  --blue-deep: #6b7fe0;
  --blue-soft: #e8f1fe;
  --pink: rgba(236, 160, 255, 0.35);
  --ok: #1f9d63;
  --ok-soft: #e6f6ee;
  --err: #d64545;
  --err-soft: #fdecec;
  --radius: 28px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 28px 24px 40px;
}

.brand {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 28px;
  background: linear-gradient(90deg, #a9cbf7, var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
}
.left { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.right { position: sticky; top: 24px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 30, 60, 0.04);
}

/* Form */
.form {
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.form label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form label span { font-size: 12px; font-weight: 600; color: var(--muted); }
input {
  font: inherit;
  font-size: 15px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fc;
  outline: none;
  width: 100%;
}
input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px var(--blue-soft); }

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--blue), var(--blue-deep)); color: #fff; }

/* Viewer */
.viewer { padding: 22px 22px 8px; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.viewer-head h2 { font-size: 17px; margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-deep); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }

.viewer-body {
  max-height: calc(100vh - 290px);
  min-height: 300px;
  overflow-y: auto;
  padding: 2px 6px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.viewer-body.empty { color: var(--muted); align-items: center; justify-content: center; font-size: 14px; }
.line { display: flex; flex-direction: column; gap: 3px; max-width: 88%; }
.line .who { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 0 4px; }
.line .say { font-size: 16px; line-height: 1.55; padding: 10px 14px; border-radius: 18px; }
.line.doctor { align-self: flex-start; }
.line.doctor .say { background: #f3f5fa; border-top-left-radius: 6px; }
.line.patient { align-self: flex-end; text-align: right; }
.line.patient .say { background: var(--blue-soft); border-top-right-radius: 6px; text-align: left; }
.line.other .say { background: #f7f3fb; }

.btn.ghost { background: #f1f3f8; color: var(--text); }

/* Silence pop-up */
.modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(28, 31, 42, 0.35);
  display: grid; place-items: center; padding: 16px;
  animation: fade 0.15s ease-out;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card); border-radius: var(--radius);
  width: min(380px, 100%); padding: 28px 24px 22px; text-align: center;
  box-shadow: 0 20px 50px rgba(20, 30, 60, 0.2);
}
.modal-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--err-soft); color: var(--err); display: grid; place-items: center; }
.modal-icon svg { width: 26px; height: 26px; }
.modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.modal-card p { margin: 0 0 20px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }

/* Voice bubble card */
.bubble { padding: 40px 28px 28px; display: flex; flex-direction: column; align-items: center; }
.orb-wrap { width: 200px; height: 200px; display: grid; place-items: center; }
.orb {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #7d8fe6 0%, #6fa6f5 35%, #9cc9fb 62%, #d9ecff 82%, #ffffff 100%);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.9), 0 0 40px 16px var(--pink);
  transform: scale(var(--s, 1));
  transition: transform 0.08s linear, filter 0.3s;
  filter: saturate(0.55);
}
.bubble.recording .orb { filter: none; }
.bubble.paused .orb { filter: saturate(0.3); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(0.95); } }

.status { margin: 18px 0 2px; font-size: 16px; font-weight: 500; }
.timer { margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dots { display: flex; gap: 9px; margin: 18px 0 26px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #c9ccd5; transition: background 0.2s; }
.dots i.on { background: var(--text); }

.controls { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.main-btn {
  width: 68px; height: 68px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep)); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 22px rgba(77, 155, 245, 0.35);
}
.main-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.main-btn svg { width: 28px; height: 28px; }
.main-btn .i-pause { display: none; }
.bubble.recording .main-btn .i-pause { display: block; }
.bubble.recording .main-btn .i-mic { display: none; }

.icon-btn {
  border: 0; background: none; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font: inherit; font-size: 12px; font-weight: 500;
}
.icon-btn svg { width: 22px; height: 22px; padding: 13px; box-sizing: content-box; border-radius: 50%; background: #f1f3f8; }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn.submit { width: 100%; background: var(--text); color: #fff; padding: 14px; }

.msg { width: 100%; margin-top: 14px; padding: 12px 14px; border-radius: 16px; font-size: 13px; line-height: 1.5; }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg ul { margin: 0; padding-left: 18px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .right { position: static; order: -1; }
  .form { grid-template-columns: 1fr; }
  .viewer-body { max-height: none; }
}
@media (max-width: 480px) {
  body { padding: 20px 16px 32px; }
}
