/* ════════════════════════════════════════════════════════════════════════════
   AIMedNotes — Modern Dark UI Design System (C4c)
   Phase-Based UI + Transcript Drawer
   ════════════════════════════════════════════════════════════════════════════ */

/* ═══ CSS VARIABLES ═══ */
:root {
    --bg-deep: #0f0f1a;
    --bg-base: #151524;
    --bg-raised: #1b1b30;
    --bg-surface: #21213b;
    --bg-hover: #292952;
    --border: rgba(255, 255, 255, 0.05);
    --border-b: rgba(255, 255, 255, 0.10);
    --border-c: rgba(255, 255, 255, 0.15);
    --cyan: #06b6d4;
    --cyan-dim: #0891b2;
    --cyan-glow: rgba(6, 182, 212, 0.12);
    --cyan-bright: #22d3ee;
    --purple: #a78bfa;
    --purple-glow: rgba(167, 139, 250, 0.12);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.15);
    --green: #22c55e;
    --amber: #f59e0b;
    --text: #e2e8f0;
    --text-2: #94a3b8;
    --text-3: #7e8ca3; /* ≥4.5:1 on all app surfaces — functional muted text */
    --text-4: #64748b; /* decorative/de-emphasized only */
    --sidebar-w: 220px;
    --drawer-w: 360px;
    --topbar-h: 42px;

    /* Legacy compat aliases */
    --accent-color: var(--cyan);
    --text-color: var(--text);
    --border-color: var(--border-b);
    --bg-color: var(--bg-deep);
}

/* ═══ RESET & BASE ═══ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; overflow: hidden; height: 100%; color-scheme: dark; }

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background: var(--bg-deep);
    color: var(--text);
    height: 100%;
    display: flex;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    line-height: 1.5;
}

/* Form controls don't inherit fonts by default — without this, stray
   inputs/buttons render in Arial (F-015) */
input, button, textarea, select { font-family: inherit; }

/* ═══ HIDDEN ELEMENTS ═══ */
.hidden { display: none !important; }

/* Visible to screen readers only */
.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;
}

#reviseControls {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.recording-mode-toggle { display: none !important; }

/* Hide button span text — app.js still updates these via querySelector('span').textContent */
.rec-btn > span,
.record-btn > span,
.ra > span { display: none; }


/* ════════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-base);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
}

.sb-brand {
    padding: 17px 16px 15px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 9px;
}

.sb-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    flex-shrink: 0;
}

.sb-name { font-size: .9rem; font-weight: 600; }
.sb-name span { color: var(--cyan); }

.sb-nav {
    padding: 10px 6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
}

/* Ensure sidebar sits on top and isn't clipped by adjacent elements */
.sidebar { overflow: visible; }

.nl {
    font-size: .6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--text-4);
    padding: 11px 10px 5px;
}

.ni {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    font-size: .82rem;
    color: var(--text-3);
    border-radius: 5px;
    cursor: pointer;
    transition: all .12s;
    text-decoration: none;
    user-select: none;
}

.ni:hover { background: var(--bg-hover); color: var(--text-2); }
.ni.active { background: var(--cyan-glow); color: var(--cyan-bright); }
.ni i { width: 16px; text-align: center; font-size: .74rem; }

.bdg {
    margin-left: auto;
    font-size: .58rem;
    font-weight: 600;
    background: var(--bg-surface);
    color: var(--text-4);
    padding: 1px 5px;
    border-radius: 3px;
}
.bdg:empty { display: none; }

/* Sidebar footer — hidden (sign-out available via Preferences view) */
.sb-foot {
    display: none;
}

.ua {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan-dim), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.un { font-size: .74rem; font-weight: 500; color: var(--text); }
.ur { font-size: .58rem; color: var(--text-4); }

/* Sidebar auth (populated by app.js onAuthStateChanged) */
.sb-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan-dim), var(--purple));
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sb-user-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sb-email { font-size: .72rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-signout { font-size: .62rem; color: var(--text-4); text-decoration: none; }
.sb-signout:hover { color: var(--cyan); }


/* ════════════════════════════════════════════════════════════════════════════
   MAIN AREA
   ════════════════════════════════════════════════════════════════════════════ */
.main {
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--sidebar-w);
    right: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: right .25s cubic-bezier(.4, 0, .2, 1);
}


/* ═══ TOPBAR ═══ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 22px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
    min-height: var(--topbar-h);
    flex-shrink: 0;
}

.tb-left { display: flex; align-items: center; gap: 12px; }
.topbar-workflows { display: flex; align-items: center; min-width: 0; }
.tb-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Hamburger — hidden on desktop, shown on mobile via @media */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-b);
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-size: 14px;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    flex-shrink: 0;
}
.hamburger:hover { background: var(--bg-hover); color: var(--text); }

/* Sidebar backdrop (mobile overlay) */
.sb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .3s, visibility .3s;
}
.sb-backdrop.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .78rem; }
.bc-item { color: var(--text-3); }
.bc-item.active { color: var(--cyan-bright); font-weight: 500; }
.bc-sep { color: var(--text-4); font-size: .55rem; }

.w-tabs {
    display: flex;
    background: var(--bg-surface);
    border-radius: 5px;
    padding: 2px;
    gap: 1px;
}

.wt {
    padding: 6px 13px;
    font-family: inherit;
    font-size: .76rem;
    font-weight: 500;
    color: var(--text-3);
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: color .12s, background .12s;
}

.wt:hover { color: var(--text-2); }
.wt.active,
.wt.workflow-btn-active { background: var(--bg-hover); color: var(--cyan-bright); }

/* Touch devices: workflow tabs + preference segments meet the 44px minimum
   touch target (Jesse drives this on an iPad) without changing the compact
   pointer-device look. */
@media (pointer: coarse) {
    .wt { padding: 12px 16px; }
    .pref-toggle-btn { padding: 12px 16px; }
}

