/* =====================================================
   GRAFT COUNTER - ULTRA PREMIUM DESIGN SYSTEM
   Dark theme matching the landing page aesthetics
   ===================================================== */

/* CSS Variables - Premium Design Tokens */
:root {
    /* Base Colors - Dark Theme */
    --bg-primary: #050A14;
    --bg-secondary: #0A1628;
    --bg-tertiary: #0F1D32;
    --bg-card: rgba(15, 29, 50, 0.6);
    --bg-dark: #050A14;
    --bg-panel-overlay: rgba(15, 22, 40, 0.85);
    --accent-glow-strong: rgba(20, 184, 166, 0.3);
    --bg-elevated: #112240;

    /* Borders */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.05);
    --border-hover: rgba(255, 255, 255, 0.15);
    --border-focus: rgba(20, 184, 166, 0.4);

    /* Text Colors */
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-inverse: #FFFFFF;

    /* Medical Accent */
    --accent-primary: #14B8A6;
    --accent-primary-light: #2DD4BF;
    --accent-primary-dark: #0D9488;
    --accent-gradient: linear-gradient(135deg, #0D9488 0%, #14B8A6 50%, #2DD4BF 100%);
    --accent-glow: rgba(20, 184, 166, 0.12);

    /* Secondary */
    --accent-secondary: #3B82F6;
    --accent-secondary-light: #60A5FA;

    /* Status */
    --success: #10B981;
    --success-light: rgba(16, 185, 129, 0.15);
    --danger: #EF4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --warning: #F59E0B;

    /* Marker */
    --marker-color: #10B981;

    /* Shadows - Layered for depth (Dark theme) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    --shadow-accent: 0 4px 14px rgba(20, 184, 166, 0.15);
    --shadow-accent-lg: 0 8px 30px rgba(20, 184, 166, 0.2);

    /* Border Radius */
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Subtle Background Gradient (pages without landing layers, e.g. app) */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(20, 184, 166, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(59, 130, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

body.app-page {
    background: var(--bg-dark);
}

body.app-page::before {
    display: none;
}

/* =====================================================
   LANDING-ALIGNED APP SHELL (index.html parity)
   ===================================================== */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.bg-glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: orbFloat 20s ease-in-out infinite;
}

.bg-glow-orb:nth-child(1) {
    width: 600px;
    height: 600px;
    background: var(--accent-primary-dark);
    top: -10%;
    left: -5%;
}

.bg-glow-orb:nth-child(2) {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    top: 50%;
    right: -10%;
    animation-delay: -7s;
    opacity: 0.2;
}

.bg-glow-orb:nth-child(3) {
    width: 500px;
    height: 500px;
    background: #8B5CF6;
    bottom: -15%;
    left: 30%;
    animation-delay: -14s;
    opacity: 0.15;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 0.6;
        transform: scale(1);
    }
    90% {
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: translateY(-20vh) scale(0.5);
    }
}

.page-content {
    position: relative;
    z-index: 1;
}

/* Fixed nav — same structure as landing */
.app-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0 2rem;
    transition: background 0.4s ease, border-color 0.4s ease, backdrop-filter 0.4s ease;
}

.app-nav.scrolled {
    background: rgba(5, 10, 20, 0.8);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid var(--border-color);
}

.app-nav .nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.app-nav .nav-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.app-nav .nav-logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(20, 184, 166, 0.15);
}

.app-nav .nav-logo-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-inverse);
}

.app-nav .nav-logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-inverse);
    letter-spacing: -0.02em;
}

.app-nav .nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.app-nav .nav-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    position: relative;
}

.app-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent-primary);
    transition: width 0.3s ease;
    border-radius: 1px;
}

.app-nav .nav-link:hover {
    color: var(--text-inverse);
}

.app-nav .nav-link:hover::after {
    width: 100%;
}

.app-nav .nav-auth {
    gap: 0.75rem;
    flex-shrink: 0;
}

.app-nav .nav-auth .header-actions {
    margin-top: 0;
    justify-content: flex-end;
}

/* App hero strip — landing hero-badge styling */
.app-hero-strip {
    text-align: center;
    margin-bottom: 1.25rem;
    padding: 0 0.5rem;
}

.app-hero-strip .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.4375rem 1.25rem 0.4375rem 0.4375rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.app-hero-strip .badge-pulse {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-hero-strip .badge-pulse::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-light));
    opacity: 0.4;
    animation: badgePulse 2s ease-in-out infinite;
}

.app-hero-strip .badge-pulse svg {
    width: 14px;
    height: 14px;
    color: white;
    position: relative;
    z-index: 1;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.5); opacity: 0; }
}

.app-hero-subtitle {
    font-size: 0.9375rem;
    color: var(--text-muted);
    max-width: 28rem;
    margin: 0 auto;
    line-height: 1.5;
}

.app-hero-note {
    display: none;
    margin: -0.15rem auto 0.65rem;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(251, 191, 36, 0.45);
    background: rgba(251, 191, 36, 0.14);
    color: #fef3c7;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.35;
    max-width: 34rem;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

@media (max-width: 900px) {
    .app-hero-note {
        display: inline-flex;
    }
}

body.app-page {
    --bg-card: rgba(255, 255, 255, 0.04);
    --border-color: rgba(255, 255, 255, 0.08);
}

/* App Container */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.25rem 1.25rem;
}

