:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary: #a855f7;
    --accent: #22d3ee;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --success: #10b981;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 95vw;
    height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
}

/* Header Styling */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px var(--primary-glow));
}

.logo h1 {
    font-weight: 800;
    letter-spacing: -0.5px;
    font-size: 1.8rem;
}

.logo h1 span {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1.25rem;
    border-radius: 999px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    backdrop-filter: blur(10px);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34, 211, 238, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}

/* Main Layout */
main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    min-height: 0;
}

.vision-container {
    position: relative;
    background: #000;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

#input-video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.4;
}

#output-canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 2;
}

.gesture-overlay {
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    z-index: 10;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 1.5rem 2.5rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#gesture-name {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#gesture-emoji {
    font-size: 3.5rem;
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Controls Panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
}

.card h3 {
    font-size: 1rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gesture-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gesture-list li {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.gesture-list li.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateX(5px);
}

.confidence-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--accent));
    transition: width 0.3s ease;
}

#confidence-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #4f46e5;
    box-shadow: 0 0 20px var(--primary-glow);
}

.btn-secondary {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    background: var(--bg-card);
    padding: 0.25rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.btn-toggle {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-dim);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.btn-toggle.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Alphabet Grid */
.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
}

.char-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.char-box.active {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.1);
}

/* Magnified Char */
.magnified-char {
    font-size: 6rem;
    font-weight: 900;
    background: linear-gradient(to bottom, #fff, var(--text-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: -1rem;
}

.hidden {
    display: none !important;
}

/* History List */
.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
    padding-right: 5px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.85rem;
    animation: slide-in-right 0.3s ease-out;
}

.history-item .time {
    color: var(--text-dim);
    font-size: 0.7rem;
}

.empty-msg {
    color: var(--text-dim);
    font-size: 0.8rem;
    text-align: center;
    padding: 1rem 0;
}

/* Stats Styling */
.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-item span:last-child {
    font-weight: 600;
    color: var(--accent);
}

@keyframes slide-in-right {
    from { transform: translateX(10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Lock Animation */
.gesture-overlay.locked {
    border-color: var(--success);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
    transform: scale(1.05);
}

/* Scrollable Panel */
.controls-panel {
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-gutter: stable;
}

.controls-panel::-webkit-scrollbar {
    width: 6px;
}

.controls-panel::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    gap: 1.5rem;
    transition: opacity 0.5s;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid #FFF;
    border-bottom-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    padding: 1rem;
}