/* OR mode: amber accent when OR workflow is active */
body.or-mode .wt.workflow-btn-active { color: #f59e0b; }
body.or-mode .topbar { border-bottom-color: rgba(245, 158, 11, .35); }
body.or-mode .sticky-header { border-bottom-color: rgba(245, 158, 11, .2); }
body.or-mode #bcWorkflow { color: #f59e0b; }

/* OT Mike mode: teal accent when OT workflow is active */
body.ot-mode .wt.workflow-btn-active { color: #14b8a6; }
body.ot-mode .topbar { border-bottom-color: rgba(20, 184, 166, .35); }
body.ot-mode .sticky-header { border-bottom-color: rgba(20, 184, 166, .2); }
body.ot-mode #bcWorkflow { color: #14b8a6; }

/* Appeal mode: violet accent. No audio recording, so hide the recording
   strip and the standard encounter input; show the Appeal panel instead. */
body.appeal-mode .wt.workflow-btn-active { color: #8b5cf6; }
body.appeal-mode .topbar { border-bottom-color: rgba(139, 92, 246, .35); }
body.appeal-mode .sticky-header { border-bottom-color: rgba(139, 92, 246, .2); }
body.appeal-mode #bcWorkflow { color: #8b5cf6; }
body.appeal-mode .rec-strip { display: none; }
body.appeal-mode #standbyScreen { display: none; }
body.appeal-mode .input-area { display: none; }
#appealPanel { display: none; }
body.appeal-mode #appealPanel { display: block; }
body.secondary-view-active #appealPanel { display: none !important; }
body:not(.appeal-mode) #appealPanel { display: none !important; }

.appeal-panel { padding: 14px 0; }
.appeal-panel .in-card { margin-bottom: 14px; }
.appeal-panel textarea { width: 100%; min-height: 110px; }
/* Style the native file input + checkbox to match the design system (F-003) */
#appealFileInput {
    display: block;
    width: 100%;
    padding: 14px;
    border: 1px dashed var(--border, rgba(255, 255, 255, .15));
    border-radius: 8px;
    background: var(--bg-input, rgba(255, 255, 255, .03));
    color: var(--text-3);
    font-family: inherit;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .12s;
}
#appealFileInput:hover { border-color: #8b5cf6; }
#appealFileInput::file-selector-button {
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    color: #c4b5fd;
    background: rgba(139, 92, 246, .14);
    border: 1px solid rgba(139, 92, 246, .35);
    border-radius: 6px;
    padding: 6px 14px;
    margin-right: 12px;
    cursor: pointer;
    transition: background .12s;
}
#appealFileInput::file-selector-button:hover { background: rgba(139, 92, 246, .25); }
.appeal-toolbar input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #8b5cf6;
    cursor: pointer;
}
.appeal-files-list { margin-top: 8px; font-size: .8rem; color: var(--text-secondary, #9aa); }
.appeal-files-list .afi { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.appeal-files-list .afi button { background: none; border: none; color: #f87171; cursor: pointer; }
.appeal-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0 14px; }
.appeal-toolbar label { display: flex; align-items: center; gap: 6px; font-size: .8rem; }
.appeal-generate-btn { background: #8b5cf6; color: #fff; border: none; padding: 9px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.appeal-generate-btn:disabled { opacity: .5; cursor: not-allowed; }

@media (pointer: coarse) {
    .appeal-toolbar label,
    #appealProfileBtn,
    .appeal-generate-btn { min-height: 44px; }
}
.appeal-deadline-banner { background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .4); color: #f59e0b; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }
.appeal-flag-banner { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .4); color: #f87171; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.appeal-gaps-callout { background: rgba(245, 158, 11, .08); border: 1px solid rgba(245, 158, 11, .35); border-radius: 8px; padding: 12px 14px; margin: 14px 0; }
.appeal-gaps-callout h4 { margin: 0 0 8px; color: #f59e0b; font-size: .85rem; }
.appeal-gaps-callout ul { margin: 0; padding-left: 18px; font-size: .82rem; }
.appeal-citations { font-size: .78rem; color: var(--text-secondary, #9aa); margin: 12px 0; }
.appeal-citations a { color: #8b5cf6; }
.appeal-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 9999; }
.appeal-modal-backdrop.show { display: flex; }
.appeal-modal { background: var(--bg-panel, #16181d); border: 1px solid var(--border, #2a2d36); border-radius: 12px; padding: 22px; width: min(560px, 92vw); max-height: 88vh; overflow-y: auto; }
.appeal-modal h3 { margin: 0 0 14px; }
.appeal-modal label { display: block; font-size: .8rem; margin: 10px 0 4px; }
.appeal-modal input, .appeal-modal textarea { width: 100%; padding: 7px 9px; background: var(--bg-input, #0f1115); border: 1px solid var(--border, #2a2d36); color: inherit; border-radius: 6px; }
.appeal-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.st-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: .65rem;
    font-weight: 500;
    color: var(--green);
    background: rgba(34, 197, 94, .07);
    border-radius: 16px;
}

.st-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
}


/* ═══ STICKY HEADER ═══ */
.sticky-header {
    background: var(--bg-deep);
    flex-shrink: 0;
}


/* ═══ RECORDING STRIP ═══ */
.rec-strip {
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    padding: 10px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

/* Record button — round, red outline, pulses when recording */
.rec-btn,
.record-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--red);
    background: rgba(239, 68, 68, .05);
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: inherit;
}

.rec-btn:hover,
.record-btn:hover { background: rgba(239, 68, 68, .12); transform: scale(1.05); }
.rec-btn.recording-active,
.record-btn.recording-active,
.rec-btn.recording,
.record-btn.recording {
    background: var(--red);
    color: #fff;
    animation: recording-glow 1.8s ease-in-out infinite;
}

@keyframes recording-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .15); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Timer */
.rec-timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: .04em;
    min-width: 56px;
    color: var(--text);
}

/* Legacy .timer class compat */
.timer {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: .04em;
    min-width: 56px;
    color: var(--text);
}

.rec-sep { width: 1px; height: 26px; background: var(--border-c); flex-shrink: 0; }

/* Recording status */
.recording-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.status-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-4);
    transition: all .2s;
}

.recording-active .status-indicator,
.recording-status.active .status-indicator {
    background: var(--red);
    box-shadow: 0 0 6px var(--red-glow);
}

.volume-meter {
    width: 40px;
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    overflow: hidden;
}

.volume-bar {
    height: 100%;
    width: 0%;
    background: var(--cyan);
    border-radius: 2px;
    transition: width 0.1s ease;
}

.processing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: .78rem;
    font-weight: 500;
    color: var(--cyan);
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    white-space: nowrap;
    z-index: 5;
    background: var(--bg-raised);
}

.processing-indicator.hidden { display: none; }

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-c);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#processingText { font-size: .76rem; color: var(--text-3); }

/* Action buttons in rec strip */
.rec-actions { display: flex; gap: 6px; }

.ra {
    padding: 9px 18px;
    font-family: inherit;
    font-size: .82rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ra i { font-size: 1rem; }

.ra.process {
    background: var(--cyan);
    color: #fff;
}

.ra.process:hover:not(:disabled) {
    background: var(--cyan-bright);
    box-shadow: 0 0 14px var(--cyan-glow);
    transform: translateY(-1px);
}

.ra.process:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ra.clear {
    background: var(--bg-surface);
    color: var(--text-3);
    border: 1px solid var(--border);
}

.ra.clear:hover { background: var(--bg-hover); color: var(--text-2); }

/* Cancel state — sits above processing indicator overlay */
#transcribeButton.cancel-state,
.ra.cancel-state {
    position: relative;
    z-index: 6;
    background: rgba(239, 68, 68, .12);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, .3);
}

#transcribeButton.cancel-state:hover,
.ra.cancel-state:hover {
    background: rgba(239, 68, 68, .2);
}

/* Confirm-pending state for Clear button */
.ra.confirm-pending,
.clear-btn.confirm-pending {
    background: rgba(239, 68, 68, .12) !important;
    border-color: var(--red) !important;
    color: var(--red) !important;
}

/* Transcript toggle button — opens a docked panel on wide screens and an overlay below. */
.transcript-toggle {
    display: flex !important;
    padding: 7px 12px;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
    border: 1px solid rgba(167, 139, 250, .2);
    border-radius: 6px;
    background: rgba(167, 139, 250, .06);
    color: var(--purple);
    cursor: pointer;
    transition: all .15s;
    align-items: center;
    gap: 5px;
    margin-left: 0;
}

.transcript-toggle:hover { background: rgba(167, 139, 250, .12); border-color: rgba(167, 139, 250, .3); }
.transcript-toggle.active { background: rgba(167, 139, 250, .15); border-color: var(--purple); color: var(--purple); }

/* Toggle switches */
.rec-toggles {
    display: flex;
    gap: 14px;
    margin-left: auto;
    flex-shrink: 1;
    min-width: 0;
}

.stog {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .75rem;
    color: var(--text-3);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

/* Hide the real checkbox */
.stog input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Toggle switch visual */
.str {
    width: 30px;
    height: 17px;
    border-radius: 9px;
    background: var(--bg-surface);
    border: 1px solid var(--border-b);
    position: relative;
    transition: all .2s;
    flex-shrink: 0;
}

.str::after {
    content: '';
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--text-4);
    top: 2px;
    left: 2px;
    transition: all .2s;
}

/* Checked state — activated via JS reading the checkbox */
.stog input[type="checkbox"]:checked + .str {
    background: rgba(6, 182, 212, .18);
    border-color: var(--cyan);
}

.stog input[type="checkbox"]:checked + .str::after {
    left: 15px;
    background: var(--cyan);
    box-shadow: 0 0 6px var(--cyan-glow);
}


/* ═══ PROGRESS BAR ═══ */
.progress-bar-container {
    padding: 12px 22px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
}

.progress-stages {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-stage {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .68rem;
    color: var(--text-4);
    transition: color .2s;
}

.progress-stage.active { color: var(--cyan); }
.progress-stage.completed { color: var(--green); }

.stage-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .58rem;
    font-weight: 600;
    transition: all .2s;
}

.progress-stage.active .stage-icon {
    background: var(--cyan-glow);
    border-color: var(--cyan);
    color: var(--cyan);
}

.progress-stage.completed .stage-icon {
    background: rgba(34, 197, 94, .12);
    border-color: var(--green);
    color: var(--green);
}

.stage-label { font-weight: 500; }

.progress-bar-bg {
    height: 4px;
    background: var(--bg-surface);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 4px;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cyan), var(--cyan-bright));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-time {
    display: flex;
    justify-content: space-between;
    font-size: .62rem;
    color: var(--text-4);
}

.progress-percentage { font-weight: 600; color: var(--cyan); }
.progress-eta { font-weight: 400; }


/* ═══ COLLAPSED INPUT BAR ═══ */
.collapsed-input {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 22px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    cursor: pointer;
    transition: background .15s;
    min-height: 36px;
}

.collapsed-input:hover { background: var(--bg-surface); }
.collapsed-input.visible { display: flex; }

.ci-icon { color: var(--cyan); font-size: .7rem; flex-shrink: 0; }
.ci-text { font-size: .72rem; color: var(--text-3); }

.ci-chevron {
    margin-left: auto;
    color: var(--text-4);
    font-size: .6rem;
    transition: transform .25s;
}

.collapsed-input.expanded .ci-chevron { transform: rotate(180deg); }


/* ═══ CONTENT AREA ═══ */
.content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}


/* ═══ INPUT AREA ═══ */
.input-area {
    overflow: hidden;
    transition: max-height .35s cubic-bezier(.4, 0, .2, 1), opacity .25s ease, padding .3s ease;
    max-height: 600px;
    opacity: 1;
    padding: 16px 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-area.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 22px;
    pointer-events: none;
}

