:root {
  --ink: #16231e;
  --muted: #66736d;
  --paper: #fbfdfb;
  --canvas: #edf3ef;
  --line: #d8e2dc;
  --green: #1d6b4f;
  --green-dark: #13513b;
  --green-soft: #dcece3;
  --coral: #d96855;
  --coral-soft: #fae3de;
  --amber: #a86d16;
  --shadow: 0 24px 70px rgba(29, 61, 46, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 3%, rgba(255,255,255,.95) 0 8%, transparent 30%),
    linear-gradient(145deg, #eef4f0 0%, #e8f0eb 55%, #f3f5f0 100%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  min-height: 100vh;
}

button, textarea, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.app-shell { width: min(1440px, 100%); margin: 0 auto; min-height: 100vh; }
.topbar { height: 92px; display: flex; align-items: center; justify-content: space-between; padding: 0 44px; }
.brand { display: flex; gap: 12px; align-items: center; border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; color: var(--green); background: rgba(255,255,255,.72); border: 1px solid rgba(29,107,79,.14); border-radius: 15px; box-shadow: 0 8px 20px rgba(29,61,46,.08); }
.brand-mark svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; line-height: 1; }
.brand small { color: var(--muted); margin-top: 5px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.local-badge { display: flex; align-items: center; gap: 9px; color: var(--green-dark); font-size: 13px; background: rgba(255,255,255,.66); border: 1px solid rgba(29,107,79,.12); padding: 10px 14px; border-radius: 999px; }
.local-badge span { width: 8px; height: 8px; border-radius: 50%; background: #34a36f; box-shadow: 0 0 0 5px rgba(52,163,111,.12); }
main { padding: 44px 44px 80px; }
.start-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(430px, 560px); gap: 64px 7vw; align-items: center; }
.hero-copy { padding-left: 2vw; }
.eyebrow, .section-kicker { color: var(--green); font-weight: 700; font-size: 11px; letter-spacing: .15em; text-transform: uppercase; }
h1, h2 { margin: 0; }
h1 { font: 500 clamp(42px, 5vw, 75px)/1.03 Georgia, "Times New Roman", serif; letter-spacing: -.035em; max-width: 800px; }
h1 em { color: var(--green); font-weight: 400; }
.hero-text { color: var(--muted); font-size: 17px; line-height: 1.7; max-width: 620px; margin: 28px 0 0; }
.recorder-card { background: rgba(251,253,251,.94); border: 1px solid rgba(255,255,255,.9); padding: 34px; border-radius: 30px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.recorder-card::before { content: ""; position: absolute; inset: -80px -50px auto auto; width: 210px; height: 210px; background: radial-gradient(circle, rgba(80,157,119,.14), transparent 68%); }
.recorder-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; position: relative; }
.recorder-head h2, .panel-heading h2, .section-heading h2 { font: 500 30px/1.15 Georgia, serif; margin-top: 7px; }
.timer { font: 600 28px/1 "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.04em; padding-top: 10px; }
#waveform { display: block; width: 100%; height: 120px; margin: 24px 0 5px; border-radius: 18px; background: linear-gradient(180deg, #f3f7f4, #eef4f0); }
.recording-status { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13px; margin: 12px 0 24px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a6b0aa; }
.is-recording .status-dot { background: var(--coral); box-shadow: 0 0 0 5px rgba(217,104,85,.14); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(217,104,85,0); } }
.consent-check { display: flex; align-items: flex-start; gap: 11px; color: #4f5e57; font-size: 13px; line-height: 1.45; cursor: pointer; padding: 13px 14px; border-radius: 13px; background: #f2f6f3; }
.consent-check input { width: 17px; height: 17px; accent-color: var(--green); flex: 0 0 auto; margin-top: 1px; }
.record-actions { margin-top: 18px; }
.record-button, .stop-button, .upload-button { width: 100%; min-height: 58px; border-radius: 16px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 11px; transition: transform .2s, box-shadow .2s, opacity .2s; }
.record-button { background: var(--green); box-shadow: 0 12px 28px rgba(29,107,79,.2); }
.record-button:hover:not(:disabled), .stop-button:hover, .upload-button:hover:not(:disabled) { transform: translateY(-2px); }
.record-button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }
.record-icon { width: 13px; height: 13px; border-radius: 50%; background: #fff; }
.stop-button { background: var(--coral); box-shadow: 0 12px 28px rgba(217,104,85,.18); }
.stop-button span { width: 12px; height: 12px; background: #fff; border-radius: 2px; }
.upload-divider { display: flex; align-items: center; gap: 10px; color: #98a39d; font-size: 11px; margin: 13px 4px; }
.upload-divider::before, .upload-divider::after { content: ""; height: 1px; background: #e1e8e4; flex: 1; }
.upload-button { color: var(--green-dark); background: #f3f7f4; border: 1px solid #cdded4; min-height: 52px; }
.upload-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.upload-button:disabled { opacity: .5; cursor: wait; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.recorder-note { color: #89948f; font-size: 11px; line-height: 1.5; text-align: center; margin: 14px 20px 0; }
.history-section { grid-column: 1 / -1; margin-top: 30px; background: rgba(251,253,251,.68); border: 1px solid rgba(255,255,255,.8); border-radius: 26px; padding: 28px; }
.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading h2 { font-size: 27px; }
.text-button, .back-button, .danger-link { border: 0; background: none; cursor: pointer; padding: 8px; font-size: 13px; }
.text-button, .back-button { color: var(--green); }
.history-list { margin-top: 21px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.empty-history { grid-column: 1 / -1; color: #8a9690; text-align: center; padding: 32px; border: 1px dashed var(--line); border-radius: 17px; }
.history-item { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.78); border-radius: 17px; padding: 17px; cursor: pointer; transition: border-color .2s, transform .2s; }
.history-item:hover { border-color: #9bbbac; transform: translateY(-2px); }
.history-date { color: var(--green); font-size: 12px; font-weight: 700; }
.history-preview { margin: 9px 0 6px; font-size: 14px; line-height: 1.35; min-height: 38px; }
.history-status { color: var(--muted); font-size: 11px; }
.consultation-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 25px; }
.back-button { justify-self: start; }
.danger-link { color: #a6483b; justify-self: end; }
.consultation-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.consultation-state span { width: 8px; height: 8px; background: #5eac82; border-radius: 50%; }
.processing-card { max-width: 840px; margin: 8vh auto; background: var(--paper); border-radius: 30px; box-shadow: var(--shadow); padding: 48px; text-align: center; }
.processing-orbit { width: 72px; height: 72px; margin: 0 auto 25px; border: 1px solid #b7d1c3; border-radius: 50%; display: grid; place-items: center; animation: rotate 2.2s linear infinite; }
.processing-orbit::before { content: ""; width: 50px; height: 50px; border: 1px solid #d6e4dc; border-radius: 50%; }
.processing-orbit span { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--green); transform: translateY(-36px); }
@keyframes rotate { to { transform: rotate(360deg); } }
.processing-copy h2 { font: 500 35px/1.2 Georgia, serif; margin: 9px 0 12px; }
.processing-copy p { color: var(--muted); }
.model-info { color: var(--green-dark); font-size: 13px; font-weight: 700; margin: 14px 0 0; }
.progress-track { height: 7px; background: #e5ece8; border-radius: 999px; overflow: hidden; margin-top: 30px; }
.progress-track div { height: 100%; width: 10%; background: linear-gradient(90deg, var(--green), #65a987); border-radius: inherit; transition: width .5s ease; }
.error-card { max-width: 840px; margin: 30px auto; padding: 20px 24px; border-radius: 18px; background: var(--coral-soft); border: 1px solid #edc7bf; }
.error-card p { color: #7f4238; white-space: pre-wrap; }
.secondary-button { border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 10px 15px; cursor: pointer; color: var(--green-dark); font-weight: 700; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(330px, .85fr); gap: 22px; align-items: start; }
.document-panel, .transcript-panel { background: rgba(251,253,251,.94); border: 1px solid rgba(255,255,255,.9); border-radius: 26px; box-shadow: 0 12px 45px rgba(29,61,46,.07); padding: 30px; }
.transcript-panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.panel-heading h2 { font-size: 28px; }
.panel-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.save-state { color: var(--muted); font-size: 12px; }
.pdf-button { border: 1px solid #a9c7b7; background: var(--green); color: #fff; border-radius: 11px; padding: 10px 14px; cursor: pointer; font-weight: 700; font-size: 12px; box-shadow: 0 7px 18px rgba(29,107,79,.14); }
.pdf-button:hover:not(:disabled) { transform: translateY(-1px); }
.pdf-button:disabled { opacity: .55; cursor: wait; }
.review-notice { background: #fff8e9; color: #7a5a20; border-left: 3px solid #d5a64c; padding: 12px 14px; border-radius: 4px 12px 12px 4px; font-size: 12px; line-height: 1.5; margin: 22px 0; }
.timing-summary { color: var(--muted); background: #f1f6f3; border-radius: 10px; padding: 10px 12px; margin: -10px 0 22px; font-size: 11px; }
.document-form { display: grid; gap: 24px; }
.document-form label { display: grid; gap: 9px; }
.document-form label > span { font: 600 16px/1.2 Georgia, serif; }
.document-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.document-field-heading > span { font: 600 16px/1.2 Georgia, serif; }
.copy-block-button { margin-left: auto; flex: 0 0 auto; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); background: #f5f8f6; color: var(--green-dark); border-radius: 9px; cursor: pointer; transition: background .18s, border-color .18s, color .18s, transform .18s; }
.copy-block-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.copy-check-icon { display: none; }
.copy-block-button:hover { border-color: #91b6a2; background: var(--green-soft); transform: translateY(-1px); }
.copy-block-button--copied { border-color: #69a986; background: var(--green); color: #fff; }
.copy-block-button--copied .copy-icon { display: none; }
.copy-block-button--copied .copy-check-icon { display: block; }
.copy-block-button:focus-visible { outline: 3px solid rgba(29,107,79,.18); outline-offset: 1px; }
.document-form label small { color: var(--muted); font: 400 11px/1 "Segoe UI", sans-serif; margin-left: 5px; }
.patient-grid { display: grid; grid-template-columns: 1.5fr .8fr .8fr; gap: 14px; padding: 17px; border: 1px solid var(--line); background: #f5f8f6; border-radius: 15px; }
.patient-grid label { gap: 7px; }
.patient-grid label > span { font: 600 13px/1.2 "Segoe UI", sans-serif; color: #3f4c46; }
.patient-grid input { width: 100%; min-width: 0; color: var(--ink); border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 11px 12px; outline: none; }
.patient-grid input:focus { border-color: #7cad94; box-shadow: 0 0 0 3px rgba(29,107,79,.08); }
textarea { width: 100%; resize: vertical; color: var(--ink); border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 13px 14px; line-height: 1.55; outline: none; transition: border .2s, box-shadow .2s; }
textarea:focus { border-color: #7cad94; box-shadow: 0 0 0 3px rgba(29,107,79,.08); }
.diagnosis-grid { display: grid; grid-template-columns: .35fr 1fr; gap: 14px; }
.warnings { background: #fff6e1; border: 1px solid #ead6a8; color: #73561c; border-radius: 12px; padding: 12px; font-size: 12px; line-height: 1.5; margin-top: 18px; }
.transcript-list { overflow: auto; padding-right: 6px; }
.transcript-line { padding: 12px 0; border-top: 1px solid #e4ebe7; }
.transcript-line:first-child { border-top: 0; }
.transcript-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.timestamp { color: #929d97; font-size: 10px; font-variant-numeric: tabular-nums; }
.transcript-line p { margin: 0; color: #3f4c46; font-size: 13px; line-height: 1.55; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 20px); background: #173a2d; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1050px) {
  .start-view { grid-template-columns: 1fr; }
  .hero-copy { padding: 0; }
  .recorder-card { max-width: 680px; width: 100%; }
  .history-list { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: 1fr; }
  .transcript-panel { position: static; max-height: 650px; }
}
@media (max-width: 650px) {
  .topbar { height: 78px; padding: 0 18px; }
  .local-badge { width: 10px; height: 10px; padding: 0; font-size: 0; background: #34a36f; border: 0; }
  .local-badge span { display: none; }
  main { padding: 24px 14px 50px; }
  h1 { font-size: 40px; }
  .hero-text { font-size: 15px; }
  .recorder-card, .document-panel, .transcript-panel { padding: 22px 17px; border-radius: 22px; }
  .recorder-head h2 { font-size: 25px; }
  .timer { font-size: 22px; }
  .history-section { padding: 20px 14px; }
  .history-list { grid-template-columns: 1fr; }
  .consultation-toolbar { grid-template-columns: 1fr 1fr; }
  .consultation-state { display: none; }
  .processing-card { margin: 5vh 0; padding: 35px 20px; }
  .diagnosis-grid { grid-template-columns: 1fr; }
  .patient-grid { grid-template-columns: 1fr; }
  .panel-heading { align-items: flex-start; }
  .panel-actions { justify-content: flex-start; }
}
