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

body {
    background: #1a1a2e;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    padding: 12px 20px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    gap: 16px;
}

header h1 {
    font-size: 18px;
    color: #F472B6;
    font-weight: 600;
}

header .question {
    font-size: 15px;
    color: #e0e0e0;
    font-weight: 600;
    border-left: 2px solid #F472B6;
    padding-left: 10px;
}

header .instructions {
    font-size: 13px;
    color: #999;
}

.category-what-header {
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.4;
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-what-header .what-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    font-weight: 600;
    margin-right: 4px;
}

/* How-to-use / how-it-works horizontal strip below the header */
.category-how-works {
    display: flex;
    gap: 1px;
    background: #0f3460;
    border-bottom: 1px solid #0f3460;
    max-height: 22vh;
}

.category-how-works .chw-pane {
    flex: 1 1 50%;
    min-width: 0;
    background: #16213e;
    padding: 10px 16px 12px;
    overflow-y: auto;
}

.category-how-works .chw-pane h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 4px;
    font-weight: 600;
}

header kbd {
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 12px;
    font-family: inherit;
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 0;
}

.canvas-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

/* Instructions pane */
.instructions-toggle {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
}

.instructions-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #16213e;
    color: #F472B6;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.instructions-btn:hover,
.instructions-btn.active {
    background: #F472B6;
    color: #1a1a2e;
}

.instructions-pane {
    display: none;
    position: absolute;
    top: 36px;
    left: 0;
    width: 360px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 16px 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.instructions-pane.visible {
    display: block;
}

.instructions-pane h3 {
    font-size: 14px;
    color: #F472B6;
    margin-bottom: 10px;
}

.instructions-pane ol {
    list-style: decimal;
    padding-left: 18px;
    font-size: 12px;
    line-height: 1.6;
    color: #ccc;
}

.instructions-pane ol li {
    margin-bottom: 6px;
}

.instructions-pane h3 + ol + h3 {
    margin-top: 12px;
}

.instructions-tip {
    font-size: 12px;
    line-height: 1.5;
    color: #a5b4c8;
    margin-top: 4px;
}

.instructions-pane kbd {
    background: #333;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: inherit;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.zoom-slider {
    width: 120px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.zoom-track {
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    position: relative;
}

.zoom-thumb {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: #F472B6;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    transition: background 0.15s;
}

.zoom-thumb:hover {
    background: #f9a8d4;
}

.zoom-thumb:active {
    cursor: grabbing;
}

.zoom-label {
    font-size: 12px;
    color: #999;
    min-width: 42px;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.zoom-label:hover {
    color: #F472B6;
}

#canvas-wrapper {
    position: relative;
    overflow: auto;
    max-width: 100%;
    max-height: calc(100vh - 170px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

#annotation-canvas {
    display: block;
    cursor: crosshair;
    border: 1px solid #0f3460;
    border-radius: 4px;
}

/* Side panel */
.side-panel {
    width: 475px;
    background: #16213e;
    border-left: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.side-panel h2 {
    font-size: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid #0f3460;
    color: #F472B6;
}

.category-context {
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
    max-height: 40vh;
    overflow-y: auto;
}

.category-context h2 {
    font-size: 13px;
    padding: 10px 16px 6px;
    border-bottom: none;
    color: #c4b5fd;
}

.category-context-block {
    padding: 0 16px 10px;
}

.category-context-block h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 4px;
    font-weight: 600;
}

.category-context-text {
    font-size: 13px;
    line-height: 1.5;
    color: #cbd5e1;
}

.annotation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.annotation-item {
    padding: 8px 10px;
    background: #1a1a2e;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 12px;
    border: 1px solid transparent;
    transition: border-color 0.15s;
}

.annotation-item.active {
    border-color: #F472B6;
}

.annotation-item .item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.annotation-item .info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.annotation-item .number {
    color: #F472B6;
    font-weight: 700;
    font-size: 14px;
    min-width: 20px;
}

.annotation-item .coords {
    color: #777;
    font-size: 11px;
}

.annotation-item .item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.annotation-item .item-mic {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}

.annotation-item .item-mic:hover { color: #7ec8e3; }
.annotation-item .item-mic.recording { color: #e74c3c; animation: pulse 1s infinite; }

.annotation-item .delete-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: 4px;
}

.annotation-item .delete-btn:hover {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.annotation-item .explanation-input {
    width: 100%;
    background: #111;
    color: #ddd;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    font-family: inherit;
    resize: vertical;
    min-height: 32px;
    max-height: 80px;
    line-height: 1.4;
}

.annotation-item .explanation-input:focus {
    border-color: #7ec8e3;
    outline: none;
}

.annotation-item .explanation-input::placeholder {
    color: #555;
}

.annotation-item .explanation-input.missing {
    border-color: #e74c3c;
}

.side-hint {
    font-size: 11px;
    color: #666;
    padding: 0 8px 4px;
}

.group-toolbar {
    padding: 0 0 4px;
    min-height: 4px;
}

.group-toolbar .btn {
    font-size: 11px;
    padding: 3px 10px;
}

.group-check {
    margin-right: 4px;
    cursor: pointer;
    accent-color: #F472B6;
}

.coords-wrap {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.annotation-item .split-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
}

.annotation-item .split-btn:hover {
    color: #f1c40f;
}

/* Transcript section */
.transcript-section {
    border-top: 1px solid #0f3460;
    flex: 2.7;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.transcript {
    padding: 10px 16px;
    font-size: 16px;
    color: #e0e0e0;
    line-height: 1.55;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    outline: none;
    cursor: text;
    border: 1px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s;
}

.transcript:focus {
    border-color: #F472B6;
}

.transcript:empty::before {
    content: "Click to edit transcript.";
    color: #666;
}

.transcript-interim {
    padding: 0 16px 6px;
    font-size: 12px;
    color: #666;
    font-style: italic;
    display: none;
}

/* Bottom bar */
.bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: #16213e;
    border-top: 1px solid #0f3460;
}

.status-text {
    font-size: 13px;
    color: #999;
}

.status-text .highlight {
    color: #F472B6;
}

.bottom-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Mic button */
.mic-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #444;
    background: #1a1a2e;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.mic-btn:hover {
    border-color: #F472B6;
    color: #F472B6;
}

.mic-btn.recording {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    animation: pulse-ring 1.2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.3); }
    70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-secondary {
    background: #333;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background: #444;
}

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

.btn-primary {
    background: #F472B6;
    color: #1a1a2e;
    font-weight: 600;
}

.btn-primary:hover {
    background: #f9a8d4;
}

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

/* Error overlay */
/* Video instruction overlay (Prolific first load) */
.video-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-box {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 28px 32px;
    max-width: 820px;
    width: 90vw;
    text-align: center;
}

.video-box h2 {
    color: #e0e0e0;
    margin-bottom: 18px;
    font-size: 20px;
}

.video-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 20px;
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-start-btn {
    font-size: 16px;
    padding: 12px 32px;
}

.error-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.error-overlay.visible {
    display: flex;
}

.error-box {
    background: #16213e;
    border: 1px solid #e74c3c;
    border-radius: 10px;
    padding: 32px;
    max-width: 400px;
    text-align: center;
}

.error-box h2 {
    color: #e74c3c;
    margin-bottom: 12px;
}

.error-box p {
    color: #999;
    font-size: 14px;
}

/* Gallery overlay */
.gallery-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px;
}

.gallery-overlay.visible {
    display: flex;
}

.gallery-box {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    padding: 24px;
    max-width: 900px;
    width: 100%;
}

.gallery-box h2 {
    color: #F472B6;
    margin-bottom: 16px;
    font-size: 18px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.gallery-item {
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
    position: relative;
}

.gallery-item:hover {
    border-color: #F472B6;
    transform: scale(1.02);
}

.gallery-item img {
    width: 100%;
    display: block;
    aspect-ratio: 4/3;
    object-fit: cover;
    background: #111;
}

.gallery-item .gallery-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #e0e0e0;
    font-size: 12px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* Gallery tabs */
.gallery-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.gallery-tab {
    padding: 6px 16px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}

.gallery-tab.active {
    background: #F472B6;
    color: #1a1a2e;
    border-color: #F472B6;
    font-weight: 600;
}

.gallery-tab:hover:not(.active) {
    border-color: #F472B6;
    color: #e0e0e0;
}

/* Dataset browser */
.dataset-controls {
    margin-bottom: 12px;
}

.class-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #1a1a2e;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
}

.class-search:focus {
    border-color: #F472B6;
}

.class-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
    padding: 2px;
}

.class-item {
    padding: 8px 12px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #1a1a2e;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s;
}

.class-item:hover {
    border-color: #F472B6;
    color: #F472B6;
}

.class-item .class-count {
    color: #666;
    font-size: 11px;
}

.dataset-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 13px;
    color: #999;
}