.in-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.in-head {
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.in-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 5px;
}

.in-label i { color: var(--cyan); font-size: .58rem; }

.opt-tag {
    font-size: .55rem;
    font-weight: 500;
    color: var(--purple);
    background: rgba(167, 139, 250, .07);
    padding: 1px 5px;
    border-radius: 3px;
}

.in-card textarea {
    width: 100%;
    min-height: 80px;
    background: transparent;
    border: none;
    padding: 10px 14px;
    font-family: inherit;
    font-size: .84rem;
    line-height: 1.55;
    color: var(--text);
    resize: vertical;
    outline: none;
}

.in-card textarea::placeholder { color: var(--text-3); }

/* Legacy textarea styles (for textareas outside .in-card) */
textarea {
    font-family: inherit;
    color: var(--text);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 6px;
}


/* ═══ STANDBY SCREEN ═══ */
.standby {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 20px;
    text-align: center;
}

/* Legacy compat */
.standby-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 20px;
    text-align: center;
}

.standby.hidden,
.standby-screen.hidden { display: none; }

/* Record-first hero (Focus Flow phase 5): the glyph IS the primary action —
   sized for a confident thumb tap on iPad, with a breathing halo ring. */
.sb-glyph {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(6, 182, 212, .08), rgba(167, 139, 250, .08));
    border: 1px solid var(--border-b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: var(--cyan);
    margin-bottom: 18px;
    animation: float 4s ease-in-out infinite;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    position: relative;
}
.sb-glyph:hover, .sb-glyph:focus-visible {
    border-color: var(--cyan);
    color: var(--cyan-bright);
}

.sb-glyph::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1px solid rgba(6, 182, 212, .3);
    animation: sb-halo 3s ease-out infinite;
    pointer-events: none;
}

@keyframes sb-halo {
    0%   { transform: scale(.92); opacity: .7; }
    70%  { transform: scale(1.18); opacity: 0; }
    100% { transform: scale(1.18); opacity: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.sb-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 3px;
}

.sb-hint {
    font-size: .8rem;
    color: var(--text-3);
    margin-bottom: 20px;
}

/* Legacy standby classes */
.standby-content { text-align: center; }
.standby-logo { font-size: 24px; color: var(--cyan); margin-bottom: 14px; }
.standby-title { font-size: .95rem; font-weight: 600; color: var(--text-2); margin-bottom: 3px; }
.standby-subtitle { font-size: .8rem; color: var(--text-4); margin-bottom: 10px; }
.standby-instructions { display: none; } /* replaced by sb-hint */
.standby-step { display: none; }


/* ════════════════════════════════════════════════════════════════════════════
   NOTE OUTPUT PANEL
   ════════════════════════════════════════════════════════════════════════════ */
.note-panel {
    display: none;
    flex-direction: column;
}

.note-panel.active,
.note-panel:not(.hidden) {
    display: flex;
}

/* Legacy container class compat (was .container on aiResponseContainer) */
#aiResponseContainer { border: none; margin: 0; padding: 0; }
#aiResponseContainer .card { background: transparent; border: none; padding: 0; margin: 0; }

/* Note header bar — sticky so it stays visible while scrolling through note */
.n-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px;
    background: linear-gradient(180deg, var(--bg-surface), var(--bg-raised));
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.nb-left { display: flex; align-items: center; gap: 10px; }

.nb-ico {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--cyan-glow), rgba(167, 139, 250, .06));
    border: 1px solid var(--border-b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--cyan);
}

.nb-title { margin: 0; font-size: .86rem; font-weight: 600; color: var(--text); }
.nb-meta { font-size: .64rem; color: var(--text-3); }

.nb-actions { display: flex; gap: 5px; align-items: center; }

.nb-btn {
    padding: 6px 12px;
    font-family: inherit;
    font-size: .72rem;
    font-weight: 500;
    border-radius: 5px;
    cursor: pointer;
    transition: all .12s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nb-ghost {
    background: transparent;
    border: 1px solid var(--border-b);
    color: var(--text-3);
}

.nb-ghost:hover { background: var(--bg-hover); color: var(--text); }

.nb-primary {
    background: var(--cyan);
    border: none;
    color: #fff;
}

.nb-primary:hover {
    background: var(--cyan-bright);
    box-shadow: 0 0 14px var(--cyan-glow);
}

/* Legacy response header compat */
.response-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
}

.response-header-right { display: flex; gap: 6px; }

/* AI Response text area */
.ai-response-text {
    padding: 0 24px;
    /* Reading column — clinical notes are documents; don't sprawl full-width
       on desktop/iPad landscape */
    max-width: 900px;
    margin: 0 auto;
}


/* ═══ NOTE SECTIONS (generated dynamically by app.js) ═══ */
.note-section {
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.note-section:last-of-type { border-bottom: none; }
.note-section:hover { background: rgba(255, 255, 255, .01); }

.section-header {
    display: flex;
    align-items: center;
    padding: 11px 22px;
    gap: 8px;
    cursor: default;
}

/* Collapsible sections (Focus Flow ph 5) — scoped to the LIVE note panel
   only: history cards render the same .note-section markup and a leaked
   section-collapsed class must not clip content there. */
#aiResponseText .section-header { cursor: pointer; }

/* Collapse affordance: chevron at the far right of the header. Points down
   when expanded, right when collapsed. Plain glyph — FA fonts don't render
   reliably in pseudo-elements. */
#aiResponseText .section-header::after {
    content: '›';
    margin-left: auto;
    color: var(--text-4);
    font-size: .9rem;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform .15s, opacity .15s;
    opacity: 0;
}

#aiResponseText .note-section:hover .section-header::after,
#aiResponseText .note-section.section-collapsed .section-header::after { opacity: 1; }

#aiResponseText .note-section.section-collapsed .section-header::after { transform: rotate(0deg); }
/* Collapse by CLIPPING, not display:none — several save/learn/verify paths
   read section text via innerText, which returns '' for display:none nodes
   (a collapsed section would look deleted). Clipped text stays in the
   render tree, so innerText still sees it. */
#aiResponseText .note-section.section-collapsed .section-body {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    margin: 0;
}

.section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--cyan);
    display: flex;
    align-items: center;
    gap: 7px;
}

.section-title i { font-size: .6rem; }

/* Section action buttons — appear on hover, positioned LEFT of title */
.section-actions {
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity .15s;
    order: -1;
}

.note-section:hover .section-actions { opacity: 1; }

.section-actions button {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-4);
    font-size: .6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
    font-family: inherit;
}

.section-actions button:hover { background: var(--bg-hover); color: var(--cyan); }

.section-body {
    padding: 0 22px 18px;
    /* Source Serif 4 — the .note-body migration planned in redesign.css,
       now applied: notes read as clinical documents, not UI chrome */
    font-family: var(--c-font-serif, Georgia, serif);
    font-size: .95rem;
    line-height: 1.7;
    color: var(--text-2);
    max-width: 75ch;
}

.section-body p { margin-bottom: 5px; }
.section-body p:last-child { margin-bottom: 0; }
.section-body strong { color: var(--text); font-weight: 600; }

/* Touch devices: section actions can't be hover-discovered — keep them
   softly visible and give them real touch targets */
@media (pointer: coarse) {
    .section-actions { opacity: .7; }
    .section-actions button { width: 44px; height: 44px; font-size: .8rem; }
}

/* Section badges (failed, warning, success) */
.section-badge {
    font-size: .55rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
}

.section-badge.failed,
.section-badge.error {
    color: var(--red);
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .2);
}

.section-badge.warning {
    color: var(--amber);
    background: rgba(245, 158, 11, .08);
    border: 1px solid rgba(245, 158, 11, .2);
}

.section-badge.success {
    color: var(--green);
    background: rgba(34, 197, 94, .08);
    border: 1px solid rgba(34, 197, 94, .2);
}

/* Retry button */
.retry-btn,
.section-retry {
    font-size: .68rem;
    color: var(--cyan);
    background: transparent;
    border: 1px solid var(--border-b);
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    transition: all .12s;
    font-family: inherit;
}

.retry-btn:hover,
.section-retry:hover {
    background: var(--cyan-glow);
    border-color: var(--cyan);
}

/* Inline regen prompt */
.inline-regen-prompt {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 22px 12px;
    background: rgba(6, 182, 212, .04);
    border-top: 1px solid var(--border);
}

.inline-regen-prompt input {
    flex: 1;
    padding: 6px 10px;
    font-family: inherit;
    font-size: .8rem;
    background: var(--bg-deep);
    border: 1px solid var(--border-b);
    border-radius: 5px;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}

.inline-regen-prompt input:focus { border-color: var(--cyan); }

.inline-regen-prompt button {
    padding: 6px 12px;
    font-family: inherit;
    font-size: .72rem;
    font-weight: 500;
    border-radius: 5px;
    cursor: pointer;
    transition: all .12s;
    border: none;
}

