:root {
  --bg: #06100f;
  --bg-2: #091513;
  --panel: #0d1d1a;
  --panel-2: #112521;
  --line: rgba(208, 255, 240, 0.11);
  --line-strong: rgba(208, 255, 240, 0.2);
  --text: #effcf8;
  --muted: #8ca9a0;
  --mint: #6af1bd;
  --mint-2: #2dd49b;
  --red: #ff5d64;
  --amber: #ffbf5b;
  --blue: #70b7ff;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.38);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overflow-x: hidden; }
button, input, textarea { font: inherit; }
button { -webkit-touch-callout: none; }
.hidden { display: none !important; }

.app-shell { min-height: 100dvh; background: radial-gradient(circle at 50% -10%, rgba(63, 211, 159, 0.12), transparent 36%), linear-gradient(180deg, #071210 0%, #050c0b 100%); padding-bottom: calc(82px + var(--safe-bottom)); }
.topbar { height: calc(68px + var(--safe-top)); padding: calc(13px + var(--safe-top)) 18px 10px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; backdrop-filter: blur(18px); background: linear-gradient(180deg, rgba(6,16,15,.96), rgba(6,16,15,.78)); border-bottom: 1px solid rgba(255,255,255,.045); }
.brand-block { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 36px; height: 36px; border-radius: 11px; object-fit: cover; box-shadow: 0 0 0 1px rgba(106,241,189,.22), 0 7px 20px rgba(0,0,0,.35); }
.brand-name { font-size: 14px; letter-spacing: .16em; font-weight: 800; }
.brand-subtitle { font-size: 8px; letter-spacing: .22em; color: var(--muted); margin-top: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.035); color: #bad2cb; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.screen { display: none; max-width: 760px; margin: 0 auto; padding: 16px 16px 26px; animation: screenIn .22s ease; }
.screen.active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.recorder-card { background: linear-gradient(145deg, rgba(17,37,33,.97), rgba(8,20,18,.98)); border: 1px solid var(--line-strong); border-radius: 26px; padding: 15px; box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.035); position: relative; overflow: hidden; }
.recorder-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.025) 50%, transparent 65%); transform: translateX(-100%); animation: sheen 8s ease-in-out infinite; }
@keyframes sheen { 0%,75% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.recorder-header { display: flex; align-items: center; justify-content: space-between; padding: 2px 3px 12px; color: var(--muted); font-size: 10px; letter-spacing: .13em; }
.state-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: #667b75; box-shadow: 0 0 0 4px rgba(102,123,117,.08); vertical-align: -1px; }
.state-dot.recording { background: var(--red); box-shadow: 0 0 0 4px rgba(255,93,100,.12), 0 0 16px rgba(255,93,100,.45); animation: pulse 1.35s infinite; }
.state-dot.paused { background: var(--amber); box-shadow: 0 0 0 4px rgba(255,191,91,.11); }
.state-dot.processing { background: var(--blue); box-shadow: 0 0 0 4px rgba(112,183,255,.11); }
@keyframes pulse { 50% { opacity: .5; transform: scale(.78); } }
.state-label { font-weight: 800; }
.quality-pill { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.025); letter-spacing: .06em; }
.patient-ref-field { margin: 0 0 12px; padding: 11px 12px; border: 1px solid rgba(106,241,189,.14); border-radius: 15px; background: rgba(106,241,189,.045); position: relative; z-index: 1; }
.patient-ref-field label { display: block; color: var(--muted); font-size: 9px; letter-spacing: .13em; font-weight: 800; margin-bottom: 7px; }
.patient-ref-field input { width: 100%; min-height: 40px; border-radius: 11px; border: 1px solid var(--line); background: #06110f; color: var(--text); padding: 0 11px; outline: none; }
.patient-ref-field input:focus { border-color: rgba(106,241,189,.42); box-shadow: 0 0 0 3px rgba(106,241,189,.06); }

.display-panel { min-height: 238px; padding: 17px 14px 12px; border-radius: 19px; background: linear-gradient(180deg, #06110f, #081612); border: 1px solid rgba(106,241,189,.12); box-shadow: inset 0 0 30px rgba(0,0,0,.32); position: relative; }
.display-topline { display: flex; justify-content: space-between; color: #618177; font-size: 9px; letter-spacing: .15em; font-weight: 700; }
.timer { text-align: center; font-family: "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; font-size: clamp(42px, 13vw, 72px); letter-spacing: -.055em; line-height: 1.05; margin: 20px 0 9px; color: #dffdf3; text-shadow: 0 0 24px rgba(106,241,189,.12); }
#waveformCanvas { width: 100%; height: 78px; display: block; border-radius: 10px; }
.review-timeline { margin-top: 2px; }
.review-timeline input[type="range"] { width: 100%; accent-color: var(--mint); }
.review-timeline.overwrite input[type="range"] { accent-color: var(--red); }
.timeline-labels { display: flex; justify-content: space-between; color: #67867c; font: 10px "SFMono-Regular", Consolas, monospace; margin-top: 2px; }
.overwrite-hint { color: #ff969a; text-align: center; font-size: 10px; letter-spacing: .07em; margin-top: 6px; }

.processing-panel { min-height: 135px; display: flex; align-items: center; justify-content: center; gap: 15px; padding: 20px; }
.processing-panel strong { display: block; font-size: 11px; letter-spacing: .14em; }
.processing-panel span { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; }
.spinner { width: 31px; height: 31px; border-radius: 50%; border: 3px solid rgba(112,183,255,.15); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.transport-controls { height: 126px; display: flex; align-items: center; justify-content: center; gap: 28px; }
.record-button { width: 86px; height: 86px; border-radius: 50%; border: 7px solid #142a25; background: linear-gradient(145deg, #ff7076, #d83e48); box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 12px 30px rgba(255,65,74,.22), inset 0 3px 4px rgba(255,255,255,.25), inset 0 -5px 10px rgba(118,0,7,.28); display: grid; place-items: center; transition: transform .12s, filter .12s; }
.record-button:active { transform: scale(.95); filter: brightness(.95); }
.record-button.paused { background: linear-gradient(145deg, #ffc76b, #d88c24); box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 12px 30px rgba(255,185,66,.2), inset 0 3px 4px rgba(255,255,255,.25); }
.record-glyph { width: 28px; height: 28px; background: white; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.28); }
.record-button.recording .record-glyph { border-radius: 7px; width: 25px; height: 25px; }
.record-button.paused .record-glyph { width: 0; height: 0; border-radius: 0; background: transparent; border-top: 16px solid transparent; border-bottom: 16px solid transparent; border-left: 25px solid white; margin-left: 5px; box-shadow: none; }
.transport-btn { width: 62px; height: 62px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,.035); color: #c5dcd5; display: grid; place-items: center; align-content: center; gap: 3px; }
.transport-btn svg { width: 25px; height: 25px; fill: currentColor; }
.transport-btn span { font-size: 8px; letter-spacing: .08em; font-weight: 800; }
.transport-btn:active { background: rgba(255,255,255,.08); }

.primary-actions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; min-height: 43px; }
.soft-btn, .wide-btn, .compact-btn { border: 1px solid var(--line); color: #c8ded7; background: rgba(255,255,255,.04); border-radius: 13px; min-height: 43px; font-size: 10px; letter-spacing: .11em; font-weight: 800; }
.soft-btn.primary, .wide-btn.primary { color: #062119; border-color: rgba(106,241,189,.55); background: linear-gradient(180deg, #78f4c5, #42dca4); }
.soft-btn.danger, .wide-btn.danger { color: #ff9ea2; border-color: rgba(255,93,100,.28); background: rgba(255,93,100,.08); }
.soft-btn.amber { color: #ffd491; border-color: rgba(255,191,91,.3); background: rgba(255,191,91,.07); }
.soft-btn.confirm { color: #fff0f0; border-color: rgba(255,93,100,.6); background: rgba(255,93,100,.24); }

.quick-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 12px; }
.quick-action { min-height: 65px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); color: #849f97; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.quick-action.active { color: var(--mint); border-color: rgba(106,241,189,.2); background: rgba(106,241,189,.045); }
.quick-action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.quick-action span { font-size: 8px; font-weight: 800; letter-spacing: .08em; }

.tip-card { margin-top: 14px; display: flex; gap: 12px; padding: 14px; border: 1px solid rgba(112,183,255,.13); background: rgba(112,183,255,.035); border-radius: 18px; color: #bed0ca; }
.tip-icon { width: 25px; height: 25px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; background: rgba(112,183,255,.12); color: var(--blue); font-weight: 800; }
.tip-card strong { font-size: 11px; letter-spacing: .04em; }
.tip-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(72px + var(--safe-bottom)); padding: 6px 8px var(--safe-bottom); display: grid; grid-template-columns: repeat(5,1fr); background: rgba(5,13,12,.94); backdrop-filter: blur(20px); border-top: 1px solid rgba(255,255,255,.07); }
.nav-btn { border: none; background: transparent; color: #5e7970; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn span { font-size: 8px; letter-spacing: .09em; font-weight: 800; }
.nav-btn.active { color: var(--mint); }

.section-heading { display: flex; justify-content: space-between; align-items: flex-start; margin: 4px 2px 16px; }
.section-heading h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.compact-btn { min-height: 35px; padding: 0 13px; }
.danger-text { color: #ff8a8f; }
.list-stack { display: flex; flex-direction: column; gap: 10px; }
.empty-state { padding: 48px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.list-card { border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.025); padding: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.12); }
.list-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.list-card-title { font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.list-card-meta { font-size: 9px; color: var(--muted); margin-top: 4px; }
.patient-ref-chip { display: inline-flex; width: fit-content; max-width: 100%; margin-top: 8px; padding: 4px 8px; border-radius: 999px; border: 1px solid rgba(106,241,189,.18); background: rgba(106,241,189,.06); color: #9ff7d5; font-size: 9px; line-height: 1.3; }
.patient-ref-chip.locked { border-color: rgba(255,191,91,.18); background: rgba(255,191,91,.06); color: #ffdb9f; }
.patient-ref-chip.error { border-color: rgba(255,93,100,.18); background: rgba(255,93,100,.06); color: #ffb3b6; }
.list-card-preview { color: #bed0ca; margin: 11px 0; font-size: 11px; line-height: 1.55; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.list-card-actions { display: flex; gap: 7px; }
.mini-btn { flex: 1; min-height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.03); color: #abc2bb; font-size: 9px; letter-spacing: .08em; font-weight: 800; }
.mini-btn.danger { color: #ff858a; }
.list-audio { width: 100%; height: 36px; margin: 10px 0; filter: sepia(.2) saturate(.8) hue-rotate(95deg); }

.result-header-card, .editor-card, .settings-card { border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.026); padding: 15px; margin-bottom: 12px; }
.result-header-card { display: flex; align-items: center; justify-content: space-between; }
.result-status { display: flex; gap: 11px; align-items: center; }
.result-status strong { display: block; font-size: 12px; letter-spacing: .09em; }
.result-status span:not(.success-check) { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.success-check { width: 35px; height: 35px; border-radius: 50%; display: grid; place-items: center; background: rgba(106,241,189,.12); color: var(--mint); font-weight: 900; }
.editor-card label, .setting-group label { display: block; color: var(--muted); font-size: 9px; letter-spacing: .13em; font-weight: 800; margin-bottom: 9px; }
#reportEditor { width: 100%; min-height: 52vh; resize: vertical; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: #06110f; color: var(--text); font-size: 15px; line-height: 1.62; outline: none; }
#reportEditor:focus, .setting-group input:focus { border-color: rgba(106,241,189,.42); box-shadow: 0 0 0 3px rgba(106,241,189,.06); }
.editor-stats { display: flex; justify-content: space-between; color: #657f77; font-size: 9px; margin-top: 8px; }
.result-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.action-btn { min-height: 61px; border-radius: 15px; border: 1px solid var(--line); background: rgba(255,255,255,.035); color: #abc2bb; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.action-btn.primary { color: #052017; border-color: rgba(106,241,189,.45); background: linear-gradient(180deg, #78f4c5, #42dca4); }
.action-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.action-btn span { font-size: 8px; letter-spacing: .09em; font-weight: 900; }

.settings-card h2 { margin: 0 0 13px; font-size: 15px; }
.setting-group { margin-bottom: 16px; }
.setting-group input { width: 100%; min-height: 45px; border-radius: 12px; border: 1px solid var(--line); background: #06110f; color: var(--text); padding: 0 12px; outline: none; }
.setting-group small { display: block; color: #6d8980; line-height: 1.45; font-size: 9px; margin-top: 6px; }
.input-with-button { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.input-with-button button { min-width: 67px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: #a9c2ba; font-size: 9px; letter-spacing: .09em; font-weight: 800; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid rgba(255,255,255,.055); }
.setting-row strong { display: block; font-size: 12px; }
.setting-row span { display: block; color: var(--muted); font-size: 9px; margin-top: 4px; line-height: 1.4; }
.switch { position: relative; width: 47px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #243631; transition: .22s; }
.switch span::before { content: ""; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px; border-radius: 50%; background: #91a69f; transition: .22s; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.switch input:checked + span { background: rgba(106,241,189,.32); }
.switch input:checked + span::before { transform: translateX(20px); background: var(--mint); }
.wide-btn { width: 100%; margin-top: 8px; }
.warning-card { border-color: rgba(255,191,91,.18); background: rgba(255,191,91,.035); }
.warning-card p { color: #b9aaa0; font-size: 10px; line-height: 1.55; margin: 0; }
.inline-status { margin-top: 10px; padding: 10px; border-radius: 11px; font-size: 10px; line-height: 1.4; background: rgba(112,183,255,.07); color: #a9d2ff; border: 1px solid rgba(112,183,255,.15); }
.inline-status.error { background: rgba(255,93,100,.07); color: #ff9da1; border-color: rgba(255,93,100,.15); }

.toast-host { position: fixed; z-index: 100; left: 14px; right: 14px; bottom: calc(88px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.toast { max-width: 540px; width: 100%; padding: 12px 14px; border-radius: 14px; background: rgba(13,29,26,.97); border: 1px solid var(--line-strong); color: #d7ebe5; box-shadow: 0 15px 45px rgba(0,0,0,.45); font-size: 11px; line-height: 1.45; transform: translateY(15px); opacity: 0; transition: .2s; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255,93,100,.35); color: #ffb3b6; }
.toast.success { border-color: rgba(106,241,189,.3); color: #9ff7d5; }
.toast.warning { border-color: rgba(255,191,91,.32); color: #ffdb9f; }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.7); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(100%, 420px); border-radius: 22px; border: 1px solid var(--line-strong); background: #0c1c19; padding: 20px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-card p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }

@media (min-width: 680px) {
  .screen { padding-top: 28px; }
  .recorder-card { padding: 22px; }
  .display-panel { min-height: 290px; }
  #waveformCanvas { height: 105px; }
  .transport-controls { height: 145px; }
  .record-button { width: 96px; height: 96px; }
}

/* v1.1 mobile refinements */
.screen { padding-top: calc(18px + var(--safe-top)); }
.quick-actions { grid-template-columns: 1.45fr .9fr .75fr; }
.quick-action span { line-height: 1.25; text-align: center; }
.audio-filter { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: -3px 0 13px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.audio-filter-btn { min-height: 39px; border: 0; border-radius: 10px; background: transparent; color: #78958c; font-size: 9px; letter-spacing: .11em; font-weight: 850; }
.audio-filter-btn.active { color: #062119; background: linear-gradient(180deg, #78f4c5, #42dca4); box-shadow: 0 6px 16px rgba(45,212,155,.15); }
.list-card-actions { flex-wrap: wrap; }
.list-card-actions .mini-btn { min-width: 29%; }

/* v1.2.1 compact-header refinement
   The native Android app already has bottom Settings navigation, so the large
   RADDICTATE title bar/header is redundant on the recorder screen and wastes
   vertical space. Keep safe-area padding so content does not sit under the
   phone status bar. */
.topbar { display: none !important; }
.screen { padding-top: calc(8px + var(--safe-top)) !important; }
@media (min-width: 680px) {
  .screen { padding-top: 14px !important; }
}

/* v1.2.3 recorder workflow fix
   Keep the space-saving header removal, but collapse it instead of leaving any
   possible sticky/transparent touch layer. */
.topbar {
  position: static !important;
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.screen { padding-top: calc(10px + var(--safe-top)) !important; }
@media (min-width: 680px) { .screen { padding-top: 14px !important; } }

/* Make the live recording button visually match its action: pressing it pauses. */
.record-glyph { position: relative; }
.record-button.recording .record-glyph {
  width: 31px;
  height: 31px;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.record-button.recording .record-glyph::before,
.record-button.recording .record-glyph::after {
  content: "";
  display: block;
  width: 8px;
  height: 31px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.record-button.paused .record-glyph::before,
.record-button.paused .record-glyph::after,
.record-button:not(.recording) .record-glyph::before,
.record-button:not(.recording) .record-glyph::after { content: none; }

/* Reduce confusing duplicate controls: the large red button is the pause button. */
#pauseBtn { display: none !important; }
.primary-actions { grid-template-columns: repeat(2, minmax(0,1fr)); }
.quick-action:disabled { opacity: .42; filter: grayscale(.25); }

/* Clearer overwrite review: slider itself stays neutral; canvas shows kept vs discarded. */
.review-timeline.overwrite input[type="range"] { accent-color: var(--amber); }
.overwrite-hint {
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255,93,100,.06);
  border: 1px solid rgba(255,93,100,.16);
}

.resume-mode-card p { margin-bottom: 10px; }
.resume-mode-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.resume-mode-actions .wide-btn { margin-top: 0; }
.wide-btn.danger { color: #fff0f0; border-color: rgba(255,93,100,.45); background: rgba(255,93,100,.16); }
