/* ==========================================================================
   Fonts (self-hosted, variable)
   ========================================================================== */

@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/roboto-latin-wght-normal-P5vfNz3.woff2") format('woff2');
}

@font-face {
    font-family: 'Source Code Pro';
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url("../fonts/source-code-pro-latin-wght-normal-vhAiBSL.woff2") format('woff2');
}

@font-face {
    font-family: 'Source Code Pro';
    font-style: italic;
    font-weight: 200 900;
    font-display: swap;
    src: url("../fonts/source-code-pro-latin-wght-italic-PVtbLdE.woff2") format('woff2');
}

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
    --font-heading: 'Roboto', system-ui, sans-serif;
    --font-body: 'Source Code Pro', ui-monospace, monospace;

    /* Palette: light (fondo blanco) */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f3f2ef;
    --text: #1a1916;
    --text-muted: #6d695f;
    --border: #e5e3dd;
    --border-strong: #c3bfb5;
    --accent: #d8431b;
    --accent-hover: #b93614;
    --accent-contrast: #ffffff;
    --accent-soft: #fbe4dc;
    --success: #2e7d4f;
    --success-soft: #dcefe3;
    --map-fill: #1f8a5b; /* países del mapa: verde para no sumar más naranja */
    --warning: #9a6300;
    --warning-soft: #f6ead0;
    --danger: #b3261e;
    --danger-soft: #f7dcda;
    --focus: #2d5bff;

    /* Colores de las opciones de una encuesta, por posición: 6 tonos distintos (paleta categórica apta para daltonismo) */
    --opt-1: #2a78d6;
    --opt-2: #e34948;
    --opt-3: #1baf7a;
    --opt-4: #eda100;
    --opt-5: #008300;
    --opt-6: #e87ba4;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;

    /* Type scale */
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-lg: 1.125rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;
    --text-3xl: clamp(2.25rem, 5vw, 3.5rem);

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 14px;
    --container: 1120px;
    --container-narrow: 720px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
    --transition: 150ms ease;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #111110;
    --surface: #191917;
    --surface-2: #22221f;
    --text: #ecebe6;
    --text-muted: #9b978c;
    --border: #2d2c28;
    --border-strong: #45443e;
    --accent: #ff7446;
    --accent-hover: #ff8f68;
    --accent-contrast: #140a06;
    --accent-soft: #3b2017;
    --success: #6fcf97;
    --map-fill: #4cc38a;
    --success-soft: #16301f;
    --warning: #f0b44c;
    --warning-soft: #33280f;
    --danger: #ff8a80;
    --danger-soft: #3a1714;
    --focus: #7c9bff;
    --shadow: none;
    --opt-1: #3987e5;
    --opt-2: #e66767;
    --opt-3: #199e70;
    --opt-4: #c98500;
    --opt-5: #008300;
    --opt-6: #d55181;

    color-scheme: dark;
}

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

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-3xl); font-weight: 700; letter-spacing: -0.035em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin: 0; }

a {
    color: inherit;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 3px;
    transition: color var(--transition), text-decoration-color var(--transition);
}

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

img { max-width: 100%; display: block; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

::selection {
    background: var(--accent);
    color: var(--accent-contrast);
}

/* Que [hidden] gane a cualquier display de componente (.empty-state, .agreement, flex…) */
[hidden] { display: none !important; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

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

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--space-5);
}

.container--narrow { max-width: var(--container-narrow); }

.site-main {
    flex: 1;
    padding-block: var(--space-7) var(--space-9);
}

.stack > * + * { margin-top: var(--stack-gap, var(--space-4)); }

.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }

