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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Views */
.view {
    display: none;
    min-height: 100vh;
}
.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
#view-client.active {
    justify-content: flex-start;
    padding-top: 2rem;
}
#view-helper.active {
    height: 100vh;
    justify-content: flex-start;
    align-items: stretch;
    overflow: hidden;
}

/* Helper waiting state (between auth and video) */
.helper-waiting {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 1.5rem;
    color: var(--text-secondary, #808080);
}
.helper-waiting-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #1a1a3e;
    border-top: 3px solid #4a90d9;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Panels */
.panel {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

/* Client panel is wider to fit horizontal steps */
#view-client > .panel {
    max-width: 960px;
}

/* Client steps layout — horizontal cards on wide screens */
#view-client > .panel > .steps-container {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

/* Steps */
.step {
    display: none;
    text-align: left;
    padding: 1rem;
    border-top: none;
    margin-top: 0;
    background: #0d1a33;
    border: 1px solid #0f3460;
    border-radius: 8px;
    flex: 1;
    min-width: 0;
}
.step.active { display: flex; flex-direction: column; }
.step.completed {
    display: flex;
    flex-direction: column;
    opacity: 0.5;
}
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #0f3460;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}
.step h3 {
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}
.step p {
    font-size: 0.85rem;
    margin-bottom: 0.6rem;
}

/* On narrow screens, stack steps vertically */
@media (max-width: 700px) {
    #view-client > .panel {
        max-width: 500px;
    }
    #view-client > .panel > .steps-container {
        flex-direction: column;
    }
}