.inline-regen-prompt .regen-go {
    background: var(--cyan);
    color: #fff;
}

.inline-regen-prompt .regen-go:hover { background: var(--cyan-bright); }

.inline-regen-prompt .regen-cancel {
    background: var(--bg-surface);
    color: var(--text-3);
    border: 1px solid var(--border);
}

.inline-regen-prompt .regen-cancel:hover { background: var(--bg-hover); }

/* Section loading spinner */
.section-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 22px;
    font-size: .76rem;
    color: var(--text-3);
}

/* Regen button */
.regen-btn,
.section-regen {
    font-size: .6rem;
    padding: 2px 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-4);
    border-radius: 3px;
    cursor: pointer;
    transition: all .12s;
    font-family: inherit;
}

.regen-btn:hover,
.section-regen:hover {
    background: var(--bg-hover);
    border-color: var(--border-b);
    color: var(--cyan);
}

/* Brace quick-add dropdown */
.brace-add-btn { margin-left: 2px; }

.brace-quickadd-dropdown {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

.brace-quickadd-list { padding: 0 4px; }

.brace-quickadd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: .78rem;
    border-radius: 4px;
    transition: background .1s;
}

.brace-quickadd-item:hover { background: var(--bg-hover); }

.brace-quickadd-item input[type="checkbox"] {
    accent-color: var(--cyan);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.brace-quickadd-title { color: var(--text-1); }

.brace-quickadd-source {
    font-size: .65rem;
    color: var(--cyan);
    margin-left: auto;
}

.brace-quickadd-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px 4px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.brace-quickadd-add {
    flex: 1;
    padding: 6px 12px;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    background: var(--cyan);
    color: #fff;
    transition: opacity .12s;
}

.brace-quickadd-add:disabled { opacity: .4; cursor: default; }
.brace-quickadd-add:not(:disabled):hover { opacity: .85; }

.brace-quickadd-cancel {
    padding: 6px 12px;
    font-family: inherit;
    font-size: .75rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--bg-surface);
    color: var(--text-3);
    transition: background .12s;
}

.brace-quickadd-cancel:hover { background: var(--bg-hover); }

/* Note section fade-in animation */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.note-section.fade-in { animation: fadeInUp 0.3s ease forwards; }

/* ═══ INLINE TRANSCRIPT (Focus Flow phase 5) ═══
   Collapsed strip under the note; expands in place. The side drawer stays
   for desktop side-by-side reading. */
.inline-transcript {
    margin: 18px 22px 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
}

.it-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    transition: color .12s;
}

.it-toggle:hover { color: var(--text-2); }

.it-chevron { font-size: .6rem; transition: transform .15s; }
.it-chevron.it-open { transform: rotate(90deg); }

.it-meta {
    margin-left: auto;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-4);
    font-size: .7rem;
}

.it-body {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    font-size: .82rem;
    line-height: 1.7;
    color: var(--text-2);
    white-space: pre-wrap;
    max-height: 320px;
    overflow-y: auto;
}

/* ═══ SKELETON LOADING STATES ═══ */
@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton-line {
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--bg-deep) 25%, rgba(148,163,184,.08) 50%, var(--bg-deep) 75%);
    background-size: 800px 100%;
    animation: shimmer 1.5s ease infinite;
}

/* Skeleton container for note sections while generating */
.skeleton-section {
    border-bottom: 1px solid var(--border);
    padding: 11px 22px;
}
.skeleton-section-title {
    width: 120px;
    height: 10px;
    margin-bottom: 12px;
}
.skeleton-section-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 0 8px;
}
.skeleton-section-body .skeleton-line:nth-child(1) { width: 95%; }
.skeleton-section-body .skeleton-line:nth-child(2) { width: 80%; }
.skeleton-section-body .skeleton-line:nth-child(3) { width: 60%; }

/* History skeleton */
.skeleton-history-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.skeleton-history-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    flex-shrink: 0;
}
.skeleton-history-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.skeleton-history-lines .skeleton-line:nth-child(1) { width: 60%; height: 10px; }
.skeleton-history-lines .skeleton-line:nth-child(2) { width: 40%; height: 8px; }

/* Add Section Dropdown */
.add-section-container { position: relative; }

.add-section-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-b);
    border-radius: 6px;
    padding: 4px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
    z-index: 100;
}

.add-section-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    font-family: inherit;
    font-size: .76rem;
    color: var(--text-2);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all .12s;
}

.add-section-dropdown button:hover { background: var(--bg-hover); color: var(--text); }


/* ════════════════════════════════════════════════════════════════════════════
   TRANSCRIPT DRAWER
   ════════════════════════════════════════════════════════════════════════════ */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--drawer-w);
    background: var(--bg-base);
    border-left: 1px solid var(--border-b);
    z-index: 60;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

body.drawer-open .drawer { transform: translateX(0); }

@media (min-width: 1280px) {
    body.drawer-open .main { right: var(--drawer-w); }
}

@media (min-width: 769px) and (max-width: 1279px) {
    body.drawer-open .drawer { box-shadow: -18px 0 40px rgba(0, 0, 0, .45); }
}

.drawer-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.d-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(167, 139, 250, .1);
    border: 1px solid rgba(167, 139, 250, .15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    color: var(--purple);
}

.drawer-meta {
    font-size: .65rem;
    color: var(--text-3);
    margin-left: 4px;
}

.drawer-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
    font-family: inherit;
}

.drawer-close:hover { background: var(--bg-hover); color: var(--text); }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }

.drawer-body textarea {
    width: 100%;
    min-height: calc(100vh - 180px);
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    font-family: 'Outfit', sans-serif;
    font-size: .85rem;
    line-height: 1.7;
    color: var(--text-2);
    resize: vertical;
    outline: none;
}

.drawer-body textarea:focus { border-color: rgba(167, 139, 250, .25); }

.drawer-actions {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 6px;
}

.d-btn {
    padding: 7px 14px;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
    border-radius: 5px;
    cursor: pointer;
    transition: all .12s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.d-ghost {
    background: transparent;
    border: 1px solid var(--border-b);
    color: var(--text-3);
}
.d-ghost:hover { background: var(--bg-hover); color: var(--text-2); }

/* Secondary outline style for Re-process */
.d-secondary {
    background: transparent;
    border: 1px dashed var(--border-b);
    color: var(--text-3);
    font-size: .75rem;
}
.d-secondary:hover { background: rgba(167, 139, 250, .06); color: var(--purple); border-color: var(--purple); border-style: solid; }

.d-purple { background: var(--purple); border: none; color: #fff; }
.d-purple:hover { background: #b89cf5; }


/* ════════════════════════════════════════════════════════════════════════════
   AUTH OVERLAY
   ════════════════════════════════════════════════════════════════════════════ */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, .92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.auth-overlay.hidden { display: none; }

/* When signed in, the overlay should be hidden */
.auth-overlay.signed-in { display: none; }

.auth-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-b);
    border-radius: 12px;
    padding: 32px;
    width: 340px;
    max-width: 90vw;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 24px;
    justify-content: center;
}

.auth-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-input {
    padding: 10px 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border-b);
    border-radius: 6px;
    font-family: inherit;
    font-size: .84rem;
    color: var(--text);
    outline: none;
    transition: border-color .15s;
}

.auth-input:focus { border-color: var(--cyan); }
.auth-input::placeholder { color: var(--text-4); }

.auth-submit {
    padding: 10px;
    background: var(--cyan);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: .84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    margin-top: 4px;
}

.auth-submit:hover {
    background: var(--cyan-bright);
    box-shadow: 0 0 14px var(--cyan-glow);
}

.auth-forgot {
    font-size: .76rem;
    color: var(--text-3);
    text-align: center;
    text-decoration: none;
    transition: color .12s;
}

.auth-forgot:hover { color: var(--cyan); }


/* ════════════════════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, .85);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
}

.modal.hidden { display: none !important; }

.modal-content {
    background: var(--bg-raised);
    border: 1px solid var(--border-b);
    border-radius: 10px;
    width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

.template-editor-modal { width: 900px; max-width: 95vw; }

.template-section {
    position: relative;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.template-section:hover { border-color: rgba(6, 182, 212, .25); }

.template-title {
    width: 100%;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .84rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    outline: none;
    box-sizing: border-box;
}
.template-title:focus { border-color: var(--cyan-bright); }
.template-title::placeholder { color: var(--text-4); }

.template-content {
    width: 100%;
    min-height: 200px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .82rem;
    font-family: 'Outfit', sans-serif;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    box-sizing: border-box;
}
.template-content:focus { border-color: var(--cyan-bright); }
.template-content::placeholder { color: var(--text-4); }

.remove-template-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, .08);
    border: 1px solid rgba(239, 68, 68, .2);
    border-radius: 4px;
    color: var(--red, #ef4444);
    font-size: .68rem;
    padding: 3px 8px;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    z-index: 2;
}
.remove-template-btn:hover { background: rgba(239, 68, 68, .18); }

.template-section.tmpl-filtered-out { display: none; }

/* Search bar inside template editor */
.template-editor-search {
    position: sticky;
    top: 0;
    z-index: 3;
    margin-bottom: 12px;
    background: var(--bg);
    padding: 4px 0;
}
.template-editor-search i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-4);
    font-size: .72rem;
}
.template-editor-search input {
    width: 100%;
    padding: 8px 12px 8px 30px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .78rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    box-sizing: border-box;
}
.template-editor-search input:focus { border-color: var(--cyan-bright); }
.template-editor-search input::placeholder { color: var(--text-4); }
.template-editor-search .tmpl-editor-match-count {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .68rem;
    color: var(--text-4);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-3);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    font-size: .84rem;
    color: var(--text-2);
    line-height: 1.6;
}

