:root {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #17191d;
    background: #f4f5f7;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(75, 91, 255, .08), transparent 28rem),
        #f4f5f7;
}

button,
input {
    font: inherit;
}

.container {
    width: min(1320px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    background: rgba(255,255,255,.86);
    border-bottom: 1px solid #e2e5e9;
    backdrop-filter: blur(14px);
    position: relative;
    z-index: 5;
}

.nav {
    min-height: 70px;
    display: flex;
    align-items: center;
}

.nav-split {
    justify-content: space-between;
    gap: 20px;
}

.logo {
    color: #17191d;
    text-decoration: none;
    font-weight: 900;
    font-size: 1.45rem;
    letter-spacing: -.04em;
}

.back-site-link {
    color: #656d78;
    text-decoration: none;
    font-size: .92rem;
    font-weight: 700;
}

.hero {
    padding: 76px 0 38px;
}

.eyebrow {
    display: inline-block;
    color: #5a63d8;
    font-size: .78rem;
    font-weight: 850;
    letter-spacing: .12em;
}

.hero h1,
.editor-intro h1 {
    max-width: 740px;
    margin: 12px 0;
    font-size: clamp(2.5rem, 7vw, 5rem);
    letter-spacing: -.055em;
    line-height: .98;
}

.hero p,
.editor-intro p {
    max-width: 680px;
    margin: 20px 0 0;
    color: #656d78;
    line-height: 1.7;
    font-size: 1.05rem;
}

.candidates-section {
    padding: 26px 0 80px;
}

/*
 * Desktop: sempre 5 posições por linha.
 * Se houver somente 1 candidato, ele continuará ocupando 1/5 da linha.
 */
.candidate-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

.candidate-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e0e3e8;
    border-radius: 20px;
    box-shadow: 0 16px 42px rgba(20,27,43,.06);
}

.candidate-preview {
    width: 100%;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eceff3;
    border-bottom: 1px solid #e1e5ea;
}

.candidate-preview-checker,
.candidate-preview-empty {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #d2d8df;
}

