:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-light: rgba(139, 92, 246, 0.15);
    --bg: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-solid: #1e293b;
    --bg-input: rgba(51, 65, 85, 0.5);
    --bg-hover: rgba(51, 65, 85, 0.6);
    --bg-option: rgba(51, 65, 85, 0.4);
    --bg-option-selected: rgba(139, 92, 246, 0.18);
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(148, 163, 184, 0.12);
    --border-focus: rgba(139, 92, 246, 0.5);
    --success: #22c55e;
    --danger: #ef4444;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --max-width: 640px;
    --header-height: 64px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-solid: #fff;
    --bg-input: rgba(241, 245, 249, 0.8);
    --bg-hover: rgba(226, 232, 240, 0.6);
    --bg-option: rgba(241, 245, 249, 0.6);
    --bg-option-selected: rgba(139, 92, 246, 0.1);
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.1);
}

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

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    transition: background .3s var(--ease), color .3s var(--ease)
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%), radial-gradient(ellipse at 70% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%);
    z-index: -1;
    animation: bgShift 20s ease-in-out infinite alternate
}

@keyframes bgShift {
    0% {
        transform: translate(0, 0)
    }

    100% {
        transform: translate(-5%, -3%)
    }
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column
}

.header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100
}

[data-theme="light"] .header {
    background: rgba(248, 250, 252, 0.75)
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all .2s var(--ease)
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text)
}

[data-theme="dark"] .icon-moon {
    display: none
}

[data-theme="light"] .icon-sun {
    display: none
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .25s var(--ease);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3)
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.45)
}

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

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s var(--ease)
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    transition: color .2s var(--ease)
}

.btn-text:hover {
    color: var(--danger)
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 0;
    margin-bottom: 16px;
    transition: color .2s var(--ease)
}

.btn-back:hover {
    color: var(--primary)
}

.btn-add-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    transition: all .2s var(--ease)
}

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

.btn-remove-option {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all .2s var(--ease);
    flex-shrink: 0
}

.btn-remove-option:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger)
}

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

.main {
    flex: 1;
    padding: 32px 24px 64px;
    display: flex;
    justify-content: center
}

.view {
    display: none;
    width: 100%;
    max-width: var(--max-width);
    animation: fadeSlideIn .35s var(--ease)
}

.view.active {
    display: block
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-md);
    transition: background .3s var(--ease), border-color .3s var(--ease)
}

.card+.card {
    margin-top: 20px
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em
}

.subtitle {
    color: var(--text-secondary);
    font-size: .875rem;
    margin-top: 4px
}

.poll-form {
    display: flex;
    flex-direction: column;
    gap: 24px
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.form-group>label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em
}

.label-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
    font-size: .8rem
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-size: .95rem;
    outline: none;
    transition: all .2s var(--ease)
}

input[type="text"]::placeholder {
    color: var(--text-muted)
}

input[type="text"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-light)
}

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

.options-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeSlideIn .25s var(--ease)
}

.option-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0
}

.option-input {
    flex: 1
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.toggle-setting {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer
}

.toggle-setting input[type="checkbox"] {
    display: none
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    position: relative;
    transition: all .25s var(--ease);
    flex-shrink: 0
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all .25s var(--ease)
}

.toggle-setting input:checked+.toggle-slider {
    background: var(--primary);
    border-color: var(--primary)
}

.toggle-setting input:checked+.toggle-slider::after {
    left: 22px;
    background: #fff
}

.toggle-label {
    font-size: .875rem;
    color: var(--text-secondary)
}

.form-actions {
    display: flex;
    justify-content: flex-end
}

.saved-polls-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: .875rem;
    padding: 20px 0
}

.saved-poll-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-option);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .2s var(--ease)
}

.saved-poll-item:hover {
    border-color: var(--primary);
    background: var(--bg-option-selected)
}

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

.saved-poll-question {
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.saved-poll-stats {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 2px
}

.saved-poll-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0
}

.saved-poll-actions .btn-icon {
    width: 34px;
    height: 34px
}

.vote-header {
    margin-bottom: 24px
}

.vote-header h2,
.results-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: -0.02em
}

.vote-meta,
.results-meta {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: block
}

.vote-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px
}

.vote-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-option);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .2s var(--ease)
}

.vote-option:hover {
    border-color: rgba(139, 92, 246, 0.3);
    background: var(--bg-option-selected)
}

.vote-option.selected {
    border-color: var(--primary);
    background: var(--bg-option-selected);
    box-shadow: 0 0 0 1px var(--primary)
}

.vote-option-radio,
.vote-option-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s var(--ease)
}

.vote-option-radio {
    border-radius: 50%
}

.vote-option-checkbox {
    border-radius: 4px
}

.vote-option.selected .vote-option-radio,
.vote-option.selected .vote-option-checkbox {
    border-color: var(--primary);
    background: var(--primary)
}

.vote-option.selected .vote-option-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%
}

.vote-option.selected .vote-option-checkbox::after {
    content: '';
    width: 10px;
    height: 10px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 6L5 9L10 3' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat
}

.vote-option-label {
    font-size: .95rem;
    font-weight: 500
}

.vote-actions {
    display: flex;
    justify-content: flex-end
}

.results-header {
    margin-bottom: 24px
}

.results-bars {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.result-label {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.result-name {
    font-size: .9rem;
    font-weight: 600
}

.result-count {
    font-size: .8rem;
    color: var(--text-muted);
    font-weight: 500
}

.result-bar-track {
    height: 28px;
    background: var(--bg-option);
    border-radius: var(--radius-xs);
    overflow: hidden;
    position: relative
}

.result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #a78bfa);
    border-radius: var(--radius-xs);
    min-width: 0;
    transition: width .8s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    padding-left: 10px
}

.result-bar-fill.winner {
    background: linear-gradient(90deg, var(--primary), #c4b5fd);
    box-shadow: 0 0 16px rgba(139, 92, 246, 0.3)
}

.result-percent {
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap
}

.results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px
}

.modal-overlay.active {
    display: flex
}

.modal {
    background: var(--bg-card-solid);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn .3s var(--ease)
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(.95) translateY(10px)
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0)
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 10px
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 14px
}

.shortcut-item kbd {
    min-width: 48px;
    padding: 4px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: var(--font);
    font-size: .75rem;
    font-weight: 600;
    color: var(--text);
    text-align: center
}

.shortcut-item span {
    font-size: .85rem;
    color: var(--text-secondary)
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card-solid);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    transition: all .35s var(--ease);
    pointer-events: none;
    white-space: nowrap
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

@media(max-width:600px) {
    .header {
        padding: 0 16px
    }

    .main {
        padding: 20px 16px 48px
    }

    .card {
        padding: 20px
    }

    .logo h1 {
        font-size: .95rem
    }

    .results-actions {
        flex-direction: column
    }

    .results-actions .btn-secondary,
    .results-actions .btn-primary {
        width: 100%;
        justify-content: center
    }
}