.modal-body textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: .84rem;
    color: var(--text);
    resize: vertical;
    outline: none;
    line-height: 1.5;
}

.modal-body textarea:focus { border-color: var(--cyan); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}


/* ═══ BUTTONS (generic, used in modals/panels) ═══ */
.button {
    padding: 7px 14px;
    font-family: inherit;
    font-size: .76rem;
    font-weight: 500;
    border: 1px solid var(--border-b);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-3);
    cursor: pointer;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

.button:hover { background: var(--bg-hover); color: var(--text-2); }

.button-primary {
    background: var(--cyan) !important;
    color: #fff !important;
    border-color: transparent !important;
}

.button-primary:hover {
    background: var(--cyan-bright) !important;
    box-shadow: 0 0 14px var(--cyan-glow);
}

.btn-export { background: rgba(34, 197, 94, .12); color: var(--green); border-color: rgba(34, 197, 94, .2); }
.btn-export:hover { background: rgba(34, 197, 94, .2); }

.btn-samples { background: rgba(6, 182, 212, .12); color: var(--cyan); border-color: rgba(6, 182, 212, .2); }
.btn-samples:hover { background: rgba(6, 182, 212, .2); }

.btn-secondary { background: var(--bg-surface); color: var(--text-3); }
.btn-secondary:hover { background: var(--bg-hover); }

.delete-data-btn {
    background: transparent !important;
    border: 1px solid rgba(239, 68, 68, .3) !important;
    color: var(--red) !important;
}

.delete-data-btn:hover { background: rgba(239, 68, 68, .08) !important; }

.admin-button { font-size: .76rem; }
.signout-button { font-size: .76rem; }


/* ═══ TEMPLATE MANAGEMENT ═══ */
.template-management-section {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

/* Template categories — collapsible cards with inline actions */
.tmpl-search-wrap {
    position: relative;
    margin-bottom: 12px;
}
.tmpl-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-4);
    font-size: .72rem;
}
.tmpl-search-input {
    width: 100%;
    padding: 8px 12px 8px 30px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .78rem;
    font-family: 'Outfit', sans-serif;
    outline: none;
    box-sizing: border-box;
}
.tmpl-search-input:focus { border-color: var(--cyan-bright); }
.tmpl-search-input::placeholder { color: var(--text-4); }

.tmpl-categories { display: flex; flex-direction: column; gap: 8px; }

.tmpl-category {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .2s;
}
.tmpl-category.tmpl-expanded { border-color: rgba(6, 182, 212, .3); }
.tmpl-category.hidden { display: none; }

.tmpl-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
}
.tmpl-category-header:hover { background: var(--bg-hover); }

.tmpl-chevron {
    font-size: .6rem;
    color: var(--text-4);
    transition: transform .2s;
    width: 12px;
    text-align: center;
    flex-shrink: 0;
}
.tmpl-category.tmpl-expanded .tmpl-chevron { transform: rotate(90deg); }

.tmpl-cat-title {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tmpl-count-badge {
    font-size: .65rem;
    color: var(--text-4);
    flex-shrink: 0;
}

.tmpl-cat-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}
.tmpl-act-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 7px;
    font-size: .62rem;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
}
.tmpl-act-btn:hover {
    background: var(--bg-hover);
    color: var(--cyan-bright);
    border-color: var(--cyan-bright);
}
.tmpl-act-btn i { font-size: .58rem; }

.tmpl-category-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}
.tmpl-category.tmpl-expanded .tmpl-category-body {
    max-height: 5000px;
}

.tmpl-items-list {
    padding: 0 12px 10px;
}
.tmpl-items-list.hidden { display: none; }

.tmpl-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: .72rem;
    line-height: 1.4;
}
.tmpl-item:last-child { border-bottom: none; }
.tmpl-item-title {
    color: var(--text);
    font-weight: 600;
}
.tmpl-item-preview {
    color: var(--text-4);
}
.tmpl-item.tmpl-highlight {
    background: rgba(6, 182, 212, .08);
    margin: 0 -12px;
    padding: 6px 12px;
    border-radius: 4px;
}

.tmpl-empty {
    padding: 12px;
    text-align: center;
    font-size: .72rem;
    color: var(--text-4);
}

/* Template editor specifics */
.template-sections { margin-bottom: 16px; }

.template-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.add-template-btn { background: rgba(6, 182, 212, .12); color: var(--cyan); border-color: rgba(6, 182, 212, .2); }
.delete-all-btn { background: rgba(239, 68, 68, .08); color: var(--red); border-color: rgba(239, 68, 68, .2); }

.template-navigation {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 8px;
    float: right;
    z-index: 5;
}

.nav-arrow {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-b);
    background: var(--bg-surface);
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    transition: all .12s;
}

.nav-arrow:hover { background: var(--bg-hover); color: var(--text); }

.bulk-upload-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.bulk-upload-section h4 {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.bulk-upload-instructions p,
.bulk-export-instructions p,
.sample-templates-instructions p,
.template-instructions p {
    font-size: .78rem;
    color: var(--text-3);
    margin-bottom: 8px;
}

.bulk-upload-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.sample-templates-actions {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.sample-templates-list {
    max-height: 400px;
    overflow-y: auto;
}


/* ═══ VIEW PANELS (shared by History, Templates, Settings) ═══ */
.view-panel {
    padding: 20px 22px;
}

.view-panel .card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.view-title {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-title i {
    font-size: .72rem;
    color: var(--cyan);
}

.view-actions {
    display: flex;
    gap: 6px;
}

/* Legacy compat */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.major-section {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

/* ═══ NOTE HISTORY ═══ */
/* History search & filter bar */
.history-filters { padding: 0 0 12px; }
.history-search-row {
    position: relative;
    margin-bottom: 8px;
}
.history-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-4);
    font-size: .72rem;
}
.history-search {
    width: 100%;
    padding: 8px 10px 8px 30px;
    font-size: .8rem;
    font-family: inherit;
    background: var(--bg-raised);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
}
.history-search:focus { border-color: var(--cyan); outline: none; }
.history-search::placeholder { color: var(--text-3); }

.history-filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-pills { display: flex; gap: 4px; }
.filter-pill {
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    color: var(--text-3);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all .12s;
}
.filter-pill:hover { color: var(--text-2); border-color: var(--border-b); }
.filter-pill.filter-active { background: var(--bg-hover); color: var(--cyan-bright); border-color: var(--cyan); }

.history-load-more {
    text-align: center;
    padding: 12px 0;
}

.note-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-history-empty {
    text-align: center;
    padding: 40px 20px;
    font-size: .82rem;
    color: var(--text-4);
}

/* Each note history item = card with header, note box, optional inputs box.
   Left accent stripe + badge tint carry the workflow color (Focus Flow ph 4):
   clinic=cyan, or=amber, ot=teal, appeal=violet — same palette as the
   workflow tabs (body.or-mode etc.). */
.note-history-item {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--cyan);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .15s;
}

.note-history-item:hover { border-color: var(--border-b); }
.note-history-item.wf-clinic:hover { border-left-color: var(--cyan); }

.note-history-item.wf-or { border-left-color: #f59e0b; }
.note-history-item.wf-or .note-history-type {
    background: rgba(245, 158, 11, .1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, .18);
}

.note-history-item.wf-ot_mike { border-left-color: #14b8a6; }
.note-history-item.wf-ot_mike .note-history-type {
    background: rgba(20, 184, 166, .1);
    color: #14b8a6;
    border-color: rgba(20, 184, 166, .18);
}

.note-history-item.wf-appeal { border-left-color: #8b5cf6; }
.note-history-item.wf-appeal .note-history-type {
    background: rgba(139, 92, 246, .1);
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, .18);
}

/* Header: date + workflow type badge */
.note-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
}

.note-history-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-left: 12px;
}

.history-expand-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-b);
    border-radius: 5px;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: background .12s, color .12s, transform .18s;
}

