/* ================================================
   Timegrapher — Streamlined Professional Styles
   ================================================ */

/* ─── Guide Banner ─── */
.guide-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    margin-bottom: 12px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    font-size: 0.82rem;
    line-height: 1.35;
    animation: fadeInBanner 0.3s ease;
}

body.light-mode .guide-banner {
    background: rgba(79, 70, 229, 0.06);
    border-color: rgba(79, 70, 229, 0.16);
}

.guide-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-banner-icon {
    color: var(--accent);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.guide-banner-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--muted-dark);
    cursor: pointer;
    padding: 0 4px;
}

body.light-mode .guide-banner-close { color: var(--muted-light); }

/* ─── Watch Bar (One-Tap Selector) ─── */
.watch-bar {
    margin-bottom: 12px;
    border-radius: 16px;
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.light-mode .watch-bar {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.watch-select-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-strong-dark);
    border: 1px solid var(--border-dark);
    border-radius: 13px;
    padding: 10px 12px;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    text-align: left;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-tap-highlight-color: transparent;
}

body.light-mode .watch-select-btn {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.watch-select-btn:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent-tint) 50%, var(--surface-strong-dark));
}

body.light-mode .watch-select-btn:hover {
    background: color-mix(in srgb, var(--accent-tint) 50%, var(--surface-strong-light));
}

.watch-select-btn:active {
    transform: scale(0.99);
}

.watch-select-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.watch-select-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 10px;
    background: var(--accent-tint);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.watch-select-icon.auto-icon {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
}

.watch-select-icon.detecting {
    animation: pulse-dot 1.2s ease-in-out infinite;
}

.watch-select-text {
    min-width: 0;
    flex: 1;
}

.watch-title {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watch-subtitle {
    font-size: 0.73rem;
    color: var(--muted-dark);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.light-mode .watch-subtitle { color: var(--muted-light); }

.watch-select-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 8px;
}

.badge-bph, .badge-lift {
    font-size: 0.74rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    padding: 3px 7px;
    border-radius: 7px;
}

.badge-bph {
    color: var(--accent);
    background: var(--accent-tint);
}

.badge-lift {
    color: #a855f7;
    background: rgba(168, 85, 247, 0.12);
}

.watch-select-arrow {
    font-size: 0.72rem;
    color: var(--muted-dark);
    margin-left: 2px;
}

body.light-mode .watch-select-arrow { color: var(--muted-light); }

/* Quick BPH Row & Lift Stepper */
.quick-bph-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 2px;
}

.beat-rate-selector {
    position: relative;
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-strong-dark);
    border: 1px solid var(--border-dark);
}

body.light-mode .beat-rate-selector {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.beat-pill {
    position: relative;
    z-index: 1;
    padding: 4px 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted-dark);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    cursor: pointer;
    transition: color 0.18s ease;
    white-space: nowrap;
}

body.light-mode .beat-pill { color: var(--muted-light); }
.beat-pill.active { color: #fff; }

.beat-indicator {
    position: absolute;
    height: calc(100% - 6px);
    top: 3px;
    border-radius: 7px;
    background: var(--accent);
    transition: left 0.22s cubic-bezier(0.4, 0, 0.2, 1), width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.lift-angle-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-strong-dark);
    padding: 2px 6px;
    border-radius: 9px;
    border: 1px solid var(--border-dark);
}

body.light-mode .lift-angle-wrap {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.lift-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted-dark);
}

body.light-mode .lift-label { color: var(--muted-light); }

.lift-input {
    width: 44px;
    text-align: center;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    outline: none;
    padding: 0;
}

.lift-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-dark);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.light-mode .lift-btn { color: var(--muted-light); }
.lift-btn:hover { color: var(--accent); }

/* ─── Hero Primary Action Bar ─── */
.hero-action-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.ctrl-hero {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 13px 20px;
    border-radius: 14px;
    gap: 10px;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.35);
}

.ctrl-hero.recording {
    box-shadow: 0 4px 18px rgba(239, 68, 68, 0.35);
}

.ctrl-icon-only {
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    border-radius: 14px;
    font-size: 1rem;
}

/* ─── Readout Cards ─── */
.readouts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.readout-card {
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
    border-radius: 16px;
    padding: 12px 8px 14px;
    text-align: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.2s ease;
}

body.light-mode .readout-card {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.readout-card.good {
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: 0 0 14px rgba(34, 197, 94, 0.08);
}

.readout-card.warn {
    border-color: rgba(245, 158, 11, 0.35);
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.08);
}

.readout-card.bad {
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.08);
}

.readout-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 6px;
}

.readout-icon {
    font-size: 0.72rem;
    color: var(--muted-dark);
}

body.light-mode .readout-icon { color: var(--muted-light); }

