/* ==========================================
   DonutPoll - Styles
   Playful, clean, delightful
   ========================================== */

/* CSS Custom Properties */
:root {
    /* Colors - Light Mode - Warm cream tones */
    --bg-primary: #FAF8F5;
    --bg-secondary: #F7F4EF;
    --bg-card: #FFFCF8;
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --text-muted: #A0AEC0;
    --border-light: rgba(0, 0, 0, 0.06);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(255, 107, 157, 0.15);
    
    /* Accent Colors - Donut Palette */
    --accent-pink: #FF6B9D;
    --accent-coral: #FF8E72;
    --accent-peach: #FF9A8B;
    --accent-teal: #4ECDC4;
    --accent-yellow: #FFE66D;
    --accent-purple: #A78BFA;
    --accent-mint: #34D399;
    --accent-blue: #60A5FA;
    
    /* Chart Colors */
    --chart-1: #FF6B9D;
    --chart-2: #4ECDC4;
    --chart-3: #FFE66D;
    --chart-4: #A78BFA;
    --chart-5: #34D399;
    --chart-6: #60A5FA;
    --chart-7: #FF8E72;
    --chart-8: #F472B6;
    
    /* Frosting effect */
    --frosting-gradient: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    
    /* Border Radius - Rounded everything! */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transitions */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out-back: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-floaty: cubic-bezier(0.22, 1, 0.36, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
    --duration-slower: 800ms;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #1A1B26;
    --bg-secondary: #1F2937;
    --bg-card: #24283B;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border-light: rgba(255, 255, 255, 0.08);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: none; /* Disabled - causes edge cutoff on mobile */
    --frosting-gradient: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 50%);
}

/* ==========================================
   Base Styles
   ========================================== */

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

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

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color var(--duration-normal) var(--ease-smooth),
                color var(--duration-normal) var(--ease-smooth);
}

/* ==========================================
   Layout
   ========================================== */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-md);
    padding-bottom: var(--space-lg); /* Extra space for card shadow */
    overflow-x: hidden; /* Only hide horizontal overflow */
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin-bottom: var(--space-sm);
    max-width: 600px; /* Match card width */
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: stretch;
    padding: var(--space-sm) 0;
    padding-bottom: var(--space-md); /* Space for shadow */
    min-height: 0; /* Allow flex shrinking */
    overflow: visible;
}

.footer {
    text-align: center;
    padding: var(--space-sm) 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* On mobile, hide footer on chart views to give more space */
@media (max-width: 600px) {
    /* Hide footer only on results/chart views */
    .app:has(.poll-card[data-view="results"]) .footer {
        display: none;
    }
    
    .main {
        padding: var(--space-xs) 0;
    }
    
    /* Allow voting view and bar chart to scroll beyond viewport */
    .app:has(.poll-card[data-view="voting"]),
    .app:has(.poll-results[data-view="bar"]) {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }
    
    /* Keep donut chart view constrained to viewport */
    .app:has(.poll-results[data-view="donut"]) {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
    
    /* Voting view - allow options to scroll */
    .poll-card[data-view="voting"] {
        flex: none;
        height: auto;
    }
    
    .poll-card[data-view="voting"] .poll-options {
        flex: none;
    }
    
    /* Bar chart view - allow scrolling */
    .poll-card[data-view="results"]:has(.poll-results[data-view="bar"]) {
        flex: none;
        height: auto;
    }
}

.footer .heart {
    color: var(--accent-pink);
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ==========================================
   Logo
   ========================================== */

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    width: 50px;
    height: 50px;
    color: var(--accent-pink);
    filter: drop-shadow(0 2px 4px rgba(255, 107, 157, 0.3));
    transition: transform var(--duration-normal) var(--ease-smooth);
}

.logo:hover .logo-icon {
    transform: scale(1.05);
}

[data-theme="dark"] .logo-icon {
    color: var(--accent-coral);
}

.logo-text {
    font-size: 1.625rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-coral));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Hide logo text on small screens when in app header (charting page) */
@media (max-width: 420px) {
    .header .logo-text {
        display: none;
    }
    
    .header .logo-icon {
        width: 50px;
        height: 50px;
    }
}

/* ==========================================
   Header Actions (Theme Toggle & Chart Toggle)
   ========================================== */

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-card);
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--duration-normal) var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.header-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-medium);
}