.history-expand-btn:hover { background: var(--bg-hover); color: var(--cyan); }
.history-expand-btn i { transition: transform .18s; }
.note-history-item.expanded .history-expand-btn i { transform: rotate(180deg); }
.note-history-details[hidden] { display: none; }

.note-history-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 360px;
    flex-wrap: wrap;
}

.history-label-input {
    flex: 1 1 100%;
    min-width: 180px;
    padding: 3px 0;
    border: 0;
    border-bottom: 1px solid transparent;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: 600 .84rem/1.3 'Outfit', sans-serif;
}
.history-label-input:hover { border-bottom-color: var(--border-b); }
.history-label-input:focus { border-bottom-color: var(--cyan); }
.history-label-input:disabled { opacity: .65; }

.note-history-date {
    font-size: .72rem;
    color: var(--text-3);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
}

.note-history-type {
    font-size: .58rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--cyan-glow);
    color: var(--cyan);
    border: 1px solid rgba(6, 182, 212, .15);
}

.history-status-chip {
    padding: 2px 7px;
    border: 1px solid var(--border-b);
    border-radius: 999px;
    color: var(--text-3);
    font-size: .62rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.history-status-chip.shipped {
    border-color: rgba(34, 197, 94, .28);
    background: rgba(34, 197, 94, .08);
    color: #86efac;
}

/* Note content box + Inputs box */
.note-history-box {
    border-bottom: 1px solid var(--border);
}

.note-history-box:last-child { border-bottom: none; }

.note-history-box-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: rgba(255, 255, 255, .01);
    border-bottom: 1px solid var(--border);
}

.note-history-box-title {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.note-history-box-title i { font-size: .6rem; color: var(--cyan); }

.copy-history-btn {
    padding: 4px 10px;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
    border-radius: 4px;
    border: 1px solid var(--border-b);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: all .12s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.copy-history-btn:hover { background: var(--bg-hover); color: var(--cyan); border-color: rgba(6, 182, 212, .2); }

@media (pointer: coarse) {
    .history-expand-btn,
    .copy-history-btn,
    .filter-pill { min-height: 44px; }
}

@media (max-width: 768px) {
    .note-history-header {
        align-items: flex-start;
        gap: 8px;
        flex-wrap: wrap;
    }
    .note-history-actions {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .history-expand-btn { margin-left: auto; }
}

.note-history-box-content {
    padding: 12px 14px;
    font-size: .82rem;
    line-height: 1.65;
    color: var(--text-2);
    max-height: 200px;
    overflow-y: auto;
}

/* Nested note content formatting */
.note-history-box-content h3,
.note-history-box-content h4 {
    font-size: .76rem;
    font-weight: 600;
    color: var(--cyan);
    margin: 8px 0 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.note-history-box-content h3:first-child,
.note-history-box-content h4:first-child { margin-top: 0; }

.note-history-box-content p { margin-bottom: 4px; }
.note-history-box-content strong { color: var(--text); font-weight: 500; }

/* Inputs section */
.inputs-box .note-history-box-content { max-height: 150px; }

.input-section-text {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.input-section-text:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.input-label {
    display: block;
    font-size: .66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-3);
    margin-bottom: 4px;
}

/* Legacy compat for old simple note-history-item layout */
.note-history-item .note-date {
    font-size: .72rem;
    color: var(--text-4);
}

.note-history-item .note-preview {
    font-size: .78rem;
    color: var(--text-2);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-history-item .delete-note-btn:hover { color: var(--red); border-color: rgba(239, 68, 68, .3); }

/* ═══ SETTINGS PANEL ═══ */
.settings-section {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-label {
    font-size: .76rem;
    font-weight: 500;
    color: var(--text-3);
}

.settings-value {
    font-size: .76rem;
    color: var(--text-2);
}

.settings-group-label {
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 16px 4px 6px;
}
.settings-group-label:first-of-type { padding-top: 0; }

.settings-row-detail {
    display: block;
    max-width: 480px;
    margin-top: 3px;
    color: var(--text-4);
    font-size: .7rem;
    line-height: 1.4;
}
.settings-danger-row { gap: 18px; }

/* Toggle button group (Clinic/OR) */
.settings-toggle {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-b);
}
.pref-toggle-btn {
    padding: 5px 14px;
    font-size: .72rem;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    color: var(--text-3);
    border: none;
    cursor: pointer;
    transition: all .12s;
}
.pref-toggle-btn:not(:last-child) { border-right: 1px solid var(--border-b); }
.pref-toggle-btn.pref-active { background: var(--bg-hover); color: var(--cyan-bright); }
.pref-toggle-btn:hover:not(.pref-active) { color: var(--text-2); }

/* Select dropdown */
.settings-select {
    padding: 5px 10px;
    font-size: .72rem;
    font-family: inherit;
    background: var(--bg-base);
    color: var(--text-2);
    border: 1px solid var(--border-b);
    border-radius: 6px;
    cursor: pointer;
    max-width: 220px;
}
.settings-select:focus { border-color: var(--cyan); outline: none; }

/* Toggle switch */
.settings-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}
.settings-switch input { opacity: 0; width: 0; height: 0; }
.settings-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-hover);
    border-radius: 20px;
    cursor: pointer;
    transition: .2s;
}
.settings-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text-4);
    border-radius: 50%;
    transition: .2s;
}
.settings-switch input:checked + .settings-slider { background: var(--cyan); }
.settings-switch input:checked + .settings-slider::before { transform: translateX(16px); background: #fff; }


/* ═══ ERROR / MESSAGE CONTAINERS ═══ */
.error-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 500;
    max-width: 400px;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-raised);
    border: 1px solid rgba(239, 68, 68, .3);
    border-left: 3px solid var(--red);
    border-radius: 6px;
    font-size: .8rem;
    color: var(--text-2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}

.error-message i { color: var(--red); flex-shrink: 0; }

/* Toast-style message container (created dynamically by showMessage) */
#messageContainer,
#authMessageContainer,
#authErrorContainer {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    padding: 14px 24px;
    background: var(--bg-raised);
    border: 1px solid var(--border-b);
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
}


/* ═══ PERMISSION ERROR OVERLAY ═══ */
.permission-error-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, .9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
}

.permission-error-overlay.hidden { display: none; }

.permission-error-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-b);
    border-radius: 10px;
    padding: 32px;
    text-align: center;
    max-width: 420px;
}

.permission-error-icon {
    font-size: 36px;
    color: var(--red);
    margin-bottom: 14px;
}

.permission-error-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.permission-error-card p {
    font-size: .84rem;
    color: var(--text-2);
    margin-bottom: 16px;
}

.permission-instructions {
    text-align: left;
    padding: 12px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: .78rem;
    color: var(--text-3);
}

.permission-error-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.permission-error-buttons button {
    padding: 8px 16px;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all .12s;
    border: 1px solid var(--border-b);
    background: var(--bg-surface);
    color: var(--text-3);
}

.permission-error-buttons button:first-child {
    background: var(--cyan);
    border-color: transparent;
    color: #fff;
}

.permission-error-buttons button:first-child:hover {
    background: var(--cyan-bright);
}


/* ════════════════════════════════════════════════════════════════════════════
   FLOATING ACTION BUTTON (mobile)
   ════════════════════════════════════════════════════════════════════════════ */
.floating-actions {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}

.floating-actions.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.fab-main {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--red);
    background: var(--bg-raised);
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
    font-family: inherit;
}

.fab-main:hover { background: rgba(239, 68, 68, .1); }
.fab-main.recording { background: var(--red); color: #fff; }

/* Contextual FAB states (Focus Flow phase 3) — set by updateFabState() */
.fab-main.fab-ready { border-color: var(--cyan); color: var(--cyan); }
.fab-main.fab-ready:hover { background: rgba(6, 182, 212, .12); }
.fab-main.fab-processing { border-color: var(--amber); color: var(--amber); }
.fab-main.fab-processing:hover { background: rgba(245, 158, 11, .12); }

.fab-menu {
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: scale(0.8);
    transition: all .2s;
    pointer-events: none;
}

.fab-menu.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.fab-item {
    width: 44px; /* 44px minimum touch target */
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-b);
    background: var(--bg-raised);
    color: var(--text-3);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
    font-family: inherit;
}

.fab-item:hover { background: var(--bg-hover); color: var(--cyan); }

.fab-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-4);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .12s;
    font-family: inherit;
}

.fab-toggle:hover { background: var(--bg-hover); color: var(--text-2); }

/* Disable FAB when note is displayed */
.floating-actions.fab-disabled { display: none !important; }


