:root {
    --navy: #1b2951;
    --navy-mid: #263768;
    --navy-light: #34497f;
    --teal: #2ec4b6;
    --teal-dark: #25a99d;
    --teal-glow: rgba(46,196,182,0.15);
    --gold: #e9b44c;
    --bg: #f4f5f9;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --bg-output: #fcfcfe;
    --border: #e0e4ed;
    --border-light: #ebeef5;
    --text: #1a2035;
    --text-mid: #3d4663;
    --text-light: #6b7394;
    --text-muted: #9ba3bf;
    --success: #22c55e;
    --success-dark: #16a34a;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --warn-bg: #fffbf0;
    --warn-border: #f5dfab;
    --warn-text: #7c5e14;
    --sub-bg: #f0f5f4;
    --sub-accent: var(--teal);
    --radius: 14px;
    --radius-sm: 10px;
    --font-display: 'Outfit', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --shadow-xs: 0 1px 2px rgba(27,41,81,0.04);
    --shadow-sm: 0 1px 3px rgba(27,41,81,0.06), 0 1px 2px rgba(27,41,81,0.04);
    --shadow-md: 0 4px 12px rgba(27,41,81,0.07), 0 1px 3px rgba(27,41,81,0.05);
    --shadow-lg: 0 8px 30px rgba(27,41,81,0.10), 0 2px 6px rgba(27,41,81,0.04);
    --shadow-glow: 0 0 20px rgba(46,196,182,0.12);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* === AUTH SCREEN === */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy) 0%, #1a2850 50%, #162040 100%);
    flex-direction: column;
    gap: 32px;
}
.auth-screen.hidden { display: none; }
.auth-logo { text-align: center; }
.auth-logo .tempo-icon-lg {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--teal), #34d9cc);
    border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 20px rgba(46,196,182,0.4);
    margin-bottom: 16px;
}
.auth-logo h1 { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }
.auth-logo p { font-family: var(--font-body); font-size: 14px; color: rgba(255,255,255,0.5); margin-top: 4px; }
.auth-card {
    background: #fff; border-radius: 16px; padding: 36px 32px;
    width: 90%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
body.night .auth-card { background: #1e2538; }
.auth-card h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
body.night .auth-card h2 { color: #e1e4ed; }
.auth-card .auth-sub { font-size: 13px; color: var(--text-light); margin-bottom: 24px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-family: var(--font-display); font-weight: 600; font-size: 12px; color: var(--text-mid); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.auth-field input {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: var(--font-body); background: var(--bg-input); color: var(--text);
    outline: none; transition: var(--transition);
}
.auth-field input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow); }
body.night .auth-field input { background: #12161f; border-color: #2a3042; color: #e1e4ed; }
.auth-btn {
    width: 100%; padding: 13px; border: none; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    color: #fff; font-family: var(--font-display); font-size: 14px; font-weight: 700;
    cursor: pointer; transition: var(--transition); margin-top: 8px;
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-error { color: var(--error); font-size: 13px; margin-top: 12px; display: none; }
.auth-error.visible { display: block; }
.auth-loading { display: none; text-align: center; padding: 20px; color: rgba(255,255,255,0.6); font-family: var(--font-display); font-size: 14px; }
.auth-loading.visible { display: block; }

/* === APP WRAPPER === */
.app-wrapper { display: none; }
.app-wrapper.visible { display: block; }

/* === TOP BAR === */
.top-bar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
    padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 12px rgba(27,41,81,0.25), 0 1px 3px rgba(0,0,0,0.1);
}
.logo-area { display: flex; align-items: center; gap: 20px; }
.logo-divider { width: 1px; height: 28px; background: linear-gradient(180deg, transparent, rgba(255,255,255,0.2), transparent); }
.tempo-mark {
    font-family: var(--font-display); font-weight: 500; font-size: 17px;
    color: rgba(255,255,255,0.7); letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px;
}
.tempo-mark .tempo-icon {
    width: 28px; height: 28px; background: linear-gradient(135deg, var(--teal), #34d9cc);
    border-radius: 7px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; box-shadow: 0 2px 8px rgba(46,196,182,0.35);
}
.top-right { display: flex; align-items: center; gap: 14px; }
.user-pill {
    display: flex; align-items: center; gap: 8px; padding: 5px 14px;
    background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; color: rgba(255,255,255,0.6); font-size: 12px;
    font-family: var(--font-display); font-weight: 500;
}
.user-pill .user-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 6px rgba(46,196,182,0.5); }

/* === SHIFT COUNTER === */
.shift-counter {
    display: flex; align-items: center; gap: 5px; padding: 5px 12px;
    background: rgba(46,196,182,0.1); border: 1px solid rgba(46,196,182,0.2);
    border-radius: 20px; font-family: var(--font-display);
}
.shift-count {
    font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px;
    color: var(--teal); line-height: 1;
}
.shift-count.bump { animation: counterBump 0.35s ease; }
@keyframes counterBump { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
.shift-label {
    font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.45);
    text-transform: uppercase; letter-spacing: 0.5px;
}

.logout-btn {
    padding: 5px 12px; border: 1px solid rgba(255,255,255,0.12); border-radius: 16px;
    background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.5); font-size: 11px;
    font-family: var(--font-display); font-weight: 600; cursor: pointer; transition: var(--transition);
}
.logout-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.night-btn {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7); font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition);
}
.night-btn:hover { background: rgba(255,255,255,0.12); transform: rotate(20deg); }

/* === FONT SIZE TOGGLE === */
.font-size-btn {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7); font-family: var(--font-display);
    font-weight: 700; font-size: 15px; cursor: pointer; display: flex; align-items: center;
    justify-content: center; transition: var(--transition);
}
.font-size-btn:hover { background: rgba(255,255,255,0.12); }