.header-btn:active {
    transform: scale(0.95);
}

/* Header action buttons (revote, share) */
.header-action-btn {
    opacity: 0;
    animation: headerBtnFadeIn 0.3s ease forwards;
}

@keyframes headerBtnFadeIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

#changeVoteBtn:hover {
    color: var(--accent-pink);
    background: rgba(255, 107, 157, 0.1);
}

#sharePollBtn:hover {
    color: var(--accent-purple);
    background: rgba(167, 139, 250, 0.1);
}

/* Chart view toggle icons */
.chart-view-toggle .bar-icon,
.chart-view-toggle .donut-icon {
    position: absolute;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.chart-view-toggle .donut-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chart-view-toggle.showing-bars .bar-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chart-view-toggle.showing-bars .donut-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Theme toggle icons */
.theme-toggle .sun-icon,
.theme-toggle .moon-icon {
    position: absolute;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

[data-theme="dark"] .theme-toggle .sun-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

[data-theme="dark"] .theme-toggle .moon-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* ==========================================
   Poll Container
   ========================================== */

.poll-container {
    width: 100%;
    max-width: 560px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex shrinking */
}

.poll-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: 
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 8px rgba(0, 0, 0, 0.04),
        0 8px 16px rgba(0, 0, 0, 0.03);
    padding: var(--space-lg);
    position: relative;
    overflow: visible;
    transition: all var(--duration-normal) var(--ease-smooth);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Allow flex shrinking */
}

[data-theme="dark"] .poll-card {
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.1);
}

@media (max-width: 600px) {
    .poll-card {
        padding: var(--space-md);
        border-radius: var(--radius-lg);
    }
}

/* Landscape mode on mobile - optimize horizontal space */
@media (max-height: 500px) and (orientation: landscape) {
    .app-container {
        padding: 0;
        height: 100vh;
        overflow: hidden;
    }
    
    .header {
        display: none;
    }
    
    .main {
        padding: var(--space-xs);
        flex: 1;
        height: 100vh;
    }
    
    .poll-container {
        max-width: none;
        height: 100%;
    }
    
    .poll-card {
        padding: var(--space-sm);
        border-radius: var(--radius-md);
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    /* Compact question at top */
    .question {
        font-size: 0.8rem;
        margin-bottom: 0;
        padding: 0;
        flex-shrink: 0;
    }
    
    .question .emoji {
        font-size: 0.85rem;
    }
    
    /* Chart area fills remaining space */
    .chart-area {
        flex: 1;
        min-height: 0;
        overflow: visible;
        margin: 0;
    }
    
    /* Hide options list in landscape - chart only */
    .options-list {
        display: none;
    }
    
    .footer {
        display: none;
    }
    
    /* Debug controls in landscape */
    .debug-controls {
        padding: 4px !important;
        bottom: 4px !important;
    }
    
    .debug-controls button {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
}

.poll-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-pink), var(--accent-coral), var(--accent-yellow), var(--accent-teal));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    opacity: 0.7;
}

/* Hide gradient bar in light mode for cleaner look */
:root .poll-card::before {
    opacity: 0;
}

/* Decorative sprinkles on card - DISABLED to prevent layout issues
.poll-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background-image: 
        radial-gradient(circle at 20% 30%, var(--accent-pink) 2px, transparent 2px),
        radial-gradient(circle at 60% 20%, var(--accent-teal) 1.5px, transparent 1.5px),
        radial-gradient(circle at 80% 50%, var(--accent-yellow) 2px, transparent 2px),
        radial-gradient(circle at 40% 70%, var(--accent-purple) 1.5px, transparent 1.5px);
    opacity: 0.4;
    pointer-events: none;
}
*/

/* ==========================================
   Question
   ========================================== */