/* ════════════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (pointer: coarse) {
    .hamburger,
    .drawer-close,
    .fab-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    .ra,
    .transcript-toggle,
    .d-btn,
    .settings-select,
    #settingsSignOutBtn,
    #appealFileInput::file-selector-button {
        min-height: 44px;
    }
}

@media (max-width: 768px) {
    /* Sidebar: hidden off-screen, slides in when hamburger tapped */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.4, 0, .2, 1);
        z-index: 200;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .hamburger { display: flex; }

    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select,
    .in-card textarea {
        font-size: 16px;
    }

    .main {
        left: 0 !important;
        right: 0 !important;
    }

    /* Template action buttons: icon-only on mobile */
    .tmpl-act-btn span { display: none; }
    .tmpl-act-btn { padding: 4px 6px; }

    /* Drawer: hidden off-screen on mobile, slides in via transcript toggle */
    .drawer {
        width: 100%;
        transform: translateX(100%);
        transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    }
    .drawer.open,
    body.drawer-open .drawer { transform: translateX(0); }

    /* Show transcript toggle on mobile (hidden on desktop) */
    .transcript-toggle { display: flex !important; margin-left: 0; }

    .rec-strip {
        flex-wrap: wrap;
        padding: 10px 14px;
    }

    .rec-toggles {
        width: 100%;
        margin-left: 0;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        margin-top: 4px;
    }

    .n-bar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .nb-actions {
        width: 100%;
    }

    .nb-btn { flex: 1; justify-content: center; }

    .topbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "primary status"
            "workflows workflows";
        gap: 8px;
        padding: 10px 14px;
    }
    .tb-left { grid-area: primary; min-width: 0; }
    .topbar-workflows { grid-area: workflows; width: 100%; }
    .topbar-workflows .w-tabs {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        width: 100%;
    }
    .topbar-workflows .tooltip { min-width: 0; }
    .wt {
        min-width: 0;
        min-height: 44px;
        padding: 10px 6px;
        white-space: nowrap;
    }
    .tb-right { grid-area: status; margin-left: 0; align-self: center; }
    .st-pill { width: 12px; height: 12px; padding: 0; justify-content: center; }
    .st-label { display: none; }
    .appeal-panel { padding: 14px; }
    .appeal-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 0;
    }
    .appeal-toolbar label {
        width: 100%;
        min-height: 44px;
        padding: 8px 10px;
        border: 1px solid var(--border);
        border-radius: 6px;
        background: var(--bg-raised);
    }
    #appealUrgent { width: 18px; height: 18px; }
    #appealProfileBtn,
    .appeal-generate-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }
    .input-area { padding: 12px 14px; }
    .section-header { padding: 11px 14px; }
    .section-body { padding: 0 14px 16px; }

    .floating-actions { bottom: 16px; right: 16px; }

    .view-panel { padding: 12px 14px; }

    .auth-card { padding: 24px; }

    /* Standby screen: slightly smaller on mobile */
    .sb-glyph { width: 72px; height: 72px; font-size: 26px; }
    .sb-title { font-size: .9rem; }
    .sb-hint { font-size: .75rem; }
}

@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
        .sidebar {
            padding-top: env(safe-area-inset-top);
            padding-bottom: env(safe-area-inset-bottom);
        }
        .drawer-header { padding-top: calc(14px + env(safe-area-inset-top)); }
        .drawer-actions { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
        .content { padding-bottom: env(safe-area-inset-bottom); }
        .floating-actions { bottom: calc(16px + env(safe-area-inset-bottom)); }
    }
}


/* ════════════════════════════════════════════════════════════════════════════
   SCROLLBAR
   ════════════════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .06); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .1); }


/* ════════════════════════════════════════════════════════════════════════════
   UTILITY CLASSES & ANIMATIONS
   ════════════════════════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
}

/* Copy button flash */
.copy-flash { background: var(--green) !important; color: #fff !important; transition: none !important; }

/* Section content editable — default (not focused) */
.section-body[contenteditable="true"] {
    outline: none;
    border-radius: 4px;
    cursor: text;
}
/* Section content editable — actively editing */
.section-body[contenteditable="true"]:focus {
    background: #fff;
    color: #1a1a2e;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    outline: 2px solid var(--cyan);
    outline-offset: -1px;
    padding: 10px;
}
.section-body[contenteditable="true"]:focus strong {
    color: #1a1a2e;
}

/* Selection */
::selection { background: rgba(6, 182, 212, .25); }

/* Focus outlines */
:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* Tooltip styles (tooltip.js wraps [data-tooltip] in div.tooltip + span.tooltiptext) */
[data-tooltip] { position: relative; }
.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.rec-strip .tooltip { display: inline-flex; }
.tooltiptext {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    color: var(--text-2);
    font-size: .68rem;
    padding: 5px 10px;
    border-radius: 6px;
    width: max-content;
    max-width: min(320px, calc(100vw - 24px));
    white-space: normal;
    text-align: center;
    pointer-events: none;
    z-index: 999;
    border: 1px solid var(--border-b);
}
.tooltip.show .tooltiptext {
    display: block;
}
/* Hide tooltip text in toggles (too verbose for these contexts) */
.stog .tooltiptext { display: none; }

.topbar .tooltip { display: inline-flex; }

@media (pointer: coarse) {
    .tooltiptext { display: none !important; }
}

/* Print */
@media print {
    /* Hide all chrome */
    .sidebar, .sb-backdrop, .topbar, .sticky-header, .drawer, .floating-actions,
    .auth-overlay, .n-bar, .section-actions, .rec-strip,
    .input-area, .standby-screen, .fab-menu, .fab-toggle, #floatingActions,
    .kb-modal, .billing-feedback-strip, .revision-panel, .revision-controls,
    .wt, .breadcrumb, #transcriptBtn, #collapsedBar { display: none !important; }

    /* Reset layout to flow */
    * { box-shadow: none !important; text-shadow: none !important; }
    html, body { background: #fff !important; color: #000 !important; }
    body { font-family: 'Outfit', 'Segoe UI', sans-serif; font-size: 11pt; line-height: 1.6; }
    .main, .content { position: static !important; margin: 0 !important; padding: 0 !important;
        overflow: visible !important; height: auto !important; max-height: none !important; }
    #aiResponseContainer { display: block !important; }
    .note-panel { display: flex !important; }

    /* Page setup */
    @page { margin: 0.75in; size: letter; }

    /* Print header — generated via ::before on note container */
    #aiResponseText::before {
        content: "AIMedNotes \2014  Clinical Documentation";
        display: block;
        font-size: 14pt; font-weight: 600; color: #111;
        border-bottom: 2px solid #333;
        padding-bottom: 6pt; margin-bottom: 12pt;
    }

    /* Note sections */
    .note-section {
        break-inside: avoid;
        border: none !important; background: transparent !important;
        page-break-inside: avoid;
    }
    .section-header {
        padding: 6pt 0 2pt !important;
        border-bottom: 1px solid #999;
    }
    .section-title {
        color: #000 !important; font-size: 10pt; font-weight: 700;
        text-transform: uppercase; letter-spacing: .04em;
    }
    .section-title i { display: none; }
    .section-body {
        padding: 4pt 0 10pt !important; font-size: 11pt;
        color: #000 !important; line-height: 1.6;
    }
    .section-body strong { color: #000 !important; }
    .section-body p { margin-bottom: 3pt; }

    /* Links show URL */
    a[href]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }

    /* Remove decorative colors from badges */
    .section-badge { border: 1px solid #666 !important; background: transparent !important; color: #000 !important; }
}


/* ═══ LEGACY COMPAT (classes referenced by app.js but restyled) ═══ */

/* Old .container class (was wrapper div, now aiResponseContainer has it) */
.container { margin: 0; padding: 0; }

/* Old .control-panel-card (removed from HTML, keep CSS for safety) */
.control-panel-card { display: contents; }

/* Old .sticky-actions (replaced by sticky-header, keep for app.js refs) */
.sticky-actions { display: none !important; }
#stickyActions { display: none !important; }

/* Force-hide inline live transcript — app.js sets style.display='block', override with !important.
   Content syncs to drawer via MutationObserver. */
#liveTranscript { display: none !important; }
#liveTranscript * { display: none !important; }
.live-transcript-header { display: none !important; }
.live-transcript-textarea { display: none !important; }

/* Old workflow toggle buttons */
.workflow-toggle-container { display: contents; }
.workflow-section { display: contents; }
.toggle-buttons { display: contents; }
.workflow-btn { /* alias to .wt styles */ }
.workflow-btn-active { background: var(--bg-hover); color: var(--cyan-bright); }

/* Old record/action/clear btn classes (now .rec-btn / .ra) */
.record-btn { /* handled by .rec-btn above */ }
.action-btn { /* handled by .ra.process above */ }
.clear-btn { /* handled by .ra.clear above */ }

/* Old .controls wrapper */
.controls { display: contents; }

/* Old status-timer-row */
.status-timer-row { display: contents; }

/* Old checkbox-container */
.checkbox-container { display: contents; }

/* Old collapsible section (used by old input/priorNotes) */
.collapsible-section { /* no-op */ }
.collapsible-header { display: none; }
.collapsible-content { display: contents; }
.collapse-icon { display: none; }
.additional-text-container { display: contents; }

/* Old desktop grid (setupDesktopLayout creates these) */
.desktop-grid { display: contents !important; }
.desktop-mode { /* no-op */ }

/* Old footer (removed from HTML) */
.app-footer { display: none; }

/* Old HIPAA badge */
.hipaa-badge { display: none; }

/* Old brand container */
.brand-container { display: none; }
.brand-title { display: none; }

/* Improvements floating button — hidden in C4c (admin-only feature, not needed in main UI) */
.improvements-floating-btn,
#improvementsFloatingBtn { display: none !important; }

/* Old login row (replaced by auth-form) */
.login-row { display: none; }

/* Live transcript styles (hidden container, kept for JS) */
.live-transcript-container { display: none !important; }
.live-transcript-textarea {
    width: 100%;
    min-height: 100px;
    font-family: inherit;
    font-size: .84rem;
    color: var(--text);
    background: transparent;
    border: none;
    resize: none;
}

/* Copy transcript button (in hidden container) */
.copy-transcript-btn { display: none; }

/* Mode buttons (hidden) */
.mode-btn { display: none; }

/* Tab / desktop layout classes (created by setupDesktopLayout) */
.tabs { display: none !important; }
.tab { display: none !important; }
.tab-content { display: contents !important; }
.left-column, .right-column { display: contents !important; }

/* Desktop grid panel/note panel refs */
#notePanel { /* no-op, handled by .note-panel */ }
#historyPanel { /* no-op */ }

/* ── Billing Feedback Panel ── */
.billing-feedback-panel {
  margin-bottom: 1rem;
  border: 1px solid var(--amber);
  border-radius: 8px;
  background: var(--bg-surface);
  overflow: hidden;
}
.billing-feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}
.billing-feedback-header:hover { opacity: 0.85; }
.billing-feedback-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
}
.billing-feedback-badge {
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--amber);
  color: #000;
}
.billing-feedback-chevron {
  margin-left: auto;
  font-size: .7rem;
  color: var(--text-4);
}
/* All-clear state: green + quiet instead of amber warning (F-005) */
.billing-feedback-panel.all-clear { border-color: rgba(34, 197, 94, .3); }
.billing-feedback-ok { font-size: .68rem; font-weight: 600; color: #22c55e; }
.billing-feedback-content { padding: 0 14px 12px; }
.billing-feedback-empty {
  font-size: .78rem;
  color: #22c55e;
  padding: 4px 0;
}
.billing-feedback-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.billing-feedback-item:last-child { border-bottom: none; }
.billing-feedback-label-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.billing-feedback-category {
  flex-shrink: 0;
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245,158,11,0.15);
  color: var(--amber);
}
.billing-feedback-desc {
  font-size: .78rem;
  color: var(--text-2);
  line-height: 1.4;
}
.billing-feedback-input {
  width: 100%;
  padding: 6px 10px;
  font-size: .78rem;
  color: var(--text-1);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-c);
  border-radius: 5px;
  outline: none;
  transition: border-color 0.2s;
}
.billing-feedback-input:focus {
  border-color: var(--amber);
}
.billing-feedback-input::placeholder {
  color: var(--text-4);
  font-style: italic;
}
.billing-feedback-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.billing-feedback-update-btn {
  padding: 6px 16px;
  font-size: .78rem;
  font-weight: 600;
  color: #000;
  background: var(--amber);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.billing-feedback-update-btn:hover { opacity: 0.85; }
.billing-feedback-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}
.billing-feedback-option-btn {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-c);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.8rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.billing-feedback-option-btn:hover {
  border-color: var(--amber);
  color: var(--text-1);
}
.billing-feedback-option-btn.selected {
  background: var(--amber);
  color: #000;
  border-color: var(--amber);
}

