/* Design tokens */
:root {
    --bg:             oklch(0.11 0.008 250);
    --surface:        oklch(0.17 0.008 250);
    --elevated:       oklch(0.22 0.009 250);
    --border:         oklch(0.28 0.010 250);
    --border-subtle:  oklch(0.22 0.008 250);

    --text:           oklch(0.92 0.005 250);
    --text-2:         oklch(0.62 0.008 250);
    --text-3:         oklch(0.42 0.008 250);

    --accent:         oklch(0.78 0.14 76);
    --accent-dim:     oklch(0.78 0.14 76 / 0.14);
    --accent-border:  oklch(0.78 0.14 76 / 0.4);

    --rec:            oklch(0.58 0.22 22);
    --rec-dim:        oklch(0.58 0.22 22 / 0.18);
    --rec-border:     oklch(0.58 0.22 22 / 0.5);

    --ch-luma:        oklch(0.74 0.006 250);
    --ch-red:         oklch(0.66 0.18 22);
    --ch-green:       oklch(0.70 0.16 145);
    --ch-blue:        oklch(0.65 0.15 265);

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;

    --top-bar-h:  52px;
    --tab-bar-h:  40px;
    --status-h:   28px;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================
   TOP BAR
   ============================ */

#topBar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--top-bar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    z-index: 100;
}

/* Background watermark logo */
#bgLogo {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 0;
}

#bgLogo img {
    width: min(55vw, 55vh);
    height: auto;
    filter: brightness(0) invert(1);
    opacity: 0.035;
    user-select: none;
}

#topBar.recording { border-bottom-color: var(--rec-border); }

#camInfo {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 140px;
}

#cameraName {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timecode {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    letter-spacing: 0.08em;
}

#formatDisplay {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-2);
    letter-spacing: 0.04em;
}
#formatCodec { color: var(--text); font-weight: 600; }

#transportControls {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.iconBtn {
    width: 32px; height: 32px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.iconBtn:hover { color: var(--text); border-color: var(--text-3); background: var(--elevated); }
.iconBtn.activated { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }

#recordButton {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.1s;
    flex-shrink: 0;
}
#recordButton:hover { border-color: var(--rec-border); color: var(--rec); }
#recordButton.recording { border-color: var(--rec-border); color: var(--rec); background: var(--rec-dim); }

#recDot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--rec);
    flex-shrink: 0;
}

#recordButton.recording #recDot {
    animation: recPulse 1s ease-in-out infinite;
}

@keyframes recPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

/* ============================
   TAB BAR
   ============================ */

#tabBar {
    position: fixed;
    top: var(--top-bar-h);
    left: 0; right: 0;
    height: var(--tab-bar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: stretch;
    padding: 0 12px;
    z-index: 90;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    padding: 0 16px;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================
   MAIN CONTENT
   ============================ */

#mainContent {
    position: fixed;
    top: calc(var(--top-bar-h) + var(--tab-bar-h));
    bottom: var(--status-h);
    left: 0; right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1;
}

.tabPanel { display: none; padding: 20px; }
.tabPanel.active { display: block; }

/* ============================
   EXPOSURE TAB
   ============================ */

.exposureRow {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.expPill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 140px;
    flex: 1;
}

.expPillLabel {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-3);
    text-transform: uppercase;
}

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

.expValue {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    flex: 1;
    text-align: center;
    outline: none;
    min-width: 60px;
}
.expValue:focus { color: var(--accent); }

.adjBtn {
    width: 28px; height: 28px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: color 0.1s, border-color 0.1s;
}
.adjBtn:hover { color: var(--text); border-color: var(--border); }
.adjBtn:active { background: var(--elevated); }

.awbBtn {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font: inherit;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    cursor: pointer;
    transition: color 0.1s, border-color 0.1s;
}
.awbBtn:hover { color: var(--accent); border-color: var(--accent-border); }

.hidden { display: none !important; }

.settingsRow {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 0;
    border-top: 1px solid var(--border-subtle);
}

.settingGroup {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settingLabel {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text-3);
    text-transform: uppercase;
}

.settingSelect {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
    outline: none;
}
.settingSelect:focus { border-color: var(--accent); }

.settingInput {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    padding: 6px 10px;
    outline: none;
}
.settingInput:focus { border-color: var(--accent); }

.actionBtn {
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 7px 14px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    white-space: nowrap;
    align-self: flex-end;
}
.actionBtn:hover { background: var(--border); border-color: var(--text-3); }

.presetBtnRow { display: flex; gap: 4px; }

.presetBtn {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font: inherit;
    font-size: 11px;
    padding: 5px 10px;
    cursor: pointer;
    transition: all 0.1s;
}
.presetBtn:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }

