:root {
    --bg: #121212;
    --bg-raised: #1e1e1e;
    --bg-topbar: #212121;
    --bg-hover: #2a2a2a;
    --accent: #00ffcc;
    --danger: #ff3b3b;
    --warn: #ffb347;
    --text: #ffffff;
    --muted: #aaa;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
}

/* === Topbar (YouTube uslubidagi) === */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: var(--bg-topbar);
    border-bottom: 1px solid #333;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: bold;
    color: var(--accent);
}

.logo-icon {
    width: 0;
    height: 0;
    border-left: 14px solid var(--accent);
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
}

.topbar-actions .btn {
    font-size: 13px;
    padding: 6px 12px;
}

/* === Asosiy layout: main + aside === */
.layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.main {
    flex: 1;
    min-width: 0;
}

.subtitle {
    color: #888;
    margin: 0 0 12px;
    text-align: center;
}

/* === Video === */
.container {
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-raised);
    line-height: 0;
    width: 100%;
}

#video {
    transform: scaleX(-1);
    visibility: hidden;
    width: 0;
    height: 0;
}

#canvas {
    transform: scaleX(-1);
    background-color: #2a2a2a;
    display: block;
    width: 100%;
    height: auto;
}

#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: var(--accent);
    line-height: 1.4;
    text-align: center;
    padding: 0 16px;
}

.error-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    color: var(--danger);
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    line-height: 1.4;
    max-width: 90%;
}

.status-card,
.set-banner {
    margin-top: 16px;
    padding: 15px 20px;
    background: var(--bg-raised);
    border-radius: 8px;
    border: 2px solid var(--accent);
    text-align: center;
    width: 100%;
}

.status-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
}

.exercise-name {
    font-size: 22px;
    font-weight: bold;
    color: var(--accent);
    margin: 6px 0;
    min-height: 28px;
}

.count-line {
    font-size: 34px;
    font-weight: bold;
    margin: 4px 0;
}

.count-label {
    font-size: 16px;
    color: var(--muted);
    font-weight: normal;
}

.form-warnings {
    color: var(--warn);
    font-size: 14px;
    margin-top: 6px;
    min-height: 18px;
}

.set-banner {
    font-size: 18px;
    color: var(--accent);
}

.set-banner .btn {
    margin-top: 10px;
}

/* === Sidebar (aside, YouTube uslubida) === */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
}

.side-section,
.side-panel {
    background: var(--bg-raised);
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #2f2f2f;
}

/* Demo autentifikatsiya kartasi */
.auth-card {
    border-color: var(--accent);
}

.auth-user {
    font-size: 16px;
    font-weight: bold;
    color: var(--accent);
    padding: 0 8px;
}

.auth-mode {
    font-size: 12px;
    color: var(--muted);
    padding: 2px 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.auth-device {
    margin-top: 8px;
    padding: 8px;
    background: #141414;
    border-radius: 6px;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}

.device-id-text {
    color: var(--text);
    font-family: monospace;
}

.side-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    padding: 4px 8px 8px;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Mashq tugmalari nav elementlari kabi */
.side-item,
.exercise-btn {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s, color 0.15s;
}

.side-item::before,
.exercise-btn::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    flex-shrink: 0;
}

.side-item:hover,
.exercise-btn:hover {
    background: var(--bg-hover);
}

.exercise-btn.active {
    background: var(--bg-hover);
    color: var(--accent);
}

.exercise-btn.active::before {
    background: var(--accent);
}

.side-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn:hover {
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.off {
    border-color: var(--danger);
    color: var(--danger);
}

.btn.full {
    width: 100%;
}

.today-summary {
    color: var(--text);
    margin: 8px 0;
    font-size: 14px;
}

/* === Reja (plan) kartasi === */
.plan-card {
    border-color: var(--accent);
}

.plan-goal {
    font-size: 13px;
    color: var(--muted);
    padding: 0 4px 6px;
}

.plan-calories {
    text-align: center;
    padding: 6px 0 10px;
}

.plan-cal-value {
    font-size: 34px;
    font-weight: bold;
    color: var(--accent);
}

.plan-unit {
    font-size: 14px;
    color: var(--muted);
    font-weight: normal;
}

.plan-macros {
    display: flex;
    gap: 8px;
}

.macro {
    flex: 1;
    background: #141414;
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
}

.macro-val {
    display: block;
    font-size: 15px;
    font-weight: bold;
    color: var(--text);
}

.macro-name {
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.plan-extra {
    font-size: 12px;
    color: var(--muted);
    padding: 10px 4px 0;
}

.plan-preview {
    margin-top: 10px;
    font-size: 13px;
    color: var(--accent);
    background: #141414;
    border-radius: 6px;
    padding: 8px;
    min-height: 16px;
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-box {
    background: var(--bg-raised);
    border: 1px solid #333;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 14px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
    flex: 1;
}

.field input,
.field select {
    background: #141414;
    border: 1px solid #333;
    border-radius: 8px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
}

.row {
    display: flex;
    gap: 10px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
}

.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    font-weight: bold;
}

.btn.primary:hover {
    background: #4dffdd;
}

#chart {
    width: 100%;
    height: 120px;
    background: #141414;
    border-radius: 6px;
}

#ai-text {
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 20px;
    margin: 8px 0;
}

/* === Namoyish (3D mashq demo) === */
.demo-panel {
    text-align: center;
}

.demo-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #101318;
}

#demo-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.demo-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 13px;
    background: #101318;
}

.demo-hint {
    color: var(--muted);
    font-size: 12px;
    margin: 8px 0 0;
}

/* === Mobil === */
@media (max-width: 860px) {
    .layout {
        flex-direction: column;
        padding: 14px;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
        overflow: visible;
    }

    .topbar {
        padding: 8px 14px;
    }
}
