/* ── CAMERA FEED ── */
#camera_feed {
    width: 100%;
    max-width: 800px;
    height: auto;
    aspect-ratio: 1/1;
    background: black;
    border: 2px solid #333;
    display: block;
}

#stream_status {
    color: red;
    font-size: 0.85em;
    margin-top: 4px;
    min-height: 1.2em;
}

/* ── MOTION CONTROLS ── */
.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin-top: 12px;
}

.controls-label {
    font-size: 12px;
    color: #555;
    text-align: center;
    margin-top: 4px;
    letter-spacing: 0.8px;
    font-family: sans-serif;
}

/* XY pad */
.arrow-grid {
    display: grid;
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
    gap: 4px;
}

.arrow-grid button {
    width: 46px;
    height: 46px;
    font-size: 19px;
    cursor: pointer;
    border: 2px solid #333;
    border-radius: 7px;
    background: #f0f0f0;
}

.arrow-grid button:active {
    background: #bbb;
}

.arrow-grid button,
.z-controls button {
    touch-action: none;
    user-select: none;
}

.arrow-grid button:disabled,
.z-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#scan-lock-notice {
    display: none;
    margin-top: 8px;
    padding: 6px 10px;
    max-width: 520px;
    background: #fff3cd;
    border: 1px solid #e0a800;
    border-radius: 6px;
    font-size: 0.9em;
}

#scan-lock-notice button {
    margin-left: 8px;
    cursor: pointer;
}

.arrow-grid .empty {
    background: transparent;
    border: none;
    pointer-events: none;
}

/* Z pad */
.z-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}

.z-controls button {
    width: 46px;
    height: 46px;
    font-size: 19px;
    cursor: pointer;
    border: 2px solid #555;
    border-radius: 7px;
    background: #e8e8ff;
}

.z-controls button:active {
    background: #aab;
}

/* Stop */
.stop-btn {
    width: 46px;
    height: 46px;
    font-size: 16px;
    cursor: pointer;
    border: 2px solid #900;
    border-radius: 7px;
    background: #fee;
    color: #900;
    font-weight: bold;
}

.stop-btn:active {
    background: #fcc;
}

/* ── LED BUTTON, AUTOFOCUS & CAPTURE (centered on right) ── */
.led-button {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 3px solid #555;
    cursor: pointer;
    font-size: 22px;
    background: #333;
    color: #666;
    transition: all 0.3s;
}

.led-button.on {
    background: #ffeb3b;
    color: #f57f17;
    border-color: #f9a825;
    box-shadow: 0 0 18px #ffeb3b;
}

.led-controls {
    flex: 1 1 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.led-controls .manual-capture-btn {
    padding: 5px 10px;
    font-size: 12px;
}

/* ── STAGE POSITION & STEP SIZE CARD ── */
.stage-pos-card {
    font-family: sans-serif;
    font-size: 13px;
    background: #f7f9ff;
    border: 1px solid #ccd6eb;
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 280px;
}

.stage-pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.stage-pos-header b {
    color: #1a237e;
}

#nav-uncertain-badge {
    display: none;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef5350;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: bold;
}

.stage-pos-coords {
    font-family: monospace;
    font-size: 15px;
    font-weight: bold;
    color: #111;
    margin-bottom: 6px;
}

.stage-pos-limits {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
}

.nav-step-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 8px;
    font-family: sans-serif;
    font-size: 13px;
}

.nav-step-label {
    font-size: 12px;
    color: #333;
    font-weight: 600;
}

#nav-tap-steps {
    width: 5.2em;
    padding: 2px 5px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

.nav-step-presets {
    margin-top: 5px;
}

.nav-step-preset {
    padding: 2px 7px;
    border: 1px solid #888;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.nav-step-preset[aria-pressed="true"] {
    background: #1565c0;
    color: white;
}

#nav-step-help {
    margin: 6px 0 0;
    font-size: 12px;
    color: #555;
}

#btn-nav-zero {
    margin-left: auto;
    padding: 3px 9px;
    border: none;
    border-radius: 4px;
    background: #2e7d32;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

#btn-nav-zero:hover {
    background: #1b5e20;
}