.kicker {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.kicker::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 2px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.flashes {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

/* ==========================================================================
   Header & footer
   ========================================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    min-height: 64px;
}

/* Menú centrado en la página, no en el hueco entre logo y botones (que miden distinto) */
@media (min-width: 641px) {
    .site-header__inner:not(.is-collapsed) {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
    }

    .brand { justify-self: start; }
    .header-actions { justify-self: end; }
}

/* Sin sitio para centrar el menú en la fila del logo, se recoge en el botón ☰ de la derecha.
   En móvil siempre; en el resto lo decide header_layout_controller.js midiendo (depende del nombre de usuario) */
.nav-toggle { display: none; }

.site-header__inner.is-collapsed .main-nav { display: none; }
.site-header__inner.is-collapsed .nav-toggle { display: block; }

@media (max-width: 640px) {
    .main-nav { display: none; }
    .nav-toggle { display: block; }

    /* En móvil el botón de usuario es solo icono; el nombre queda para lectores de pantalla */
    .user-menu__name {
        position: absolute;
        width: 1px;
        height: 1px;
        clip: rect(0 0 0 0);
    }
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.375rem;
    letter-spacing: -0.03em;
    text-decoration: none;
}

.brand:hover { color: var(--text); }

.brand__mark {
    display: grid;
    grid-template-columns: repeat(2, 9px);
    gap: 2.5px;
}

.brand__mark span {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--text);
}

.brand__mark span:nth-child(2) { background: var(--accent); }


.main-nav {
    display: flex;
    gap: var(--space-4);
    font-size: var(--text-sm);
}

.main-nav a {
    white-space: nowrap; /* "Propose a poll" nunca se parte en dos líneas */
    text-decoration: none;
    color: var(--text-muted);
    padding-block: var(--space-1);
}

.main-nav a:hover,
.main-nav a[aria-current="page"] { color: var(--text); }

.main-nav a[aria-current="page"] {
    box-shadow: inset 0 -2px 0 var(--accent);
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Todos los botones de la cabecera con la misma altura que el botón cuadrado del tema */
.header-actions .btn {
    height: 34px;
    padding-block: 0;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.icon-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

/* grid y no inline/block: sin la línea de texto que dejaba el icono desplazado hacia arriba */
.theme-toggle .icon-moon,
[data-theme="dark"] .theme-toggle .icon-sun { display: grid; }
.theme-toggle .icon-sun,
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.site-footer {
    padding-bottom: var(--space-6);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* Franja de patrocinio sobre el pie (sustituye a la línea separadora). Tonos del logo lo bastante oscuros
   para que el texto blanco tenga contraste AA (≥ 4.5:1) en todo el degradado, en los dos temas */
.sponsor-bar {
    margin-bottom: var(--space-6);
    background: linear-gradient(100deg, #a42f12 0%, #c43a17 45%, #b3301f 70%, #9c2a3a 100%);
    color: #ffffff;
}

.sponsor-bar__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    min-height: 40px;
    margin-block: 0;
    padding-block: var(--space-2);
    text-align: center;
}

.sponsor-bar__lead { opacity: 0.9; }

.sponsor-bar__link { color: inherit; text-decoration: none; }
/* Sin el color de acento del hover general: rojo sobre la franja roja no se leería */
.sponsor-bar__link:hover { color: #ffffff; text-decoration: underline; }
.sponsor-bar__title { font-size: var(--text-xs); font-weight: 600; }
/* Con logos: título, logos y enlace; en móvil se reparten en varias líneas */
div.sponsor-bar__inner { flex-wrap: wrap; gap: var(--space-3) var(--space-5); padding-block: var(--space-3); }
.sponsor-bar__logos { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
div.sponsor-bar__inner .sponsor-bar__link { opacity: 0.9; font-size: var(--text-xs); }

/* Solo los párrafos del pie: la franja de patrocinio es un <p class="container"> y necesita su margin-inline: auto */
.site-footer__about p,
.site-footer__bottom p { margin: 0; }

/* Marca + 3 columnas de enlaces; 2 columnas en tablet y 1 en móvil */
.site-footer__grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr));
    gap: var(--space-6);
    padding-block: var(--space-4) var(--space-6);
}

.site-footer__about { display: grid; gap: var(--space-3); align-content: start; max-width: 36ch; }
.site-footer__about .brand { justify-self: start; color: var(--text); }

.site-footer__title {
    margin: 0 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text);
}

.site-footer__col ul {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-footer__col a { color: var(--text-muted); text-decoration: none; }
.site-footer__col a:hover { color: var(--text); text-decoration: underline; }

.site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
    font-size: var(--text-xs);
}

.site-footer__note { display: inline-flex; align-items: center; gap: 6px; }
.site-footer__bottom nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }

@media (max-width: 860px) {
    .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .site-footer__about { grid-column: 1 / -1; max-width: none; }
}

/* En móvil los enlaces siguen de dos en dos (son cortos): el pie no se hace tan largo */
@media (max-width: 480px) {
    .site-footer__bottom { flex-direction: column; align-items: flex-start; }
}

.icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 0.6rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.btn:active { transform: translateY(1px); }

.btn--primary {
    background: var(--accent);
    color: var(--accent-contrast);
}

.btn--primary:hover {
    background: var(--accent-hover);
    color: var(--accent-contrast);
}

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

.btn--secondary:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn--ghost:hover {
    color: var(--text);
    background: var(--surface-2);
}

.btn--sm { padding: 0.4rem 0.75rem; font-size: var(--text-xs); }
.btn--lg { padding: 0.8rem 1.4rem; font-size: var(--text-base); }
.btn--block { width: 100%; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn--primary:disabled { background: var(--accent); }

/* ==========================================================================
   Forms
   ========================================================================== */

.form { display: grid; gap: var(--space-5); }

.field { display: grid; gap: var(--space-2); }

.field__label {
    font-size: var(--text-sm);
    font-weight: 600;
}

.field__hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.field__error {
    font-size: var(--text-xs);
    color: var(--danger);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.input:hover,
.select:hover,
.textarea:hover { border-color: var(--border-strong); }

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input--invalid { border-color: var(--danger); }

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

/* iOS Safari hace zoom (y desplaza la página) al enfocar campos con font-size < 16px */
@media (pointer: coarse) {
    .input,
    .select,
    .textarea,
    .share .input { font-size: 16px; }
}

.select {
    appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    cursor: pointer;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
    cursor: pointer;
}

.checkbox input {
    margin-top: 3px;
    accent-color: var(--accent);
}

/* Honeypot: fuera de pantalla para humanos */
.hp-field {
    position: absolute;
    left: -9999px;
}

/* ==========================================================================
   Cards, badges, alerts
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--text-muted);
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge--pending_review { background: var(--warning-soft); color: var(--warning); }
.badge--approved { background: var(--success-soft); color: var(--success); }
.badge--rejected { background: var(--danger-soft); color: var(--danger); }
.badge--closed { background: var(--surface-2); color: var(--text-muted); }

.alert {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    background: var(--surface-2);
}

.alert .icon { margin-top: 3px; }
.alert--info { background: var(--accent-soft); }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--danger { background: var(--danger-soft); color: var(--danger); }

/* ==========================================================================
   Home
   ========================================================================== */

.hero {
    display: grid;
    gap: var(--space-5);
    padding-bottom: var(--space-8);
}

.hero h1 em {
    font-style: normal;
    color: var(--accent);
}

.hero__lead {
    font-size: var(--text-lg);
    color: var(--text-muted);
    max-width: 60ch;
}

.hero__actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.hero__bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-5) var(--space-7);
    flex-wrap: wrap;
}

.stats {
    display: flex;
}

.stat {
    padding-inline: var(--space-5);
}

.stat:last-child { padding-right: 0; }

.stat + .stat { border-left: 1px solid var(--border); }

.stat__value {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.stat__label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.home-polls {
    padding-top: var(--space-7);
    border-top: 1px solid var(--border);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-6);
}

.segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.segmented a,
.segmented button {
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-size: var(--text-sm);
    text-decoration: none;
    color: var(--text-muted);
}

.segmented button {
    border: 0;
    background: none;
    font-family: inherit;
    cursor: pointer;
}

.segmented a[aria-current="true"],
.segmented button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* Dispositivos de una encuesta (tarjetas, página de la encuesta y del país) */
.device-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
}