.poll-question {
    font-size: clamp(1.15rem, 5vw, 1.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    line-height: 1.3;
    text-align: center;
}

/* ==========================================
   Options (Voting State)
   ========================================== */

.poll-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Skip to Results button */
.skip-to-results {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    padding: var(--space-md) 0;
    margin-top: var(--space-sm);
    transition: all 0.2s var(--ease-floaty);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
}

.skip-to-results:hover {
    color: var(--accent-pink);
}

.skip-to-results .skip-arrow {
    transition: transform 0.2s var(--ease-floaty);
}

.skip-to-results:hover .skip-arrow {
    transform: translateX(4px);
}

.poll-option {
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    overflow: hidden;
}

.poll-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--frosting-gradient);
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.poll-option:hover {
    border-color: var(--accent-pink);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.2);
}

.poll-option:hover::before {
    opacity: 1;
}

.poll-option:active {
    transform: translateY(0) scale(0.98);
}

.poll-option.selected {
    border-color: var(--accent-pink);
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.1), rgba(255, 142, 114, 0.05));
}

.option-radio {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    border: 2px solid var(--text-muted);
    transition: all var(--duration-normal) var(--ease-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.option-radio::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    background: var(--accent-pink);
    transform: scale(0);
    transition: transform var(--duration-normal) var(--ease-bounce);
}

.poll-option:hover .option-radio {
    border-color: var(--accent-pink);
}

.poll-option.selected .option-radio {
    border-color: var(--accent-pink);
}

.poll-option.selected .option-radio::after {
    transform: scale(1);
}

.option-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    position: relative;
    z-index: 1;
}

/* Vote ripple effect */
.poll-option .ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-pink) 0%, transparent 70%);
    transform: scale(0);
    animation: ripple 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ==========================================
   Results View
   ========================================== */

/* Chart area wrapper - fills remaining space in poll-card */
#chartArea {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex children */
    overflow: visible;
}

.poll-results {
    opacity: 0;
    animation: fadeInUp var(--duration-slow) var(--ease-smooth) forwards;
    position: relative;
    overflow: visible;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex children */
}

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

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 0;
    min-height: 0; /* Allow flex to control size */
    position: relative;
    overflow: visible;
    flex: 1;
}

/* Donut wrapper - positions labels */
.donut-wrapper {
    position: relative;
    overflow: visible;
}

/* Donut Chart - Hero visualization */
.donut-svg {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.donut-segment {
    transition: transform var(--duration-normal) var(--ease-smooth);
    transform-origin: center;
    cursor: pointer;
}

/* Only apply hover on devices with fine pointer (mouse) to avoid sticky hover on touch */
@media (hover: hover) and (pointer: fine) {
    .donut-segment:hover {
        transform: scale(1.03);
        filter: brightness(1.05);
    }
}

.donut-hole {
    fill: var(--bg-card);
}

.donut-center-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    fill: var(--text-primary);
    text-anchor: middle;
    dominant-baseline: middle;
}

.donut-center-label {
    font-size: 14px;
    fill: var(--text-secondary);
}

.donut-center-value {
    font-size: 32px;
    fill: var(--text-primary);
}

/* Leader lines and labels */
.chart-label {
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 600;
    fill: var(--text-primary);
}

.chart-label-percent {
    font-weight: 700;
}

.leader-line {
    stroke: var(--text-muted);
    stroke-width: 1;
    fill: none;
    opacity: 0.6;
}

/* Bar Chart */
.bar-chart {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-md);
}

.bar-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    position: relative;
    z-index: 1;
    padding-left: 12px;
}

/* Colored accent line on left side of each bar row */
.bar-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--bar-accent-color, var(--accent-pink));
    border-radius: 2px;
    transition: background 0.3s var(--ease-floaty);
}

/* User vote indicator - shown on the bar the user voted for */
.user-vote-icon {
    margin-left: 4px;
    font-size: 0.85em;
}