body.app-page .page-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 4.75rem;
}

body.app-page .app-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding-top: 0.5rem;
}

body.app-page .app-container .patient-info-display:not(.hidden) {
    margin-bottom: 0.75rem;
}

body.app-page .upload-area {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* =====================================================
   HEADER - Compact & Premium
   ===================================================== */
.header {
    text-align: center;
    padding: 2rem 0 1.5rem;
    margin-bottom: 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

/* Matches landing page .nav-logo / .nav-logo-icon / .nav-logo-text */
.logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.logo-icon-wrap {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-light));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(20, 184, 166, 0.15);
    flex-shrink: 0;
}

.logo-icon-wrap svg {
    width: 20px;
    height: 20px;
    color: var(--text-inverse);
}

.logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-inverse);
    letter-spacing: -0.02em;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Medical Badge */
.medical-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.875rem;
    background: var(--accent-glow);
    border: 1px solid rgba(13, 148, 136, 0.15);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   UPLOAD SECTION
   ===================================================== */
.upload-section {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem;
}

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 520px;
    padding: 3.5rem 3rem;
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-2xl);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--accent-primary);
    border-style: solid;
    background: linear-gradient(180deg, rgba(20, 184, 166, 0.06) 0%, var(--bg-card) 100%);
    box-shadow: var(--shadow-lg), var(--shadow-accent);
    transform: translateY(-2px);
}

.upload-area.drag-over {
    transform: scale(1.01) translateY(-2px);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    color: var(--accent-primary);
    transition: all var(--transition-normal);
}

.upload-area:hover .upload-icon {
    background: var(--accent-glow);
    transform: translateY(-4px);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-area h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.upload-area p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.upload-area .upload-hint {
    font-size: 0.8125rem;
    margin-top: -0.75rem;
    margin-bottom: 1.25rem;
    line-height: 1.4;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.upload-btn {
    padding: 0.75rem 2rem;
    background: var(--accent-gradient);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm), var(--shadow-accent);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-accent-lg);
}

.upload-btn:active {
    transform: translateY(0);
}

/* =====================================================
   EDITOR SECTION
   ===================================================== */
.editor-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.75rem;
    animation: fadeIn 0.4s ease;
}

.editor-section.hidden {
    display: none;
}

/* =====================================================
   TOOLBAR - Clean & Unified
   ===================================================== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    gap: 1.5rem;
    flex-wrap: wrap;
    box-shadow: var(--shadow-sm);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 0.375rem;
}

.toolbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
    flex: initial;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tool-btn svg {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.tool-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.tool-btn:hover svg {
    color: var(--text-secondary);
}

.tool-btn.danger:hover {
    background: var(--danger-light);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.tool-btn.danger:hover svg {
    color: var(--danger);
}

/* Image Navigation */
.image-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-glow);
    border-color: rgba(13, 148, 136, 0.2);
    color: var(--accent-primary);
}

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

.nav-btn svg {
    width: 15px;
    height: 15px;
}

.image-counter {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}

/* =====================================================
   MARKER SETTINGS
   ===================================================== */
.marker-settings {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 1.5rem;
    padding: 0.625rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.marker-settings-palette {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

.palette-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
    max-width: 28rem;
}

.palette-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-height: 14rem;
    overflow-y: auto;
    padding: 0.125rem 0.25rem 0.125rem 0;
}

.palette-list-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.palette-list-item--active {
    border-color: rgba(20, 184, 166, 0.45);
    background: rgba(20, 184, 166, 0.08);
}

.palette-name-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Fixed popup on document.body — not inside #palette-list (avoids layout / overflow issues) */
.palette-name-tooltip.palette-name-tooltip--popup {
    position: fixed;
    z-index: 10050;
    max-width: min(19rem, calc(100vw - 2rem));
    padding: 0.625rem 1rem;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.01em;
    text-align: center;
    border: 2px solid #0f172a;
    border-radius: 16px;
    box-shadow: 5px 5px 0 rgba(15, 23, 42, 0.14);
    pointer-events: none;
}

.palette-name-tooltip.palette-name-tooltip--popup::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 11px solid transparent;
    border-right: 11px solid transparent;
    border-top: 12px solid #0f172a;
    z-index: 0;
}

.palette-name-tooltip.palette-name-tooltip--popup::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translate(-50%, -3px);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 9px solid #ffffff;
    z-index: 1;
}

.palette-name-field {
    width: 100%;
    min-width: 0;
    padding: 0.4375rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.palette-name-field:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.palette-add-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    flex-wrap: wrap;
}

.palette-add-color {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.palette-add-color:hover {
    border-color: var(--accent-primary);
}

.palette-add-row .palette-add-name-input {
    flex: 1;
    min-width: 8rem;
}

.palette-add-row .add-color-btn {
    flex-shrink: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.75rem;
    border-style: solid;
}

.setting-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setting-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.setting-group input[type="color"] {
    width: 34px;
    height: 34px;
    padding: 3px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.setting-group input[type="color"]:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.setting-group input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.setting-group input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.setting-group input[type="range"] {
    width: 80px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    appearance: none;
    cursor: pointer;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 4px rgba(13, 148, 136, 0.3);
}

.setting-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
}

.setting-group #marker-size-value {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 18px;
    text-align: center;
}

