
  :root {
    --bg: #0f1119;
    --surface: #1c2035;
    --border: #3a4060;
    --text: #ffffff;
    --muted: #a8b2d0;
    --accent: #7eb8f7;
    --accent2: #7dd4b0;
    --warn: #f5c96a;
    --danger: #f47f5f;
    --dot: #7eb8f7;
    --word-left: #ffffff;
    --word-right: #ffffff;
    --radius: 12px;
  }

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

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    min-height: 100vh;
    overflow-x: hidden;
  }

  /* ── SCREENS ── */
  .screen { display: none; min-height: 100vh; padding-bottom: 0; }
  .screen.active { display: flex; flex-direction: column; }

  /* ── SETUP SCREEN ── */
  #screen-setup {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: radial-gradient(ellipse at 30% 20%, #162035 0%, var(--bg) 60%);
  }

  #screen-settings {
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: radial-gradient(ellipse at 30% 20%, #162035 0%, var(--bg) 60%);
    text-align: center;
  }
  #screen-settings .field-group { text-align: center; }
  #screen-settings .emdr-dot-slider-group { margin: 0 auto; }
  #screen-settings .emdr-color-row { justify-content: center; }

  .setup-inner {
    width: 100%;
    max-width: 600px;
  }

  .logo {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2rem, 6vw, 3.2rem);
    font-weight: normal;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .logo-sub {
    font-size: 0.82rem;
    font-weight: normal;
    color: var(--muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin: 0 0 48px;
  }

  .section-label {
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
  }

  .field-group { margin-bottom: 32px; }

  textarea, input[type="text"], input[type="number"] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    padding: 14px 16px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
  }
  textarea:focus, input:focus { border-color: var(--accent); }
  textarea { min-height: 90px; }

  .mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mode-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
  }
  .mode-card.selected {
    border-color: var(--accent);
    background: rgba(79,195,247,0.07);
  }
  .mode-card .mode-icon { font-size: 1.5rem; margin-bottom: 6px; }
  .mode-card .mode-name { font-size: 0.82rem; color: var(--text); }
  .mode-card .mode-desc { font-size: 0.72rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }

  .slider-row {
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .slider-row input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
    height: 4px;
    border: none;
    padding: 0;
    background: none;
  }
  .slider-val {
    font-size: 0.82rem;
    color: var(--accent);
    min-width: 48px;
    text-align: right;
  }

  .btn-primary {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: var(--radius);
    color: #0a0c10;
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 8px;
  }
  .btn-primary:hover { opacity: 0.9; }
  .btn-primary:active { transform: scale(0.98); }

  .btn-secondary {
    padding: 10px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.2s;
  }
  .btn-secondary:hover { border-color: var(--accent); }

  /* ── TARGET SCREEN ── */
  #screen-target {
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: radial-gradient(ellipse at 70% 80%, #162035 0%, var(--bg) 60%);
    overflow-y: auto;
  }

  .target-layout {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
  }

  .target-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 0 8px;
  }

  .step-indicator {
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 20px;
  }

  .target-prompt {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.8rem, 4.5vw, 2.6rem);
    line-height: 1.3;
    margin-bottom: 14px;
    color: var(--text);
    font-weight: 700;
  }

  .target-hint {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.7;
  }


  /* ── READ OUT LOUD INSTRUCTIONS SCREEN (EMDR 2.0) ── */
  #screen-readaloud {
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    background: radial-gradient(ellipse at 70% 80%, #162035 0%, var(--bg) 60%);
    overflow-y: auto;
  }
  .readaloud-layout {
    width: 100%;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 32px 0 8px;
  }
  .readaloud-demo { width: 100%; margin: 6px 0 26px; }
  .readaloud-track {
    position: relative;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: 40px;
    background: var(--surface);
    overflow: hidden;
  }
  .readaloud-word {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'DM Serif Display', serif;
    font-size: 1.7rem;
    color: var(--accent);
    opacity: 0;
    transition: opacity 0.35s ease;
  }
  .readaloud-word.on { opacity: 1; }
  .readaloud-word-left { left: 10%; }
  .readaloud-word-right { right: 10%; }
  .readaloud-text p {
    font-size: 1.02rem;
    line-height: 1.7;
    color: var(--text);
    margin: 0 0 8px;
  }
  .readaloud-text strong { color: var(--accent); }
  .readaloud-tips {
    list-style: none;
    padding: 0;
    margin: 18px 0 26px;
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--muted);
  }
  .readaloud-back { margin-top: 14px; }
  @media (max-width: 680px) {
    .readaloud-layout { padding: 24px 0 8px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .readaloud-word { transition: none; }
  }

  /* ── PHASE 3 COLLAPSIBLE ── */
  .phase3-toggle {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 8px;
    margin-bottom: 0;
  }
  .phase3-toggle:hover {
    border-color: var(--accent);
    background: rgba(126,184,247,0.05);
  }
  .phase3-toggle[aria-expanded="true"] {
    border-color: var(--accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
  }
  .phase3-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .phase3-toggle-label {
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
  }
  .phase3-toggle-optional {
    font-size: 0.72rem;
    color: var(--muted);
    font-style: italic;
    letter-spacing: 0.05em;
    background: rgba(126,184,247,0.08);
    border: 1px solid rgba(126,184,247,0.2);
    border-radius: 20px;
    padding: 2px 9px;
    opacity: 0.8;
  }
  .phase3-toggle-chevron {
    color: var(--muted);
    font-size: 2.46rem;
    transition: transform 0.25s ease;
    line-height: 1;
  }
  .phase3-toggle-chevron.open {
    transform: rotate(180deg);
  }
  .phase3-body {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-top: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    padding: 16px;
    margin-bottom: 8px;
  }

  .phase3-heading {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }

  .phase3-field {
    margin-bottom: 14px;
  }

  .phase3-field textarea {
    min-height: 48px;
    font-size: 0.82rem;
  }

  .phase3-field .section-label {
    font-size: 0.72rem;
    margin-bottom: 6px;
  }

  @media (max-width: 680px) {
    .target-main {
      padding: 24px 0 8px;
    }
  }

  .suds-display {
    margin: 20px 0;
  }

  .suds-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
    letter-spacing: 0;
    text-transform: none;
  }

  .suds-scale {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .suds-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .suds-btn:hover { border-color: var(--accent); color: var(--text); }
  .suds-btn.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #0a0c10;
    font-weight: 600;
  }

  .suds-anchors {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 8px;
    padding: 0 4px;
  }

  /* ── SESSION SCREEN ── */
  #screen-session {
    position: relative;
    background-color: var(--bg);
    background-size: cover;
    background-position: center;
    overflow: hidden;
  }

  .session-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(10,12,16,0.9) 0%, transparent 100%);
  }

  .session-meta {
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* EMDR 2.0 BLS page: a "Settings" text link that appears underneath the
     Reading/Counting toggle on hover (or keyboard focus). */
  .tax-toggle-wrap {
    position: relative;
    display: inline-block;
  }
  /* Invisible extension of the hover area: a strip as tall as the toggle
     itself directly beneath it, so the hover zone is twice the toggle's
     height and covers the link and the gap above it. */
  .tax-toggle-wrap::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 100%;
  }
  .tax-settings-link {
    position: absolute;
    top: calc(100% + 11px);   /* gap between the toggle and the link */
    left: 50%;
    transform: translateX(-50%); /* centred under the toggle */
    z-index: 1;               /* above the invisible hover strip, so clicks reach the link */
    white-space: nowrap;
    padding: 0;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: underline;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease 0.12s; /* short delay before hiding */
  }
  .tax-toggle-wrap:hover .tax-settings-link,
  .tax-toggle-wrap:focus-within .tax-settings-link {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
  }
  .tax-settings-link:hover { color: var(--text); }

  .session-controls {
    display: flex;
    gap: 10px;
  }

  /* BLS TRACK */
  .bls-track {
    position: absolute;
    top: 50%;
    left: 0; right: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
  }

  /* EMDR 2.0 words/counting BLS screen: track + speed slider stacked and
     centered together (classic EMDR's .bls-track is untouched — it has no
     .words-stage-wrap ancestor, so these overrides never apply there). */
  .words-stage-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
  }
  .words-stage-wrap .bls-track {
    position: static;
    top: auto; left: auto; right: auto;
    transform: none;
    height: auto;
    width: 100%;
  }
  .words-speed-controls {
    width: min(70vw, 420px);
  }

  /* MODE: DOT */
  .dot-track {
    width: 80%;
    max-width: 800px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    position: relative;
  }

  .dot-ball {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--dot);
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(79,195,247,0.6), 0 0 40px rgba(79,195,247,0.2);
    transition: left 0s linear;
  }

  /* MODE: ALTERNATING WORDS */
  .word-stage {
    width: 90%;
    max-width: 900px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
  }

  /* Counting mode: bring the two numbers in closer than the full
     Reading-mode track width. */
  .word-stage.compact-stage {
    max-width: 730px;
  }

  .word-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    border-radius: 16px;
    padding: 20px;
    transition: background 0.15s;
  }

  .word-panel.active {
    background: rgba(79,195,247,0.05);
  }

  /* Counting mode shows one short number, not two lines of reading text —
     shrink the shaded box to fit it instead of stretching to half the track. */
  .word-panel.count-box {
    flex: 0 0 auto;
    min-width: 110px;
    min-height: 80px;
    padding: 16px 32px;
  }

  .word-line {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.4rem, 3.5vw, 2.2rem);
    line-height: 1.3;
    text-align: center;
    color: var(--text);
    opacity: 0;
    transition: opacity 0.12s ease;
    min-height: 1.3em;
  }

  .word-line.visible { opacity: 1; }
  .word-line.fading { opacity: 0; }

  .word-divider {
    width: 2px;
    height: 60px;
    background: var(--border);
    border-radius: 1px;
    flex-shrink: 0;
  }

  /* MODE: SCROLL */
  .scroll-container {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 600px;
    text-align: center;
  }

  .scroll-line {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    color: var(--text);
    line-height: 1.8;
    opacity: 0.85;
  }

  /* SUDS CHECK OVERLAY */
  .suds-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10,12,16,0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s;
  }
  .suds-overlay.show {
    opacity: 1;
    pointer-events: all;
  }

  .suds-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 500px;
    text-align: center;
  }

  .suds-title {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    margin-bottom: 8px;
  }

  .suds-sub {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 28px;
    line-height: 1.6;
  }

  /* PROGRESS */
  .session-progress {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--border);
  }
  .session-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    transition: width 0.5s ease;
  }

  /* SESSION MODE TOOLTIP (BLS screen) */
  .mode-tooltip-wrap {
    position: relative;
  }
  .mode-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 300px;
    background: #10141f;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--muted);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    pointer-events: none;
  }
  .mode-tooltip p { margin: 0 0 8px; }
  .mode-tooltip p:last-child { margin-bottom: 0; }
  .mode-tooltip strong { color: var(--text); }
  .mode-tooltip-wrap:hover .mode-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* FULLSCREEN TOGGLE */
  .fullscreen-btn {
    position: absolute;
    bottom: 16px;
    right: 20px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
  }
  .fullscreen-btn:hover {
    border-color: var(--accent);
    color: var(--text);
  }
  .fullscreen-btn svg {
    width: 18px;
    height: 18px;
  }

  /* COUNTDOWN */
  .set-countdown {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }

  /* ── HISTORY SCREEN ── */
  #screen-history {
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px;
    background: var(--bg);
  }

  .history-inner {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
  }

  .history-title {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    margin-bottom: 8px;
  }

  .history-sub {
    font-size: 0.72rem;
    color: var(--muted);
    margin-bottom: 32px;
  }

  .suds-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 100px;
    margin-bottom: 24px;
    padding: 0 4px;
  }

  .suds-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    height: 100%;
    justify-content: flex-end;
  }

  .suds-bar {
    width: 100%;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(to top, var(--accent), var(--accent2));
    transition: height 0.5s ease;
    min-height: 4px;
  }

  .suds-bar-label {
    font-size: 0.72rem;
    color: var(--muted);
  }

  .history-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
  }

  .log-entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .log-set { font-size: 0.72rem; color: var(--muted); }
  .log-suds { font-size: 1.1rem; font-family: 'DM Serif Display', serif; color: var(--accent); }
  .log-arrow { color: var(--muted); font-size: 0.82rem; margin: 0 6px; }
  .log-change { font-size: 0.72rem; }
  .log-change.down { color: var(--accent2); }
  .log-change.up { color: var(--danger); }
  .log-change.same { color: var(--muted); }

  .note-area {
    margin-bottom: 24px;
  }

  .note-area textarea {
    min-height: 80px;
  }

  .btn-row {
    display: flex;
    gap: 12px;
  }

  /* ── UTILS ── */
  .hidden { display: none !important; }

  .fade-in {
    animation: fadeIn 0.4s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* SCROLL mode track */
  .scroll-words-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    overflow: hidden;
  }

  .scroll-word-item {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    color: var(--text);
    padding: 4px 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    text-align: center;
  }

  .scroll-word-item.show {
    opacity: 1;
    transform: translateY(0);
  }

  .scroll-word-item.dim {
    opacity: 0.25;
  }

  /* Arithmetic mode */
  .arith-display {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .arith-inner {
    text-align: center;
  }

  .arith-number {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(3rem, 12vw, 7rem);
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 12px;
  }

  .arith-hint {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* dot track with scroll */
  .dot-with-scroll {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 48px;
  }

  /* ── TEXT LIBRARY ── */
  /* styles moved to compact overrides below */

  .text-preview {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.7;
    max-height: 80px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    font-style: italic;
  }

  /* ── INSTRUCTIONS BANNER ── */
  .instructions-banner {
    background: rgba(79,195,247,0.07);
    border: 1px solid rgba(79,195,247,0.2);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 32px;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.6;
  }
  .instructions-banner strong {
    color: var(--text);
    font-weight: 600;
  }

  /* ── COMPACT LIBRARY ── */
  .library-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .lib-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
  }
  .lib-card:hover { border-color: var(--muted); }
  .lib-card.selected {
    border-color: var(--accent);
    background: rgba(79,195,247,0.07);
  }
  .lib-card .lib-num {
    display: none;
  }
  .lib-card .lib-title {
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 4px;
    font-family: 'DM Mono', monospace;
    font-weight: 600;
  }
  .lib-card .lib-mood {
    font-size: 0.65rem;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
    font-weight: 400;
  }
  /* ── TAPPING SUGGESTION MODAL ── */
  #tapping-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  #tapping-modal.show {
    opacity: 1;
  }
  .tapping-modal-box {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 520px;
    width: 100%;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  }
  .tapping-modal-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.6rem;
    color: var(--text);
    margin-bottom: 16px;
  }
  .tapping-modal-body {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.8;
    margin-bottom: 28px;
  }


  #app-toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface);
    border: 1px solid var(--accent);
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 0.82rem;
    padding: 14px 24px;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
    white-space: nowrap;
  }
  #app-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }


  .reading-text-toggle {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 0;
  }
  .reading-text-toggle:hover {
    border-color: var(--accent);
    background: rgba(126,184,247,0.05);
  }
  .reading-text-toggle[aria-expanded="true"] {
    border-color: var(--accent);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom-color: transparent;
  }
  .reading-text-toggle-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .reading-text-label {
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: 'DM Mono', monospace;
  }
  .reading-text-optional {
    font-size: 0.72rem;
    color: var(--muted);
    font-style: italic;
    letter-spacing: 0.05em;
    background: rgba(126,184,247,0.08);
    border: 1px solid rgba(126,184,247,0.2);
    border-radius: 20px;
    padding: 2px 9px;
    opacity: 0.8;
  }
  .reading-text-chevron {
    color: var(--muted);
    font-size: 2.46rem;
    transition: transform 0.25s ease;
    line-height: 1;
  }
  .reading-text-toggle[aria-expanded="true"] .reading-text-chevron,
  #reading-text-chevron.open {
    transform: rotate(180deg);
  }
  .reading-text-body {
    background: var(--surface);
    border: 1px solid var(--accent);
    border-top: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    padding: 16px;
  }

  /* ── APP MODE TOGGLE ── */
  .app-mode-toggle {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 4px;
    gap: 2px;
    align-self: flex-start;
  }

  .app-mode-btn {
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: none;
    background: transparent;
    color: var(--muted);
    padding: 5px 10px;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
  }

  .app-mode-btn.active {
    background: var(--accent);
    color: #0a0c10;
    font-weight: 600;
  }

  .app-mode-btn:not(.active):hover {
    color: var(--text);
  }

  /* ── EMDR DOT TRACK (session screen, EMDR mode) ── */
  .emdr-dot-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 40px;
  }

  .emdr-track-wrap {
    width: min(70vw, 1200px);
  }

  .emdr-track {
    width: 100%;
    height: 80px;
    background: #1a1a24;
    border-radius: 40px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
  }

  .emdr-track::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1px;
    height: 30px;
    background: rgba(255,255,255,0.06);
  }

  .emdr-dot-ball {
    position: absolute;
    top: 50%;
    left: 0;
    border-radius: 50%;
    transform: translate(0, -50%) translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--emdr-dot-color, #7eb8f7);
    box-shadow: 0 0 18px var(--emdr-dot-glow, rgba(126,184,247,0.5)), 0 0 36px var(--emdr-dot-glow, rgba(126,184,247,0.3));
  }

  .emdr-dot-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: min(70vw, 1200px);
  }

  .emdr-dot-sliders {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 40px;
    width: 100%;
  }

  .emdr-dot-slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .emdr-dot-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .emdr-dot-slider-label span:last-child {
    color: var(--text);
  }

  .emdr-dot-slider-group input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    border: none;
    padding: 0;
    accent-color: var(--accent);
  }

  .emdr-dot-slider-group input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--emdr-dot-color, #7eb8f7);
    cursor: pointer;
    box-shadow: 0 0 8px var(--emdr-dot-glow, rgba(126,184,247,0.5));
  }

  .emdr-dot-slider-group input[type=range]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--emdr-dot-color, #7eb8f7);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px var(--emdr-dot-glow, rgba(126,184,247,0.5));
  }

  .emdr-color-row {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .emdr-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
  }

  .emdr-color-dot:hover { transform: scale(1.2); }
  .emdr-color-dot.selected { border-color: rgba(255,255,255,0.4); transform: scale(1.15); }

  .app-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    color: var(--muted);
    opacity: 0.35;
    pointer-events: none;
    padding: 32px 0 24px;
    width: 100%;
    align-self: center;
  }
  .app-footer a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    pointer-events: all;
  }

  /* ═══════════════════════════════════════════════════════
     FLASH TECHNIQUE — page-specific styles
     ═══════════════════════════════════════════════════════ */