.bar-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.bar-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.bar-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.bar-votes {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.bar-track {
    height: 36px;
    background: transparent;
    border-radius: var(--radius-full);
    overflow: visible;
    position: relative;
}

.bar-fill-svg {
    border-radius: var(--radius-full);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.bar-percentage {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 700;
    font-size: 0.8125rem;
    font-family: 'Nunito', sans-serif;
    white-space: nowrap;
    color: var(--text-primary);
    opacity: 0.7;
    margin-left: 8px;
    transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* When percentage is inside the bar (for high percentages like 100%) */
.bar-percentage-inside {
    position: absolute;
    right: 12px;
    left: auto;
    margin-left: 0;
    color: white;
    opacity: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

@keyframes barGrow {
    to {
        transform: scaleX(1);
    }
}

/* ==========================================
   Mobile Bar Legend (hidden by default)
   ========================================== */

.mobile-bar-legend {
    display: none;
    margin-top: 0;
}

.mobile-bar-legend .bar-chart {
    gap: 0;
}

.mobile-bar-legend .bar-item {
    padding: 6px 0;
    gap: 4px;
}

.mobile-bar-legend .bar-item.selected {
    padding: 6px var(--space-sm);
    margin: 0 calc(-1 * var(--space-sm));
}

.mobile-bar-legend .bar-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

.mobile-bar-legend .bar-label {
    font-size: 0.8125rem;
}

.mobile-bar-legend .bar-track {
    height: 8px;
    position: relative;
}

/* Move percentage to header row in mobile */
.mobile-bar-legend .bar-percentage {
    position: static !important;
    transform: none !important;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted) !important;
    text-shadow: none !important;
}

.mobile-bar-legend .bar-fill {
    overflow: hidden;
}

.mobile-bar-legend .sort-toggle-btn {
    display: none !important;
}

/* ==========================================
   Results Meta
   ========================================== */

.results-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.meta-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

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

/* Change Vote Button */
.meta-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.share-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    background: transparent;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.share-btn:hover {
    border-color: var(--accent-purple);
    color: var(--accent-purple);
    background: rgba(167, 139, 250, 0.05);
}

.share-btn svg {
    flex-shrink: 0;
}

.change-vote-btn {
    background: transparent;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.change-vote-btn:hover {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
    background: rgba(255, 107, 157, 0.05);
}

/* Poll Actions Container - outside card */
.poll-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-top: var(--space-md);
    flex-wrap: wrap;
    opacity: 0;
    animation: fadeInUp 0.4s ease 0.3s forwards;
}

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

.poll-actions .change-vote-btn,
.poll-actions .share-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.poll-actions .change-vote-btn svg,
.poll-actions .share-btn svg {
    flex-shrink: 0;
}

/* Chart Toggle Button - icon-only overlay */
.chart-toggle-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-light);
    border-radius: 50%;
    padding: 0;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

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

/* Ensure chart-container is positioned for absolute children */
.chart-container {
    position: relative;
}

.chart-toggle-btn:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    background: rgba(78, 205, 196, 0.08);
    transform: translateY(-1px);
}

.chart-toggle-btn:active {
    transform: translateY(0) scale(0.98);
}

.chart-toggle-btn svg {
    flex-shrink: 0;
}

/* ==========================================
   Legend
   ========================================== */

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    padding: 0 var(--space-md);
    width: 100%;
    max-width: 400px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-smooth);
    background: var(--bg-secondary);
}