/* Color Name Input */
.color-name-input {
    padding: 0.4375rem 0.625rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-family: inherit;
    width: 130px;
    transition: all var(--transition-fast);
}

.color-name-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.color-name-input::placeholder {
    color: var(--text-muted);
}

.palette-add-row .color-name-input {
    width: auto;
    max-width: none;
    flex: 1;
    min-width: 0;
}

/* =====================================================
   COLOR BREAKDOWN
   ===================================================== */
.color-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.color-breakdown:empty {
    display: none;
}

.color-item {
    display: flex;
    align-items: center;
    gap: 0.4375rem;
    padding: 0.3125rem 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
}

.color-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.color-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.color-count {
    color: var(--text-primary);
    font-weight: 700;
}

/* =====================================================
   ZOOM TOOLBAR
   ===================================================== */
.zoom-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.zoom-btn:hover {
    background: var(--accent-glow);
    border-color: rgba(13, 148, 136, 0.2);
    color: var(--accent-primary);
}

.zoom-btn svg {
    width: 15px;
    height: 15px;
}

.zoom-btn.text-btn {
    width: auto;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.zoom-level {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 48px;
    text-align: center;
    padding: 0 0.375rem;
}

/* =====================================================
   CANVAS CONTAINER
   ===================================================== */
.canvas-container {
    position: relative;
    flex: 1;
    min-height: min(400px, 55vh);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 899px) {
    .canvas-container {
        min-height: min(680px, 76vh);
    }

    .canvas-view {
        min-height: 360px;
    }

    .canvas-main-column .toolbar.toolbar--below-canvas {
        gap: 0.45rem 0.6rem;
        padding: 0.45rem 0.5rem;
    }
}

.canvas-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    min-width: 0;
    align-items: stretch;
    width: 100%;
}

.canvas-main-column {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.canvas-view-stack {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.canvas-view {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-view-stack.has-user-height .canvas-view {
    flex: 0 0 auto;
    height: var(--canvas-user-height, 400px);
    min-height: 180px;
}

.canvas-resize-handle {
    display: flex;
    flex-shrink: 0;
    height: 14px;
    cursor: ns-resize;
    touch-action: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, var(--bg-tertiary) 100%);
    border-top: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.canvas-resize-handle::after {
    content: '';
    width: 64px;
    height: 5px;
    border-radius: 2px;
    background: var(--text-muted);
    opacity: 0.65;
}

.canvas-resize-handle:hover::after,
.canvas-resize-handle.is-dragging::after {
    opacity: 0.85;
    background: var(--accent-primary);
}

.canvas-main-column .toolbar.toolbar--below-canvas {
    flex-shrink: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    box-shadow: none;
    background: var(--bg-secondary);
    padding: 0.5rem 0.75rem;
    gap: 0.75rem 1rem;
}

#main-canvas {
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
}

.canvas-mode-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.375rem;
    padding: 0.625rem 0.5rem;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    width: 4.5rem;
}

.canvas-mode-toolbar-label {
    font-size: 0.5625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.2;
}

.canvas-mode-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.canvas-mode-divider {
    height: 1px;
    margin: 0.125rem 0;
    background: var(--border-color);
    opacity: 0.85;
}

.canvas-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    width: 100%;
    padding: 0.45rem 0.2rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.15;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.canvas-mode-btn:hover {
    background: var(--accent-glow);
    border-color: rgba(13, 148, 136, 0.25);
    color: var(--accent-primary);
}

.canvas-mode-btn.is-active {
    background: rgba(13, 148, 136, 0.15);
    border-color: rgba(13, 148, 136, 0.45);
    color: var(--accent-primary);
    box-shadow: inset 0 0 0 1px rgba(13, 148, 136, 0.12);
}

.canvas-mode-btn-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
}

.canvas-mode-btn--icon {
    padding: 0.4rem 0.2rem;
}

.canvas-mode-btn--icon svg {
    width: 1rem;
    height: 1rem;
    display: block;
    margin: 0 auto;
}

.canvas-mode-btn--delete {
    color: var(--text-secondary);
}

.canvas-mode-btn--delete:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.35);
    color: #dc2626;
}

.canvas-mode-btn--delete:focus-visible {
    outline: 2px solid rgba(220, 38, 38, 0.45);
    outline-offset: 2px;
}

.canvas-mode-btn--delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.canvas-mode-btn-text {
    display: block;
    text-align: center;
}

@media (max-width: 640px) {
    .canvas-workspace {
        flex-direction: column;
    }

    .canvas-mode-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding: 0.5rem 0.625rem;
        gap: 0.5rem;
    }

    .canvas-mode-toolbar-label {
        width: 100%;
        text-align: center;
    }

    .canvas-mode-group {
        flex-direction: row;
        flex: 1;
        justify-content: center;
    }

    .canvas-mode-divider {
        width: 1px;
        height: 1.75rem;
        margin: 0 0.25rem;
    }
}