.device-tags li {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
}

.poll-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-5);
}

.poll-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
}

.poll-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.poll-card__media {
    position: relative;
    aspect-ratio: 16 / 12;
    border-bottom: 1px solid var(--border);
}

/* Imagen entera y centrada, dejando ver la rejilla alrededor */
.poll-card__media img {
    position: absolute;
    inset: var(--space-5);
    width: calc(100% - 2 * var(--space-5));
    height: calc(100% - 2 * var(--space-5));
    object-fit: contain;
}

.poll-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    flex: 1;
}

.poll-card__title a {
    text-decoration: none;
}

/* Toda la tarjeta clicable */
.poll-card__title a::after {
    content: '';
    position: absolute;
    inset: 0;
}

.poll-card__meta,
.poll-card__footer {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: auto;
    padding-top: var(--space-3);
    border-top: 1px dashed var(--border);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.poll-card__footer span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.poll-card__devices { gap: 8px; }

/* Fondo de rejilla: portadas con imagen y fallback sin imagen */
.poll-cover,
.poll-card__media,
.cover-fallback {
    background-color: var(--surface-2);
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
}

/* Fallback visual si la encuesta no tiene imagen */
.cover-fallback {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.cover-fallback__glyph {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    color: var(--accent);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 var(--space-4);
    line-height: 1.3;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-7);
    font-size: var(--text-sm);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
}

.pagination [aria-current="page"] {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

/* ==========================================================================
   Poll detail
   ========================================================================== */

/* Breadcrumb: Home / Countries / Spain */
.breadcrumb {
    margin-bottom: var(--space-6);
    font-size: var(--text-sm);
}

.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumb li {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.breadcrumb li + li::before {
    content: '/';
    color: var(--border-strong);
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover { color: var(--accent); }

/* Página actual: títulos largos de encuesta se cortan con puntos suspensivos */
.breadcrumb [aria-current="page"] {
    max-width: 40ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.poll-header {
    display: grid;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.poll-header h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); }

.poll-header__desc {
    font-size: var(--text-lg);
    color: var(--text-muted);
    max-width: 65ch;
}

.poll-cover {
    aspect-ratio: 21 / 8;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-7);
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    padding: var(--space-5);
}

.poll-cover img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius);
}

/* El fallback ya pinta su propia rejilla y ocupa todo el espacio */
.poll-cover:has(.cover-fallback) {
    padding: 0;
}

.poll-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-7);
    align-items: start;
}

.poll-top {
    align-items: stretch;
    margin-bottom: var(--space-7);
}

/* La portada se estira a la altura de la ficha en vez de guardar su proporción 21:8 */
.poll-top .poll-cover {
    aspect-ratio: auto;
    min-height: 260px;
    margin-bottom: 0;
}

.poll-top .aside-card {
    position: static;
    align-content: start;
}

.vote-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-block: var(--space-5);
    padding: 0;
    border: 0;
}

.vote-option {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.vote-option:hover { border-color: var(--border-strong); }

.vote-option input {
    position: absolute;
    opacity: 0;
}

.vote-option:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.vote-option:has(input:focus-visible) {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.vote-option__image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    border-radius: var(--radius);
    background: var(--surface-2);
}

.vote-option__label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    padding-inline: var(--space-1);
}

.vote-option__radio {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: 50%;
    flex-shrink: 0;
    transition: border var(--transition);
}

.vote-option:has(input:checked) .vote-option__radio {
    border: 5px solid var(--accent);
}

/* Color de la opción (el mismo de leyendas y gráficas), arriba a la derecha aunque el nombre ocupe varias líneas */
.vote-option__swatch {
    align-self: flex-start;
    margin-top: 0.3em;
    margin-left: auto;
}

/* Wireframes de ejemplo para opciones visuales */
.wireframe {
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 10px;
    display: grid;
    gap: 6px;
}

.wireframe i {
    display: block;
    border-radius: 3px;
    background: var(--border-strong);
    opacity: 0.55;
}

.wireframe i.is-accent { background: var(--accent); opacity: 1; }

.wireframe--top { grid-template-rows: 14px 1fr; }
.wireframe--top i:first-child { display: flex; justify-content: flex-end; }
.wireframe--side { grid-template-columns: 34px 1fr; }
.wireframe--bottom { grid-template-rows: 1fr 16px; }

.vote-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.voted-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-5);
}

.voted-banner__edit {
    font-weight: 600;
    color: inherit;
    text-underline-offset: 3px;
}

.results { display: grid; gap: var(--space-4); }

.result-row { display: grid; gap: 6px; }

.result-row__head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: var(--text-sm);
}

.result-row__pct {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.result-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.result-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--border-strong);
}


.country-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.country-table th {
    text-align: left;
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
}

.country-table td {
    padding: var(--space-3);
    border-bottom: 1px dashed var(--border);
    vertical-align: middle;
}

.country-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--border);
}

