:root {
    color-scheme: dark;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    --ink: #f7f8f8;
    --muted: #aeb8bd;
    --black: #080b0c;
    --charcoal: #13191b;
    --panel: #1a2225;
    --line: #334044;
    --yellow: #ffc94d;
    --orange: #f59e0b;
    --green: #22c982;
    --red: #ef5b5b;
    --blue: #55a7d9;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.tp-screen { background: var(--black); color: var(--ink); }
.eyebrow, .section-label, .footer-label, .cue-kicker {
    margin: 0 0 6px;
    color: var(--yellow);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}
.status-waiting { background: #242d30; color: var(--muted); }
.status-live { background: #14382b; border-color: #226f50; color: #8ff0c3; }
.status-error { background: #462326; border-color: #883e43; color: #ffb1b6; }

/* TV */
.tp-tv { overflow: hidden; }
.tv-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100vw;
    height: 100dvh;
    padding: 22px 28px 26px;
    background: var(--black);
}
.tv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--yellow);
}
.tv-header h1 { margin: 0; font-size: 32px; line-height: 1; }
.tv-header-status { display: flex; align-items: center; gap: 18px; }
#studioClock { min-width: 126px; font-size: 26px; font-weight: 800; text-align: right; }
.tv-stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-height: 0; padding-top: 18px; }
.tv-stage-idle { place-content: center; text-align: center; }
.tv-stage-idle h2 { margin: 0; font-size: 64px; line-height: 1.1; }
.tv-stage-idle > p:last-child { color: var(--muted); font-size: 24px; }
.tv-meta-row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 24px; }
.cue-type {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 4px;
    background: var(--yellow);
    color: #16120a;
    font-size: 12px;
    font-weight: 950;
    text-transform: uppercase;
}
.topic-label { margin-left: 14px; color: var(--blue); font-size: 17px; font-weight: 800; }
.cue-countdown { color: var(--green); font-size: 22px; font-weight: 900; }
.cue-viewport {
    display: flex;
    align-items: center;
    min-height: 0;
    overflow: hidden;
    padding: 20px 0;
}
.cue-text {
    width: 100%;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--ink);
    font-size: 72px;
    font-weight: 850;
    line-height: 1.08;
}
.prop-instruction {
    margin-bottom: 14px;
    padding: 10px 14px;
    border-left: 5px solid var(--yellow);
    background: #25230f;
    color: var(--yellow);
    font-size: 22px;
    font-weight: 800;
}
.tv-footer {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.tv-footer > div { min-width: 0; }
.tv-footer strong { display: block; overflow: hidden; color: var(--ink); font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.next-cue { padding-right: 6px; text-align: right; }

/* Unlock */
.tp-control { background: #e9edef; color: #172025; }
.unlock-shell { display: grid; min-height: 100dvh; place-items: center; padding: 24px; }
.unlock-panel {
    width: min(480px, 100%);
    padding: 32px;
    border: 1px solid #c9d0d3;
    border-top: 6px solid var(--orange);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 18px 60px rgba(17, 29, 35, .12);
}
.unlock-panel h1 { margin: 0 0 10px; font-size: 30px; }
.unlock-panel p { color: #526168; }
.unlock-panel label { display: block; margin-top: 24px; font-size: 13px; font-weight: 800; }
.unlock-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 8px; }
.form-error { padding: 10px 12px; border-left: 4px solid var(--red); background: #fff0f0; color: #9b2f35 !important; }

/* Control */
.control-shell { width: min(1680px, 100%); margin: 0 auto; padding: 18px; }
.control-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.control-header h1 { margin: 0; font-size: 28px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }
.icon-button {
    width: 40px;
    height: 40px;
    border: 1px solid #c8d0d4;
    border-radius: 5px;
    background: #fff;
    color: #253036;
    font-size: 22px;
}
.feedback { min-height: 24px; margin: 0 0 8px; font-size: 13px; font-weight: 700; }
.feedback-ok { color: #14744c; }
.feedback-error { color: #b2343b; }
.run-strip {
    display: grid;
    grid-template-columns: 1.1fr 1.5fr .8fr auto;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding: 14px 16px;
    border: 1px solid #c8d0d4;
    border-left: 6px solid var(--orange);
    border-radius: 5px;
    background: #fff;
}
.run-strip strong { display: block; overflow: hidden; color: #182126; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.control-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.panel {
    min-width: 0;
    padding: 16px;
    border: 1px solid #cbd2d5;
    border-radius: 6px;
    background: #fff;
}
.panel-span-2 { grid-column: span 2; }
.panel-span-4 { grid-column: span 4; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.count-badge { display: inline-grid; min-width: 28px; height: 28px; padding: 0 8px; place-items: center; border-radius: 999px; background: #263237; color: #fff; font-weight: 900; }
.button {
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-weight: 850;
}
.button-primary { background: var(--orange); color: #181006; }
.button-primary:hover { background: #d98505; }
.button-quiet { border-color: #c8d0d4; background: #f5f7f8; color: #263238; }
.button-danger { background: var(--red); color: #fff; }
.button-danger-soft { border-color: #e7b4b6; background: #fff2f2; color: #a63035; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
label, legend { color: #3f4b51; font-size: 12px; font-weight: 800; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
input, select, textarea {
    width: 100%;
    min-height: 40px;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid #bfc8cc;
    border-radius: 4px;
    background: #fff;
    color: #172025;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(245, 158, 11, .24); border-color: var(--orange); }
.start-form { display: grid; grid-template-columns: 1.2fr .8fr .8fr 1fr; gap: 12px; align-items: end; }
.start-form .participants-fieldset { grid-column: span 3; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 6px; }
.segmented-control label { position: relative; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: grid; height: 40px; place-items: center; border: 1px solid #c4ccd0; border-radius: 4px; background: #f3f5f6; }
.segmented-control input:checked + span { border-color: var(--orange); background: #fff1d6; color: #7b4900; }
.participant-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.participant-options label { position: relative; }
.participant-options input { position: absolute; opacity: 0; pointer-events: none; }
.participant-options span { display: inline-flex; min-height: 34px; align-items: center; padding: 0 10px; border: 1px solid #c7cfd2; border-radius: 4px; background: #f6f7f8; }
.participant-options input:checked + span { border-color: #28855f; background: #e3f6ed; color: #176142; }
.operator-cue { min-height: 130px; margin-bottom: 12px; padding: 14px; border-left: 5px solid var(--yellow); background: #171d1f; color: #fff; }
.operator-cue > p:first-child { margin: 0; font-size: 25px; font-weight: 750; line-height: 1.25; }
.operator-instruction { margin: 12px 0 0; color: var(--yellow); font-size: 14px; font-weight: 800; }
.queue-list { max-height: 440px; overflow-y: auto; }
.queue-item { display: grid; grid-template-columns: 55px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 11px 0; border-bottom: 1px solid #e1e5e7; }
.queue-item time { color: #68767c; font-size: 12px; font-weight: 850; }
.queue-item strong { font-size: 12px; }
.queue-item p { margin: 4px 0 0; color: #48565d; font-size: 13px; line-height: 1.35; }
.queue-item .button { min-height: 32px; padding: 0 9px; font-size: 12px; }
.stack-form { display: grid; gap: 12px; }
.compact-form { grid-template-columns: 1fr 1fr; }
.compact-form label:nth-of-type(n+4), .compact-form .button { grid-column: span 2; }
.review-list { max-height: 520px; overflow-y: auto; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.review-item { display: grid; gap: 9px; padding: 12px 0; border-bottom: 1px solid #e1e5e7; }
.review-item strong { font-size: 14px; }
.review-item p { margin: 0; color: #45535a; font-size: 13px; line-height: 1.4; }
.review-item small { color: #8a6200; font-weight: 700; }
.review-content { padding: 12px; border: 1px solid #dce1e3; border-radius: 5px; }
.content-admin-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.content-field-wide { grid-column: span 2; }
.toggle-field {
    display: flex;
    min-height: 40px;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border: 1px solid #c8d0d4;
    border-radius: 4px;
    background: #f6f7f8;
}
.toggle-field input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--orange); }
.content-library-toolbar { display: grid; grid-template-columns: 170px 170px minmax(240px, 1fr); gap: 10px; margin-bottom: 14px; }
.content-library-list { display: grid; gap: 8px; max-height: 700px; overflow-y: auto; }
.content-library-item {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: start;
    padding: 12px;
    border: 1px solid #dce1e3;
    border-radius: 5px;
    background: #fff;
}
.content-library-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: #718087; font-size: 11px; font-weight: 850; }
.content-library-copy { min-width: 0; }
.content-library-copy strong { display: block; margin-bottom: 6px; color: #172025; font-size: 14px; }
.content-library-copy p { margin: 0; color: #45535a; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.content-library-copy small { display: block; margin-top: 8px; color: #8a6200; font-size: 11px; font-weight: 800; }
.content-library-actions { justify-content: flex-end; }
.content-status { display: inline-flex; min-height: 24px; align-items: center; padding: 0 7px; border-radius: 3px; }
.content-status-approved { background: #dff5ea; color: #176142; }
.content-status-pending_review { background: #fff0c9; color: #7b4900; }
.content-status-rejected { background: #f7e3e4; color: #9b2f35; }
.empty-state { color: #7b888e; font-size: 13px; }
.muted { color: #7b888e; }

@media (max-width: 1100px) {
    .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .panel-span-2 { grid-column: span 2; }
    .panel-span-4 { grid-column: span 2; }
    .start-form { grid-template-columns: 1fr 1fr; }
    .content-admin-form { grid-template-columns: 1fr 1fr; }
    .start-form .participants-fieldset { grid-column: span 2; }
    .run-strip { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    .control-shell { padding: 10px; }
    .control-header { align-items: flex-start; }
    .header-actions { flex-wrap: wrap; justify-content: flex-end; }
    .run-strip, .control-grid, .start-form, .review-grid, .content-admin-form, .content-library-toolbar { grid-template-columns: 1fr; }
    .panel-span-2, .panel-span-4, .start-form .participants-fieldset { grid-column: span 1; }
    .content-field-wide { grid-column: span 1; }
    .content-library-item { grid-template-columns: 1fr; }
    .content-library-actions { justify-content: flex-start; }
    .run-strip { align-items: stretch; }
    .run-strip .button { width: 100%; }
    .compact-form { grid-template-columns: 1fr; }
    .compact-form label:nth-of-type(n+4), .compact-form .button { grid-column: span 1; }
    .unlock-row { grid-template-columns: 1fr; }
    .tv-shell { padding: 14px; }
    .tv-header h1 { font-size: 22px; }
    .tv-header-status { gap: 8px; }
    #studioClock { min-width: 94px; font-size: 19px; }
    .tv-footer { grid-template-columns: 1fr 1fr; }
    .next-cue { grid-column: span 2; text-align: left; }
}