.zoom-hint {
    position: absolute;
    bottom: 0.875rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: var(--bg-panel-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
    transition: opacity var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

/* =====================================================
   COUNTER PANEL
   ===================================================== */
.counter-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.counter-panel-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem 1rem;
    padding: 0.625rem 1.25rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow: visible;
}

.counter-panel-toolbar .graft-limit-display {
    margin-right: auto;
    padding: 0.35rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    min-height: 2.25rem;
    box-sizing: border-box;
}

.counter-panel-btn-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* visible only on mobile (≤900px), hidden on desktop */
.mobile-only {
    display: none !important;
}

/* ── Image thumbnail carousel ── */
.image-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    scrollbar-width: none;
    max-width: 50%;
    min-height: 52px;
    padding: 0.25rem;
    flex: 1 1 0;
}

.image-carousel::-webkit-scrollbar { display: none; }

.carousel-thumb {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.1s;
    outline: none;
}

.carousel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.carousel-thumb:hover {
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.carousel-thumb--active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-glow, rgba(20,184,166,0.35));
}

.carousel-thumb-badge {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1;
    background: rgba(0,0,0,0.65);
    color: #fff;
    border-radius: 3px;
    padding: 1px 3px;
    pointer-events: none;
}

.counter-panel-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.125rem 1.25rem 1.25rem;
}

.counter-stats-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}

@media (max-width: 640px) {
    .counter-stats-row {
        grid-template-columns: 1fr;
    }
}

.counter-stat-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.125rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 0;
}

.counter-stat-card--total {
    border-color: rgba(20, 184, 166, 0.25);
    background: linear-gradient(165deg, rgba(20, 184, 166, 0.08) 0%, var(--bg-secondary) 100%);
}

.counter-stat-card--target {
    border-color: rgba(255, 255, 255, 0.08);
}

.counter-stat-card-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.counter-stat-card-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    line-height: 1.35;
    margin: 0;
    font-weight: 500;
}

.upload-hint--session {
    margin-top: 0.5rem;
    max-width: 28rem;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.45;
}

.counter-stat-card .counter-value {
    font-size: 2.25rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: left;
    line-height: 1.05;
    letter-spacing: -0.03em;
    min-width: 0;
}

.counter-target-value-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
}

.counter-target-num {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.counter-target-pct {
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    color: var(--accent-primary-light, #2dd4bf);
    padding: 0.35rem 0.7rem;
    background: linear-gradient(
        135deg,
        rgba(20, 184, 166, 0.24) 0%,
        rgba(20, 184, 166, 0.1) 100%
    );
    border: 1px solid rgba(20, 184, 166, 0.4);
    border-radius: var(--radius-full);
    white-space: nowrap;
    box-shadow:
        0 0 0 1px rgba(20, 184, 166, 0.1) inset,
        0 2px 10px rgba(0, 0, 0, 0.15);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

.counter-target-progress {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 0.125rem;
}

.counter-target-progress-fill {
    height: 100%;
    width: 0%;
    max-width: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.35s ease;
}

.counter-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

.counter-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 72px;
    text-align: center;
    line-height: 1;
    letter-spacing: -0.03em;
}

.counter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.download-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent-gradient);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm), var(--shadow-accent);
}

.download-btn svg {
    width: 16px;
    height: 16px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-accent-lg);
}

.download-btn:active {
    transform: translateY(0);
}

/* =====================================================
   FOOTER
   ===================================================== */
.footer {
    text-align: center;
    padding: 1.25rem 0;
    margin-top: 0.75rem;
}