.country {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

a.country { color: inherit; text-decoration: none; }
a.country:hover { color: var(--accent); }

/* Split se lleva todo el ancho sobrante; el resto de columnas se ajusta a su contenido */
.country-table th,
.country-table td { white-space: nowrap; }

.country-table .col-split {
    width: 100%;
    padding-right: var(--space-6);
}

.stacked-bar {
    display: flex;
    height: 8px;
    min-width: 140px;
    gap: 2px;
}

.stacked-bar span {
    position: relative;
    cursor: default;
    transition: box-shadow var(--transition);
}

.stacked-bar span:first-child { border-radius: 999px 0 0 999px; }
.stacked-bar span:last-child { border-radius: 0 999px 999px 0; }

.stacked-bar span:nth-child(1) { background: var(--opt-1); }
.stacked-bar span:nth-child(2) { background: var(--opt-2); }
.stacked-bar span:nth-child(3) { background: var(--opt-3); }
.stacked-bar span:nth-child(4) { background: var(--opt-4); }
.stacked-bar span:nth-child(5) { background: var(--opt-5); }
.stacked-bar span:nth-child(6) { background: var(--opt-6); }

.stacked-bar span:hover { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--border-strong); }

/* Tooltip con el porcentaje del tramo */
.stacked-bar span[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-size: var(--text-xs);
    white-space: nowrap;
    pointer-events: none;
    z-index: 5;
}

.legend {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend span:nth-child(1) i { background: var(--opt-1); }
.legend span:nth-child(2) i { background: var(--opt-2); }
.legend span:nth-child(3) i { background: var(--opt-3); }
.legend span:nth-child(4) i { background: var(--opt-4); }
.legend span:nth-child(5) i { background: var(--opt-5); }
.legend span:nth-child(6) i { background: var(--opt-6); }

.locked-results {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.locked-results__preview {
    filter: blur(5px);
    opacity: 0.55;
    user-select: none;
    pointer-events: none;
}

.locked-results__overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    text-align: center;
    font-size: var(--text-sm);
    background: color-mix(in srgb, var(--bg) 35%, transparent);
}

.locked-results__overlay .icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.poll-results {
    margin-top: var(--space-8);
}

.vote-options:disabled .vote-option { cursor: default; }

/* Opciones no elegidas, atenuadas parte a parte (no con opacity en la tarjeta) para que el color de la opción se vea entero */
.vote-options:disabled .vote-option:not(:has(input:checked)) {
    border-color: color-mix(in srgb, var(--border) 55%, var(--surface));
    color: color-mix(in srgb, var(--text) 55%, var(--surface));
}

.vote-options:disabled .vote-option:not(:has(input:checked)) :is(.vote-option__radio, .vote-option__image) { opacity: 0.55; }

.aside-card {
    position: sticky;
    top: 88px;
    display: grid;
    gap: var(--space-5);
}

.meta-list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    font-size: var(--text-sm);
}

.meta-list div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
}

.meta-list dt { flex-shrink: 0; color: var(--text-muted); }
/* Valores largos (p. ej. el email) se parten en vez de salirse de la tarjeta */
.meta-list dd { min-width: 0; margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }

.share {
    display: flex;
    gap: var(--space-2);
}

.share .input { font-size: var(--text-xs); }

/* ==========================================================================
   Propose
   ========================================================================== */

.page-head {
    display: grid;
    gap: var(--space-3);
    margin-bottom: var(--space-7);
}

.page-head h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); }

.option-list {
    display: grid;
    gap: var(--space-2);
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: option;
}

.option-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    counter-increment: option;
}

.option-row::before {
    content: counter(option, upper-alpha);
    display: grid;
    place-items: center;
    width: 32px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.option-row { flex-wrap: wrap; }
.option-row .input { flex: 1; width: auto; }
.option-row .icon-button { flex-shrink: 0; }
.option-row .icon-button:disabled { opacity: 0.35; cursor: not-allowed; }
.option-row .field__error { flex-basis: 100%; padding-left: 40px; }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding-top: var(--space-5);
    border-top: 1px solid var(--border);
}

.confirmation {
    display: grid;
    justify-items: start;
    gap: var(--space-4);
}

.confirmation__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--success-soft);
    color: var(--success);
    font-size: 1.4rem;
}

/* ==========================================================================
   Auth
   ========================================================================== */

.auth {
    display: grid;
    place-items: center;
    padding-block: var(--space-5);
}

.auth__card {
    width: 100%;
    max-width: 420px;
    display: grid;
    gap: var(--space-6);
}

.auth__head { display: grid; gap: var(--space-2); }
.auth__head h1 { font-size: var(--text-2xl); }

.auth__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
}

.auth__footer {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* ==========================================================================
   Profile
   ========================================================================== */

.profile-head {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-wrap: wrap;
    margin-bottom: var(--space-7);
}

.avatar {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 700;
}

.profile-head__actions { margin-left: auto; }

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: var(--space-6);
    align-items: start;
}

.proposal-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.proposal-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding-block: var(--space-4);
    border-bottom: 1px dashed var(--border);
}

.proposal-item:last-child { border-bottom: 0; }

.proposal-item__main {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.proposal-item__title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: var(--space-7) var(--space-4);
    text-align: center;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}

/* ==========================================================================
   Countries
   ========================================================================== */

.country-title {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
}

.flag--lg {
    width: 40px;
    height: 30px;
    border-radius: 4px;
}

.country-poll .poll-card__body { gap: var(--space-4); }

/* Una columna: tarjetas horizontales con la portada a la derecha */
.country-polls {
    display: grid;
    gap: var(--space-5);
}