.screen { display: none; min-height: 100vh; }

/* ── SCREEN 0: DISCLAIMER (first visit) — centred like setup ── */
  #screen-disclaimer {
    align-items: center;
    justify-content: center;
    padding: 47px 20px;
    background: radial-gradient(ellipse at 30% 20%, #162035 0%, var(--bg) 60%);
  }

/* ── SCREEN 1: SETUP ── */
  #screen-setup {
    align-items: center;
    justify-content: center;
    padding: 47px 20px;
    background: radial-gradient(ellipse at 30% 20%, #162035 0%, var(--bg) 60%);
  }

.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary.btn-inactive { opacity: 0.4; }

/* ── SCREEN 2: VIDEO SETUP ── */
  #screen-video {
    align-items: center;
    justify-content: flex-start;
    padding: 32px 20px 40px;
    background: radial-gradient(ellipse at 70% 80%, #162035 0%, var(--bg) 60%);
    overflow-y: auto;
  }

.video-inner {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
  }

.step-chip {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(126,184,247,0.1);
    border: 1px solid rgba(126,184,247,0.25);
    border-radius: 20px;
    padding: 4px 12px;
    display: inline-block;
    margin-bottom: 16px;
  }

.screen-title {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    margin-bottom: 8px;
    line-height: 1.3;
  }