.footer p {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.footer-legal-app {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    margin-top: 0.5rem;
}

.footer-legal-app a {
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-decoration: none;
}

.footer-legal-app a:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.footer-legal-app-sep {
    color: var(--text-muted);
    font-size: 0.625rem;
    user-select: none;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.hidden {
    display: none !important;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */
@media (max-width: 768px) {
    .app-container {
        padding: 0 0.75rem 0.75rem;
    }

    .app-nav .nav-links:not(.nav-auth) {
        display: none;
    }

    .app-nav {
        padding: 0 1rem;
    }

    .app-nav .nav-inner {
        padding: 1rem 0;
    }

    .logo-text {
        font-size: 1rem;
    }

    .logo-icon-wrap {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .logo-icon-wrap svg {
        width: 18px;
        height: 18px;
    }

    .app-nav .nav-logo-icon {
        width: 34px;
        height: 34px;
        border-radius: 9px;
    }

    .app-nav .nav-logo-icon svg {
        width: 18px;
        height: 18px;
    }

    .app-nav .nav-logo-text {
        font-size: 1rem;
    }

    .header-actions {
        margin-top: 0;
        gap: 0.4rem;
    }

    .app-nav .nav-auth {
        gap: 0;
    }

    .mobile-session-trigger {
        display: inline-flex;
    }

    .auth-btn {
        padding: 0.4375rem 0.6875rem;
    }

    .auth-btn span {
        display: none;
    }

    .user-info {
        gap: 0.375rem;
    }

    .user-name {
        display: none;
    }

    .user-avatar,
    .settings-btn,
    .logout-btn {
        width: 32px;
        height: 32px;
    }

    .premium-badge {
        font-size: 0.5625rem;
        padding: 0.16rem 0.45rem;
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .premium-badge.premium-badge--upgrade {
        max-width: min(9.5rem, 52vw);
        font-size: 0.5rem;
    }

    .upload-area {
        padding: 2.5rem 1.5rem;
    }

    .upload-icon {
        width: 52px;
        height: 52px;
        padding: 0.875rem;
    }

    .upload-area h2 {
        font-size: 1.125rem;
    }

    .upload-btn,
    .upload-area .mobile-session-trigger {
        width: 100%;
        max-width: 220px;
        min-height: 40px;
        justify-content: center;
    }

    .upload-area .mobile-session-trigger {
        margin-top: 0.95rem;
    }

    .toolbar {
        justify-content: center;
        padding: 0.625rem;
    }

    .toolbar-left,
    .toolbar-center,
    .toolbar-right {
        width: 100%;
        justify-content: center;
    }

    .tool-btn span {
        display: none;
    }

    .marker-settings {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.65rem;
        padding: 0.625rem;
        align-items: stretch;
        border-radius: var(--radius-sm);
    }

    .marker-settings-palette {
        width: 100%;
    }

    .palette-toolbar {
        max-width: none;
        gap: 0.5rem;
    }

    .palette-label {
        font-size: 0.75rem;
        letter-spacing: 0.06em;
    }

    .palette-list {
        max-height: 7.2rem;
        padding-right: 0.125rem;
    }

    .palette-list-item {
        padding: 0.28rem 0.35rem;
        gap: 0.45rem;
    }

    .palette-name-field {
        padding: 0.4rem 0.55rem;
        font-size: 0.78rem;
    }

    .palette-add-row {
        display: grid;
        grid-template-columns: 34px 1fr auto;
        gap: 0.4rem;
        align-items: center;
    }

    .palette-add-color {
        width: 34px;
        height: 34px;
    }

    .palette-add-row .palette-add-name-input {
        min-width: 0;
    }

    .palette-add-row .add-color-btn {
        min-height: 34px;
        padding: 0.38rem 0.62rem;
        font-size: 0.7rem;
    }

    .setting-divider {
        display: none;
    }

    .setting-group {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 0.35rem 0.5rem;
        width: 100%;
        padding: 0.5rem 0.6rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-sm);
        background: var(--bg-secondary);
        align-items: center;
    }

    .setting-group label {
        grid-column: 1 / -1;
        font-size: 0.74rem;
        font-weight: 600;
    }

    .setting-group input[type=\"range\"] {
        width: 100%;
        min-width: 0;
    }

    .setting-group #marker-size-value {
        justify-self: end;
        min-width: 1.45rem;
        text-align: center;
        font-size: 0.8rem;
    }

    .counter-panel-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem 0.75rem;
    }

    .mobile-only {
        display: flex !important;
    }

    .counter-panel-toolbar .graft-limit-display {
        margin-right: 0;
        justify-content: center;
    }

    .image-carousel {
        max-width: 100%;
        width: 100%;
        min-height: 60px;
        justify-content: center;
        padding: 0.375rem 0.5rem;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        overflow-y: visible;
    }

    .carousel-thumb {
        width: 52px;
        height: 52px;
        flex-shrink: 0;
    }

    .counter-panel-btn-group {
        flex-direction: column;
    }

    .counter-stat-card .counter-value {
        text-align: center;
    }

    .counter-target-value-row {
        justify-content: center;
    }

    .counter-value {
        font-size: 2.75rem;
    }

    .download-btn,
    .action-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .canvas-container {
        min-height: min(620px, 74vh);
    }

    .canvas-view {
        min-height: 330px;
    }

    .carousel-thumb {
        width: 44px;
        height: 44px;
    }

    .setting-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    .color-name-input {
        width: 100%;
        max-width: 180px;
    }
}

/* =====================================================
   MODALS - Premium Glass Morphism
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(5, 10, 20, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: modalFadeIn 0.25s ease;
}

.modal.hidden {
    display: none;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl), 0 0 60px rgba(0, 0, 0, 0.4);
    max-width: 440px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 0;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.modal-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.125rem;
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.modal-body {
    padding: 1.5rem;
}

/* Form Styles - Refined */
.form-group {
    margin-bottom: 1.125rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6875rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-submit {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-gradient);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm), var(--shadow-accent);
}

.form-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), var(--shadow-accent-lg);
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.6875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.google-login-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.125rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.form-link {
    display: block;
    text-align: center;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.form-link a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.form-link a:hover {
    text-decoration: underline;
}

/* =====================================================
   HEADER AUTH UI
   ===================================================== */
.header-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.875rem;
}