.country-poll {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 34%);
}

.country-poll .poll-card__media {
    order: 2;
    aspect-ratio: auto;
    min-height: 220px;
    border-bottom: 0;
    border-left: 1px solid var(--border);
}

.country-poll .poll-card__body { padding: var(--space-6); }

/* Etiqueta sobre la portada, para no competir con el título */
.country-poll .badge--differs {
    position: absolute;
    top: var(--space-3);
    left: var(--space-3);
    box-shadow: var(--shadow);
}

.country-poll__title {
    font-size: var(--text-lg);
    margin: 0;
}

.country-poll__title a {
    color: inherit;
    text-decoration: none;
}

.country-poll__title a:hover { color: var(--accent); }

.country-poll__pick {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-block: var(--space-1) var(--space-2);
}

.country-poll__answer {
    display: grid;
    gap: 2px;
    padding-left: var(--space-4);
    border-left: 1px solid var(--border);
}

.country-poll__pct {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.country-poll__label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 600;
}

/* Muestra de color de una opción, mismos colores que .stacked-bar y .legend */
.swatch {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: 2px;
}

.swatch--1 { background: var(--opt-1); }
.swatch--2 { background: var(--opt-2); }
.swatch--3 { background: var(--opt-3); }
.swatch--4 { background: var(--opt-4); }
.swatch--5 { background: var(--opt-5); }
.swatch--6 { background: var(--opt-6); }

.country-poll .legend .is-top {
    color: var(--text);
    font-weight: 600;
}

.country-poll__foot {
    display: grid;
    gap: var(--space-3);
}

/* Leyenda en 2 columnas que se leen de arriba abajo (1 y 2 a la izquierda, 3 y 4 a la derecha) */
.legend--columns {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--legend-rows, 2), 1.5em);
    grid-auto-columns: minmax(0, 1fr);
    column-gap: var(--space-5);
    row-gap: var(--space-1);
}

.legend--columns > span { min-width: 0; }

