:root {
    --bg-page: #f9fafb;
    --bg-card: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent: #0f172a;
    --accent-hover: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    background: var(--bg-card);
    width: 100%;
    max-width: 440px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 32px;
}

header {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

header p {
    color: var(--text-secondary);
    font-size: 13px;
}

.tabs {
    display: flex;
    background: var(--bg-page);
    border-radius: 6px;
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.mode-view { display: none; }
.mode-view.active { display: block; }

/* User Guidance Hint */
.input-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.canvas-wrapper, .camera-wrapper {
    width: 240px;
    height: 240px;
    margin: 0 auto 16px auto;
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--border-color);
    position: relative;
}

#draw-canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
    /* Removed the scaleX(-1) mirror effect here! */
}

#target-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.primary-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--accent);
    color: #ffffff;
    border: none;
    width: 100%;
    padding: 14px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    margin-bottom: 24px;
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.primary-btn:disabled {
    opacity: 0.8;
    cursor: not-allowed;
}

.secondary-btn {
    display: block;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px;
    font-size: 13px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.secondary-btn:hover {
    background: var(--bg-page);
}

.results-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-page);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.vision-divider {
    width: 1px;
    height: 48px;
    background: var(--border-color);
}

.prediction-box, .vision-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 48%;
}

.label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 600;
}

#result-text {
    font-size: 36px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1;
}

#ai-vision {
    width: 60px;  /* Slightly larger so you can see the smooth lines */
    height: 60px;
    background: #000000;
    border-radius: 6px;
    /* Removed the 'image-rendering: pixelated' line so it stays smooth */
    border: 1px solid var(--border-color);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

/* Animations */
.hidden { display: none !important; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.processing-pulse {
    animation: pulseText 1s infinite alternate;
    color: var(--text-secondary) !important;
}

@keyframes pulseText {
    from { opacity: 0.4; }
    to { opacity: 1; }
}