.readout-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-dark);
}

body.light-mode .readout-label { color: var(--muted-light); }

.readout-body {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
}

.readout-value {
    font-size: 1.65rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.readout-card.good .readout-value { color: #22c55e; }
.readout-card.warn .readout-value { color: #f59e0b; }
.readout-card.bad  .readout-value { color: #ef4444; }

.readout-unit {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--muted-dark);
}

body.light-mode .readout-unit { color: var(--muted-light); }

/* ─── Timing Diagram ─── */
.graph-wrap {
    margin-bottom: 12px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-dark);
    background: var(--surface-dark);
}

body.light-mode .graph-wrap {
    border-color: var(--border-light);
    background: var(--surface-light);
}

.graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 6px;
    gap: 8px;
}

.graph-title-group {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.graph-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted-dark);
}

body.light-mode .graph-title { color: var(--muted-light); }

.graph-samples {
    font-size: 0.74rem;
    font-weight: 500;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--muted-dark);
}

body.light-mode .graph-samples { color: var(--muted-light); }

.graph-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.graph-view-controls {
    display: flex;
    gap: 2px;
    background: var(--surface-strong-dark);
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}

body.light-mode .graph-view-controls {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.graph-zoom-btn {
    border: none;
    background: transparent;
    color: var(--muted-dark);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

body.light-mode .graph-zoom-btn { color: var(--muted-light); }

.graph-zoom-btn.active {
    background: var(--accent);
    color: #fff;
}

.graph-action-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    background: var(--surface-strong-dark);
    color: var(--muted-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}

body.light-mode .graph-action-btn {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
    color: var(--muted-light);
}

.graph-action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.graph-container {
    position: relative;
    width: 100%;
    padding: 0 4px;
}

.graph-container canvas {
    display: block;
    width: 100%;
    height: 190px;
    border-radius: 10px;
}

.graph-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 6px 14px 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted-dark);
}

body.light-mode .legend-item { color: var(--muted-light); }

.legend-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.legend-tick {
    background: #22d3ee;
    box-shadow: 0 0 4px rgba(34, 211, 238, 0.5);
}

.legend-tock {
    background: #a78bfa;
    box-shadow: 0 0 4px rgba(167, 139, 250, 0.5);
}

/* ─── Oscilloscope / Signal Strip ─── */
.scope-wrap {
    margin-bottom: 12px;
    border-radius: 14px;
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
    overflow: hidden;
}

body.light-mode .scope-wrap {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.scope-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-dark);
    font-size: 0.74rem;
}

body.light-mode .scope-header { border-bottom-color: var(--border-light); }

.scope-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-dark);
    transition: background 0.3s ease;
}

.status-dot.listening {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.status-dot.calibrating {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: pulse-dot 0.6s ease-in-out infinite;
}

body.light-mode .status-dot { color: var(--muted-light); }

.status-text {
    font-weight: 600;
    color: var(--muted-dark);
}

body.light-mode .status-text { color: var(--muted-light); }

.scope-stats {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signal-tag {
    font-size: 0.68rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--muted-dark);
    background: var(--surface-strong-dark);
    padding: 2px 6px;
    border-radius: 6px;
}

body.light-mode .signal-tag {
    color: var(--muted-light);
    background: var(--surface-strong-light);
}

.scope-canvas-container {
    width: 100%;
    height: 42px;
    position: relative;
    background: #090c10;
}

body.light-mode .scope-canvas-container { background: #eef0f4; }

.scope-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ─── Position Matrix Card ─── */
.pos-matrix-card {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
}

body.light-mode .pos-matrix-card {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.pos-matrix-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.78rem;
    flex-wrap: wrap;
    gap: 6px;
}

.pos-picker-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pos-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-dark);
    display: flex;
    align-items: center;
    gap: 4px;
}

body.light-mode .pos-label { color: var(--muted-light); }

.pos-select {
    padding: 6px 24px 6px 10px;
    border: 1px solid var(--border-dark);
    border-radius: 9px;
    background: var(--surface-strong-dark);
    color: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M8 11.5l-5-5h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

body.light-mode .pos-select {
    background-color: var(--surface-strong-light);
    border-color: var(--border-light);
}

.pos-matrix-stats {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--accent);
}

.pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

.pos-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 4px;
    border-radius: 9px;
    background: var(--surface-strong-dark);
    border: 1px solid var(--border-dark);
    text-align: center;
}

body.light-mode .pos-cell {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.pos-cell.filled {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border-dark));
}

.pos-cell-label {
    font-size: 0.63rem;
    font-weight: 600;
    color: var(--muted-dark);
    margin-bottom: 2px;
}

body.light-mode .pos-cell-label { color: var(--muted-light); }