/* === FONT SIZE TIERS === */
body.font-md { font-size: 19px; }
body.font-md textarea, body.font-md .revision-input { font-size: 18px; }
body.font-md .form-label, body.font-md .tog-label { font-size: 17px; }
body.font-md .card-head { font-size: 18px; }
body.font-md .disclaimer { font-size: 16px; }
body.font-md .form-hint { font-size: 16px; }
body.font-md .step { font-size: 16px; }
body.font-md .setting-btn { font-size: 16px; }
body.font-md .setting-label { font-size: 17px; }
body.font-md .qi-chip { font-size: 16px; }
body.font-md .qi-hint { font-size: 15px; }
body.font-md .quick-insert-toggle { font-size: 16px; }
body.font-md .summarize-btn { font-size: 15px; }
body.font-md .dictate-btn { font-size: 15px; }
body.font-md .revision-chip { font-size: 15px; }
body.font-md .btn-copy { font-size: 16px; }
body.font-md .output-content { font-size: 14pt; }
body.font-md .output-content .section-heading { font-size: 14pt; }
body.font-md .output-content .sub-label-block { font-size: 13pt; }
body.font-md .output-content .cap-label { font-size: 13pt; }
body.font-md .output-content .rationale-label { font-size: 13pt; }
body.font-md .output-content .closing-line { font-size: 13pt; }
body.font-md textarea::placeholder { font-size: 18px; }

body.font-lg { font-size: 21px; }
body.font-lg textarea, body.font-lg .revision-input { font-size: 20px; }
body.font-lg .form-label, body.font-lg .tog-label { font-size: 19px; }
body.font-lg .card-head { font-size: 20px; }
body.font-lg .disclaimer { font-size: 18px; }
body.font-lg .form-hint { font-size: 18px; }
body.font-lg .step { font-size: 18px; }
body.font-lg .setting-btn { font-size: 18px; }
body.font-lg .setting-label { font-size: 19px; }
body.font-lg .qi-chip { font-size: 18px; }
body.font-lg .qi-hint { font-size: 17px; }
body.font-lg .quick-insert-toggle { font-size: 18px; }
body.font-lg .summarize-btn { font-size: 17px; }
body.font-lg .dictate-btn { font-size: 17px; }
body.font-lg .revision-chip { font-size: 17px; }
body.font-lg .btn-copy { font-size: 18px; }
body.font-lg .output-content { font-size: 15pt; }
body.font-lg .output-content .section-heading { font-size: 15pt; }
body.font-lg .output-content .sub-label-block { font-size: 14pt; }
body.font-lg .output-content .cap-label { font-size: 14pt; }
body.font-lg .output-content .rationale-label { font-size: 14pt; }
body.font-lg .output-content .closing-line { font-size: 14pt; }
body.font-lg textarea::placeholder { font-size: 20px; }

/* === PAGE LAYOUT === */
.page { max-width: 840px; margin: 0 auto; padding: 32px 20px 48px; }

/* === STEPS === */
.steps { display: flex; align-items: center; justify-content: center; margin-bottom: 32px; gap: 0; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 14px; font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--text-muted); transition: var(--transition); }
.step.active { color: var(--navy); }
.step.done { color: var(--teal-dark); }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; border: 2px solid var(--border); background: var(--bg-card); transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.step.active .step-num { border-color: var(--navy); background: var(--navy); color: #fff; transform: scale(1.1); box-shadow: 0 2px 8px rgba(27,41,81,0.25); }
.step.done .step-num { border-color: var(--teal); background: var(--teal); color: #fff; box-shadow: 0 2px 8px rgba(46,196,182,0.3); }
.step-line { width: 52px; height: 2px; background: var(--border); border-radius: 1px; position: relative; overflow: hidden; }
.step-line-fill { position: absolute; top: 0; left: 0; height: 100%; width: 0%; background: var(--teal); border-radius: 1px; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); }
.step-line.done .step-line-fill { width: 100%; }
.step-line.done::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent); animation: shimmer 1.5s ease-out; }
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* === CARDS === */
.card { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 22px; overflow: hidden; transition: var(--transition); animation: cardIn 0.5s ease both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.card-head { padding: 16px 24px; font-family: var(--font-display); font-size: 14px; font-weight: 700; color: #ffffff; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); border-bottom: none; display: flex; align-items: center; gap: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.card-head-icon { font-size: 16px; }
.card-body { padding: 24px; }

/* === FORMS === */
.form-group { margin-bottom: 20px; position: relative; }
.form-group:last-child { margin-bottom: 0; }
.form-label { display: block; font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 7px; letter-spacing: 0.01em; }
.form-hint { font-family: var(--font-body); font-weight: 400; color: var(--text-light); font-size: 12px; margin-top: 2px; }
textarea { width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-body); resize: vertical; background: var(--bg-input); color: var(--text); line-height: 1.65; transition: var(--transition); }
textarea:focus { outline: none; border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px var(--teal-glow), var(--shadow-sm); }

/* === TOGGLES === */
.option-toggle { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-input); border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; user-select: none; transition: var(--transition); margin-bottom: 18px; }
.option-toggle:hover { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-glow); }
.tog { width: 42px; height: 24px; border-radius: 12px; background: #c8cee0; position: relative; flex-shrink: 0; transition: background 0.3s ease; }
.tog.active { background: var(--teal); box-shadow: 0 0 8px rgba(46,196,182,0.3); }
.tog::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 3px; left: 3px; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.tog.active::after { transform: translateX(18px); }
.tog-label { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--text); }
.follow-toggle { margin-bottom: 22px; border-width: 2px; }
.follow-toggle.active-follow { border-color: var(--gold); background: rgba(233,180,76,0.06); }
body.night .follow-toggle.active-follow { border-color: rgba(233,180,76,0.4); background: rgba(233,180,76,0.05); }
.complexity-toggle.active-complex { border-color: #8b5cf6; background: rgba(139,92,246,0.06); }
.complexity-toggle.active-complex .tog.active { background: #8b5cf6; box-shadow: 0 0 8px rgba(139,92,246,0.3); }
body.night .complexity-toggle.active-complex { border-color: rgba(139,92,246,0.4); background: rgba(139,92,246,0.05); }
.complexity-toggle.brain-pulse { animation: brainPulse 0.45s ease-in-out 3; }
@keyframes brainPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(139,92,246,0); } 50% { box-shadow: 0 0 14px 4px rgba(139,92,246,0.35); } }

