:root {
    --bg: #f7f7f8;
    --fg: #1a1a1a;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --bar: #2563eb;
    --bar-bg: #e5e7eb;
    --card: #ffffff;
    --ok: #16a34a;
    --warn: #ea580c;
}

* { box-sizing: border-box; }

body {
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    margin: 0;
    line-height: 1.5;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.narrow { max-width: 720px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
h3 { font-size: 16px; margin: 0 0 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 14px; }

button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:disabled { background: var(--muted); cursor: not-allowed; }

.btn-secondary {
    background: var(--card);
    color: var(--fg);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 800px) {
    .split { grid-template-columns: 1fr; }
}

textarea.csv {
    width: 100%;
    min-height: 420px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card);
    resize: vertical;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.preview .question {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--border);
}
.preview .question:last-child { border-bottom: none; }

.preview .question.clickable {
    cursor: pointer;
    padding: 8px;
    margin: 0 -8px 16px;
    border-radius: 6px;
    transition: background 0.15s ease;
}
.preview .question.clickable:hover { background: var(--bg); }

.preview .type-badge {
    display: inline-block;
    font-size: 11px;
    background: var(--bar-bg);
    color: var(--muted);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    text-transform: uppercase;
}

.preview ul { padding-left: 20px; margin: 6px 0; }

.option {
    display: block;
    padding: 8px 12px;
    margin-bottom: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--card);
}
.option:hover { background: var(--bg); }
.option input { margin-right: 8px; }

.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--bar-bg);
    color: var(--muted);
}
.status-pill.saving { background: #fef3c7; color: #92400e; }
.status-pill.saved { background: #dcfce7; color: #166534; }

.link-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 6px 0;
}
.link-row code {
    flex: 1;
    padding: 6px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    overflow: auto;
    white-space: nowrap;
}

.bar-row {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 8px;
}
.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 4px;
}
.bar-track {
    height: 22px;
    background: var(--bar-bg);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: var(--bar);
    transition: width 0.4s ease;
    min-width: 0;
}

.bar-row.winner .bar-fill { background: var(--ok); }
.bar-row.winner .bar-label strong { color: var(--ok); }
.bar-row.winner .crown { color: var(--ok); font-weight: bold; }

.totals {
    font-size: 14px;
    color: var(--muted);
    margin-bottom: 4px;
}

.empty {
    color: var(--muted);
    font-style: italic;
    padding: 24px;
    text-align: center;
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.success-box {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}
