* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
  touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.container {
    background: white;
    border-radius: 12px;
    padding: 0 30px 30px 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.spacer {
    height: 20px;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.subtitle {
    color: #666;
    margin-bottom: 25px;
    font-size: 14px;
}

.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 -30px;
    padding: 0 30px;
    border-bottom: 2px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    background: #f7fafc;
}

.tab-button {
    background: transparent;
    color: #4a5568;
    border: 0;
    border-radius: 12px 12px 0 0;
    padding: 10px 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    top: 2px;
}

.tab-button.active {
    background: #fff;
    color: #1a202c;
    border: 2px solid #e2e8f0;
    border-bottom: 0;
    box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.08);
}

.tab-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tab-button-all {
    margin-left: auto;
}

.tab-nav .collapsible-header {
    margin-left: 8px;
    padding: 10px 18px;
    border-radius: 12px 12px 0 0;
    background: transparent;
    color: #4a5568;
    box-shadow: none;
    font-size: 16px;
    border: 0;
    position: relative;
    top: 2px;
}

.tab-panel {
    display: none;
    padding-top: 20px;
}

.tab-panel.active {
    display: block;
}

button {
    margin: 5px;
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

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

input[type="number"], input[type="text"] {
    padding: 8px 12px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    width: 150px;
    margin: 5px;
}

/* Hide spinner controls so inputs behave like plain text fields */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.input-with-unit {
    display: inline-flex;
    align-items: center;
    position: relative;
    margin: 5px;
}

.input-with-unit input[type="number"] {
    margin: 0;
    padding-right: 35px;
}

.unit-label {
    position: absolute;
    right: 12px;
    color: #718096;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
}

.select-with-label {
    display: flex;
    flex-direction: column;
    margin: 5px;
    min-width: 140px;
}

.select-with-label label {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
}

.distance-select, .stack-select {
    padding: 10px 12px;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
    font-size: 16px;
    font-weight: 600;
    background: white;
}

input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

.slider-control {
    --slider-fill: #4299e1;
    --slider-bg: #edf2f7;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(66, 153, 225, 0.05);
}

.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
}

.slider-header span:last-child {
    font-size: 18px;
    color: #1a365d;
}

.slider-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 36px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--slider-fill) 0%, var(--slider-fill) 50%, var(--slider-bg) 50%, var(--slider-bg) 100%);
    box-shadow: inset 0 0 0 2px rgba(226, 232, 240, 0.9);
    cursor: pointer;
    transition: box-shadow 0.15s ease-in-out;
}

.slider-control input[type="range"]::-webkit-slider-runnable-track {
    height: 36px;
    border-radius: 999px;
    background: transparent;
}

.slider-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 44px;
    width: 44px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid var(--slider-fill);
    box-shadow: 0 4px 10px rgba(66, 153, 225, 0.35);
    margin-top: -4px;
}

.slider-control input[type="range"]::-moz-range-track {
    height: 36px;
    border-radius: 999px;
    background: transparent;
}

.slider-control input[type="range"]::-moz-range-thumb {
    height: 44px;
    width: 44px;
    border-radius: 50%;
    border: 4px solid var(--slider-fill);
    background: #fff;
    box-shadow: 0 4px 10px rgba(66, 153, 225, 0.35);
}

.slider-ticks {
    margin-top: 12px;
}

.slider-tick {
    min-height: 64px;
    font-size: 16px;
}

label {
    display: block;
    margin: 10px 5px 5px 5px;
    color: #4a5568;
    font-weight: 600;
    font-size: 14px;
}

#connect {
    background: #667eea;
    color: white;
}

#disconnect {
    background: #f56565;
    color: white;
}

#status {
    margin: 20px 0;
    padding: 15px;
    border-radius: 8px;
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.connected {
    background: #d4edda;
    border: 2px solid #28a745;
}

.connecting {
    background: #fff3cd;
    border: 2px solid #ffc107;
}

.disconnected {
    background: #f8d7da;
    border: 2px solid #dc3545;
}

#controls-setup {
    display: none;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 22px;
    user-select: none;
    background: #718096;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    margin: 10px 5px 15px 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toggle-icon {
    font-size: 18px;
    transition: transform 0.2s ease;
}

.collapsible-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 1500px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
}

.expert-section {
    padding: 10px 0 5px 0;
}

.expert-section + .expert-section {
    border-top: 1px solid #e2e8f0;
    margin-top: 10px;
    padding-top: 15px;
}

