@font-face {
    font-family: 'Instrument Sans';
    src: url('/fonts/InstrumentSans.ttf') format('truetype');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
:root { color-scheme: dark; }

html, body {
    margin: 0;
    padding: 0;
    background: #000000;
    color: #ffffff;
    font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
}

body {
    display: flex;
    flex-direction: column;
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 48px 36px;
}

body.admin-layout {
    max-width: 960px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding-bottom: 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.wordmark {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    line-height: 0.94;
    letter-spacing: -0.025em;
    color: #ffffff;
    text-decoration: none;
}

.header-status, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.header-status.ok .status-dot { background: #ffffff; }
.header-status.error .status-dot { background: #ffffff; opacity: 0.9; }
.header-status.ok { color: #ffffff; }

.tag {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

.tag-spaced {
    margin: 0 0 18px;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 28px;
    padding: 40px 0;
}

body.admin-layout main {
    justify-content: flex-start;
    gap: 0;
    padding: 44px 0;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 24px;
}

.label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.48);
    margin: 0 0 10px;
}

h1, h2 {
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.015em;
}

h1 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
body.admin-layout h1 { font-size: 1.9rem; margin-bottom: 24px; }
h2 { font-size: 1.35rem; margin-bottom: 24px; }

.hidden { display: none !important; }

.actions, #codeBar, .row-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}

.row-actions {
    align-items: center;
}

.row-actions-spaced {
    margin-bottom: 16px;
}

#codeInput {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.28em;
    text-align: center;
    width: 168px;
    padding: 13px 12px;
    background: #000000;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 0;
    outline: none;
}

#codeInput::placeholder {
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.2em;
}

#codeInput:focus { border-color: #ffffff; }

button {
    font-family: inherit;
    border-radius: 0;
    padding: 14px 28px;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn-primary, #startBtn, #confirmBtn {
    background: #ffffff;
    color: #000000;
    border: 1px solid #ffffff;
}

.btn-primary:hover:not(:disabled), #startBtn:hover:not(:disabled), #confirmBtn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.86);
}

.btn-secondary, #cancelCodeBtn, #freezeBtn, #stopBtn {
    background: transparent;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-secondary:hover:not(:disabled), #cancelCodeBtn:hover:not(:disabled), #freezeBtn:hover:not(:disabled), #stopBtn:hover:not(:disabled) {
    border-color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

#freezeBtn.active {
    background: #ffffff;
    color: #000000;
    border-color: #ffffff;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.74rem;
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mode-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    user-select: none;
}

.mode-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: #000000;
    transition: background 0.15s ease, border-color 0.15s ease;
    flex-shrink: 0;
}

.switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.55);
    transition: transform 0.15s ease, background 0.15s ease;
}

.mode-toggle input:checked + .switch {
    background: #ffffff;
    border-color: #ffffff;
}

.mode-toggle input:checked + .switch::after {
    transform: translateX(20px);
    background: #000000;
}

.mode-toggle input:disabled + .switch {
    opacity: 0.35;
    cursor: not-allowed;
}

.mode-title {
    font-size: 0.84rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.mode-meta {
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.48);
}

.preview-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.32);
    pointer-events: none;
}

.preview-frame.active .preview-placeholder { display: none; }

video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000000;
}

.login-box { max-width: 460px; }

.section {
    padding: 32px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}
.section:first-child { padding-top: 0; }
.section:last-child { border-bottom: none; }

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    max-width: 480px;
}

.field-spaced {
    margin-top: 18px;
}

label {
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
    font-family: inherit;
    font-size: 1rem;
    padding: 13px 16px;
    background: #000000;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    outline: none;
}

input:focus, select:focus { border-color: #ffffff; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    cursor: pointer;
    max-width: 480px;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #ffffff;
}

.checkbox-row span {
    font-size: 0.86rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
}

.session-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.session-grid-compact {
    margin-bottom: 16px;
}

.metric-value {
    font-size: 1.25rem;
    font-weight: 600;
}

footer {
    padding-top: 22px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
}

#status.ok, #feedback.ok { color: #ffffff; }
#status.error, #feedback.error {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.security-badge {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.42);
}

@media (max-width: 640px) {
    body { padding: 24px 20px; }
    main { padding: 28px 0; }
    button { width: 100%; }
    .actions, #codeBar { width: 100%; }
    #codeInput { width: 100%; }
}
