/* ═══════════════════════════════════════════════════════════
   STAR Voting — Dark/Orange Functional Design System
   ═══════════════════════════════════════════════════════════ */

:root {
    --orange: #f97316;
    --orange-hover: #ea580c;
    --orange-dim: rgba(249, 115, 22, 0.12);
    --orange-glow: rgba(249, 115, 22, 0.25);
    --bg: #0c0c0c;
    --surface: #141414;
    --surface-2: #1c1c1c;
    --surface-3: #242424;
    --border: #222;
    --border-hover: #333;
    --text: #e8e8e8;
    --text-2: #999;
    --text-3: #666;
    --red: #ef4444;
    --green: #22c55e;
    --radius: 8px;
    --radius-lg: 12px;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Navigation ─────────────────────────────────────────── */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--orange);
    text-decoration: none;
    letter-spacing: -0.02em;
    font-family: var(--mono);
}

.nav-links {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-2);
}

.nav-link.active {
    color: var(--orange);
}

/* ── Layout ─────────────────────────────────────────────── */

.main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 56px);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

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

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.15s;
}

.card:hover {
    border-color: var(--border-hover);
}

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

.card-header h2,
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.card-description {
    color: var(--text-2);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.8125rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--sans);
}

.btn-primary {
    background: var(--orange);
    color: #000;
}

.btn-primary:hover {
    background: var(--orange-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface-3);
    color: var(--text);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--text-2);
}

.btn-outline:hover {
    border-color: var(--orange);
    color: var(--orange);
}

.btn-danger {
    background: var(--red);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
}

.btn-danger:hover {
    opacity: 0.8;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Forms ──────────────────────────────────────────────── */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    font-family: var(--sans);
    transition: border-color 0.15s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--orange);
}

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

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* ── Poll Cards ─────────────────────────────────────────── */

.poll-card {
    cursor: default;
}

.poll-card:hover {
    border-color: var(--orange);
}

.poll-status {
    font-size: 0.6875rem;
    font-weight: 700;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.poll-status.active {
    color: var(--orange);
    background: var(--orange-dim);
}

.poll-status.ended {
    color: var(--text-3);
    background: var(--surface-3);
}

.poll-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-3);
    font-family: var(--mono);
    margin-bottom: 0.75rem;
}

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

/* ── Score Bubbles ──────────────────────────────────────── */

.score-bubbles {
    display: flex;
    gap: 0.5rem;
}

.score-bubble {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9375rem;
    font-family: var(--mono);
    cursor: pointer;
    border: 2px solid var(--border-hover);
    background: var(--surface-2);
    color: var(--text-3);
    transition: all 0.15s;
}

.score-bubble:hover {
    border-color: var(--orange);
    color: var(--text);
    background: var(--surface-3);
}

.score-bubble.active {
    border-color: var(--orange);
    background: var(--orange);
    color: #000;
    font-weight: 800;
}

/* ── Results ────────────────────────────────────────────── */

.results-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.result-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.result-item.winner-item {
    border-color: var(--orange);
    background: var(--orange-dim);
}

.winner-badge {
    background: var(--orange);
    color: #000;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 800;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.result-title {
    font-weight: 600;
    font-size: 0.9375rem;
}

.result-score {
    font-weight: 700;
    color: var(--orange);
    font-family: var(--mono);
    font-size: 0.875rem;
}

.result-bar {
    height: 6px;
    background: var(--surface-3);
    border-radius: 3px;
    overflow: hidden;
}

.result-fill {
    height: 100%;
    background: var(--orange);
    transition: width 0.4s ease;
    border-radius: 3px;
}

/* ── Poll Breakdown ─────────────────────────────────────── */

.poll-breakdown {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.poll-breakdown summary {
    cursor: pointer;
    color: var(--text-3);
    font-size: 0.75rem;
    font-weight: 500;
    user-select: none;
}

.poll-breakdown summary:hover {
    color: var(--orange);
}

.breakdown-content {
    margin-top: 0.5rem;
    padding: 0.625rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.8125rem;
}

.breakdown-item span:first-child {
    color: var(--text-2);
}

.breakdown-item span:last-child {
    font-weight: 600;
    font-family: var(--mono);
}

/* ── Runoff ─────────────────────────────────────────────── */

.runoff-results {
    display: grid;
    gap: 0.75rem;
}

.runoff-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.runoff-item.winner-highlight {
    border-color: var(--orange);
    background: var(--orange-dim);
}

.candidate-name {
    font-weight: 600;
}

.candidate-ballots {
    font-size: 0.75rem;
    color: var(--text-3);
    font-family: var(--mono);
}

.runoff-score {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--orange);
    font-family: var(--mono);
}

.runoff-explanation {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.runoff-explanation h4 {
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.runoff-explanation p {
    color: var(--text-2);
    font-size: 0.8125rem;
    line-height: 1.6;
}

.tie-explanation {
    background: rgba(249, 115, 22, 0.08);
    border: 1px solid var(--orange);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.tie-explanation h3 {
    color: var(--orange);
    font-size: 0.9375rem;
    margin-bottom: 0.5rem;
}

.tie-explanation p {
    color: var(--text-2);
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* ── Utilities ──────────────────────────────────────────── */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-3);
    font-size: 0.8125rem;
    gap: 0.5rem;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--red);
    font-size: 0.875rem;
}

.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    animation: slideIn 0.2s ease;
}

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

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

.message-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
}

.message-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--green);
    color: var(--green);
}

.message-warning {
    background: var(--orange-dim);
    border: 1px solid var(--orange);
    color: var(--orange);
}

/* ── Option Input ───────────────────────────────────────── */

.option-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.char-counter {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6875rem;
    color: var(--text-3);
    font-family: var(--mono);
    pointer-events: none;
    background: var(--bg);
    padding: 0 2px;
}

.char-counter-textarea {
    top: 0.5rem;
    transform: none;
}

.duration-inputs {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-2);
}

.duration-inputs .form-input {
    width: 70px;
    text-align: center;
}

/* ── Hero ───────────────────────────────────────────────── */

.hero {
    text-align: center;
    padding: 3rem 0 1rem;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--orange);
    margin-bottom: 0.5rem;
}

.hero-sub {
    color: var(--text-3);
    font-size: 0.875rem;
    max-width: 480px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 640px) {
    .nav-container {
        padding: 0 1rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .page-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .score-bubble {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 0.8125rem;
    }
}