.btn-primary {
    background: #4299e1;
    color: white;
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-warning {
    background: #ed8936;
    color: white;
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-stop {
    background: #e53e3e;
    color: white;
}

.btn-stop {
    display: none;
}

.btn-stop.visible {
    display: inline-block;
}

.btn-stop:disabled {
    background: #fc8181;
    opacity: 0.6;
}

.btn-info {
    background: #38b2ac;
    color: white;
}

.btn-secondary {
    background: #718096;
    color: white;
}

.connection-bar {
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 2px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    justify-content: space-between;
}

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

.status-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #718096;
    margin: 0;
}

#connection-label {
    margin: 0;
    font-weight: 600;
    color: #2d3748;
}

.indicator {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #cbd5f5;
    box-shadow: 0 0 0 6px rgba(66, 153, 225, 0.15);
    display: inline-block;
}

.indicator.disconnected {
    background: #f56565;
    box-shadow: 0 0 0 6px rgba(245, 101, 101, 0.2);
}

.indicator.connecting {
    background: #ecc94b;
    box-shadow: 0 0 0 6px rgba(236, 201, 75, 0.2);
}

.indicator.connected {
    background: #48bb78;
    box-shadow: 0 0 0 6px rgba(72, 187, 120, 0.2);
  }

.indicator.no-cam {
    background: #ed8936;
    box-shadow: 0 0 0 6px rgba(237, 137, 54, 0.2);
  }

.connection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-card {
    background: linear-gradient(145deg, #f8fafc 0%, #ffffff 40%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 0 16px;
    margin: 0 0 20px 0;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    /* transition: border-color 0.2s ease, box-shadow 0.2s ease; */
}

.status-card--active {
    /* border-color: #63b3ed; */
    box-shadow: 0 14px 36px rgba(66, 153, 225, 0.18);
}

.status-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 12px 0 4px 0;
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    color: #2d3748;
    padding: 8px 10px;
    background: rgba(226, 232, 240, 0.35);
    border-radius: 10px;
}

.status-row.subtle {
    font-weight: 500;
    color: #4a5568;
    background: transparent;
    padding: 4px 0 0 0;
  }

.status-timestamp {
    font-size: 13px;
    color: #4a5568;
    font-weight: 600;
}

.subtle {
    color: #718096;
}

.warning {
    background: #fff3cd;
    border: 2px solid #ffc107;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

.warning h2 {
    color: #856404;
    margin-bottom: 10px;
}

.warning p {
    color: #856404;
    line-height: 1.6;
}

.input-group {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    margin: 10px 0;
}

.button-grid-5, .button-grid-7, .button-grid-3 {
    display: grid;
    gap: 5px;
    width: 100%;
    margin: 10px 0;
}
.button-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.button-grid-7 {
    grid-template-columns: repeat(7, 1fr);
}

.button-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.button-grid-3.button-grid-tight {
    grid-template-columns: 20% 60% 20%;
}

.button-grid-5 button, .button-grid-7 button, .button-grid-3 button {
    margin: 0;
    min-height: 80px;
}

.button-grid-5 input[type="number"], .button-grid-5 input[type="text"], .button-grid-7 input[type="number"], .button-grid-7 input[type="text"] {
    margin: 0;
    width: 100%;
}

.custom-command input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    margin: 5px;
    font-size: 15px;
}

@media (max-width: 1300px) {
    body {
        padding: 0;
        max-width: none;
        margin: 0;
    }

    .container {
        padding: 16px;
        border-radius: 0;
        box-shadow: none;
        /* min-height: 100vh; */
    }

    button {
        padding: 10px 16px;
        font-size: 14px;
    }

    input[type="number"], input[type="text"], .custom-command input[type="text"] {
        width: 120px;
    }

    .connection-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .status-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .input-with-unit {
        width: 100%;
    }

    .input-with-unit input[type="number"] {
        width: 100%;
        padding-right: 12px;
    }

    .input-with-unit .unit-label {
        position: static;
        margin-left: 6px;
    }

    .slider-tick {
        min-height: 52px;
        font-size: 15px;
    }

    .slider-control {
        padding: 12px;
    }

    .slider-control input[type="range"] {
        height: 28px;
    }

    .slider-control input[type="range"]::-webkit-slider-thumb,
    .slider-control input[type="range"]::-moz-range-thumb {
        height: 38px;
        width: 38px;
    }
}

#version-footer {
    position: fixed;
    bottom: 8px;
    right: 16px;
    font-size: 11px;
    color: #cbd5e0;
    z-index: 0;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}