/* === CONSULT SETTING SELECTOR === */
.setting-selector { margin-bottom: 18px; padding: 12px 16px; background: var(--bg-input); border: 1.5px solid var(--border); border-radius: var(--radius-sm); }
.setting-label { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 8px; }
.setting-buttons { display: flex; gap: 0; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--border); }
.setting-btn { flex: 1; padding: 9px 14px; border: none; background: var(--bg-card); color: var(--text-light); font-family: var(--font-display); font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--transition); }
.setting-btn:first-child { border-right: 1px solid var(--border); }
.setting-btn:hover:not(.active) { background: var(--teal-glow); color: var(--text-mid); }
.setting-btn.active { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,0.08); }
body.night .setting-selector { background: #12161f; border-color: #2a3042; }
body.night .setting-buttons { border-color: #2a3042; }
body.night .setting-btn { background: #181d2a; color: #505a72; }
body.night .setting-btn:first-child { border-right-color: #2a3042; }
body.night .setting-btn:hover:not(.active) { background: rgba(46,196,182,0.08); color: #7c85a3; }
body.night .setting-btn.active { background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: #fff; box-shadow: 0 0 12px rgba(46,196,182,0.3); }

/* === BUTTONS === */
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn { padding: 13px 24px; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; font-family: var(--font-display); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition); letter-spacing: 0.01em; }
.btn-primary { flex: 1; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); color: #fff; box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.1); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary .btn-icon { color: var(--teal); font-size: 16px; }
.btn-ghost { background: transparent; color: var(--text-light); border: 1.5px solid var(--border); padding: 13px 20px; }
.btn-ghost:hover { background: var(--bg-input); border-color: #c8cee0; }
.btn-copy { background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: #fff; width: 100%; box-shadow: 0 2px 8px rgba(46,196,182,0.25); font-size: 13px; }
.btn-copy:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(46,196,182,0.3); }
.btn-copy:disabled { background: #d1d5db; cursor: not-allowed; box-shadow: none; transform: none; }

/* === PROGRESS BAR === */
.progress-bar { display: none; margin-top: 18px; text-align: center; }
.progress-bar.visible { display: block; animation: fadeSlide 0.3s ease; }
@keyframes fadeSlide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.progress-track { height: 5px; background: var(--border-light); border-radius: 4px; overflow: visible; position: relative; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--navy), var(--teal)); border-radius: 4px; width: 0%; transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1); position: relative; overflow: hidden; }
.progress-shimmer { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 35%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,0.4) 65%, transparent 100%); animation: shimmerSweep 1.4s ease-in-out infinite; }
@keyframes shimmerSweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

.progress-glow { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 10px; height: 10px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 12px rgba(46,196,182,0.6), 0 0 24px rgba(46,196,182,0.3); transition: left 0.8s cubic-bezier(0.4, 0, 0.2, 1); left: 0%; z-index: 2; animation: glowPulse 1.5s ease-in-out infinite; }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 12px rgba(46,196,182,0.6), 0 0 24px rgba(46,196,182,0.3); transform: translate(-50%, -50%) scale(1); } 50% { box-shadow: 0 0 20px rgba(46,196,182,0.8), 0 0 40px rgba(46,196,182,0.4); transform: translate(-50%, -50%) scale(1.4); } }

/* Phase label */
.progress-phase { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; min-height: 24px; }
.phase-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; color: var(--teal); transition: opacity 0.3s ease; animation: phaseIconPop 0.3s ease; }
.phase-icon svg { width: 16px; height: 16px; }
@keyframes phaseIconPop { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.phase-text { font-family: var(--font-display); font-size: 14px; font-weight: 500; color: var(--text-light); animation: phaseSlideIn 0.4s ease; }
@keyframes phaseSlideIn { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: translateY(0); } }

/* Big percentage */
.progress-percent { text-align: center; margin: 8px 0 16px; font-family: 'JetBrains Mono', monospace; font-size: 32px; font-weight: 700; color: var(--text); letter-spacing: -2px; line-height: 1; transition: opacity 0.3s ease; }