.legend-item:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.legend-item.selected {
    color: var(--text-primary);
    font-weight: 600;
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.08), rgba(255, 142, 114, 0.04));
    border: 1px solid rgba(255, 107, 157, 0.2);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.legend-label {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.legend-votes {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* ==========================================
   Animations
   ========================================== */

/* Staggered option animation */
.poll-option {
    opacity: 0;
    animation: optionSlideIn var(--duration-slow) var(--ease-smooth) forwards;
}

.poll-option:nth-child(1) { animation-delay: 150ms; }
.poll-option:nth-child(2) { animation-delay: 200ms; }
.poll-option:nth-child(3) { animation-delay: 250ms; }
.poll-option:nth-child(4) { animation-delay: 300ms; }
.poll-option:nth-child(5) { animation-delay: 350ms; }
.poll-option:nth-child(6) { animation-delay: 400ms; }

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

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

/* Bar stagger animation */
.bar-item:nth-child(1) .bar-fill { animation-delay: 0ms; }
.bar-item:nth-child(2) .bar-fill { animation-delay: 80ms; }
.bar-item:nth-child(3) .bar-fill { animation-delay: 160ms; }
.bar-item:nth-child(4) .bar-fill { animation-delay: 240ms; }
.bar-item:nth-child(5) .bar-fill { animation-delay: 320ms; }
.bar-item:nth-child(6) .bar-fill { animation-delay: 400ms; }

/* Morph transition container */
.chart-morph-container {
    transition: all var(--duration-slower) var(--ease-smooth);
}

/* ==========================================
   Responsive - Fluid scaling, no breakpoint jumps
   ========================================== */

/* Chart container always scales naturally */
.chart-container {
    min-height: auto;
    padding: 0;
    overflow: visible;
}

.chart-container svg {
    max-width: 100%;
    max-height: 100%;
}

/* Mobile bar legend stays hidden - we show full donut with labels */
.mobile-bar-legend {
    display: none !important;
}

/* Results meta stacks vertically on narrow screens */
.results-meta {
    flex-wrap: wrap;
    gap: var(--space-sm);
}

/* ==========================================
   Share Modal
   ========================================== */

.share-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease-floaty), visibility 0.3s var(--ease-floaty);
}

.share-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.share-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-medium);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s var(--ease-bounce);
}

.share-modal-overlay.open .share-modal {
    transform: scale(1) translateY(0);
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

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

.share-modal-close {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s var(--ease-floaty);
}

.share-modal-close:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.share-link-container {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.share-link-input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.share-copy-btn {
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-coral));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--ease-floaty);
    white-space: nowrap;
}

.share-copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 157, 0.3);
}

.share-copy-btn.copied {
    background: var(--accent-mint);
}

.share-social {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

.share-social-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-floaty);
    color: white;
}

.share-social-btn:hover {
    transform: translateY(-2px) scale(1.1);
}

.share-social-btn.twitter {
    background: #1DA1F2;
}

.share-social-btn.facebook {
    background: #4267B2;
}

.share-social-btn.linkedin {
    background: #0A66C2;
}

.share-social-btn.email {
    background: var(--text-secondary);
}

/* ==========================================
   Confirmation Modal (Pause/Resume)
   ========================================== */
.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s var(--ease-floaty), visibility 0.2s var(--ease-floaty);
    padding: var(--space-md);
}

.confirm-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.confirm-modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.2s var(--ease-floaty);
}

.confirm-modal-overlay.open .confirm-modal {
    transform: scale(1);
}

.confirm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.confirm-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.confirm-modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.confirm-modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.confirm-modal-message {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: var(--space-lg);
}

.confirm-modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.confirm-modal-btn {
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.confirm-modal-btn.cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

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

.confirm-modal-btn.confirm {
    background: var(--accent-pink);
    color: white;
}

.confirm-modal-btn.confirm:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Pause button states */
#pausePollBtn.paused .pause-icon {
    display: none;
}

#pausePollBtn.paused .resume-icon {
    display: block;
}

#pausePollBtn:not(.paused) .pause-icon {
    display: block;
}

#pausePollBtn:not(.paused) .resume-icon {
    display: none;
}

/* Poll paused state banner */
.poll-paused-banner {
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-pink));
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    font-weight: 600;
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.poll-paused-banner svg {
    flex-shrink: 0;
}

/* ==========================================
   Accessibility
   ========================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.poll-option:focus-visible {
    outline: 2px solid var(--accent-pink);
    outline-offset: 2px;
}

/* ==========================================
   Touch Optimization
   ========================================== */