/* ── ACTION BUTTONS ── */
.getbutton,
.downloadbutton,
.autofocusbutton,
.scannowbutton {
    border: none;
    color: white;
    padding: 6px 15px;
    font-size: 13px;
    cursor: pointer;
    display: inline-block;
    margin-right: 6px;
}

.getbutton,
.downloadbutton,
.autofocusbutton {
    background-color: #4CAF50;
}

.scannowbutton {
    background-color: #1565C0;
}

.scannowbutton.secondary-scan-btn {
    background-color: #546e7a;
}

.getbutton:hover,
.downloadbutton:hover,
.autofocusbutton:hover {
    background-color: #388E3C;
}

.scannowbutton:hover {
    background-color: #0D47A1;
}

.scannowbutton.secondary-scan-btn:hover {
    background-color: #37474f;
}

.stop-scan-btn {
    border: none;
    border-radius: 4px;
    background-color: #c62828;
    color: #fff;
    padding: 6px 15px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: inline-block;
}

.stop-scan-btn:hover:not(:disabled) {
    background-color: #8e0000;
}

.stop-scan-btn:disabled {
    background-color: #e0b4b4;
    color: #fff;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ── MANUAL PICTURE CAPTURE & RECENT GALLERY ── */
.manual-capture-box {
    margin-top: 16px;
    padding: 12px 14px;
    background: #f7f9ff;
    border: 1px solid #ccd6eb;
    border-radius: 8px;
    font-family: sans-serif;
    font-size: 13px;
}

.manual-capture-header,
.manual-recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.manual-capture-header {
    margin-bottom: 8px;
}

.manual-capture-header b {
    color: #1a237e;
    font-size: 14px;
}

.manual-capture-muted {
    color: #666;
    font-size: 12px;
}

.manual-capture-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.manual-capture-btn {
    border: none;
    border-radius: 5px;
    background-color: #2e7d32;
    color: #fff;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

.manual-capture-btn:hover:not(:disabled) {
    background-color: #1b5e20;
}

.manual-capture-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

#manual-capture-label {
    flex: 1 1 200px;
    min-width: 160px;
    padding: 5px 8px;
    border: 1px solid #b0bec5;
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
}

#manual-capture-status {
    font-size: 12px;
    color: #2e7d32;
    min-height: 1.2em;
}

#manual-capture-status.error {
    color: #c62828;
}

.manual-capture-viewer {
    margin-top: 12px;
    padding: 10px;
    background: #fff;
    border: 1px solid #cfd8dc;
    border-radius: 6px;
}

.manual-capture-viewer-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.manual-capture-viewer-bar button {
    padding: 3px 9px;
    border: 1px solid #888;
    border-radius: 4px;
    background: #f0f0f0;
    cursor: pointer;
}

.manual-capture-viewer-bar button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#manual-capture-caption {
    flex: 1 1 auto;
    font-size: 12px;
    color: #222;
}

.manual-download-btn,
.manual-refresh-btn {
    padding: 3px 10px;
    border: 1px solid #1565c0;
    border-radius: 4px;
    background: #e3f2fd;
    color: #0d47a1;
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

.manual-download-btn:hover,
.manual-refresh-btn:hover {
    background: #bbdefb;
    color: #0d47a1;
    text-decoration: none;
}

#manual-preview-img {
    display: block;
    width: 100%;
    max-width: 440px;
    height: auto;
    aspect-ratio: 1/1;
    object-fit: contain;
    background: #111;
    border: 1px solid #333;
    border-radius: 4px;
    margin: 0 auto;
}

.manual-recent-header {
    margin: 12px 0 6px;
    font-size: 12px;
    font-weight: bold;
    color: #37474f;
}

.manual-capture-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-top: 6px;
}

.manual-thumb-card {
    background: #111;
    border: 2px solid transparent;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    text-align: left;
}

.manual-thumb-card.active {
    border-color: #2e7d32;
}

.manual-thumb-card img {
    display: block;
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
}

.manual-thumb-meta {
    padding: 3px 4px;
    color: #e0e0e0;
    font-size: 10px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 900px) {
    .manual-capture-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