.pos-cell-val {
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.pos-cell-val.rate-good { color: #22c55e; }
.pos-cell-val.rate-warn { color: #f59e0b; }
.pos-cell-val.rate-bad  { color: #ef4444; }

/* ─── Settings Accordion ─── */
.settings-accordion {
    margin-bottom: 12px;
    border-radius: 14px;
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
    overflow: hidden;
}

body.light-mode .settings-accordion {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.settings-accordion-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted-dark);
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}

.settings-accordion-toggle::-webkit-details-marker { display: none; }
body.light-mode .settings-accordion-toggle { color: var(--muted-light); }

.settings-chevron {
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.settings-accordion[open] .settings-chevron { transform: rotate(180deg); }

.settings-accordion-body {
    padding: 0 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.setting-label {
    display: flex;
    flex-direction: column;
    font-size: 0.82rem;
    font-weight: 500;
}

.setting-sub {
    font-size: 0.68rem;
    color: var(--muted-dark);
    margin-top: 1px;
}

body.light-mode .setting-sub { color: var(--muted-light); }

.setting-control {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.setting-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-strong-dark);
    outline: none;
    cursor: pointer;
}

body.light-mode .setting-slider { background: var(--surface-strong-light); }

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.setting-switch {
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.setting-value {
    font-size: 0.76rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    min-width: 24px;
    text-align: right;
}

/* ─── Session Log ─── */
.log-section {
    margin-bottom: 24px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-dark);
    background: var(--surface-dark);
}

body.light-mode .log-section {
    border-color: var(--border-light);
    background: var(--surface-light);
}

.log-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.log-toggle-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-toggle-left i { color: var(--muted-dark); }
body.light-mode .log-toggle-left i { color: var(--muted-light); }

.log-chevron {
    font-size: 0.72rem;
    color: var(--muted-dark);
    transition: transform 0.25s ease;
}

.log-section.open .log-chevron { transform: rotate(180deg); }

.log-body {
    display: none;
    padding: 0 12px 12px;
}

.log-section.open .log-body { display: block; }

.log-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid var(--border-dark);
}

body.light-mode .log-table-wrap { border-color: var(--border-light); }

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.74rem;
    white-space: nowrap;
}

.log-table th {
    padding: 8px 10px;
    text-align: left;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-dark);
    background: var(--surface-strong-dark);
    border-bottom: 1px solid var(--border-dark);
}

body.light-mode .log-table th {
    color: var(--muted-light);
    background: var(--surface-strong-light);
    border-bottom-color: var(--border-light);
}

.log-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-dark);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.73rem;
}

body.light-mode .log-table td { border-bottom-color: var(--border-light); }
.log-table tr:last-child td { border-bottom: none; }

.log-table .rate-good { color: #22c55e; }
.log-table .rate-warn { color: #f59e0b; }
.log-table .rate-bad  { color: #ef4444; }

.log-del-btn {
    background: none;
    border: none;
    color: var(--muted-dark);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 6px;
}

.log-del-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.log-empty {
    text-align: center;
    padding: 16px;
    font-size: 0.8rem;
    color: var(--muted-dark);
}

body.light-mode .log-empty { color: var(--muted-light); }
.log-empty.hidden { display: none; }

.log-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Global Buttons ─── */
.ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--surface-strong-dark);
    color: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.1s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

body.light-mode .ctrl-btn {
    border-color: var(--border-light);
    background: var(--surface-strong-light);
}

.ctrl-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-dark));
    background: color-mix(in srgb, var(--accent-tint) 60%, var(--surface-strong-dark));
}

body.light-mode .ctrl-btn:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border-light));
    background: color-mix(in srgb, var(--accent-tint) 70%, var(--surface-strong-light));
}

.ctrl-btn:active { transform: scale(0.97); }

.ctrl-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.ctrl-primary:hover {
    background: color-mix(in srgb, var(--accent) 85%, #fff);
    border-color: color-mix(in srgb, var(--accent) 85%, #fff);
}

body.light-mode .ctrl-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.ctrl-primary.recording {
    background: #ef4444;
    border-color: #ef4444;
}

.ctrl-primary.recording:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.ctrl-accent {
    background: color-mix(in srgb, var(--accent) 18%, var(--surface-strong-dark));
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border-dark));
    color: var(--accent);
}

body.light-mode .ctrl-accent {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface-strong-light));
    border-color: color-mix(in srgb, var(--accent) 20%, var(--border-light));
    color: var(--accent);
}

.ctrl-danger { color: #ef4444; }
.ctrl-danger:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
}

.ctrl-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: 9px;
}