/* Ensure minimum touch target size on mobile */
@media (pointer: coarse) {
    /* Labels need adequate padding for touch */
    .donut-label {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Increase button tap targets */
    .btn,
    .theme-toggle,
    .action-btn,
    .history-btn,
    .share-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text selection during drag */
    .donut-label,
    .poll-option {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Improve touch feedback */
    .donut-label:active {
        transform: scale(1.05);
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .poll-option:hover {
        transform: none;
    }
}

/* Debug controls dark mode */
[data-theme="dark"] .debug-controls {
    background: rgba(36, 40, 59, 0.95) !important;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3) !important;
}

[data-theme="dark"] .debug-controls button {
    background: #1f2937 !important;
    color: #94a3b8 !important;
    border-color: #374151 !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================
   Landing Page Styles
   ========================================== */

.landing {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-md);
    padding-bottom: 0;
    -webkit-user-select: none;
    user-select: none;
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.landing-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
    gap: 0;
}

.landing-footer {
    text-align: center;
    padding: clamp(24px, 5vh, 48px) 0;
    padding-bottom: max(env(safe-area-inset-bottom, 16px), 16px);
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: auto;
}

.landing-footer .heart {
    color: var(--accent-pink);
    display: inline-block;
    animation: heartbeat 1.5s ease-in-out infinite;
}

.landing-footer .copyright {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Hero Section */
.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2xl);
    padding: var(--space-xl) 0;
}

.hero-content {
    flex: 1;
    max-width: 480px;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.hero-emoji {
    display: inline-block;
    animation: wiggle 2s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-xl);
}

.hero-ctas {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-coral) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(255, 107, 157, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
}

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

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: none;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08), inset 0 0 0 2.5px var(--border-light);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12), inset 0 0 0 2.5px var(--accent-pink);
}

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

/* Hero Graphic */
.hero-graphic {
    flex-shrink: 0;
    position: relative;
}

.hero-donut {
    filter: drop-shadow(0 10px 30px rgba(255, 107, 157, 0.2));
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Features Section */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    padding: var(--space-2xl) 0;
    margin-top: var(--space-xl);
    border-top: 1px solid var(--border-light);
}

.feature {
    text-align: center;
    padding: var(--space-lg);
}

.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-coral) 100%);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: var(--space-md);
}

.feature-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.feature-desc {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Mobile Landing Styles */
@media (max-width: 700px) {
    .hero {
        flex-direction: column-reverse;
        text-align: center;
        gap: var(--space-lg);
        padding: var(--space-md) 0;
    }
    
    .hero-content {
        max-width: 100%;
    }
    
    .hero-ctas {
        justify-content: center;
    }
    
    .hero-graphic {
        margin-top: var(--space-md);
    }
    
    .hero-donut {
        width: 200px;
        height: 200px;
    }
    
    .features {
        grid-template-columns: 1fr;
        gap: var(--space-md);
        padding: var(--space-lg) 0;
    }
    
    .feature {
        padding: var(--space-md);
    }
}

@media (max-width: 400px) {
    .hero-ctas {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================
   Spinning Donut Landing
   ========================================== */

.spinning-donut-container {
    position: relative;
    width: 182px;
    height: 182px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(8px, 2vh, 20px);
    -webkit-tap-highlight-color: transparent;
    overflow: visible;
}

.spinning-donut {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 8px 24px rgba(255, 107, 157, 0.3));
    transition: filter 0.3s ease;
}

.spinning-donut:hover {
    filter: drop-shadow(0 12px 32px rgba(255, 107, 157, 0.4));
}

.spinning-donut:active {
    filter: drop-shadow(0 4px 16px rgba(255, 107, 157, 0.3));
}

.sprinkle-field {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}

.sprinkle-particle {
    position: absolute;
    border-radius: 3px;
    animation: fling-sprinkle 0.88s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fling-sprinkle {
    0% {
        transform: translate(var(--start-x), var(--start-y)) rotate(0deg);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--end-x), var(--end-y)) rotate(var(--rotation));
        opacity: 0;
    }
}

/* Simplified Hero */
.hero-simple {
    text-align: center;
    max-width: 480px;
    padding: 0 var(--space-md);
}

.hero-simple .hero-title {
    font-size: clamp(2rem, 5vw, 2.75rem);
    margin-bottom: var(--space-xs);
    line-height: 1.2;
}

.hero-simple .hero-subtitle {
    font-size: 1rem;
    margin-bottom: var(--space-md);
    color: var(--text-muted);
}

.hero-simple .hero-ctas {
    justify-content: center;
}

/* Center everything on landing */
.landing .landing-main {
    text-align: center;
}

/* Smooth scaling for smaller viewports */
.spinning-donut-container {
    transform: scale(clamp(0.75, 0.5 + 50vw / 200, 1));
    transform-origin: center center;
}

.hero-simple .hero-title {
    font-size: clamp(1.6rem, 5vw, 2.75rem);
}

.hero-simple .hero-subtitle {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
}

/* ==========================================
   Create Poll Page
   ========================================== */

.create-main {
    justify-content: flex-start;
    padding-top: var(--space-md);
}

.create-container {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding-bottom: var(--space-xl);
}

.create-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-soft);
    position: relative;
}

