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

:root {
    --bg: #0a0a0a;
    --surface: #141414;
    --border: #272727;
    --border-bright: #3a3a3a;
    --text: #e8e8e8;
    --muted: #666;
    --dimmed: #3d3d3d;
    --accent: #e8e8e8;
    --red: #e05252;
    --blue: #5b8dee;
    --green: #5ec97a;
    --yellow: #d4aa3f;
    --sorange: #d97b3a;
    --purple: #9b7fe8;
    --pink: #d965a0;
    --font-mono: 'IBM Plex Mono', monospace;
    --font-sans: 'IBM Plex Sans', sans-serif;
    --radius: 6px;
    --transition: 0.22s ease;
    --grid-line: rgba(0, 0, 0, 0.05);
}

html,
body {
    width: 100%;
    height: 100%;
    max-height:100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-weight: 300;
    overflow: hidden;
    /* align-content: center; */

}

/* ── Layout ── */
#app {
    display: flex;
    flex-direction: column;
    align-content: center;
    align-items: center;
    width: 98%;
    height: 95%;
    padding: 0rem 1rem;
    margin: auto;
}

.page {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    max-width: 95vw;
    width: 650px;
    max-width:calc(95vw - 2rem);
    animation: fadein 0.4s ease;
    margin: auto;
}

.page.active {
    display: flex;
}

#pg-task {
    justify-content: space-around;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.task-title {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-arrows {
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: border-color var(--transition), background var(--transition);
    font-family: var(--font-mono);
}

.nav-btn:hover {
    border-color: var(--border-bright);
    background: var(--surface);
}

.nav-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.nav-btn.hidden {
    visibility: hidden;
}

/* ── Typography ── */
.section-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.2rem;
}

h2 {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 1rem;
    line-height: 1.3;
    color: var(--text);
}

p {
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 300;
    line-height: 1.75;
    color: #bbb;
    margin-bottom: 0.85rem;
}

ul {
    list-style: none;
    margin-bottom: 1rem;
}

ul li {
    font-family: var(--font-sans);
    font-size: 16px;
    color: #bbb;
    padding: 5px 0 5px 18px;
    position: relative;
    line-height: 1.6;
}

ul li::before {
    content: '—';
    position: absolute;
    left: 0;
    color: var(--dimmed);
}

.warn {
    border: 1px solid #5a3030;
    background: #1a0d0d;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 15px;
    color: #e08080;
    margin-top: 1rem;
}

.caution {
    border: 1px solid #5a3030;
    background: #1a0d0d;
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--yellow);
    margin-top: 1rem;
}

/* ── Buttons ── */
.btn,
select {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0.05em;
    padding: 5px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-bright);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    margin:auto;
margin-top:1.5rem;
}

.btn:hover {
    background: var(--surface);

    border-color: #555;
}

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

.btn-primary,
select {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.btn-primary:hover {
    background: #ccc;
    border-color: #ccc;
}

/* ── Mic status bar ── */
.mic-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    width: 100%;
    margin-bottom: 1.5rem;
}

.mic-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dimmed);
    flex-shrink: 0;
    transition: background 0.3s;
}

.mic-dot.listening {
    background: var(--red);
    animation: pulse 1s infinite;
}

.mic-dot.ready {
    background: var(--green);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.3
    }
}

.mic-label {
    font-size: 13px;
    color: var(--muted);
    font-family: var(--font-mono);
}

.mic-heard {
    margin-left: auto;
    font-size: 13px;
    color: var(--dimmed);
    font-family: var(--font-mono);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Stimulus display ── */
#stim-area {
    width: 100%;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 1.2rem;
    position: relative;
    overflow: hidden;
}


/* ── Progress ── */
.progress-wrap {
    width: 100%;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    margin-bottom: 1.2rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--text);
    border-radius: 2px;
    transition: width 0.35s ease;
}

/* ── Stats row ── */
.stats-row {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 1.2rem;
}



.stat {
    flex: 1;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}

.stat-lbl {
    display: block;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.stat-val {
    display: block;
    font-size: 22px;
    font-weight: 500;
    color: var(--text);
}

/* ── Feedback ── */
#feedback-line {
    font-size: 14px;
    color: var(--muted);
    min-height: 18px;
    text-align: center;
    width: 100%;
    transition: color 0.2s;
    font-family: var(--font-mono);
}

#feedback-line.ok {
    color: var(--green);
}

#feedback-line.bad {
    color: var(--red);
}

/* ── Results ── */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin: 1.2rem 0;
}

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

.result-card .rc-lbl {
    display: block;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
}

.result-card .rc-val {
    display: block;
    font-size: 30px;
    font-weight: 500;
}

.trial-log {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 0.5rem;
}

.trial-log-header {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 1.2fr 1.5fr;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 7px 12px;
    gap: 8px;
}

.trial-log-header span {
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
}

.trial-log-body {
    max-height: 180px;
    overflow-y: auto;
}

.trial-row {
    display: grid;
    grid-template-columns: 2fr 2fr 2fr 1.2fr 1.5fr;
    padding: 6px 12px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    align-items: center;
}

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

.trial-row span {
    font-family: var(--font-mono);
    color: #aaa;
}

.badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.1em;
    padding: 2px 7px;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge.ok {
    background: #0e2a15;
    color: var(--green);
}

.badge.bad {
    background: #2a0e0e;
    color: var(--red);
}

.badge.type-con {
    background: #1a1a2e;
    color: #7b94d4;
}

.badge.type-inc {
    background: #2a1a10;
    color: #c4895a;
}

.color-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}

/* ── Step instruction ── */
.step-num {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.step-demo {
    font-family: var(--font-mono);
    font-size: 48px;
    font-weight: 600;
    margin: 1.2rem 0;
}

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

#exert {
    max-height: 30vh;
    overflow: hidden;
}

/* scrollbar */
.trial-log-body::-webkit-scrollbar {
    width: 4px;
}

.trial-log-body::-webkit-scrollbar-track {
    background: var(--surface);
}

.trial-log-body::-webkit-scrollbar-thumb {
    background: var(--border-bright);
    border-radius: 4px;
}

canvas {
    image-rendering: pixelated;
    border: solid var(--accent) 2px;
    width: 250px;
    height: 150px;
    max-width: 95vw;
    margin: auto;
}




strong.plot-label {
    margin: auto;
    margin-block-start: 2rem;
    text-align: center;
}

.canvas-cont {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    margin: auto;
}

input[type="checkbox"] {
    width: 25px;
    height: 25px;
    accent-color: var(--green);
    margin: auto;
    margin-right: 0;
}

;

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232735;
    --border: #2d3142;
    --text: #e4e6eb;
    --text-dim: #8b92a5;
    --label: #6b7280;
    --correct: #10b981;
    --correct-bg: rgba(16, 185, 129, 0.12);
    --incorrect: #ef4444;
    --incorrect-bg: rgba(239, 68, 68, 0.12);
    --accent: #3b82f6;
    --pitch-low: #60a5fa;
    --pitch-high: #f472b6;
}

.trial-log {
    background: var(--bg);
    border-radius: 12px;
    padding: 24px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    border: 1px solid var(--border);
}

.trial-log-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
}

/* Custom scrollbar */
.trial-log-header::-webkit-scrollbar {
    height: 8px;
}

.trial-log-header::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 4px;
}

.trial-log-header::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.trial-log-header::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Each row — replaces justify-content: space-between with a flex layout
where items have a consistent min-width, so columns align across rows */
.trial-log-header>div {
    display: flex !important;
    gap: 6px !important;
    justify-content: flex-start !important;
    align-items: center;
    min-width: max-content;
}

/* Row label (the "Word", "You said", etc. column on the left) */
.trial-log-header>div>div:first-child {
    width: 100px !important;
    min-width: 100px;
    flex-shrink: 0;
    position: sticky;
    left: 0;
    background: var(--bg);
    z-index: 2;
    padding: 8px 12px 8px 0;
    border-right: 1px solid var(--border);
}

.trial-log-header>div>div:first-child span {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--label);
}

/* Default cell styling */
.trial-log-header .c {
    min-width: 150px;
    padding: 8px 10px;
    text-align: center;
    font-size: 13px;
    background: var(--surface);
    border-radius: 6px;
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease;
}

/* Target (Word) row — neutral, slightly emphasized */
#results-log-target .c {
    font-weight: 600;
    color: var(--text);
    background: var(--surface-2);
}

/* Response (You said) row — empty cells faded */
#results-log-response .c {
    color: var(--text);
    font-weight: 500;
}

#results-log-response .c:empty,
#results-log-response .c:not(:first-child):where([class]) {
    /* handled via :empty below */
}

#results-log-response .c:empty {
    background: transparent;
    border-style: dashed;
    border-color: var(--border);
    min-height: 36px;
}

#results-log-response .c:empty::before {
    content: '—';
    color: var(--text-dim);
    opacity: 0.4;
}

/* Correct row — color-coded true/false pills */
#results-log-correct .c {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 10px;
}

/* Style by text content using attribute trick won't work,
so use :has() or JS — here's a CSS-only approach via content match */
#results-log-correct .c {
    color: var(--text-dim);
}

/* Inline JS would tag these, but we can use :has + attr selectors.
Simplest: style based on textContent via a small post-render step
OR use the pattern below where we match by inner text via :has */

/* Pitch row — visualized as compact data chips */
#results-log-hz .c {
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    font-size: 11px;
    color: var(--pitch-low);
    background: rgba(96, 165, 250, 0.08);
    border-color: rgba(96, 165, 250, 0.2);
    min-width: 150px;
    padding: 6px 8px;
}

/* Hover state for inspection */
.trial-log-header .c:hover {
    transform: translateY(-1px);
    background: var(--surface-2);
}

/* Optional: a summary bar at the top */
.trial-log-body {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .trial-log {
        padding: 16px;
        border-radius: 8px;
    }

    .stats-row{
	flex-direction:column;
	height:45%;
    }

    .page{
	max-height:100%;
    }
    .canvas-cont{
	max-height:50%;
    }
    .canvas-cont>canvas{
	height:70%;
	width:100%;
    }
strong.plot-label{
    margin:0.5rem;
}
    .page > *{flex:1;}
    .trial-log-header .c {
        min-width: 60px;
        font-size: 12px;
        padding: 6px 8px;
    }
}