h1 { font-size: 1.8rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; margin-bottom: 1rem; color: #a0c4ff; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
p { margin-bottom: 1rem; color: #b0b0b0; line-height: 1.5; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
    color: #fff;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: #0f3460; }
.btn-primary:hover { background: #1a4a7a; }
.btn-secondary { background: #533483; }
.btn-secondary:hover { background: #6a45a0; }
.btn-danger { background: #c0392b; }
.btn-danger:hover { background: #e74c3c; }
.btn-ghost {
    background: transparent;
    border: 1px solid #444;
    color: #b0b0b0;
}
.btn-ghost:hover { background: #2a2a4a; }

.btn-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.2rem 2rem;
    font-size: 1.1rem;
    min-width: 200px;
}
.btn-large small {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.3rem;
}
.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.role-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.role-buttons .btn-large {
    flex: 1;
    max-width: 250px;
}

/* Connection ID display */
.connection-id-display {
    font-family: "Courier New", monospace;
    font-size: 1.4rem;
    letter-spacing: 0.3rem;
    padding: 0.6rem;
    background: #0a0a1a;
    border: 2px solid #0f3460;
    border-radius: 8px;
    text-align: center;
    color: #a0c4ff;
    margin: 0.5rem 0;
    user-select: all;
    word-break: break-all;
}

/* Connection ID input */
.connection-id-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0;
    align-items: stretch;
}
.connection-id-input {
    flex: 1 1 200px;
    min-width: 0;
    font-family: "Courier New", monospace;
    font-size: 1.5rem;
    letter-spacing: 0.2rem;
    padding: 0.6rem 1rem;
    background: #0a0a1a;
    border: 2px solid #0f3460;
    border-radius: 8px;
    color: #a0c4ff;
    outline: none;
}
.connection-id-input::placeholder {
    font-size: 0.85rem;
    letter-spacing: 0;
    color: #505070;
    font-family: inherit;
}
.connection-id-input:focus { border-color: #1a4a7a; }

/* Status */
.status {
    padding: 0.8rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}
.status-waiting { background: #1a1a3e; color: #a0a0c0; }
.status-connected { background: #0a2a1a; color: #4caf50; }
.status-warning { background: #2a1a0a; color: #ff9800; }
.status-error { background: #2a0a0a; color: #f44336; }

/* Video */
.video-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0; /* Critical: allows flex item to shrink below content size */
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.video-container video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Video loading overlay */
.video-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
    background: #000;
}
.video-loading.hidden { display: none; }
.video-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #1a1a3e;
    border-top-color: #a0c4ff;
    border-radius: 50%;
    animation: video-spin 1s linear infinite;
}
@keyframes video-spin { to { transform: rotate(360deg); } }
.video-loading-text {
    margin-top: 1rem;
    color: #808080;
    font-size: 0.85rem;
}

/* Stats bar */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    background: #0a0a1a;
    border-bottom: 1px solid #1a1a3e;
    font-size: 0.8rem;
    font-family: "Courier New", monospace;
    flex-shrink: 0; /* Never collapse — always visible above video */
}
.stat { white-space: nowrap; }
.stat-spacer { flex: 1; }

.stat.good { color: #4caf50; }
.stat.warning { color: #ff9800; }
.stat.bad { color: #f44336; }

/* Stats detail */
.stats-detail {
    background: #0a0a1a;
    border-bottom: 1px solid #1a1a3e;
    padding: 1rem;
    font-size: 0.8rem;
    font-family: "Courier New", monospace;
    max-height: 200px;
    overflow-y: auto;
}
.stats-detail h4 { margin-bottom: 0.5rem; color: #a0c4ff; }

/* UAC overlay */
.uac-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.uac-message {
    background: #1a1a3e;
    border: 2px solid #ff9800;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    text-align: center;
}
.uac-message h3 { color: #ff9800; }
.uac-hint { font-size: 0.85rem; color: #808080; margin-bottom: 0; }

/* Control banner */
.control-banner {
    background: #2a1a0a;
    border: 1px solid #ff9800;
    border-radius: 8px;
    padding: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #ff9800;
    font-size: 0.85rem;
}
.control-banner .btn {
    white-space: nowrap;
}

/* Helper controls */
.helper-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #16213e;
    border-top: 1px solid #0f3460;
    flex-shrink: 0; /* Never collapse — always visible below video */
}

/* Connection indicator */
.connection-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 100;
}
.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
}
.indicator-dot.yellow { background: #ff9800; }
.indicator-dot.red { background: #f44336; }

/* Compact floating control panel — shown after connection */
.mini-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 280px;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 12px;
    padding: 0.8rem;
    z-index: 150;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    font-size: 0.85rem;
}
.mini-panel.hidden { display: none; }
.mini-panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.mini-panel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
}
.mini-panel-dot.paused { background: #ff9800; }
.mini-panel-dot.ended { background: #808080; }
.mini-panel-title {
    font-weight: 500;
    color: #c0c0c0;
}
.mini-panel-status {
    color: #808080;
    font-size: 0.8rem;
    margin-bottom: 0.6rem;
}
.mini-panel-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.mini-panel-buttons > div {
    display: flex;
    gap: 0.4rem;
}
.mini-btn {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #0d1a33;
    color: #a0c4ff;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.mini-btn:hover { background: #1a2a4a; }
.mini-btn-secondary {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #0f3460;
    background: #0d1a33;
    color: #a0c4ff;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.mini-btn-secondary:hover { background: #1a2a4a; }
.mini-btn-end {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #3a1a1a;
    background: #2a0a0a;
    color: #f08080;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}
.mini-btn-end:hover { background: #3a1a1a; }
.mini-panel-verification {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: #606060;
}

/* Mini-panel hint — animated pointer to the floating panel */
.mini-panel-hint {
    position: fixed;
    bottom: 50%;
    right: 1.5rem;
    text-align: center;
    animation: hint-bounce 2s ease-in-out infinite;
}
.mini-panel-hint.hidden { display: none; }
.mini-panel-hint-text {
    color: #808080;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}
.mini-panel-hint-arrow {
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 16px solid #0f3460;
    margin: 0 auto;
}
@keyframes hint-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(10px); }
}

/* Dialog */
.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.dialog-content {
    background: #16213e;
    border: 2px solid #0f3460;
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
}
.dialog-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Log panel */
.log-panel {
    background: #0a0a0a;
    border-top: 1px solid #1a1a3e;
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.75rem;
}
.log-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 1rem;
    background: #1a1a2e;
    border-bottom: 1px solid #1a1a3e;
    position: sticky;
    top: 0;
}
.log-header span { flex: 1; font-weight: bold; }
#log-content, #helper-log-content {
    padding: 0.5rem 1rem;
    font-family: "Courier New", monospace;
    white-space: pre-wrap;
    word-break: break-all;
    color: #888;
    line-height: 1.4;
}

.log-toggle {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    padding: 0.4rem 0.8rem;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 100;
}

/* Downloads list */
#all-downloads {
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
#all-downloads a {
    color: #a0c4ff;
    font-size: 0.85rem;
}

/* Utility */
.hidden { display: none !important; }
.link-small { font-size: 0.8rem; color: #a0c4ff; }

/* Platform instructions */
.platform-instructions {
    margin: 0.5rem 0;
    padding: 0.6rem;
    background: #0a0a1a;
    border: 1px solid #1a1a3e;
    border-radius: 8px;
    text-align: left;
}
.platform-instructions h4 {
    margin-bottom: 0.5rem;
    color: #a0c4ff;
    font-size: 0.85rem;
}
.instruction-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.instruction {
    font-size: 0.8rem;
    line-height: 1.4;
    color: #c0c0c0;
}
.instruction-num {
    display: inline-block;
    font-weight: bold;
    color: #a0c4ff;
    min-width: 1.5rem;
}
.warning-box {
    display: inline-block;
    margin: 0.4rem 0;
    padding: 0.4rem 0.8rem;
    background: #2a1a0a;
    border: 1px solid #ff9800;
    border-radius: 4px;
    color: #ffb74d;
    font-size: 0.8rem;
    font-style: italic;
}
code {
    background: #1a1a3e;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #a0c4ff;
}
.code-block {
    display: block;
    margin: 0.4rem 0;
    padding: 0.5rem 0.8rem;
    background: #1a1a3e;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.8rem;
    color: #a0c4ff;
    word-break: break-all;
    user-select: all;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #444;
    border-top-color: #a0c4ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

/* Hint text */
.hint {
    font-size: 0.8rem;
    color: #808080;
    margin-top: 0.3rem;
    margin-bottom: 0;
}

/* Fingerprint display */
.fingerprint-display {
    position: fixed;
    bottom: 3.5rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 20px;
    font-size: 0.75rem;
    font-family: "Courier New", monospace;
    z-index: 100;
}
.fingerprint-label { font-size: 0.85rem; }
.fingerprint-text { color: #a0c4ff; letter-spacing: 0.05rem; }
.fingerprint-status { font-size: 0.75rem; }
.fingerprint-status.verified { color: #4caf50; }
.fingerprint-status.mismatch { color: #f44336; }
.fingerprint-status.unverified { color: #ff9800; }

.fingerprint-inline {
    font-family: "Courier New", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.03rem;
}

/* Helper view layout */
#view-helper .panel {
    margin: auto;
}