.screen-sub {
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.7;
    margin-bottom: 28px;
  }

.instruction-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 28px;
    font-size: 0.82rem;
    line-height: 1.8;
    color: var(--muted);
  }

.instruction-box strong { color: var(--text); }

.suggestion-label {
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
  }

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
  }

.suggestion-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
    font-family: 'DM Mono', monospace;
    font-size: 0.78rem;
    color: var(--text);
  }

.suggestion-chip:hover { border-color: var(--accent); background: rgba(126,184,247,0.05); }

.suggestion-chip.active { border-color: var(--accent2); background: rgba(125,212,176,0.08); color: var(--accent2); }

.suggestion-chip .chip-icon { font-size: 1.3rem; display: block; margin-bottom: 5px; }

/* ── YOUTUBE SEARCH RESULTS ── */
  .search-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
  }

.search-result-card:hover { border-color: var(--accent); background: rgba(126,184,247,0.05); }

.search-result-card img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }

.search-result-card .srch-title {
    font-size: 0.72rem;
    padding: 8px 10px;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

.search-loading { font-size: 0.78rem; color: var(--muted); margin-bottom: 12px; }

.custom-search-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
  }

.custom-search-row input { flex: 1; }

.custom-search-row button {
    padding: 0 20px;
    white-space: nowrap;
  }