.candidate-preview-checker {
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e1e5e9 25%, transparent 25%),
        linear-gradient(-45deg, #e1e5e9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e1e5e9 75%),
        linear-gradient(-45deg, transparent 75%, #e1e5e9 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.candidate-preview-checker img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.candidate-preview-empty {
    display: grid;
    place-items: center;
    color: #969da7;
    background: #f5f6f8;
    font-weight: 800;
}

.candidate-content {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.candidate-number {
    align-self: flex-start;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border-radius: 999px;
    background: #17191d;
    color: #fff;
    font-size: .9rem;
    font-weight: 850;
    letter-spacing: .03em;
}

.candidate-copy {
    flex: 1;
}

.candidate-card h2 {
    margin: 14px 0 5px;
    font-size: 1.18rem;
    line-height: 1.12;
    letter-spacing: -.025em;
}

.candidate-office {
    margin: 0 0 11px;
    color: #646c77;
    font-weight: 650;
    font-size: .86rem;
    line-height: 1.35;
}

.candidate-description {
    margin: 0 0 14px;
    color: #6f7782;
    line-height: 1.5;
    font-size: .84rem;
}

.select-button {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 11px;
    background: #17191d;
    color: #fff;
    font: inherit;
    font-size: .88rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    text-align: center;
    transition: transform .15s ease, background .15s ease;
}

.select-button:hover {
    transform: translateY(-1px);
    background: #292d33;
}

.select-button-disabled {
    background: #e8eaee;
    color: #8a9099;
    cursor: not-allowed;
}

.empty-state {
    padding: 42px;
    text-align: center;
    border: 1px dashed #c9ced6;
    border-radius: 20px;
    background: rgba(255,255,255,.55);
}

.empty-state h2 { margin-top: 0; }

.empty-state p {
    color: #707783;
    margin-bottom: 0;
}

.site-footer {
    padding: 26px 0;
    border-top: 1px solid #e0e3e7;
    color: #8a919a;
    font-weight: 700;
}

/* Editor */
.editor-shell {
    padding-top: 50px;
    padding-bottom: 72px;
}

.editor-intro {
    margin-bottom: 30px;
}

.editor-intro h1 {
    font-size: clamp(2.4rem, 6vw, 4.6rem);
    margin-bottom: 14px;
}

.editor-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.editor-meta span {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 0 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #dde1e6;
    font-size: .9rem;
    font-weight: 800;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
    gap: 26px;
    align-items: start;
}

.editor-preview-card {
    padding: 18px;
    background: #fff;
    border: 1px solid #e0e4e9;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(22,30,48,.08);
    position: sticky;
    top: 22px;
}

.canvas-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 18px;
    background: #e8ebef;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.canvas-wrap.has-photo:active,
.canvas-wrap.is-dragging {
    cursor: grabbing;
}

#editorCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.canvas-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    pointer-events: none;
    color: #717986;
    text-align: center;
}

.canvas-empty[hidden] { display: none; }

.canvas-empty-icon {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: rgba(255,255,255,.82);
    border: 1px solid #d3d8df;
    color: #3f4650;
    font-size: 1.6rem;
}

.canvas-empty strong {
    color: #3c424a;
    font-size: 1.05rem;
}

.canvas-empty span { font-size: .88rem; }

.privacy-note {
    margin-top: 13px;
    color: #747d89;
    font-size: .84rem;
    text-align: center;
    line-height: 1.5;
}

.editor-controls {
    display: grid;
    gap: 14px;
}

.control-card {
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 14px;
    padding: 20px;
    border-radius: 19px;
    background: #fff;
    border: 1px solid #e0e4e9;
    box-shadow: 0 14px 38px rgba(22,30,48,.05);
    transition: opacity .18s ease;
}

.control-disabled { opacity: .52; }

.step-number {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: #17191d;
    color: #fff;
    font-weight: 900;
}

.control-copy h2 {
    margin: 2px 0 6px;
    font-size: 1.15rem;
    letter-spacing: -.02em;
}

.control-copy p {
    margin: 0 0 16px;
    color: #737b87;
    font-size: .92rem;
    line-height: 1.5;
}

.photo-picker,
.download-button {
    min-height: 50px;
    width: 100%;
    border: 0;
    border-radius: 13px;
    background: #17191d;
    color: #fff;
    font-weight: 850;
    cursor: pointer;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.photo-picker:hover,
.download-button:not(:disabled):hover {
    background: #2a2e34;
}

.download-button:disabled,
.secondary-action:disabled {
    cursor: not-allowed;
}

.range-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: .88rem;
    font-weight: 800;
    color: #444b55;
}

.zoom-range {
    width: 100%;
    margin: 12px 0 16px;
    accent-color: #17191d;
}

.adjust-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.secondary-action {
    min-height: 42px;
    border-radius: 11px;
    border: 1px solid #d7dce2;
    background: #f6f7f8;
    color: #363c45;
    font-weight: 780;
    cursor: pointer;
}

.editor-status {
    min-height: 22px;
    margin-top: 9px;
    text-align: center;
    font-size: .85rem;
    color: #6d7580;
}

.editor-status[data-type="error"] { color: #c84552; }
.editor-status[data-type="success"] { color: #258748; }

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

/* Responsividade do grid */
@media (max-width: 1180px) {
    .candidate-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .candidate-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .candidate-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .editor-layout {
        grid-template-columns: 1fr;
    }

    .editor-preview-card {
        position: static;
    }
}

@media (max-width: 520px) {
    .hero { padding-top: 52px; }

    .candidate-grid {
        grid-template-columns: 1fr;
    }

    .candidate-card {
        max-width: 100%;
    }

    .editor-shell { padding-top: 34px; }

    .editor-intro h1 { font-size: 2.6rem; }

    .control-card {
        grid-template-columns: 36px 1fr;
        padding: 17px;
    }

    .step-number {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }

    .adjust-actions {
        grid-template-columns: 1fr;
    }
}