/* ============================
   COLOR SCIENCE TAB
   ============================ */

.csGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.csCard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.csCard--full { grid-column: 1 / -1; }

.csCardTitle {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-3);
    text-transform: uppercase;
}

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

.csOptionBtn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-2);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.12s;
}
.csOptionBtn:hover { color: var(--text); border-color: var(--text-3); background: var(--elevated); }
.csOptionBtn.selected { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }

.csCurrentRow {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}
.csCurrentLabel { font-size: 10px; color: var(--text-3); letter-spacing: 0.06em; }
.csCurrentValue { font-size: 13px; font-weight: 600; color: var(--accent); }

.csQuickPresets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.csQuickBtn {
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font: inherit;
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    transition: all 0.12s;
}
.csQuickBtn:hover { border-color: var(--accent-border); background: var(--accent-dim); }

.csQuickBtnName { font-size: 13px; font-weight: 700; }
.csQuickBtnDetail { font-size: 10px; color: var(--text-2); letter-spacing: 0.04em; }

.formatGrid {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.statusNote { font-size: 11px; color: var(--text-2); align-self: center; }

.sectionDivider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 12px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.sectionDivider::before, .sectionDivider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

/* ============================
   COLOR CORRECTION TAB
   ============================ */

.ccGrid {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
}

.ccRow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}
.ccRow:last-child { border-bottom: none; }
.ccRow:hover { background: var(--elevated); }

.ccRowLabel {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-2);
    width: 52px;
    flex-shrink: 0;
}

.ccChannels {
    display: flex;
    gap: 24px;
    flex: 1;
}

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

.ccChLabel {
    font-size: 11px;
    font-weight: 700;
    width: 12px;
    flex-shrink: 0;
}

.ccVal {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    min-width: 44px;
    outline: none;
    text-align: right;
}
.ccVal:focus { color: var(--accent); }

.ccApplyBtn, .ccResetBtn {
    width: 30px; height: 30px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.1s;
}
.ccApplyBtn:hover { color: var(--accent); border-color: var(--accent-border); }
.ccResetBtn:hover { color: var(--text); border-color: var(--border); }

.sliderGroup {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.sliderRow { display: flex; align-items: center; gap: 12px; }

.sliderLabel {
    font-size: 11px;
    color: var(--text-2);
    width: 110px;
    flex-shrink: 0;
}

.slider {
    flex: 1;
    height: 4px;
    appearance: none;
    background: var(--elevated);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.sliderVal {
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    width: 44px;
    text-align: right;
    outline: none;
}
.sliderVal:focus { color: var(--accent); }

/* ============================
   LENS TAB
   ============================ */

.lensGrid {
    display: flex;
    gap: 24px;
    justify-content: center;
    padding: 20px;
    height: calc(100vh - var(--top-bar-h) - var(--tab-bar-h) - var(--status-h) - 40px);
}

.lensCard {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 40px;
    min-width: 120px;
}

.lensCardLabel {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-3);
    text-transform: uppercase;
}

.vertSlider {
    writing-mode: vertical-lr;
    direction: rtl;
    flex: 1;
    width: 4px;
    appearance: none;
    background: var(--elevated);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}
.vertSlider::-webkit-slider-thumb {
    appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 4px var(--accent-dim);
}

.lensActionBtn {
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 20px;
    cursor: pointer;
    transition: all 0.1s;
}
.lensActionBtn:hover { border-color: var(--accent-border); color: var(--accent); background: var(--accent-dim); }

.lensValueLabel {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    font-weight: 600;
}

/* ============================
   SYSTEM TAB
   ============================ */

.sysGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.sysCard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sysCard--full { grid-column: 1 / -1; }

.sysCardTitle {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text-3);
    text-transform: uppercase;
}

.sysRow { display: flex; flex-direction: column; gap: 4px; }
.sysRow--inline { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; }

.hostnameInput { min-width: 220px; }

.apiResponse {
    font-size: 11px;
    color: var(--text-2);
    background: var(--bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    word-break: break-all;
    min-height: 36px;
}

.linkRow { display: flex; gap: 16px; flex-wrap: wrap; }
.sysLink { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 0.04em; }

/* ============================
   STATUS BAR
   ============================ */

#statusBar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--status-h);
    background: var(--bg);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    font-size: 10px;
    color: var(--text-3);
    letter-spacing: 0.04em;
    z-index: 100;
}

.version { opacity: 0.5; }

#mainContent::-webkit-scrollbar { width: 6px; }
#mainContent::-webkit-scrollbar-track { background: transparent; }
#mainContent::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