.yt-frame-wrap {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    position: relative;
  }

.yt-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
  }

.yt-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    padding: 20px;
  }

.yt-placeholder-icon { font-size: 2.5rem; opacity: 0.4; }

/* ── SCREEN 3: SESSION ── */
  #screen-session {
    position: relative;
    background: var(--bg);
    overflow: hidden;
    height: 100vh;
    max-height: 100vh;
  }

.session-target-summary {
    font-size: 0.72rem;
    color: var(--muted);
    max-width: 60%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

.session-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: calc(100vh - 65px);
    overflow: hidden;
  }

.session-video-area {
    flex: 1;
    position: relative;
    background: #000;
    min-height: 0;
    overflow: hidden;
  }

.session-video-area iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
  }

.session-footer {
    padding: 14px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
  }

.round-info {
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--muted);
  }

.flash-counter {
    display: flex;
    gap: 6px;
    align-items: center;
  }

.flash-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.2s;
  }

.flash-pip.done { background: var(--accent); }

.flash-pip.active { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

.session-footer-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
  }

.next-flash-timer {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    min-width: 80px;
    text-align: right;
  }

/* ── FLASH OVERLAY ── */
  #flash-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #7eb8f7, #7dd4b0);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

#flash-overlay.flash-on {
    opacity: 1;
    pointer-events: all;
  }