/* ─── Modals ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    width: min(540px, 100%);
    max-height: 84vh;
    display: flex;
    flex-direction: column;
    border-radius: 20px 20px 0 0;
    background: var(--surface-dark);
    border: 1px solid var(--border-dark);
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light-mode .modal-content {
    background: var(--surface-light);
    border-color: var(--border-light);
}

.modal-overlay.open .modal-content { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 10px;
    flex-shrink: 0;
}

.modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--surface-strong-dark);
    color: var(--muted-dark);
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

body.light-mode .modal-close {
    background: var(--surface-strong-light);
    color: var(--muted-light);
}

.modal-search {
    position: relative;
    padding: 0 18px 12px;
    flex-shrink: 0;
}

.modal-search-icon {
    position: absolute;
    left: 32px;
    top: 50%;
    transform: translateY(calc(-50% - 6px));
    font-size: 0.82rem;
    color: var(--muted-dark);
    pointer-events: none;
}

.modal-search-input {
    width: 100%;
    padding: 10px 14px 10px 36px;
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    background: var(--surface-strong-dark);
    color: inherit;
    font-size: 0.86rem;
    font-family: inherit;
    outline: none;
}

body.light-mode .modal-search-input {
    border-color: var(--border-light);
    background: var(--surface-strong-light);
}

.modal-search-input:focus { border-color: var(--accent); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 18px 18px;
    -webkit-overflow-scrolling: touch;
}

/* Modal Quick Option Cards */
.modal-quick-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.modal-quick-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 11px;
    background: var(--surface-strong-dark);
    border: 1px solid var(--border-dark);
    cursor: pointer;
    color: inherit;
    font-family: inherit;
    text-align: left;
    transition: all 0.15s ease;
}

body.light-mode .modal-quick-card {
    background: var(--surface-strong-light);
    border-color: var(--border-light);
}

.modal-quick-card:hover {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.modal-quick-card i {
    font-size: 1.1rem;
    color: var(--accent);
}

.modal-quick-card-auto i { color: #22c55e; }

.modal-quick-title {
    font-size: 0.82rem;
    font-weight: 700;
}

.modal-quick-sub {
    font-size: 0.68rem;
    color: var(--muted-dark);
}

body.light-mode .modal-quick-sub { color: var(--muted-light); }

/* Watch group & item list */
.watch-group { margin-bottom: 12px; }

.watch-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted-dark);
    padding: 0 4px 5px;
    margin: 0;
}

body.light-mode .watch-group-title { color: var(--muted-light); }

.watch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    gap: 8px;
}

.watch-item:hover { background: var(--surface-strong-dark); }
body.light-mode .watch-item:hover { background: var(--surface-strong-light); }

.watch-item-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.watch-item-model {
    font-size: 0.84rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watch-item-caliber {
    font-size: 0.7rem;
    color: var(--muted-dark);
}

body.light-mode .watch-item-caliber { color: var(--muted-light); }

.watch-item-badges {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.watch-item-bph {
    font-size: 0.74rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--accent);
}

.watch-item-lift {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: #a855f7;
    background: rgba(168, 85, 247, 0.1);
    padding: 2px 5px;
    border-radius: 5px;
}

.watch-no-results {
    text-align: center;
    padding: 24px 10px;
    font-size: 0.84rem;
    color: var(--muted-dark);
}

/* Guide modal body */
.guide-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guide-step {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.guide-step-num {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-step-text {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.35;
}

.guide-step-text strong {
    display: block;
    font-size: 0.86rem;
    margin-bottom: 2px;
}

.guide-step-text p {
    margin: 0 0 4px;
    color: var(--muted-dark);
}

body.light-mode .guide-step-text p { color: var(--muted-light); }

.guide-step-text ul {
    margin: 4px 0 0;
    padding-left: 16px;
    color: var(--muted-dark);
}

body.light-mode .guide-step-text ul { color: var(--muted-light); }
.guide-step-text li { margin-bottom: 3px; }

/* ─── Animations ─── */
@keyframes fadeInBanner {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.25); }
}

/* ─── Responsive ─── */
@media (min-width: 601px) {
    .modal-content {
        border-radius: 20px;
        border-bottom: 1px solid var(--border-dark);
        max-height: 72vh;
    }
    body.light-mode .modal-content { border-bottom-color: var(--border-light); }
    .modal-overlay { align-items: center; }
    .modal-content { transform: translateY(20px); }
}

@media (max-width: 600px) {
    .readout-card {
        padding: 10px 4px 12px;
        border-radius: 13px;
    }
    .readout-value { font-size: 1.35rem; }
    .readout-label, .readout-unit { font-size: 0.64rem; }
    .pos-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
    .pos-cell { padding: 5px 2px; }
    .pos-cell-label { font-size: 0.58rem; }
    .pos-cell-val { font-size: 0.72rem; }
}
