* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #111;
    color: #eee;
    overflow: hidden;
}

.wrap {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* NEW: row of top-right badges */
.badgeRow {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 9999;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Top-right controller status */
.controllerStatus {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    gap: 8px;
    align-items: center;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #666;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.0);
}

.live {
    color: #37ff5b;
}

.live .dot {
    background: #37ff5b;
    box-shadow: 0 0 12px rgba(55, 255, 91, 0.35);
}

.inactive {
    color: #ff4d4d;
}

.inactive .dot {
    background: #ff4d4d;
    box-shadow: 0 0 12px rgba(255, 77, 77, 0.25);
}

/* NEW: neutral/warn for Pi health badge */
.neutral {
    color: #bbb;
}

.neutral .dot {
    background: #888;
    box-shadow: 0 0 12px rgba(136, 136, 136, 0.12);
}

.warn {
    color: #ffb020;
}

.warn .dot {
    background: #ffb020;
    box-shadow: 0 0 12px rgba(255, 176, 32, 0.22);
}

.left {
    width: 66.666%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.right {
    width: 33.333%;
    padding: 10px;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 12px;
    min-width: 0;
}

.previewBox {
    flex: 7;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #333;
    position: relative;
    min-height: 200px;
}

img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Rotation rule added */
img.rotated {
    transform: rotate(-90deg);
    width: 100vh;
    height: 100vw;
}

/* Histogram overlays (inside previewBox only) */
.histPanel {
    position: absolute;
    bottom: 10px;
    width: 25%;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    overflow: hidden;
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 220px;
}

.histLeft {
    left: 10px;
}

.histRight {
    right: 10px;
}

.histHeader {
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    font-size: 12px;
    color: #ddd;
    user-select: none;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(0, 0, 0, 0.25);
}

.histHeader .chev {
    opacity: 0.85;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.histBody {
    flex: 1;
    padding: 8px;
    display: block;
}

.histPanel.collapsed .histBody {
    display: none;
}

.histCanvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
}

.previewOverlay {
    position: absolute;
    bottom: 10px;

    /* Centered horizontally */
    left: 50%;
    transform: translateX(-50%);

    /* Keep it between the two 25% histogram panels */
    width: 40%;
    max-width: 900px;
    min-width: 300px;

    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    color: #ddd;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;

    z-index: 4; /* below hist panels */
}

.progressBox {
    flex: 3;
    border-radius: 12px;
    border: 1px solid #333;
    background: #0b0b0b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.progressText {
    font-size: 140px;
    font-weight: 900;
    color: #ff2d2d;
    letter-spacing: 2px;
    text-shadow: 0 0 18px rgba(255, 45, 45, 0.25);
    line-height: 1;
    user-select: none;
}

.countdownText {
    margin-top: 14px;
    font-size: 40px;
    font-weight: 800;
    color: #ffb3b3;
    opacity: 0.9;
    user-select: none;
}

.done {
    color: #37ff5b !important;
    text-shadow: 0 0 18px rgba(55, 255, 91, 0.25) !important;
}

.status {
    font-size: 13px;
    color: #bbb;
    margin-bottom: 6px;
}

label {
    display: block;
    margin-top: 10px;
    font-size: 13px;
    color: #bbb;
}

input, select {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    border-radius: 10px;
    border: 1px solid #333;
    background: #0f0f0f;
    color: #eee;
    outline: none;
    min-width: 0;
}

button {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 14px;
    border-radius: 12px;
    border: 0;
    background: #2d6cdf;
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 15px;
}

.dualButton {
    display: flex;
    width: 100%;
    margin-top: 14px;
    gap: 0;
}

.dualButton button {
    flex: 1;
    border-radius: 0;
    margin-top: 0;
}

.dualButton .leftBtn {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
    background: #2d6cdf;
}

.dualButton .rightBtn {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    background: #9c27b0;
}

.dualButton .focusActive {
    background: #d32f2f !important;
}

.dualButton button:disabled {
    background: #444 !important;
    cursor: not-allowed;
}

button:disabled {
    background: #444;
    cursor: not-allowed;
}

.hint {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
    line-height: 1.35;
}

.log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    background: #0b0b0b;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 10px;
}

.cameraRow {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    margin-bottom: 10px;
}

.cameraField {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cameraField label {
    margin-bottom: 3px;
    font-size: 12px;
    opacity: 0.85;
}

.cameraField select {
    width: 100%;
}

.rightBtn.stop {
    background:#c62828;
}