.flash-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2.6rem, 10vw, 6.5rem);
    color: #0a0c10;
    letter-spacing: -0.02em;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

#flash-overlay.flash-on .flash-text { opacity: 1; }

/* ── SUDS CHECK OVERLAY ── */
  #suds-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,12,16,0.95);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
  }

#suds-overlay.show {
    opacity: 1;
    pointer-events: all;
  }

.suds-card-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 12px;
  }

.suds-card-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.8rem;
    margin-bottom: 8px;
  }

.suds-card-memory {
    font-size: 0.78rem;
    color: var(--accent);
    background: rgba(126,184,247,0.08);
    border: 1px solid rgba(126,184,247,0.2);
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 20px;
    font-style: italic;
  }

.suds-card-sub {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.6;
  }

.suds-card .suds-scale { justify-content: center; }

.suds-trend {
    margin-top: 16px;
    font-size: 0.78rem;
    color: var(--muted);
    min-height: 1.2em;
  }

.trend-down { color: var(--accent2); }

.trend-up { color: var(--danger); }

.trend-same { color: var(--muted); }

.suds-card-actions {
    margin-top: 24px;
    display: flex;
    gap: 10px;
    justify-content: center;
  }

/* ── SCREEN 4: SUMMARY ── */
  #screen-summary {
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px;
    overflow-y: auto;
    background: var(--bg);
  }

.summary-inner {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
  }

.summary-title {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    margin-bottom: 6px;
  }

.summary-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin-bottom: 36px;
  }

.summary-stat-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 32px;
  }

.summary-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    text-align: center;
  }

.stat-value {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    color: var(--accent);
    display: block;
    margin-bottom: 4px;
  }

.stat-label {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

.chart-x-labels {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
  }

.chart-x-label {
    flex: 1;
    font-size: 0.68rem;
    color: var(--muted);
    text-align: center;
  }

.log-round { font-size: 0.72rem; color: var(--muted); }

.log-suds-val { font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: var(--accent); }

.hidden { display: none !important; }

@media (max-width: 500px) {
    .summary-stat-row { grid-template-columns: 1fr 1fr; }
    .suds-btn { width: 34px; height: 34px; font-size: 0.75rem; }
  }