.mobile-session-trigger {
    display: none;
    width: auto;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 0.95rem;
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.mobile-session-trigger:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

.mobile-session-trigger svg {
    width: 16px;
    height: 16px;
}

.auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.auth-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

.auth-btn svg {
    width: 15px;
    height: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

/* =====================================================
   AUTH & FORM ENHANCEMENTS
   ===================================================== */
.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-row .form-group {
    flex: 1;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
    padding: 0 1rem;
}

.google-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.6875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.google-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
}

.google-icon {
    width: 18px;
    height: 18px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: var(--accent-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.premium-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a1a;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 700;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: default;
    max-width: 100%;
}

.premium-badge:disabled {
    opacity: 1;
}

.premium-badge.premium-badge--upgrade {
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.5625rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.premium-badge.premium-badge--upgrade:hover {
    filter: brightness(1.06);
    transform: scale(1.02);
}

.premium-badge.premium-badge--upgrade:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.logout-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.logout-btn svg {
    width: 16px;
    height: 16px;
}

.logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

/* Patient Info Display */
.patient-info-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4375rem 0.875rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    margin-top: 0.625rem;
}

.patient-label {
    color: var(--text-muted);
}

.patient-value {
    font-weight: 600;
    color: var(--text-primary);
}

.patient-divider {
    color: var(--text-muted);
}

.patient-date {
    color: var(--text-secondary);
}

/* =====================================================
   PAYWALL MODAL (aligned with landing promo-fomo card)
   ===================================================== */
.paywall-content {
    max-width: min(1000px, 96vw);
}

#paywall-modal .paywall-content--promo {
    position: relative;
    max-width: min(920px, 96vw);
    padding: 2.5rem 1.75rem 1.5rem;
    background: linear-gradient(155deg, rgba(15, 29, 50, 0.96) 0%, rgba(8, 18, 35, 0.99) 100%);
    border: 1px solid rgba(20, 184, 166, 0.35);
    border-radius: var(--radius-xl);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 24px 80px rgba(0, 0, 0, 0.55),
        0 0 60px rgba(20, 184, 166, 0.12);
    overflow: hidden;
}

#paywall-modal .paywall-glow {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.35) 0%, transparent 70%);
    top: -100px;
    right: -80px;
    pointer-events: none;
    filter: blur(10px);
}

#paywall-modal .paywall-fomo-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

#paywall-modal .paywall-fomo-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-inverse);
}

.paywall-header {
    text-align: center;
    padding: 0 0.5rem 1.25rem;
    position: relative;
    z-index: 1;
}

#paywall-modal .paywall-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #0f172a;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.35);
}

.paywall-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-inverse);
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.paywall-subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.55;
    max-width: 36rem;
    margin-left: auto;
    margin-right: auto;
}

#paywall-modal .paywall-quota-info {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0 0 1rem;
}

.plans-grid--paywall {
    align-items: stretch;
}

#paywall-modal .plan-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.35rem 1.25rem 1.25rem;
    text-align: center;
    transition: all var(--transition-normal);
    position: relative;
    border-radius: var(--radius-lg);
}

#paywall-modal .plan-card--free {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#paywall-modal .plan-card--premium {
    border: 1px solid rgba(20, 184, 166, 0.45);
    background: linear-gradient(180deg, rgba(20, 184, 166, 0.12) 0%, rgba(0, 0, 0, 0.2) 100%);
    box-shadow: 0 0 40px rgba(20, 184, 166, 0.08);
}

#paywall-modal .plan-card--premium::before {
    content: '50% OFF';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #0f172a;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
    pointer-events: none;
}

#paywall-modal .paywall-content--pro-user .plan-card--premium::before {
    display: none;
}

#paywall-modal .paywall-price-row--single {
    justify-content: center;
}

#paywall-modal .paywall-price-note-pro {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.45;
}

.plan-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-inverse);
    margin-bottom: 0.5rem;
}

.plan-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    margin-bottom: 0.25rem;
}

#paywall-modal .plan-price--free {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.125rem;
    margin-bottom: 0.5rem;
}

#paywall-modal .plan-price-amount-free {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-inverse);
    letter-spacing: -0.02em;
}

#paywall-modal .plan-price--free .plan-price-suffix {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

#paywall-modal .plan-price--premium {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#paywall-modal .paywall-price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

#paywall-modal .paywall-price-was {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-thickness: 2px;
}

#paywall-modal .paywall-price-now {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent-primary-light), var(--accent-primary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--accent-primary);
}

#paywall-modal .paywall-price-meta {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    width: 100%;
    margin-top: 0.25rem;
    line-height: 1.4;
}

#paywall-modal .paywall-price-save {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.45;
}

#paywall-modal .paywall-price-save strong {
    color: #fbbf24;
    font-weight: 700;
}

.plan-features {
    list-style: none;
    margin: 1rem 0 0;
    flex: 1 1 auto;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    text-align: left;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.plan-features li::before {
    content: '\2713';
    color: var(--success);
    font-weight: 700;
    font-size: 0.75rem;
}

.plan-select-btn {
    width: 100%;
    padding: 0.625rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

#paywall-modal .plan-card .plan-select-btn {
    margin-top: auto;
}

#paywall-modal .plan-select-btn--outline {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
}

#paywall-modal .plan-select-btn--outline:hover {
    border-color: rgba(255, 255, 255, 0.22);
    color: var(--text-inverse);
}

#paywall-modal .plan-select-btn--cta {
    position: relative;
    z-index: 2;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-light));
    border: none;
    color: #fff;
    font-size: 0.9375rem;
    font-weight: 700;
    box-shadow: 0 0 28px var(--accent-glow-strong);
}