.legend--columns .legend__label {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge--differs { background: var(--accent-soft); color: var(--accent); }

/* Buscador del índice de países, a la derecha de los botones de orden */
.search {
    flex: 0 1 280px;
}

.country-count { margin: 0 0 var(--space-3); }

/* ==========================================================================
   User menu (cabecera)
   ========================================================================== */

.user-menu { position: relative; }

/* Menú "Log in / Sign up" para visitantes: solo en móvil, donde sustituye a los dos botones (.header-auth) */
.guest-menu { display: none; }

.user-menu__toggle { gap: var(--space-2); }

/* Nombres largos (hasta 30 caracteres) no ensanchan la cabecera */
.user-menu__name {
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-menu__toggle[aria-expanded="true"] .icon:last-child { transform: rotate(180deg); }

.user-menu__panel {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 50;
    display: grid;
    min-width: 220px;
    padding: var(--space-2);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.user-menu__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.user-menu__item:hover,
.user-menu__item[aria-current="page"],
.user-menu__item[aria-current="true"] { background: var(--surface-2); }

/* Selector de idioma: el panel solo necesita el ancho de "English" / "Español" */
.locale-menu__panel { min-width: 160px; }
.locale-menu__panel form { margin: 0; }
.locale-menu .icon-button .flag { border-radius: 2px; }
.user-menu__item .icon { color: var(--text-muted); }

.user-menu__sep {
    margin: var(--space-2) 0;
    border: 0;
    border-top: 1px solid var(--border);
}

/* ==========================================================================
   World map (Leaflet sin tiles)
   ========================================================================== */

.world-map {
    position: relative;
    z-index: 0; /* los paneles de Leaflet (z-index 400+) no pisan la cabecera fija */
    height: 380px;
    margin-bottom: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.world-map.leaflet-container {
    background: var(--surface);
    font: inherit;
}

/* Sin anillo de foco al pinchar un país: el mapa es decorativo (la tabla es la versión accesible) */
.world-map path:focus,
.world-map.leaflet-container:focus { outline: none; }

.world-map .world-map__country { cursor: default; }
.world-map .world-map__country--link { cursor: pointer; }

/* Muestras que el controlador lee para pintar con los colores del tema */
.world-map__probe-fill { background: var(--map-fill); }
.world-map__probe-empty { background: var(--surface-2); }
.world-map__probe-stroke { background: var(--surface); }
.world-map__probe-text { background: var(--text); }

/* Botones + / − con los colores del tema (Leaflet trae blanco y grises fijos, que en oscuro desentonan).
   Selectores con .world-map.leaflet-container porque la CSS de Leaflet se carga después de app.css */
.world-map.leaflet-container .leaflet-bar {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.world-map.leaflet-container .leaflet-bar a {
    background: var(--surface);
    color: var(--text);
    border-bottom-color: var(--border);
    transition: background var(--transition);
}

.world-map.leaflet-container .leaflet-bar a:last-child { border-bottom: 0; }

.world-map.leaflet-container .leaflet-bar a:hover,
.world-map.leaflet-container .leaflet-bar a:focus-visible { background: var(--surface-2); }

/* Zoom al tope: mismo fondo, solo el signo atenuado */
.world-map.leaflet-container .leaflet-bar a.leaflet-disabled {
    background: var(--surface);
    color: var(--border-strong);
}

.world-map__tip-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-2);
    font-weight: 600;
}

/* Bandera a la altura del texto del nombre */
.world-map__tip-title .flag {
    width: calc(1em * 4 / 3);
    height: 1em;
}

.world-map__tip-lines {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: var(--space-2);
    row-gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.world-map__tip-lines li { display: contents; }
.world-map__tip-lines .swatch { box-shadow: 0 0 0 1px color-mix(in srgb, var(--bg) 40%, transparent); }
.world-map__tip-pct { text-align: right; font-variant-numeric: tabular-nums; }

.world-map__tip-footer {
    display: block;
    margin-top: 4px;
    opacity: 0.7;
}

.world-map__tip-facts {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Popup al pinchar un país: resumen y enlace a su página */
.world-map__popup .leaflet-popup-content-wrapper,
.world-map__popup .leaflet-popup-tip {
    background: var(--text);
    color: var(--bg);
    box-shadow: none;
}

.world-map__popup .leaflet-popup-content-wrapper { border-radius: var(--radius-sm); }

.world-map__popup .leaflet-popup-content {
    margin: 8px 28px 8px 10px;
    font-size: var(--text-xs);
    line-height: 1.5;
}

/* Flecha sobre el punto pinchado aunque place() desplace la caja hacia un lado */
.world-map__popup .leaflet-popup-tip-container { margin-left: calc(-20px + var(--tip-shift, 0px)); }

/* Debajo del punto cuando arriba no cabe: el hueco de la flecha pasa arriba y la flecha apunta hacia arriba */
.world-map__popup.world-map__popup--below {
    margin-top: 20px;
    margin-bottom: 0;
}

.world-map__popup--below .leaflet-popup-tip-container {
    top: -20px;
    margin-top: 0;
}

.world-map__popup--below .leaflet-popup-tip { margin: 11px auto 0; }

.world-map__popup.leaflet-popup a.leaflet-popup-close-button { color: var(--bg); opacity: 0.7; }
.world-map__popup.leaflet-popup a.leaflet-popup-close-button:hover { color: var(--bg); opacity: 1; }

.world-map__popup a.world-map__tip-title {
    color: var(--bg);
    text-decoration: none;
}

.world-map__popup a.world-map__tip-title:hover { text-decoration: underline; text-underline-offset: 2px; }

.world-map__popup .world-map__tip-link {
    display: block;
    margin-top: var(--space-2);
    color: var(--bg);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.section-head__title {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.country-map { margin: 0 0 var(--space-6); }
.country-map .world-map { margin-bottom: var(--space-2); }

/* Fila del país del visitante, primera en el índice */
.country-table tr.is-mine td { background: var(--accent-soft); }
.country-table tr.is-mine td:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.country-table tr.is-mine td:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

/* Coincidencia con el global en el índice de países: ocupa el ancho sobrante */
.country-table .col-agreement {
    width: 100%;
    padding-right: var(--space-6);
}

.agreement {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.meter {
    flex: 1;
    max-width: 320px;
    height: 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
}

.agreement__value {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    min-width: 3.5em;
}

/* ==========================================================================
   Prose (privacy)
   ========================================================================== */

.prose { max-width: 68ch; }
.prose h2 { margin-top: var(--space-7); margin-bottom: var(--space-3); }
.prose p,
.prose ul { margin-bottom: var(--space-4); color: var(--text-muted); }
.prose ul { padding-left: var(--space-5); }
.prose li + li { margin-top: var(--space-2); }
.prose strong { color: var(--text); }

/* ==========================================================================
   Sponsors
   ========================================================================== */

/* Logo de un sponsor: siempre sobre blanco, para que cualquier logo se vea igual en los dos temas y sobre la franja roja */
.sponsor-logo {
    display: inline-grid;
    place-items: center;
    height: 36px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: #ffffff;
    color: #1a1916;
    text-decoration: none;
    font-weight: 600;
    font-size: var(--text-sm);
}

/* Alto fijo de la caja: el logo se ajusta dentro sin deformarse */
.sponsor-logo img { display: block; height: 100%; width: auto; max-width: 140px; min-height: 0; object-fit: contain; }
.sponsor-logo:hover { box-shadow: 0 0 0 2px var(--accent); }
/* En el pie, mismas cajas que en la franja Gold de arriba (Gold va primero) */
.sponsor-bar .sponsor-logo { height: 24px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border); }
.sponsor-bar .sponsor-logo img { max-width: 120px; }

/* Fondo según el nivel, igual en la franja de arriba, el pie y /sponsors. Tonos claros fijos (también en
   modo oscuro) para que cualquier logo oscuro se lea; el bronce, más discreto */
.sponsor-logo.sponsor-logo--gold:not(.sponsor-logo--empty) {
    background: linear-gradient(135deg, #fff6d6 0%, #f6e3a1 100%);
    border-color: #e0c064;
}

.sponsor-logo.sponsor-logo--silver:not(.sponsor-logo--empty) {
    background: linear-gradient(135deg, #f7f8fa 0%, #dfe3e8 100%);
    border-color: #c3c9d1;
}

.sponsor-logo.sponsor-logo--bronze:not(.sponsor-logo--empty) {
    background: #faf3ee;
    border-color: #ead8ca;
}

/* Franja Gold: debajo del header, en todas las páginas */
.gold-strip {
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.gold-strip__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-1) var(--space-2);
    padding-block: 6px;
}

.gold-strip__label {
    margin-right: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gold-strip__label:hover { color: var(--text); }
.gold-strip .sponsor-logo { height: 24px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--border); }
.gold-strip .sponsor-logo img { max-width: 120px; }

/* Página /sponsors */

.sponsor-section { margin-bottom: var(--space-8); }
.sponsor-section > h2 { margin-bottom: var(--space-3); }
.sponsor-section > p.muted { margin: 0 0 var(--space-5); }

.sponsor-why {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-5);
    margin: var(--space-5) 0 0;
    padding: 0;
    list-style: none;
}

.sponsor-why h3 { margin: var(--space-3) 0 var(--space-2); font-size: var(--text-base); }
.sponsor-why p { margin: 0; font-size: var(--text-sm); }

.sponsor-why__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.2rem;
}

.tier-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-5);
    margin-block: 0 var(--space-4);
}

.tier-card { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-5); }
.tier-card--gold { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.tier-card__head { display: grid; gap: var(--space-1); }
.tier-card__name { margin: 0; font-size: var(--text-lg); }
.tier-card__price { margin: 0; }
.tier-card__price strong { font-family: var(--font-heading); font-size: 2rem; color: var(--text); }

.tier-card__perks {
    display: grid;
    gap: var(--space-2);
    align-content: start;
    flex: 1;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--text-sm);
}

.tier-card__perks li { display: flex; gap: var(--space-2); }
.tier-card__perks .icon { margin-top: 3px; color: var(--success); }

.tier-card__slots { margin: 0; font-size: var(--text-xs); color: var(--success); }
.tier-card__slots--full { color: var(--text-muted); }

.sponsor-group + .sponsor-group { margin-top: var(--space-7); }
.sponsor-group__title { margin: 0 0 var(--space-4); }

/* Alineado a la izquierda y con cajas iguales en los tres niveles */
.sponsor-logos { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.sponsor-logos .sponsor-logo { width: 220px; height: 88px; padding: 12px 20px; border: 1px solid var(--border); }
.sponsor-logos .sponsor-logo img { max-width: 100%; }

/* Hueco libre: invita a ocuparlo */
.sponsor-logo--empty {
    border: 1px dashed var(--border-strong);
    background: transparent;
    color: var(--text-muted);
    font-weight: 400;
    font-size: var(--text-xs);
}

.sponsor-logos .sponsor-logo--empty { border-style: dashed; border-color: var(--border-strong); }
.sponsor-logo--empty:hover { color: var(--text); }

.sponsor-section.prose h2 { margin-top: 0; }
.sponsor-faq { margin: 0; }
.sponsor-faq dt { margin-top: var(--space-4); font-weight: 600; color: var(--text); }
.sponsor-faq dd { margin: var(--space-1) 0 0; color: var(--text-muted); }

/* Al bajar a #contact (tras enviar), que el header fijo no tape el título */
.sponsor-contact { margin-bottom: 0; scroll-margin-top: calc(64px + var(--space-5)); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: var(--space-5);
}

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

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .sponsor-section { margin-bottom: var(--space-7); }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 860px) {
    .poll-layout,
    .profile-layout { grid-template-columns: 1fr; }
    .aside-card { position: static; }
    .poll-top .poll-cover { min-height: 200px; }
}

@media (max-width: 640px) {
    .container { padding-inline: var(--space-4); }
    .site-main { padding-block: var(--space-6) var(--space-8); }
    .header-actions .header-auth { display: none; }
    /* En móvil, solo el título de la franja de patrocinio: cabe en una línea */
    .sponsor-bar__lead { display: none; }
    /* Franja Gold: a la izquierda en escritorio, centrada en móvil */
    .gold-strip__inner { justify-content: center; }
    .header-actions .guest-menu { display: block; }
    /* Botones de icono más grandes al dedo; el de texto cede padding lateral para que quepan */
    .header-actions .btn { height: 40px; padding-inline: 0.8rem; }
    .header-actions .icon-button { width: 40px; height: 40px; font-size: 1.125rem; }
    /* Menú de usuario igual que los botones de icono: cuadrado, mismo icono y sin flecha */
    .header-actions .user-menu__toggle {
        width: 40px;
        padding: 0;
        justify-content: center;
        gap: 0;
        background: transparent;
        font-size: 1.125rem;
    }
    /* Sin la flecha del menú de usuario; el icono único del menú de visitante (primero y último a la vez) se queda */
    .header-actions .user-menu__toggle .icon:last-child:not(:first-child) { display: none; }
    .hero__bar { flex-direction: column; align-items: stretch; }
    .hero__actions .btn { flex: 1 1 auto; }
    .search { flex-basis: 100%; }
    /* Las pestañas que no caben en una línea pasan a la siguiente, ocupando todo el ancho */
    .segmented--wrap { display: flex; flex-wrap: wrap; width: 100%; }
    .segmented--wrap a { flex: 1 1 auto; text-align: center; white-space: nowrap; }
    .world-map { height: 240px; }
    .stats {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding-top: var(--space-5);
        border-top: 1px solid var(--border);
    }
    .stat { padding-inline: var(--space-4); }
    .stat:first-child { padding-left: 0; }
    .poll-grid { grid-template-columns: 1fr; }
    .country-poll { grid-template-columns: minmax(0, 1fr); }
    .country-poll .poll-card__media {
        order: 0;
        aspect-ratio: 16 / 9;
        min-height: 0;
        border-left: 0;
        border-bottom: 1px solid var(--border);
    }
    .country-poll .poll-card__body { padding: var(--space-5); }
    /* La portada crece con la imagen en vez de encogerla a 21:8 */
    .poll-cover:has(img) { aspect-ratio: auto; padding: var(--space-4); }
    .poll-cover img { width: 100%; max-height: 70vh; }
    .vote-options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
    .card { padding: var(--space-5); }
    .country-table .hide-sm { display: none; }
    .country-table td:first-child { white-space: normal; }
    .country-table .col-split,
    .country-table .col-agreement { padding-right: var(--space-3); }
    .meter { min-width: 48px; }
    .stacked-bar { min-width: 80px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* Vote quickly: una encuesta cada vez con barra de progreso */
.quick-vote__progress { margin: 0; }

.quick-vote__bar {
    appearance: none;
    width: 100%;
    height: 6px;
    border: 0;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border);
}

.quick-vote__bar::-webkit-progress-bar { background: var(--border); }
.quick-vote__bar::-webkit-progress-value { background: var(--accent); }
.quick-vote__bar::-moz-progress-bar { background: var(--accent); }

.quick-vote .vote-options { margin-bottom: var(--space-6); }

.quick-vote-done { margin-bottom: var(--space-6); }

/* ==========================================================================
   Evolution (encuesta): resultado global al cierre de cada mes
   ========================================================================== */

.evolution-chart {
    position: relative;
    height: 280px;
}

.evolution-data { margin-top: var(--space-4); }
.evolution-data summary { cursor: pointer; font-size: var(--text-sm); color: var(--text-muted); }
.evolution-data__scroll { overflow-x: auto; margin-top: var(--space-3); }

.evolution-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.evolution-table th,
.evolution-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px dashed var(--border);
    text-align: left;
    white-space: nowrap;
}

.evolution-table thead th {
    font-weight: 500;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom-style: solid;
}

.evolution-table tbody th { font-weight: 500; }
.evolution-table .num { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
    .evolution-chart { height: 220px; }
}

/* ==========================================================================
   Compare: dos países, encuesta a encuesta
   ========================================================================== */

.compare-picker {
    display: grid;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.compare-picker__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}

.compare-picker__field {
    display: flex;
    align-items: flex-end;
    gap: var(--space-2);
    flex: 1 1 180px;
    min-width: 0;
}

.compare-picker__field .field { flex: 1; min-width: 0; }
.compare-picker__remove { width: 42px; height: 42px; flex-shrink: 0; }
.compare-picker > .btn { justify-self: start; }

.compare-summary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.compare-summary__item {
    display: grid;
    gap: var(--space-1);
    flex: 1 1 200px;
    padding: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.compare-summary__value {
    font-family: var(--font-heading);
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
}

.compare-list {
    display: grid;
    gap: var(--space-5);
}

.compare-item { display: grid; gap: var(--space-4); }
/* Leyenda separada de las barras de los países */
.compare-item > .legend { margin-top: var(--space-3); }

.compare-item__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

/* Una columna por país (2 o 3); pasan a varias filas si no caben */
.compare-item__sides {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(max(200px, calc((100% - var(--space-6) * 2) / var(--compare-columns, 2))), 1fr));
    column-gap: var(--space-6);
    row-gap: var(--space-2);
}

/* Nombre, porcentaje y barra comparten filas con los otros países (subgrid): si una respuesta ocupa
   dos líneas, las demás columnas crecen igual y las barras quedan a la misma altura */
.compare-side {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    align-items: center;
}

.compare-side .country-poll__pick { margin: 0; }
.compare-side .stacked-bar { align-self: start; margin-bottom: var(--space-4); }

.compare-side__country {
    display: flex;
    /* Nombre y nº de votos sobre la misma línea base (tamaños distintos); la bandera, centrada */
    align-items: baseline;
    gap: var(--space-2);
    margin: 0 0 var(--space-2);
    font-weight: 600;
}

.compare-side__country .flag { align-self: center; }

.badge--agree { background: var(--success-soft); color: var(--success); }
.badge--agree::before { display: none; }
.badge--agree .icon { width: 12px; height: 12px; }

@media (max-width: 640px) {
    .compare-item__sides { grid-template-columns: 1fr; }
    .compare-item__head { flex-direction: column; }
}

/* Buscador de países (Tom Select, country_search_controller.js) con el aspecto de .select */
.ts-wrapper.select {
    padding: 0;
    border: 0;
    background: none;
}

.ts-wrapper.select .ts-control {
    min-height: 42px;
    padding: 0.65rem 2.2rem 0.65rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.8rem center;
    box-shadow: none;
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    cursor: text;
}

.ts-wrapper.select .ts-control > input {
    color: var(--text);
    font: inherit;
}

/* Siempre una línea: en campos estrechos Tom Select bajaba el cursor de búsqueda a una segunda línea */
.ts-wrapper.select .ts-control { flex-wrap: nowrap; overflow: hidden; }
.ts-wrapper.select.has-items:not(.is-searching) .ts-control > input { flex: 0 0 0; min-width: 0; width: 0 !important; }
.ts-wrapper.select .ts-control > .item { min-width: 0; overflow: hidden; }
.country-search__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ts-wrapper.select .ts-control > input::placeholder { color: var(--text-muted); }
.ts-wrapper.select.has-items:not(.is-searching) .ts-control > input::placeholder { color: transparent; }
.ts-wrapper.select:hover .ts-control { border-color: var(--border-strong); }
.ts-wrapper.select.is-searching .ts-control > .item { display: none; }
/* Con el país oculto, el campo de búsqueda ocupa todo el ancho (Tom Select lo deja a size=1) */
.ts-wrapper.select.is-searching .ts-control > input { flex: 1 1 auto; min-width: 0; width: auto !important; }

.ts-wrapper.select.focus .ts-control {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.ts-dropdown {
    margin-top: var(--space-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    font-size: var(--text-sm);
    overflow: hidden;
}

.ts-dropdown .option,
.ts-dropdown .no-results { padding: 0.5rem 0.8rem; }
.ts-dropdown .active { background: var(--surface-2); color: var(--text); }
.ts-dropdown .selected { color: var(--accent); }
.ts-dropdown .highlight { background: var(--accent-soft); color: inherit; border-radius: 2px; }

.country-search__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

@media (pointer: coarse) {
    .ts-wrapper.select .ts-control { font-size: 16px; }
}
