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

:root {
    --bg:        #0b0f1a;
    --surface:   #141926;
    --surface2:  #1c2436;
    --border:    rgba(255,255,255,0.08);
    --text:      #e8edf5;
    --muted:     rgba(255,255,255,0.38);
    --accent:    #38bdf8;
    --green:     #4ade80;
    --yellow:    #fbbf24;
    --red:       #f87171;
    --radius:    14px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Nunito', sans-serif;
    height: 100vh; width: 100vw;
    overflow: hidden;
    user-select: none;
}
.mono { font-family: 'JetBrains Mono', monospace; }

#input-video { position: fixed; left: -9999px; }

/* ─── MODALS ──────────────────────────────────────────────── */
.overlay-modal {
    position: fixed; inset: 0; z-index: 500;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5,8,20,0.94);
    backdrop-filter: blur(4px);
}
.overlay-modal.hidden { display: none; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.2rem 2.6rem;
    max-width: 480px; width: 94%;
    box-shadow: 0 32px 80px rgba(0,0,0,0.7);
    animation: fadeUp 0.4s cubic-bezier(0.22,1,0.36,1);
    max-height: 92vh; overflow-y: auto;
}
.modal-box.wide { max-width: 640px; }

@keyframes fadeUp {
    from { opacity:0; transform: translateY(20px) scale(0.97); }
    to   { opacity:1; transform: translateY(0)    scale(1);    }
}

.modal-logo {
    font-size: 3.2rem; text-align: center; margin-bottom: 0.6rem;
    animation: swing 2s ease-in-out infinite;
}
@keyframes swing {
    0%,100% { transform: rotate(-6deg); }
    50%     { transform: rotate(6deg);  }
}

h1 {
    text-align: center; font-size: 1.8rem; font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 40%, var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 0.5rem;
}
.modal-sub {
    text-align: center; font-size: 0.88rem; color: var(--muted);
    line-height: 1.7; margin-bottom: 1.4rem;
}

.info-grid {
    display: grid; grid-template-columns: repeat(3,1fr); gap: 0.6rem;
    margin-bottom: 1.3rem;
}
.info-item {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 0.75rem 0.5rem;
    text-align: center; font-size: 0.75rem; color: var(--muted);
    line-height: 1.5;
}
.info-icon { display: block; font-size: 1.4rem; margin-bottom: 0.3rem; }

.hand-select {
    display: flex; gap: 0.6rem; margin-bottom: 1.1rem;
}
.hand-btn {
    flex: 1; padding: 0.55rem;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; color: var(--muted);
    font-family: 'Nunito',sans-serif; font-weight: 900;
    font-size: 0.82rem; letter-spacing: 2px; cursor: pointer;
    transition: all 0.15s;
}
.hand-btn.active {
    background: rgba(56,189,248,0.15);
    border-color: rgba(56,189,248,0.5);
    color: var(--accent);
}

.primary-btn {
    width: 100%; padding: 0.9rem;
    background: linear-gradient(135deg, #0369a1, #38bdf8);
    border: none; border-radius: 12px; color: white;
    font-family: 'Nunito',sans-serif; font-size: 1.05rem;
    font-weight: 900; letter-spacing: 2px; cursor: pointer;
    box-shadow: 0 4px 20px rgba(56,189,248,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
.primary-btn:hover { transform: scale(1.02); box-shadow: 0 0 28px rgba(56,189,248,0.6); }

.secondary-btn {
    padding: 0.9rem 1.6rem;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 12px; color: var(--text);
    font-family: 'Nunito',sans-serif; font-size: 1rem;
    font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.secondary-btn:hover { background: var(--surface); border-color: rgba(255,255,255,0.2); }

.danger-btn {
    padding: 0.55rem 1.2rem;
    background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3);
    border-radius: 10px; color: var(--red);
    font-family: 'Nunito',sans-serif; font-size: 0.82rem;
    font-weight: 900; letter-spacing: 1px; cursor: pointer;
    transition: all 0.15s;
}
.danger-btn:hover:not(:disabled) { background: rgba(248,113,113,0.25); }
.danger-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.privacy {
    text-align: center; font-size: 0.66rem;
    color: rgba(255,255,255,0.22); margin-top: 0.7rem;
}

/* ─── TOP BAR ──────────────────────────────────────────────── */
#top-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: 52px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.2rem;
    padding-right: 200px; /* Kamera Aktif badge için alan */
}

/* Kamera Aktif badge'ini top-bar ile hizala */
#cn-active-badge {
    top: 10px !important;
}

.bar-left { display: flex; align-items: center; gap: 1rem; }
#hand-badge {
    font-size: 0.7rem; font-weight: 900; letter-spacing: 2px;
    color: var(--accent); background: rgba(56,189,248,0.12);
    border: 1px solid rgba(56,189,248,0.3);
    border-radius: 6px; padding: 0.25rem 0.6rem;
}
#session-timer { font-size: 1.3rem; color: var(--yellow); letter-spacing: 3px; }