/* ── Keyboard Shortcuts Modal ── */
.kb-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.kb-modal.hidden { display: none; }
.kb-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
}
.kb-modal-content {
  position: relative; z-index: 1;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; width: 420px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: fadeInUp .2s ease;
}
.kb-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.kb-modal-header h3 {
  font-size: .95rem; font-weight: 600; color: var(--text-1); margin: 0;
}
.kb-modal-header h3 i { color: var(--cyan); margin-right: 8px; }
.kb-modal-close {
  background: none; border: none; color: var(--text-3);
  font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 0 4px;
}
.kb-modal-close:hover { color: var(--text-1); }
.kb-modal-body { padding: 16px 20px 20px; }
.kb-group { margin-bottom: 14px; }
.kb-group:last-child { margin-bottom: 0; }
.kb-group-title {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3); margin-bottom: 6px;
}
.kb-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 0; font-size: .82rem; color: var(--text-2);
}
.kb-row span { margin-left: auto; }
.kb-row kbd {
  display: inline-block; min-width: 24px; text-align: center;
  padding: 2px 7px; font-family: var(--font-mono);
  font-size: .72rem; font-weight: 500;
  background: var(--bg-deep); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text-1);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* ── Transcript recovery banner (async transcription jobs, 2026-07-07) ───── */
.transcript-recovery-banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9000; display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 640px); padding: 12px 16px;
  background: var(--c-raised, #161B26);
  border: 1px solid var(--c-border-strong, rgba(255,255,255,.12));
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.45);
  color: var(--c-text, #ECEEF3); font-size: 13.5px; line-height: 1.4;
}
.transcript-recovery-banner .fa-life-ring { color: var(--c-accent, #7CC4FF); font-size: 16px; }
.transcript-recovery-banner .trb-msg { flex: 1; min-width: 0; }
.transcript-recovery-banner .trb-restore {
  border: none; background: var(--c-accent, #7CC4FF); color: var(--c-bg, #0B0E14);
  font-family: inherit; font-weight: 600; font-size: 13px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.transcript-recovery-banner .trb-dismiss {
  border: 1px solid var(--c-border-strong, rgba(255,255,255,.12)); background: transparent;
  color: var(--c-text-2, #A8B0C0); font-family: inherit; font-size: 13px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}

/* ── Durable Clinic generation preview ─────────────────────────────────── */
#aiResponseText .generation-preview {
  display: grid;
  gap: 14px;
}
#aiResponseText .generation-preview-section {
  min-height: 132px;
  padding: 18px 20px;
  background: var(--c-raised, #161b26);
  border: 1px solid var(--c-border, rgba(255,255,255,.08));
  border-radius: 12px;
}
#aiResponseText .generation-preview-section[data-state="ready"] {
  border-color: color-mix(in srgb, var(--c-accent, #7cc4ff) 34%, transparent);
}
#aiResponseText .generation-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
#aiResponseText .generation-preview-header h3 {
  margin: 0;
  color: var(--c-text, #eceef3);
  font: 600 .86rem/1.25 var(--font-ui, Outfit, sans-serif);
  letter-spacing: .025em;
  text-transform: uppercase;
}
#aiResponseText .generation-preview-status {
  flex: none;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: var(--c-text-2, #a8b0c0);
  font: 600 .68rem/1.2 var(--font-ui, Outfit, sans-serif);
  letter-spacing: .03em;
}
#aiResponseText .generation-preview-status.status-ready {
  background: rgba(74, 222, 128, .12);
  color: #86efac;
}
#aiResponseText .generation-preview-status.status-running,
#aiResponseText .generation-preview-status.status-retrying {
  background: rgba(124, 196, 255, .12);
  color: var(--c-accent, #7cc4ff);
}
#aiResponseText .generation-preview-status.status-failed {
  background: rgba(245, 158, 11, .12);
  color: #fbbf24;
}
#aiResponseText .generation-preview-body {
  color: var(--c-text, #eceef3);
  font: 400 1rem/1.65 var(--font-note, "Source Serif 4", serif);
  white-space: pre-wrap;
}
#aiResponseText .generation-preview-skeleton {
  display: grid;
  gap: 9px;
  white-space: normal;
}
#aiResponseText .generation-preview-skeleton .skeleton-line:nth-child(2) { width: 92%; }
#aiResponseText .generation-preview-skeleton .skeleton-line:nth-child(3) { width: 68%; }
#aiResponseText .generation-preview-recovery {
  padding: 16px 18px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 12px;
  background: rgba(245, 158, 11, .07);
}
#aiResponseText .generation-preview-recovery p {
  margin: 0 0 12px;
  color: var(--c-text-2, #a8b0c0);
}
@media (max-width: 768px) {
  #aiResponseText .generation-preview { gap: 10px; }
  #aiResponseText .generation-preview-section {
    min-height: 116px;
    padding: 15px 16px;
  }
  #aiResponseText .generation-preview-body { font-size: 1rem; }
  #aiResponseText .generation-preview-recovery .nb-btn { min-height: 44px; }
}