#paywall-modal .plan-select-btn--cta:hover {
    box-shadow: 0 0 40px var(--accent-glow-strong);
}

.plan-select-btn:hover {
    transform: translateY(-2px);
}

.paywall-footer {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0.5rem 0 0;
    box-sizing: border-box;
}

#paywall-modal .paywall-dismiss-link {
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#paywall-modal .paywall-dismiss-link:hover {
    color: var(--text-secondary);
}

/* =====================================================
   GRAFT LIMIT DISPLAY
   ===================================================== */
.graft-limit-display {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0;
}

.limit-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.limit-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.limit-text {
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.upgrade-link {
    background: none;
    border: none;
    color: var(--accent-primary);
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.premium-badge-small {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1a1a1a;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 700;
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    animation: toastSlideUp 0.3s ease;
    font-size: 0.875rem;
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.toast-fade-out {
    animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastFadeOut {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
}

/* =====================================================
   COUNTER PANEL ADDITIONS
   ===================================================== */
.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

.action-btn svg {
    width: 15px;
    height: 15px;
}

@media (max-width: 600px) {
    .plans-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   SIDEBAR - Session History
   ===================================================== */
.app-layout {
    display: flex;
    flex: 1;
    gap: 0.75rem;
    min-height: 0;
}

.sidebar {
    width: 272px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 52px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.sidebar-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar.collapsed .sidebar-title span {
    display: none;
}

.sidebar-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.sidebar-toggle {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--accent-glow);
    border-color: rgba(13, 148, 136, 0.2);
    color: var(--accent-primary);
}

.sidebar-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.625rem;
}

.new-session-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--accent-glow, rgba(20,184,166,0.1));
    border: 1px dashed var(--accent-primary, #14B8A6);
    border-radius: var(--radius-md);
    color: var(--accent-primary, #14B8A6);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.new-session-btn:hover {
    background: rgba(20,184,166,0.18);
    color: var(--accent-primary-light, #2DD4BF);
}

.sidebar.collapsed .sidebar-content {
    display: none;
}

/* Session Items */
.session-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.session-item:hover {
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

.session-item.active {
    border-color: var(--accent-primary);
    background: var(--accent-glow);
}

.session-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

.session-grafts {
    display: flex;
    align-items: center;
    gap: 0.1875rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.session-date {
    color: var(--text-muted);
}

.session-delete {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.session-item:hover .session-delete {
    opacity: 1;
}

.session-delete:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.session-delete svg {
    width: 12px;
    height: 12px;
}

.palette-list-item .session-delete {
    flex-shrink: 0;
    align-self: center;
    opacity: 1;
}

.palette-list-item .session-delete svg {
    pointer-events: none;
}

/* Empty State */
.sidebar-empty {
    text-align: center;
    padding: 2rem 0.75rem;
    color: var(--text-muted);
}

.sidebar-empty svg {
    width: 36px;
    height: 36px;
    margin-bottom: 0.625rem;
    opacity: 0.4;
}

.sidebar-empty p {
    font-size: 0.75rem;
}

/* Main Content Area */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Responsive Sidebar */
@media (max-width: 900px) {
    .header-actions {
        margin-top: 0;
        gap: 0.4rem;
    }

    .app-nav .nav-auth {
        gap: 0;
    }

    .mobile-session-trigger {
        display: inline-flex;
        margin-top: 0.55rem;
    }

    .upload-area .mobile-session-trigger {
        width: 100%;
        max-width: 220px;
    }

    .auth-btn {
        padding: 0.4375rem 0.6875rem;
    }

    .auth-btn span {
        display: none;
    }

    .user-info {
        gap: 0.375rem;
    }

    .user-name {
        display: none;
    }

    .user-avatar,
    .settings-btn,
    .logout-btn {
        width: 32px;
        height: 32px;
    }

    .premium-badge {
        font-size: 0.5625rem;
        padding: 0.16rem 0.45rem;
        max-width: 5.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .premium-badge.premium-badge--upgrade {
        max-width: min(9.5rem, 52vw);
        font-size: 0.5rem;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 4.5rem;
        bottom: 0;
        z-index: 1200;
        width: 272px;
        border-radius: 0;
        border-left: none;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open.collapsed {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 272px;
        transform: translateX(-100%);
    }

    .sidebar.collapsed .sidebar-title span,
    .sidebar.collapsed .sidebar-content {
        display: initial;
    }

    .sidebar.collapsed .sidebar-content {
        display: block;
    }

    .sidebar-overlay {
        position: fixed;
        top: 4.5rem;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 1190;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-sidebar-toggle {
        display: flex;
    }
}

@media (min-width: 901px) {
    .mobile-sidebar-toggle,
    .sidebar-overlay {
        display: none;
    }
}

.mobile-sidebar-toggle {
    display: none;
    position: fixed;
    left: 0.875rem;
    bottom: 0.875rem;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: var(--shadow-lg), var(--shadow-accent);
    cursor: pointer;
    z-index: 98;
}

.mobile-sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

/* =====================================================
   ACCURACY DISPLAY
   ===================================================== */
.accuracy-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.625rem;
    font-weight: 700;
}

.accuracy-badge.excellent {
    background: rgba(16, 185, 129, 0.15);
    color: #34D399;
}

.accuracy-badge.good {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
}

.accuracy-badge.fair {
    background: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
}

.accuracy-badge.poor {
    background: rgba(239, 68, 68, 0.15);
    color: #F87171;
}

.accuracy-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.accuracy-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.accuracy-bar-fill.excellent {
    background: linear-gradient(90deg, #10B981, #34D399);
}

.accuracy-bar-fill.good {
    background: linear-gradient(90deg, #3B82F6, #60A5FA);
}

.accuracy-bar-fill.fair {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.accuracy-bar-fill.poor {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

/* =====================================================
   PALETTE & TOOLBAR STYLES
   ===================================================== */

.palette-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* Color swatch button (left of name in list row) */
.palette-list .palette-swatch {
    -webkit-appearance: none;
    appearance: none;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-xs);
    display: flex;
    align-items: center;
    justify-content: center;
}

.palette-list .palette-swatch:hover {
    transform: scale(1.06);
    box-shadow: var(--shadow-sm);
}

.palette-list-item--active .palette-swatch {
    border-color: var(--text-inverse);
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent-primary);
    transform: scale(1.05);
}

/* Add Color Button */
.add-color-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3125rem 0.625rem;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-color-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.add-color-btn svg {
    width: 12px;
    height: 12px;
}

/* Setting Divider */
.setting-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

/* Color Picker in Modal */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-color-input {
    width: 100px;
    height: 40px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Paywall layout width (padding lives on .paywall-content--promo) */
#paywall-modal .modal-content {
    max-width: min(920px, 96vw);
}

/* Mobile Paywall: full-page style below fixed top nav */
@media (max-width: 900px) {
    #paywall-modal {
        padding: 4.5rem 0 0;
        align-items: flex-start;
        justify-content: flex-start;
        background: rgba(5, 10, 20, 0.9);
    }

    #paywall-modal .modal-content {
        width: 100vw;
        max-width: none;
        height: calc(100dvh - 4.5rem);
        max-height: calc(100dvh - 4.5rem);
        margin: 0;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        border-left: none;
        border-right: none;
        border-top: none;
        overflow-y: auto;
    }

    #paywall-modal .paywall-content--promo {
        padding: 1.15rem 0.95rem 1rem;
    }

    #paywall-modal .paywall-header {
        padding: 0 0.35rem 0.8rem;
    }

    #paywall-modal .paywall-fomo-close {
        top: 0.6rem;
        right: 0.55rem;
        width: 34px;
        height: 34px;
    }

    #paywall-modal .plans-grid--paywall {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    #paywall-modal .plan-card {
        padding: 1.05rem 0.9rem 1rem;
    }

    #paywall-modal .paywall-footer {
        padding-bottom: 0.4rem;
    }
}

@media (max-width: 768px) {
    .paywall-title {
        font-size: 1.2rem;
    }

    .paywall-subtitle {
        font-size: 0.875rem;
    }

    #paywall-modal .paywall-price-now {
        font-size: 2.05rem;
    }
}

/* =====================================================
   SETTINGS & ACCOUNT MANAGEMENT
   ===================================================== */
.settings-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.settings-btn svg {
    width: 18px;
    height: 18px;
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1.75rem 0;
}

.danger-zone {
    border: 1px solid rgba(239, 68, 68, 0.15);
    background: rgba(239, 68, 68, 0.03);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.danger-zone h3 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--danger);
    margin-bottom: 0.375rem;
}

.danger-zone p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.delete-account-btn {
    padding: 0.625rem 1rem;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.delete-account-btn:hover {
    background: var(--danger);
    color: white;
}

/* Mobile: settings should feel like a full page, not a cramped popup */
@media (max-width: 900px) {
    #settings-modal {
        padding: 4.5rem 0 0;
        align-items: flex-start;
        justify-content: flex-start;
        background: rgba(5, 10, 20, 0.9);
    }

    #settings-modal .modal-content {
        width: 100vw;
        max-width: none;
        height: calc(100dvh - 4.5rem);
        max-height: calc(100dvh - 4.5rem);
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
        border-left: none;
        border-right: none;
        border-top: none;
        margin: 0;
        display: flex;
        flex-direction: column;
    }

    #settings-modal .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 0.9rem 1rem;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--border-color);
    }

    #settings-modal .modal-title {
        font-size: 1.1rem;
        line-height: 1.3;
    }

    #settings-modal .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 1rem;
    }

    #settings-modal .form-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    #settings-modal .form-group {
        margin-bottom: 0.9rem;
    }

    #settings-modal .settings-divider {
        margin: 1.1rem 0;
    }

    #settings-modal .danger-zone {
        padding: 1rem;
    }
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.btn-cancel {
    padding: 0.625rem 1.125rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cancel:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.save-session-modal-hint {
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

#save-session-modal .modal-actions .form-submit {
    width: auto;
    min-width: 140px;
    flex-shrink: 0;
}

.btn-danger {
    padding: 0.625rem 1.125rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* Utilities */
.text-danger {
    color: var(--danger) !important;
}

.mb-4 {
    margin-bottom: 1rem !important;
}