.create-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-pink), var(--accent-coral), var(--accent-yellow), var(--accent-teal));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    opacity: 0.7;
}

:root .create-card::before {
    opacity: 0;
}

/* Create page needs full-page scroll on mobile */
body:has(.create-main) {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
}

body:has(.create-main) .app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
}

/* Mobile: Remove card styling for seamless feel */
@media (max-width: 500px) {
    body:has(.create-main) {
        background: var(--bg-card);
    }
    
    .create-main {
        padding-top: 0;
    }
    
    .create-container {
        padding-bottom: var(--space-2xl);
    }
    
    .create-card {
        background: transparent;
        box-shadow: none;
        border-radius: 0;
        padding: var(--space-md);
        padding-top: var(--space-lg);
    }
    
    .create-card::before {
        display: none;
    }
}

.create-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: var(--space-xl);
}

.create-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-label {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: -4px;
}

/* Text Inputs */
.form-input {
    width: 100%;
    padding: var(--space-md);
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-smooth);
    outline: none;
}

.form-input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.form-input:hover {
    border-color: var(--accent-pink);
}

.form-input:focus {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.15);
}

.char-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

.char-count {
    font-weight: 600;
}

/* Options Container */
.options-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.option-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    animation: slideIn var(--duration-normal) var(--ease-out-back);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.option-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-smooth);
    overflow: hidden;
}

.option-input-wrapper:hover {
    border-color: var(--accent-pink);
}

.option-input-wrapper:focus-within {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.15);
}

.option-color {
    width: 4px;
    align-self: stretch;
    flex-shrink: 0;
}

.option-input-wrapper .form-input {
    border: none;
    background: transparent;
    padding-left: var(--space-md);
}

.option-input-wrapper .form-input:hover,
.option-input-wrapper .form-input:focus {
    border: none;
    box-shadow: none;
}

/* Length Indicator - border glow feedback */
.length-indicator {
    position: absolute;
    bottom: 0;
    left: 4px;
    right: 0;
    height: 3px;
    background: transparent;
    transition: all var(--duration-fast) var(--ease-smooth);
    pointer-events: none;
}

.length-indicator.green {
    background: linear-gradient(90deg, var(--accent-mint) 0%, var(--accent-mint) var(--fill-percent, 0%), transparent var(--fill-percent, 0%));
}

.length-indicator.yellow {
    background: linear-gradient(90deg, var(--accent-yellow) 0%, var(--accent-yellow) var(--fill-percent, 0%), transparent var(--fill-percent, 0%));
}

.length-indicator.red {
    background: linear-gradient(90deg, var(--accent-coral) 0%, var(--accent-coral) var(--fill-percent, 0%), transparent var(--fill-percent, 0%));
}