.bar-center { display: flex; align-items: center; gap: 0.5rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-wait   { background: var(--muted); }
.dot-active { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
#status-text { font-size: 0.82rem; color: var(--muted); font-weight: 700; }

/* ─── APP LAYOUT ───────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }
#app.hidden { display: none; }

#main-content {
    display: flex;
    margin-top: 52px;
    height: calc(100vh - 52px);
    overflow: hidden;
}

/* ─── CAM PANEL ────────────────────────────────────────────── */
#cam-panel {
    position: relative;
    flex: 0 0 auto;
    width: 50%;
    background: #080c16;
    border-right: 1px solid var(--border);
}
#skeleton-canvas {
    width: 100%; height: 100%;
    display: block;
}
#cam-label {
    position: absolute; bottom: 10px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.62rem; letter-spacing: 2px;
    color: var(--muted); font-weight: 700;
}

/* ─── METRICS PANEL ────────────────────────────────────────── */
#metrics-panel {
    flex: 1;
    display: flex; flex-direction: column;
    gap: 0.7rem; padding: 0.9rem 1rem;
    overflow-y: auto;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
}
.metric-title {
    font-size: 0.58rem; letter-spacing: 3px; font-weight: 900;
    color: var(--muted); margin-bottom: 0.65rem;
}

/* Grip score */
.grip-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.grip-pct { font-size: 1.8rem; font-weight: 900; color: var(--accent); font-family: 'JetBrains Mono', monospace; }
.grip-bar-track {
    height: 10px; background: rgba(255,255,255,0.07);
    border-radius: 5px; overflow: hidden; margin-bottom: 0.35rem;
}
.grip-bar-fill {
    height: 100%; width: 0%; border-radius: 5px;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8, #7dd3fc);
    transition: width 0.18s, background 0.3s;
}
.grip-sub {
    display: flex; justify-content: space-between;
    font-size: 0.62rem; color: var(--muted);
}
#grip-max-label { color: var(--yellow); font-weight: 700; }

/* Finger bars */
.finger-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.finger-row { display: flex; align-items: center; gap: 0.7rem; }
.finger-name {
    width: 68px; font-size: 0.72rem; font-weight: 700;
    color: var(--muted); flex-shrink: 0;
}
.finger-track {
    flex: 1; height: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 4px; overflow: hidden;
}
.finger-fill {
    height: 100%; border-radius: 4px;
    transition: width 0.18s, background 0.3s;
}
.finger-deg {
    width: 38px; text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem; font-weight: 700;
}

/* Joint detail */
.joint-detail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
}
.joint-cell {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px; padding: 0.45rem 0.5rem;
    text-align: center;
}
.joint-cell-name { font-size: 0.58rem; color: var(--muted); letter-spacing: 1px; margin-bottom: 0.2rem; }
.joint-cell-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem; font-weight: 700;
}

/* Session max */
.session-max {
    display: flex; gap: 0.4rem; flex-wrap: wrap;
}
.max-chip {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.35rem 0.65rem;
    display: flex; flex-direction: column; align-items: center;
}
.max-chip-name { font-size: 0.55rem; color: var(--muted); letter-spacing: 1px; }
.max-chip-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem; font-weight: 700; color: var(--yellow);
}

/* ─── REPORT ───────────────────────────────────────────────── */
.report-title { font-size: 1.4rem; font-weight: 900; margin-bottom: 0.8rem; text-align: center; }

.report-meta {
    display: flex; gap: 1rem; justify-content: center;
    font-size: 0.8rem; color: var(--muted); margin-bottom: 1.2rem;
}

.report-section { margin-bottom: 1.2rem; }
.report-section h3 {
    font-size: 0.68rem; letter-spacing: 2px; color: var(--muted);
    font-weight: 900; margin-bottom: 0.7rem;
}

.report-angles {
    display: grid; grid-template-columns: repeat(5,1fr); gap: 0.5rem;
}
.ra-cell {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 0.6rem 0.4rem; text-align: center;
}
.ra-name  { font-size: 0.6rem; color: var(--muted); margin-bottom: 0.3rem; }
.ra-val   { font-family: 'JetBrains Mono',monospace; font-size: 1.3rem; font-weight: 700; }
.ra-sub   { font-size: 0.6rem; color: var(--muted); }

.report-compare {
    display: grid; grid-template-columns: repeat(5,1fr); gap: 0.5rem;
}
.cmp-cell {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 0.5rem 0.4rem; text-align: center;
}
.cmp-name   { font-size: 0.58rem; color: var(--muted); margin-bottom: 0.25rem; }
.cmp-delta  { font-size: 1rem; font-weight: 900; }
.cmp-delta.pos { color: var(--green); }
.cmp-delta.neg { color: var(--red); }
.cmp-delta.neu { color: var(--muted); }

.modal-actions { display: flex; gap: 0.7rem; margin-top: 0.5rem; }
.modal-actions .primary-btn { flex: 1; }

#report-chart { border-radius: 8px; background: var(--surface2); display: block; width: 100%; }