.dataset-back-btn {
    margin-bottom: 12px;
    padding: 6px 14px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 13px;
}

.dataset-back-btn:hover {
    border-color: #F472B6;
    color: #e0e0e0;
}

/* In-house testing */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(244, 114, 182, 0.15);
    border: 1px solid #F472B6;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    color: #F472B6;
}

.inhouse-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.inhouse-progress {
    font-size: 12px;
    color: #999;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.inhouse-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1001;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px;
}

.inhouse-overlay.visible {
    display: flex;
}

.inhouse-box {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 10px;
    padding: 28px;
    max-width: 800px;
    width: 100%;
}

.inhouse-box h2 {
    color: #F472B6;
    margin-bottom: 20px;
    font-size: 20px;
}

.inhouse-tester {
    margin-bottom: 20px;
}

.inhouse-tester label,
.inhouse-category-section label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 6px;
}

.inhouse-tester input {
    max-width: 300px;
}

.inhouse-category-section {
    margin-top: 16px;
}

.inhouse-category-section .class-search {
    margin-bottom: 12px;
}

.inhouse-category-section .class-list {
    max-height: 350px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
}

.toast-success {
    background: #10b981;
    color: #fff;
}

.toast-info {
    background: #3b82f6;
    color: #fff;
}

.toast-error {
    background: #ef4444;
    color: #fff;
    text-align: left;
    max-width: 400px;
}

.chain-badge {
    background: #f59e0b;
    color: #000;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    animation: chain-pulse 1.2s ease-in-out infinite;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chain-badge.chain-badge-off {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #334155;
    animation: none;
}

.chain-badge .chain-key {
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 3px;
    padding: 0 5px;
    font-size: 11px;
    font-family: inherit;
    color: #cbd5e1;
}

.chain-badge.chain-badge-off .chain-key {
    background: #16213e;
}

@keyframes chain-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