/* Border glow based on length */
.option-input-wrapper.length-green {
    border-color: var(--accent-mint);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

.option-input-wrapper.length-yellow {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 0 3px rgba(255, 230, 109, 0.25);
}

.option-input-wrapper.length-red {
    border-color: var(--accent-coral);
    box-shadow: 0 0 0 3px rgba(255, 142, 114, 0.2);
}

/* Question input length indicator */
.question-wrapper {
    position: relative;
}

.question-wrapper .form-input {
    transition: all var(--duration-fast) var(--ease-smooth);
}

.question-wrapper.length-green .form-input {
    border-color: var(--accent-mint);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

.question-wrapper.length-yellow .form-input {
    border-color: var(--accent-yellow);
    box-shadow: 0 0 0 3px rgba(255, 230, 109, 0.25);
}

.question-wrapper.length-red .form-input {
    border-color: var(--accent-coral);
    box-shadow: 0 0 0 3px rgba(255, 142, 114, 0.2);
}

/* Remove Option Button */
.option-remove {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-smooth);
    flex-shrink: 0;
}

.option-remove:hover:not(:disabled) {
    background: rgba(255, 107, 157, 0.1);
    color: var(--accent-pink);
}

.option-remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Add Option Button */
.add-option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    margin-top: var(--space-sm);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.add-option-btn:hover:not(:disabled) {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
    background: rgba(255, 107, 157, 0.05);
}

.add-option-btn:disabled {
    opacity: 0.6;
    cursor: default;
    border-style: solid;
    background: var(--bg-secondary);
}

.add-option-btn .checkmark {
    color: var(--accent-mint);
}

/* Drag handle for reordering */
.option-drag-handle {
    width: 24px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: grab;
    opacity: 0.5;
    transition: all var(--duration-fast) var(--ease-smooth);
    flex-shrink: 0;
    touch-action: none;
}

.option-drag-handle:hover {
    opacity: 1;
    color: var(--text-secondary);
}

.option-drag-handle:active {
    cursor: grabbing;
}

.option-row.dragging {
    opacity: 0.5;
    transform: scale(1.02);
}

.option-row.drag-over {
    border-top: 2px solid var(--accent-pink);
    margin-top: -2px;
}

/* Settings */
.settings-group {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-top: var(--space-sm);
}

.settings-group .form-label {
    margin-bottom: var(--space-sm);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-light);
}

.setting-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.setting-row:first-of-type {
    padding-top: 0;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-light);
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-smooth);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-bounce);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent-pink), var(--accent-coral));
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.2);
}

/* Create Button */
.create-btn {
    width: 100%;
    justify-content: center;
    padding: var(--space-lg);
    font-size: 1.0625rem;
    margin-top: var(--space-sm);
}

.create-btn .btn-icon {
    transition: transform var(--duration-fast) var(--ease-smooth);
}

.create-btn:hover .btn-icon {
    transform: translateX(4px);
}

/* Mobile adjustments */
@media (max-width: 500px) {
    .create-card {
        padding: var(--space-lg);
        border-radius: var(--radius-lg);
    }
    
    .create-title {
        font-size: 1.25rem;
    }
    
    .settings-group {
        padding: var(--space-md);
    }
    
    .setting-row {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: var(--space-sm);
    }
    
    .setting-info {
        min-width: 0;
    }
    
    .setting-desc {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .option-drag-handle {
        display: none; /* Hide drag on mobile - touch reorder is complex */
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Share modal trigger animation */
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.create-btn.success {
    animation: successPulse 0.3s ease-out;
    background: linear-gradient(135deg, var(--accent-mint), var(--accent-teal));
}

/* ==========================================
   Create Page Share Modal
   ========================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--ease-smooth);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.share-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 420px;
    width: 100%;
    position: relative;
    transform: translateY(20px) scale(0.95);
    transition: transform var(--duration-normal) var(--ease-out-back);
}

.modal-overlay.active .share-modal {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-smooth);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.share-modal-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.share-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-md);
    background: linear-gradient(135deg, var(--accent-mint), var(--accent-teal));
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    animation: popIn 0.4s var(--ease-out-back);
}

@keyframes popIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.share-modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.share-modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.share-link-container {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.share-link-input {
    flex: 1;
    padding: var(--space-md);
    font-size: 0.875rem;
    font-family: 'Nunito', monospace;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    outline: none;
    min-width: 0;
}

.share-link-input:focus {
    border-color: var(--accent-pink);
}

.share-copy-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-smooth);
    white-space: nowrap;
}

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

.share-copy-btn.copied {
    background: var(--accent-mint);
    border-color: var(--accent-mint);
    color: white;
}

.share-copy-btn.copied .copy-icon {
    display: none;
}

.share-copy-btn.copied .check-icon {
    display: block !important;
}

.share-actions {
    display: flex;
    justify-content: center;
}

.share-go-btn {
    min-width: 160px;
}