/* Deep thinking indicator */
.deep-indicator { display: inline-flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 20px; background: rgba(139,92,246,0.06); border: 1px solid rgba(139,92,246,0.2); font-family: var(--font-display); font-size: 12px; font-weight: 600; color: #8b5cf6; letter-spacing: 0.3px; margin: 0 auto; }
.progress-bar .deep-indicator { display: none; }
.progress-bar .deep-indicator.visible { display: inline-flex; }

.deep-pulse { width: 8px; height: 8px; border-radius: 50%; background: #8b5cf6; animation: deepPulseAnim 2s ease-in-out infinite; }
@keyframes deepPulseAnim { 0%, 100% { box-shadow: 0 0 0 0 rgba(139,92,246,0.5); opacity: 1; } 50% { box-shadow: 0 0 0 8px rgba(139,92,246,0); opacity: 0.7; } }

/* === ERRORS === */
.error-msg { color: var(--error); background: var(--error-bg); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 16px; border: 1px solid var(--error-border); display: none; align-items: center; gap: 8px; font-family: var(--font-body); }
.error-msg.visible { display: flex; animation: fadeSlide 0.3s ease; }
.error-msg::before { content: '⚠'; font-size: 15px; }

/* === PHI MODAL === */
.phi-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.phi-overlay.visible { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.phi-modal { background: #fff; border-radius: 16px; max-width: 480px; width: 90%; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); overflow: hidden; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.phi-modal-header { background: linear-gradient(135deg, #dc2626, #b91c1c); padding: 20px 24px; display: flex; align-items: center; gap: 12px; color: #fff; }
.phi-modal-header .phi-icon { width: 42px; height: 42px; background: rgba(255,255,255,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.phi-modal-header h3 { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0; }
.phi-modal-header p { font-size: 13px; opacity: 0.9; margin: 2px 0 0; }
.phi-modal-body { padding: 20px 24px; }
.phi-modal-body .phi-detail { font-size: 14px; color: #374151; line-height: 1.6; margin-bottom: 16px; }
.phi-modal-body .phi-items { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.phi-modal-body .phi-items .phi-item { font-size: 13px; color: #991b1b; padding: 8px 10px; display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid rgba(254,202,202,0.5); cursor: pointer; transition: background 0.15s ease; border-radius: 6px; margin: 0 -10px; }
.phi-modal-body .phi-items .phi-item:hover { background: rgba(220,38,38,0.08); }
.phi-modal-body .phi-items .phi-item:last-child { border-bottom: none; }
.phi-modal-body .phi-items .phi-item::before { content: '•'; font-size: 8px; color: #dc2626; flex-shrink: 0; }
.phi-type { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; color: #7f1d1d; white-space: nowrap; font-family: var(--font-display); }
.phi-match { background: #fecaca; color: #991b1b; padding: 2px 8px; border-radius: 4px; font-family: 'SF Mono', 'Fira Code', monospace; font-size: 13px; font-weight: 600; word-break: break-all; }
body.night .phi-type { color: #fca5a5; }
body.night .phi-match { background: #4a1616; color: #fca5a5; }
.phi-modal-footer { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 8px; }
.phi-dismiss { width: 100%; padding: 13px; border: none; border-radius: 10px; background: linear-gradient(135deg, #dc2626, #b91c1c); color: #fff; font-family: var(--font-display); font-size: 14px; font-weight: 700; cursor: pointer; transition: var(--transition); }
.phi-dismiss:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220,38,38,0.3); }
.phi-override { width: 100%; padding: 13px; border: none; border-radius: 10px; background: linear-gradient(135deg, #16a34a, #15803d); color: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--transition); opacity: 0.85; }
.phi-override:hover { opacity: 1; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(22,163,74,0.3); }
body.night .phi-modal { background: #1f2937; }
body.night .phi-modal-body .phi-detail { color: #d1d5db; }
body.night .phi-modal-body .phi-items { background: #261616; border-color: #4a2020; }
body.night .phi-modal-body .phi-items .phi-item { color: #fca5a5; }

/* === MISMATCH MODAL === */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.2s ease; }
.overlay.visible { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 90%; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
body.night .modal { background: #1f2937; }
.mismatch-modal { max-width: 600px; }
.mismatch-modal .modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.mismatch-modal .modal-header h3 { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #f59e0b; }
.mismatch-modal .modal-icon { font-size: 28px; }
.mismatch-intro { color: var(--text-mid); margin-bottom: 16px; line-height: 1.5; font-size: 14px; }
body.night .mismatch-intro { color: #c9d1d9; }
.mismatch-details-box { background: var(--bg-input); border: 1px solid rgba(245,158,11,0.2); border-radius: 8px; padding: 16px; margin-bottom: 16px; max-height: 250px; overflow-y: auto; }
body.night .mismatch-details-box { background: #1a1a2e; border-color: #f59e0b33; }
.mismatch-details { color: var(--text-light); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
body.night .mismatch-details { color: #9ca3af; }
.mismatch-action { color: #10b981; font-weight: 500; margin-bottom: 20px; font-size: 14px; }
.modal-buttons { display: flex; gap: 10px; }
.modal-buttons .btn { flex: 1; }

/* === OUTPUT CARD === */
.output-card { display: none; }
.output-card.visible { display: block; animation: outputReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) both; }
@keyframes outputReveal { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.output-content { background: var(--bg-output); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 28px; min-height: 200px; font-family: Arial, Helvetica, sans-serif; font-size: 12pt; line-height: 1.65; white-space: pre-wrap; overflow-y: auto; max-height: 75vh; color: var(--text); box-shadow: inset 0 1px 3px rgba(27,41,81,0.03); }
.output-content .section-heading { display: block; font-family: var(--font-display); font-weight: 700; font-size: 12pt; color: var(--navy); margin-top: 28px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--border-light); letter-spacing: 0.4px; text-transform: uppercase; }
.output-content .section-heading:first-child { margin-top: 0; }
.output-content .copy-group:first-child .section-heading { margin-top: 0; }
.output-content .sub-label-block { display: block; margin: 16px 0 6px 0; padding: 9px 16px; background: var(--sub-bg); border-left: 3px solid var(--sub-accent); border-radius: 0 8px 8px 0; font-family: var(--font-display); font-weight: 700; font-size: 11pt; color: var(--navy-mid); letter-spacing: 0.02em; }
.output-actions { margin-top: 16px; }
.copy-group { position: relative; }
.copy-group:has(.section-copy-btn) { padding-bottom: 32px; }
.section-copy-btn { position: absolute; bottom: 8px; right: 0; display: flex; align-items: center; gap: 5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); color: var(--text-light); font-family: var(--font-display); font-size: 11px; font-weight: 600; cursor: pointer; opacity: 0; transition: var(--transition); z-index: 2; box-shadow: var(--shadow-xs); }
.copy-group:hover .section-copy-btn { opacity: 1; }
.section-copy-btn:hover { background: var(--teal); color: #fff; border-color: var(--teal); box-shadow: var(--shadow-sm); }
.section-copy-btn.copied { opacity: 1; background: var(--success-dark); color: #fff; border-color: var(--success-dark); }
.output-content .cap-label { display: inline; font-family: var(--font-display); font-weight: 700; font-size: 11pt; color: var(--navy-mid); }
body.night .output-content .cap-label { color: #8ad4cd; }
.output-content .rationale-label { font-family: var(--font-display); font-weight: 700; font-size: 11pt; color: var(--text-mid); font-style: italic; }
body.night .output-content .rationale-label { color: #9ca3af; }
.output-content .closing-line { display: block; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-light); font-style: italic; color: var(--text-mid); font-size: 11pt; }

/* Staggered output section reveals */
.output-content .note-section { opacity: 0; transform: translateY(16px); transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.output-content .note-section.section-revealed { opacity: 1; transform: translateY(0); }
.output-content.sections-animating .note-section:nth-child(1) { transition-delay: 0ms; }
.output-content.sections-animating .note-section:nth-child(2) { transition-delay: 150ms; }
.output-content.sections-animating .note-section:nth-child(3) { transition-delay: 300ms; }
.output-content.sections-animating .note-section:nth-child(4) { transition-delay: 450ms; }
.output-content.sections-animating .note-section:nth-child(5) { transition-delay: 600ms; }
.output-content.sections-animating .note-section:nth-child(6) { transition-delay: 750ms; }
.output-content.sections-animating .note-section:nth-child(7) { transition-delay: 900ms; }
.output-content.sections-animating .note-section:nth-child(8) { transition-delay: 1050ms; }

/* === REVISION CARD === */
.revision-card { display: none; }
.revision-card.visible { display: block; animation: cardIn 0.5s ease both; }
.revision-card .card-head { background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); }
body.night .revision-card .card-head { background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%); }
.revision-input { width: 100%; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font-body); resize: vertical; background: var(--bg-input); color: var(--text); line-height: 1.65; transition: var(--transition); }
.revision-input:focus { outline: none; border-color: #8b5cf6; background: #fff; box-shadow: 0 0 0 3px rgba(139,92,246,0.15), var(--shadow-sm); }
body.night .revision-input:focus { background: #1a2030; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,0.12); }
.revision-examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; margin-bottom: 14px; }
.revision-chip { padding: 5px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 11px; font-family: var(--font-display); font-weight: 500; color: var(--text-light); background: var(--bg-input); cursor: pointer; transition: var(--transition); white-space: nowrap; }
.revision-chip:hover { border-color: #8b5cf6; color: #7c3aed; background: rgba(139,92,246,0.06); }
body.night .revision-chip:hover { border-color: #8b5cf6; color: #a78bfa; background: rgba(139,92,246,0.1); }
.btn-revise { flex: 1; background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); color: #fff; box-shadow: 0 2px 8px rgba(124,58,237,0.25); }
.btn-revise:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(124,58,237,0.35); }
.btn-revise:active:not(:disabled) { transform: translateY(0); }
.btn-revise:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-revise .btn-icon { color: #c4b5fd; font-size: 16px; }
.revision-progress { display: none; margin-top: 14px; }
.revision-progress.visible { display: block; animation: fadeSlide 0.3s ease; }
.revision-error { color: var(--error); background: var(--error-bg); padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 12px; border: 1px solid var(--error-border); display: none; align-items: center; gap: 8px; font-family: var(--font-body); }
.revision-error.visible { display: flex; animation: fadeSlide 0.3s ease; }

/* === NEW NOTE BUTTON === */
.new-note-row { text-align: center; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.btn-new-note {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 32px; border: 2px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-card);
    color: var(--text-mid); font-family: var(--font-display);
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: var(--transition);
}
.btn-new-note:hover { border-color: var(--navy); color: var(--navy); background: var(--bg-input); }
body.night .btn-new-note:hover { border-color: var(--teal); color: var(--teal); }

/* === DISCLAIMER === */
.disclaimer { margin-top: 28px; padding: 16px 20px; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius-sm); font-size: 12px; color: var(--warn-text); line-height: 1.55; font-family: var(--font-body); box-shadow: var(--shadow-xs); }
.disclaimer strong { font-family: var(--font-display); font-weight: 700; }
.disclaimer .sep { display: block; height: 1px; background: var(--warn-border); margin: 10px 0; }

/* === PILOT RATING === */
.rating-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.rating-label { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--text-mid); margin-bottom: 10px; text-align: center; }
.star-row { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.star-btn { background: none; border: none; font-size: 32px; cursor: pointer; transition: transform 0.2s ease, filter 0.2s ease; padding: 2px 4px; filter: grayscale(1) opacity(0.35); line-height: 1; }
.star-btn:hover { transform: scale(1.2); }
.star-btn.lit { filter: none; transform: scale(1.05); }
.star-btn.lit:hover { transform: scale(1.25); }
.rating-hint { text-align: center; font-family: var(--font-body); font-size: 11px; color: var(--text-muted); margin-top: 2px; min-height: 16px; }
.feedback-area { display: none; margin-top: 14px; animation: fadeSlide 0.3s ease; }
.feedback-area.visible { display: block; }
.feedback-input { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-body); resize: vertical; background: var(--bg-input); color: var(--text); line-height: 1.55; transition: var(--transition); }
.feedback-input:focus { outline: none; border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px var(--teal-glow); }
body.night .feedback-input:focus { background: #1a2030; }
.feedback-input::placeholder { color: var(--text-muted); }
.btn-submit-rating { margin-top: 10px; width: 100%; padding: 12px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%); color: #fff; font-family: var(--font-display); font-size: 13px; font-weight: 700; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-submit-rating:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-submit-rating:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.rating-success { display: none; text-align: center; padding: 14px; margin-top: 10px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius-sm); font-family: var(--font-display); font-size: 13px; font-weight: 600; color: #16a34a; }
.rating-success.visible { display: block; animation: fadeSlide 0.3s ease; }
body.night .rating-success { background: #0a1f0a; border-color: #1a4a1a; color: #4ade80; }
.rating-error { display: none; text-align: center; padding: 10px; margin-top: 8px; background: var(--error-bg); border: 1px solid var(--error-border); border-radius: var(--radius-sm); font-size: 12px; color: var(--error); }
.rating-error.visible { display: block; }

/* === DARK MODE === */
body.night { --bg: #0f1219; --bg-card: #181d2a; --bg-input: #12161f; --bg-output: #181d2a; --border: #2a3042; --border-light: #232940; --text: #e1e4ed; --text-mid: #b0b7cf; --text-light: #7c85a3; --text-muted: #4f5672; --sub-bg: #1a2233; --sub-accent: var(--teal); --error-bg: #261616; --error-border: #4a2020; --warn-bg: #1f1c12; --warn-border: #3d3518; --warn-text: #d4a832; --shadow-xs: 0 1px 2px rgba(0,0,0,0.2); --shadow-sm: 0 1px 3px rgba(0,0,0,0.3); --shadow-md: 0 4px 12px rgba(0,0,0,0.3); --shadow-lg: 0 8px 30px rgba(0,0,0,0.4); }
body.night .top-bar { background: linear-gradient(135deg, #0a0e18 0%, #131829 100%); box-shadow: 0 2px 12px rgba(0,0,0,0.5); }
body.night .card-head { background: linear-gradient(135deg, #0f1524 0%, #1a2440 100%); color: #ffffff; }
body.night .output-content .section-heading { color: var(--teal); border-bottom-color: #232940; }
body.night .output-content .sub-label-block { background: #141c2c; border-left-color: var(--teal); color: #8ad4cd; }
body.night textarea:focus { background: #1a2030; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(46,196,182,0.12); }
body.night .btn-ghost { color: var(--text-light); border-color: #2a3042; }
body.night .btn-ghost:hover { background: #1e2435; }
body.night .option-toggle { background: #12161f; border-color: #2a3042; }
body.night .step-num { background: #181d2a; }
body.night .step.active .step-num { background: var(--navy-light); border-color: var(--navy-light); }
body.night .disclaimer { background: #17150e; border-color: #3d3518; }
body.night .output-content { box-shadow: inset 0 1px 3px rgba(0,0,0,0.15); }
body.night .progress-percent { color: #e1e4ed; }
body.night .deep-indicator { background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.25); color: #a78bfa; }

/* === DICTATION BUTTON === */
.dictate-btn {
    position: absolute; top: 0; right: 0; display: flex; align-items: center; gap: 6px;
    padding: 5px 12px; border: 1.5px solid var(--border); border-radius: 20px;
    background: var(--bg-input); color: var(--text-light); font-family: var(--font-display);
    font-size: 11px; font-weight: 600; cursor: pointer; transition: var(--transition); z-index: 2;
}
.dictate-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-glow); }
.dictate-btn.recording { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); animation: recPulse 1.5s ease-in-out infinite; }
.dictate-btn.recording:hover { border-color: #dc2626; color: #dc2626; background: rgba(239,68,68,0.12); }
@keyframes recPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); } 50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); } }
.dictate-btn .mic-icon { display: flex; align-items: center; justify-content: center; }
.dictate-btn .rec-dot { width: 6px; height: 6px; border-radius: 50%; background: #ef4444; display: none; }
.dictate-btn.recording .rec-dot { display: inline-block; animation: blink 1s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.dictate-btn .dictate-label { white-space: nowrap; }
body.night .dictate-btn { background: var(--bg-input); border-color: var(--border); color: var(--text-light); }
body.night .dictate-btn:hover { border-color: var(--teal); color: var(--teal); }
body.night .dictate-btn.recording { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.1); }

/* === SUMMARIZE BUTTON === */
.summarize-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; margin-top: 8px;
    border: 1.5px solid var(--border); border-radius: 20px; background: var(--bg-input);
    color: var(--text-light); font-family: var(--font-display); font-size: 11px; font-weight: 600;
    cursor: pointer; transition: var(--transition);
}
.summarize-btn:hover:not(:disabled) { border-color: #8b5cf6; color: #8b5cf6; background: rgba(139,92,246,0.06); }
.summarize-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.summarize-btn.summarizing { border-color: #8b5cf6; color: #8b5cf6; background: rgba(139,92,246,0.06); }
.summarize-btn.summarize-done { border-color: var(--teal); color: var(--teal-dark); background: rgba(46,196,182,0.06); }
body.night .summarize-btn { background: var(--bg-input); border-color: var(--border); color: var(--text-light); }
body.night .summarize-btn:hover:not(:disabled) { border-color: #8b5cf6; color: #a78bfa; background: rgba(139,92,246,0.1); }
body.night .summarize-btn.summarize-done { border-color: var(--teal); color: var(--teal); }

/* === QUICK-INSERT DOT PHRASES === */
.quick-insert-tray { margin-bottom: 8px; }
.quick-insert-toggle {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
    border: none; background: none; color: var(--text-light); font-family: var(--font-display);
    font-size: 11px; font-weight: 600; cursor: pointer; transition: var(--transition);
}
.quick-insert-toggle:hover { color: var(--teal); }
.qi-icon { font-size: 12px; }
.qi-chevron { font-size: 8px; transition: transform 0.2s ease; display: inline-block; }
.qi-chevron.qi-open { transform: rotate(180deg); }
.qi-chips {
    display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 0;
}
.qi-chip {
    padding: 4px 11px; border: 1px solid var(--border); border-radius: 16px;
    font-size: 11px; font-family: var(--font-display); font-weight: 500;
    color: var(--text-light); background: var(--bg-input); cursor: pointer;
    transition: var(--transition); white-space: nowrap;
}
.qi-chip:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-glow); }
.qi-chip-warn { color: var(--error); font-weight: 700; }
body.night .qi-chip { background: var(--bg-input); border-color: var(--border); color: var(--text-light); }
body.night .qi-chip:hover { border-color: var(--teal); color: var(--teal); background: rgba(46,196,182,0.08); }
body.night .quick-insert-toggle { color: var(--text-light); }
body.night .quick-insert-toggle:hover { color: var(--teal); }
.qi-hint {
    width: 100%; font-size: 10px; color: var(--text-muted); font-family: var(--font-display);
    font-weight: 500; margin-top: 2px; letter-spacing: 0.2px;
}

/* === INLINE PICKER === */
.qi-picker {
    position: absolute; z-index: 200; min-width: 160px; max-width: 320px; max-height: 200px; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(27,41,81,0.15), 0 2px 6px rgba(27,41,81,0.08);
    padding: 4px; animation: pickerIn 0.15s ease;
}
@keyframes pickerIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.qi-picker-option {
    padding: 6px 12px; border-radius: 5px; font-size: 13px; font-family: var(--font-body);
    color: var(--text); cursor: pointer; transition: background 0.1s ease; white-space: nowrap;
}
.qi-picker-option:hover { background: var(--teal-glow); color: var(--teal-dark); }
body.night .qi-picker {
    background: #1e2538; border-color: #2a3042;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.2);
}
body.night .qi-picker-option { color: #e1e4ed; }
body.night .qi-picker-option:hover { background: rgba(46,196,182,0.12); color: var(--teal); }
.qi-picker-option.selected { background: rgba(46,196,182,0.12); color: var(--teal-dark); font-weight: 500; }
.qi-picker-option.selected::before { content: '✓ '; font-weight: 700; color: var(--teal); }
body.night .qi-picker-option.selected { background: rgba(46,196,182,0.15); color: var(--teal); }
body.night .qi-picker-option.selected::before { color: var(--teal); }
.qi-picker-done {
    display: none; padding: 6px 12px; margin: 4px; border-radius: 6px; text-align: center;
    background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: #fff;
    font-family: var(--font-display); font-size: 12px; font-weight: 600; cursor: pointer;
    transition: var(--transition); border: none;
}
.qi-picker-done:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* === CONSULT SETTING REQUIRED PULSE === */
.setting-selector.setting-required {
    animation: setting-pulse 1s ease-in-out infinite;
    border: 1.5px solid rgba(220, 50, 50, 0.6) !important;
}
@keyframes setting-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(220, 50, 50, 0.3); }
    50% { box-shadow: 0 0 16px rgba(220, 50, 50, 0.6); }
}

/* === DASHBOARD TAB BUTTON === */
.dashboard-tab-btn {
    padding: 5px 14px; border: 1px solid rgba(255,255,255,0.15); border-radius: 16px;
    background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.6); font-size: 12px;
    font-family: var(--font-display); font-weight: 600; cursor: pointer; transition: var(--transition);
    letter-spacing: 0.3px;
}
.dashboard-tab-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.25); }
.dashboard-tab-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); box-shadow: 0 0 10px rgba(46,196,182,0.3); }

/* ================================================================
   DASHBOARD — Light/dark mode aware
   Uses CSS variables as defaults (light mode), body.night overrides
   for dark glassmorphic treatment
   ================================================================ */

.dashboard-panel {
    display: none;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 60px;
    background: var(--bg);
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}
.dashboard-panel.visible { display: block; animation: cardIn 0.5s ease both; }
body.night .dashboard-panel { background: #0a0d14; }

/* Ambient background orbs */
.dashboard-panel::before {
    content: '';
    position: fixed;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 172, 254, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.dashboard-panel::after {
    content: '';
    position: fixed;
    bottom: -200px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}
body.night .dashboard-panel::before { background: radial-gradient(circle, rgba(79, 172, 254, 0.06) 0%, transparent 70%); }
body.night .dashboard-panel::after { background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 70%); }

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
    position: relative;
    z-index: 1;
}
.dash-header h2 {
    font-family: 'Sora', 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    margin: 0;
}
body.night .dash-header h2 {
    background: linear-gradient(135deg, #e8ecf4 0%, #8b95b0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Live pulse dot */
.dash-live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #34d399;
    margin-right: 6px;
    vertical-align: middle;
    animation: dashPulse 2s ease-in-out infinite;
}
@keyframes dashPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52,211,153,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(52,211,153,0); }
}

/* Range buttons */
.dash-range-btns {
    display: flex;
    gap: 4px;
    position: relative;
    z-index: 1;
}
.dash-range-btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.dash-range-btn:hover {
    color: var(--text);
    background: rgba(0,0,0,0.04);
}
.dash-range-btn.active {
    background: linear-gradient(135deg, rgba(79,172,254,0.12), rgba(139,92,246,0.12));
    color: #3b82f6;
    box-shadow: 0 0 12px rgba(79,172,254,0.08);
}
body.night .dash-range-btn { color: #505a72; }
body.night .dash-range-btn:hover { color: #e8ecf4; background: rgba(255,255,255,0.04); }
body.night .dash-range-btn.active { color: #4facfe; box-shadow: 0 0 12px rgba(79,172,254,0.1); }

.dash-loading { display: none; text-align: center; padding: 40px; color: var(--text-light); font-family: 'Sora', sans-serif; font-size: 14px; }
.dash-loading.visible { display: block; }
.dash-error { display: none; text-align: center; padding: 16px; color: #fb7185; font-family: 'Sora', sans-serif; font-size: 13px; }
.dash-error.visible { display: block; }
.dash-content { display: none; position: relative; z-index: 1; }
.dash-content.visible { display: block; }

/* Stat cards */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}
.dash-stat {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 16px 16px;
    text-align: center;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: statFadeIn 0.5s ease forwards;
    opacity: 0;
    transform: translateY(12px);
}
.dash-stat:nth-child(1) { animation-delay: 0ms; }
.dash-stat:nth-child(2) { animation-delay: 80ms; }
.dash-stat:nth-child(3) { animation-delay: 160ms; }
.dash-stat:nth-child(4) { animation-delay: 240ms; }
.dash-stat:nth-child(5) { animation-delay: 320ms; }
.dash-stat:nth-child(6) { animation-delay: 400ms; }
@keyframes statFadeIn {
    to { opacity: 1; transform: translateY(0); }
}
.dash-stat:hover {
    border-color: rgba(79, 172, 254, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
body.night .dash-stat {
    background: rgba(17, 22, 36, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(255,255,255,0.06);
    box-shadow: none;
}
body.night .dash-stat:hover {
    background: rgba(25, 32, 52, 0.8);
    border-color: rgba(99, 179, 237, 0.15);
    box-shadow: none;
}
.dash-stat-icon {
    font-size: 18px;
    margin-bottom: 8px;
    opacity: 0.8;
}
.dash-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    letter-spacing: -0.5px;
}
.dash-stat-label {
    font-family: 'Sora', 'Outfit', sans-serif;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 6px;
}
body.night .dash-stat-label { color: #505a72; }

/* Top glow accent line on stat cards — light mode (subtler) */
.dash-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 1px;
}
.dash-stat:nth-child(1)::before { background: linear-gradient(90deg, transparent, rgba(79,172,254,0.25), transparent); }
.dash-stat:nth-child(2)::before { background: linear-gradient(90deg, transparent, rgba(167,139,250,0.25), transparent); }
.dash-stat:nth-child(3)::before { background: linear-gradient(90deg, transparent, rgba(52,211,153,0.25), transparent); }
.dash-stat:nth-child(4)::before { background: linear-gradient(90deg, transparent, rgba(251,113,133,0.25), transparent); }
.dash-stat:nth-child(5)::before { background: linear-gradient(90deg, transparent, rgba(251,191,36,0.25), transparent); }
.dash-stat:nth-child(6)::before { background: linear-gradient(90deg, transparent, rgba(45,212,191,0.25), transparent); }
/* Night mode: brighter glow lines */
body.night .dash-stat:nth-child(1)::before { background: linear-gradient(90deg, transparent, rgba(79,172,254,0.4), transparent); }
body.night .dash-stat:nth-child(2)::before { background: linear-gradient(90deg, transparent, rgba(167,139,250,0.4), transparent); }
body.night .dash-stat:nth-child(3)::before { background: linear-gradient(90deg, transparent, rgba(52,211,153,0.4), transparent); }
body.night .dash-stat:nth-child(4)::before { background: linear-gradient(90deg, transparent, rgba(251,113,133,0.4), transparent); }
body.night .dash-stat:nth-child(5)::before { background: linear-gradient(90deg, transparent, rgba(251,191,36,0.4), transparent); }
body.night .dash-stat:nth-child(6)::before { background: linear-gradient(90deg, transparent, rgba(45,212,191,0.4), transparent); }
/* Colored stat values — same in both modes */
.dash-stat:nth-child(1) .dash-stat-value { color: #4facfe; }
.dash-stat:nth-child(2) .dash-stat-value { color: #a78bfa; }
.dash-stat:nth-child(3) .dash-stat-value { color: #34d399; }
.dash-stat:nth-child(4) .dash-stat-value { color: #fb7185; }
.dash-stat:nth-child(5) .dash-stat-value { color: #fbbf24; }
.dash-stat:nth-child(6) .dash-stat-value { color: #2dd4bf; }

/* Chart cards */
.dash-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.dash-chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.3s ease;
}
.dash-chart-card:hover { border-color: rgba(79,172,254,0.12); }
body.night .dash-chart-card {
    background: rgba(17, 22, 36, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-color: rgba(255,255,255,0.06);
    box-shadow: none;
}
body.night .dash-chart-card:hover { border-color: rgba(255,255,255,0.1); }
.dash-chart-wide { grid-column: 1 / -1; }
.dash-chart-card h3 {
    font-family: 'Sora', 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dash-chart-card h3::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: #4facfe;
}
body.night .dash-chart-card h3 { color: #505a72; }
.dash-empty {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Sora', sans-serif;
}

/* Vertical bars */
.dash-bars-vertical {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 140px;
    padding-bottom: 22px;
    position: relative;
}
.dash-vbar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    position: relative;
    cursor: pointer;
}
.dash-vbar {
    width: 100%;
    min-height: 3px;
    border-radius: 4px 4px 1px 1px;
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s ease;
    opacity: 0.85;
}
.dash-vbar-col:hover .dash-vbar {
    opacity: 1;
    filter: brightness(1.2);
}
.dash-vbar-label {
    position: absolute;
    bottom: -20px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}
body.night .dash-vbar-label { color: #505a72; }

/* Horizontal bars */
.dash-hbar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    opacity: 0;
    animation: hbarSlideIn 0.4s ease forwards;
}
.dash-hbar-row:nth-child(1) { animation-delay: 0ms; }
.dash-hbar-row:nth-child(2) { animation-delay: 80ms; }
.dash-hbar-row:nth-child(3) { animation-delay: 160ms; }
.dash-hbar-row:nth-child(4) { animation-delay: 240ms; }
.dash-hbar-row:nth-child(5) { animation-delay: 320ms; }
.dash-hbar-row:last-child { margin-bottom: 0; }
@keyframes hbarSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}
.dash-hbar-label {
    width: 140px;
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-mid);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
body.night .dash-hbar-label { color: #8b95b0; }
.dash-hbar-track {
    flex: 1;
    height: 24px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
}
body.night .dash-hbar-track { background: rgba(255,255,255,0.03); }
.dash-hbar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    min-width: 3px;
    opacity: 0.8;
}
.dash-hbar-row:hover .dash-hbar-fill { opacity: 1; }
.dash-hbar-count {
    width: 36px;
    flex-shrink: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-align: left;
}
body.night .dash-hbar-count { color: #e8ecf4; }

/* Activity table */
.dash-table-wrap { overflow-x: auto; }
.dash-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.dash-table th {
    font-family: 'Sora', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.dash-table td {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 10px 12px;
    color: var(--text-mid);
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
.dash-table tbody tr {
    transition: background 0.15s ease;
}
.dash-table tbody tr:hover {
    background: var(--bg-input);
}
body.night .dash-table th { border-bottom-color: rgba(255,255,255,0.06); }
body.night .dash-table td { color: #8b95b0; border-bottom-color: rgba(255,255,255,0.03); }
body.night .dash-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.dash-model-cell {
    font-size: 10px;
    color: var(--text-muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status pills */
.dash-status-ok {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    color: #16a34a;
    background: rgba(34,197,94,0.1);
    padding: 3px 10px;
    border-radius: 20px;
}
.dash-status-ok::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #16a34a;
}
.dash-status-err {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    color: #ef4444;
    background: rgba(239,68,68,0.1);
    padding: 3px 10px;
    border-radius: 20px;
}
.dash-status-err::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ef4444;
}
body.night .dash-status-ok { color: #34d399; background: rgba(52,211,153,0.08); }
body.night .dash-status-ok::before { background: #34d399; }
body.night .dash-status-err { color: #fb7185; background: rgba(251,113,133,0.08); }
body.night .dash-status-err::before { background: #fb7185; }

/* Mode badges in table */
.dash-mode-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.dash-mode-badge-deep {
    color: #7c3aed;
    border-color: rgba(139,92,246,0.25);
    background: rgba(139,92,246,0.08);
}
body.night .dash-mode-badge { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.06); }
body.night .dash-mode-badge-deep { color: #a78bfa; border-color: rgba(167,139,250,0.2); background: rgba(167,139,250,0.06); }

/* Token usage grid */
.dash-token-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
.dash-token-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s ease;
}
.dash-token-item:hover {
    border-color: rgba(79,172,254,0.15);
}
body.night .dash-token-item { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.06); }
body.night .dash-token-item:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); }
.dash-token-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}
.dash-token-label {
    font-family: 'Sora', sans-serif;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 4px;
}
.dash-token-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}
.dash-token-note {
    font-family: 'Sora', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 12px;
    font-style: italic;
}
body.night .dash-token-label { color: #505a72; }
body.night .dash-token-sub { color: #505a72; }
body.night .dash-token-note { color: #505a72; }

/* === DASHBOARD RESPONSIVE === */
@media (max-width: 768px) {
    .dash-stats { grid-template-columns: repeat(3, 1fr); }
    .dash-charts { grid-template-columns: 1fr; }
    .dash-token-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-hbar-label { width: 100px; font-size: 10px; }
}
@media (max-width: 480px) {
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .dash-hbar-label { width: 80px; }
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
    .top-bar { padding: 0 16px; height: 54px; }
    .tempo-mark { font-size: 18px; }
    .tempo-mark .tempo-icon { width: 24px; height: 24px; font-size: 12px; }
    .page { padding: 22px 14px 36px; }
    .step { padding: 4px 8px; font-size: 11px; }
    .step-line { width: 28px; }
    .card-body { padding: 18px; }
    .output-content { padding: 20px; }
    .user-pill { display: none; }
    .shift-label { display: none; }
}
