:root {
    --primary: #4f883d;
    --primary-dark: #355d29;
    --primary-soft: #edf6ea;
    --ink: #203042;
    --muted: #6d7887;
    --panel-border: #dfe5ec;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --preview-bg: #e9edf4;
    --shadow: 0 24px 60px rgba(24, 39, 75, 0.12);
    --radius: 5px;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Nunito", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 211, 163, 0.45), transparent 28%),
        radial-gradient(circle at right center, rgba(150, 204, 180, 0.35), transparent 24%),
        linear-gradient(180deg, #f4f7fb 0%, #edf1f7 100%);
}

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
}

.app-header {
    grid-column: 1 / -1;
    padding: 18px 28px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(223, 229, 236, 0.9);
    box-shadow: 0 10px 28px rgba(24, 39, 75, 0.06);
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 0.76rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--primary);
}

.app-header h1 {
    margin: 0;
    font-size: 1.7rem;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.header-copy {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 780px;
}

.panel {
    background: rgba(255, 255, 255, 0.94);
    border-right: 1px solid var(--panel-border);
    overflow-y: auto;
}

.section {
    padding: 18px 20px;
    border-bottom: 1px solid #eef2f6;
}

.section-title {
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--primary);
    margin-bottom: 14px;
}

.form-group {
    display: grid;
    gap: 10px;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

label,
.option-label,
.ai-label {
    display: block;
    font-weight: 800;
    color: var(--ink);
}

textarea,
select,
.ai-group input[type="text"],
.ai-group input[type="number"] {
    width: 100%;
    border: 1px solid #d5dde8;
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    font: inherit;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

textarea:focus,
select:focus,
.ai-group input[type="text"]:focus,
.ai-group input[type="number"]:focus {
    outline: none;
    border-color: rgba(79, 136, 61, 0.75);
    box-shadow: 0 0 0 4px rgba(79, 136, 61, 0.12);
}

textarea {
    min-height: 190px;
    resize: vertical;
    padding: 14px 16px;
    font-size: 1.05rem;
    line-height: 1.5;
}

select,
.ai-group input[type="text"],
.ai-group input[type="number"] {
    padding: 12px 14px;
}

.helper-text {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.counter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.92rem;
}

.counter-row strong {
    min-width: 42px;
    text-align: right;
    color: var(--primary-dark);
    font-size: 1rem;
}

.option-group {
    display: grid;
    gap: 12px;
}

.option-group + .option-group {
    margin-top: 18px;
}

.option-group.compact {
    margin-top: 18px;
}

.choice-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.choice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 2px solid #dfe5ec;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.choice-btn:hover,
.check-card:hover,
.btn-primary:hover,
.btn-secondary:hover,
.ai-btn:hover {
    transform: translateY(-1px);
}

.choice-btn input,
.check-card input {
    accent-color: var(--primary);
    margin: 0;
}

.choice-btn:has(input:checked) {
    border-color: var(--primary);
    background: linear-gradient(180deg, #f7fff4 0%, #edf6ea 100%);
    box-shadow: 0 10px 18px rgba(79, 136, 61, 0.12);
}

.symbols-info {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, #f4f8ff 0%, #edf3fb 100%);
    border: 1px solid #d8e3f0;
    color: #325173;
    font-size: 0.88rem;
    line-height: 1.45;
}

.checks-grid {
    display: grid;
    gap: 10px;
}

.check-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface-soft);
    border: 1px solid #e3e9f1;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.check-card:has(input:checked) {
    border-color: rgba(79, 136, 61, 0.45);
    box-shadow: 0 8px 16px rgba(79, 136, 61, 0.08);
}

.actions-section {
    display: grid;
    gap: 12px;
}

.info-box,
#info {
    border-radius: var(--radius);
    padding: 14px 16px;
    background: #f5f7fa;
    border: 1px solid #e0e6ed;
    color: var(--muted);
    line-height: 1.45;
}

.info-warning {
    background: #fff1ef;
    border-color: #f6c8bf;
    color: #8b3b30;
}

.info-success {
    background: #eef9ee;
    border-color: #cde8cb;
    color: #2f6e3d;
}

button {
    font: inherit;
}

.btn-primary,
.btn-secondary,
.ai-btn,
#aiSubmitBtn,
.ai-secondary {
    border: none;
    cursor: pointer;
    border-radius: var(--radius);
    font-weight: 800;
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease, background 0.14s ease;
}

.btn-primary,
.ai-btn,
#aiSubmitBtn {
    background: linear-gradient(180deg, #5c9d47 0%, #4f883d 100%);
    color: #fff;
    box-shadow: 0 14px 26px rgba(79, 136, 61, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px 16px;
}

.btn-secondary {
    width: 100%;
    padding: 13px 16px;
    background: #fff;
    color: var(--primary-dark);
    border: 2px solid rgba(79, 136, 61, 0.25);
}

.ai-btn {
    margin: 0;
    padding: 10px 14px;
    white-space: nowrap;
}

.btn-primary:disabled,
.btn-secondary:disabled,
.ai-btn:disabled,
#aiSubmitBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

#downloadSection {
    display: none;
    gap: 10px;
}

#downloadSection p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.45;
}

.preview-area {
    padding: 24px 26px 32px;
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.48)),
        radial-gradient(circle at top right, rgba(255, 228, 167, 0.45), transparent 24%),
        linear-gradient(180deg, #eff3f9 0%, #e7edf5 100%);
}

.preview-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.preview-label {
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: #6f7b8f;
    margin-bottom: 8px;
}

.preview-head h2 {
    margin: 0;
    font-size: 1.55rem;
    letter-spacing: -0.04em;
}

.preview-head p {
    margin: 8px 0 0;
    color: var(--muted);
    max-width: 560px;
}

.preview-stats {
    flex-shrink: 0;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(223, 229, 236, 0.9);
    color: var(--primary-dark);
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(24, 39, 75, 0.07);
}

.preview-empty {
    min-height: 260px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 32px;
    border-radius: var(--radius);
    border: 2px dashed rgba(79, 136, 61, 0.25);
    background: rgba(255, 255, 255, 0.56);
    color: var(--muted);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.preview-empty.hidden {
    display: none;
}

.preview-empty-badge {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 92px;
    padding: 10px 18px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    background: #fff;
    color: var(--primary-dark);
    font-family: "Baloo 2", "Nunito", sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 14px 28px rgba(79, 136, 61, 0.12);
}

.preview-empty h3 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.preview-empty p {
    margin: 0;
}

#preview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
    gap: 24px;
    justify-content: flex-start;
}

#preview.has-cards {
    margin-top: 8px;
}

.preview-render {
    display: block;
    width: 100%;
    max-width: 320px;
    height: auto;
}

.dobble-card {
    position: relative;
    width: min(100%, 320px);
    aspect-ratio: 1;
    overflow: hidden;
    isolation: isolate;
    padding: 18px;
    background: var(--card-background, #fff9eb);
    box-shadow: var(--card-shadow, 0 18px 30px rgba(24, 39, 75, 0.16));
}

.dobble-card::before {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: inherit;
    border: 2px dashed var(--card-ring, rgba(255, 255, 255, 0.7));
    opacity: 0.8;
    pointer-events: none;
}

.dobble-card.square {
    border-radius: var(--radius);
    border: 6px solid var(--card-border, #e28b49);
}

.dobble-card.hex {
    border: 6px solid var(--card-border, #e28b49);
    clip-path: polygon(25% 5%, 75% 5%, 96% 50%, 75% 95%, 25% 95%, 4% 50%);
    filter: drop-shadow(0 18px 30px rgba(24, 39, 75, 0.16));
}

.card-spark {
    position: absolute;
    inset: auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--spark-color, rgba(255, 255, 255, 0.7));
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
    opacity: 0.95;
    z-index: 0;
}

.word {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    max-width: 66%;
    padding: 0.3em 0.72em;
    text-align: center;
    line-height: 1.15;
    flex-wrap: wrap;
    white-space: normal;
    border-radius: var(--word-radius, var(--radius));
    border: 2px solid var(--word-border, rgba(0, 0, 0, 0.1));
    background: var(--word-fill, rgba(255, 255, 255, 0.82));
    color: var(--word-color, #28313c);
    box-shadow: 0 10px 18px rgba(24, 39, 75, 0.14);
    transform-origin: center;
    backdrop-filter: blur(1px);
}

.word.word-plain {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding: 0;
    max-width: 60%;
}

.word[data-shape="ticket"] {
    border-radius: var(--radius);
}

.word[data-shape="cloud"] {
    border-radius: var(--radius);
}

.word[data-shape="tag"] {
    border-radius: var(--radius);
}

.ai-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 20px 20px;
    z-index: 1000;
}

.ai-modal[aria-hidden="false"] {
    display: flex;
}

.ai-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(19, 29, 46, 0.58);
    backdrop-filter: blur(6px);
}

.ai-dialog {
    position: relative;
    width: min(560px, calc(100% - 12px));
    padding: 24px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    z-index: 1;
}

.ai-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.ai-kicker {
    margin: 0 0 6px;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 800;
    color: var(--primary);
}

.ai-header h3 {
    margin: 0;
    font-size: 1.35rem;
}

.ai-close {
    margin: 0;
    padding: 8px 12px;
    background: #f2f5f9;
    color: var(--ink);
    border-radius: var(--radius);
    border: none;
    box-shadow: none;
}

.ai-group {
    margin-bottom: 16px;
}

.ai-group label,
.ai-label {
    margin-bottom: 8px;
}

.ai-radios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 10px;
}

.ai-radios label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: #f6f8fb;
    font-weight: 700;
}

.ai-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.ai-status {
    flex: 1;
    min-height: 22px;
    font-size: 0.92rem;
    color: var(--muted);
}

.ai-buttons {
    display: flex;
    gap: 10px;
}

.ai-buttons button {
    margin: 0;
    padding: 12px 16px;
}

.ai-secondary {
    background: #eef2f6;
    color: var(--ink);
    box-shadow: none;
}

@media (max-width: 1080px) and (min-width: 841px) {
    .app {
        grid-template-columns: minmax(330px, 360px) minmax(0, 1fr);
    }

    .app-header {
        padding: 16px 20px;
    }

    .section {
        padding: 16px;
    }

    .preview-area {
        padding: 18px 18px 24px;
    }

    .preview-head {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 16px;
    }

    .preview-stats {
        width: 100%;
    }

    #preview {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
        justify-items: center;
    }

    .preview-render {
        max-width: 290px;
    }
}

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

    .panel {
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }

    .preview-area {
        padding-top: 20px;
    }
}

@media (max-width: 720px) {
    .app-header {
        padding: 18px 18px 16px;
    }

    .section,
    .preview-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .choice-row {
        grid-template-columns: 1fr;
    }

    .label-row,
    .preview-head,
    .ai-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-stats {
        width: 100%;
    }

    #preview {
        grid-template-columns: 1fr;
        justify-content: center;
    }

    .dobble-card {
        margin: 0 auto;
    }
}

@media print {
    body {
        background: #fff;
    }

    .app {
        display: block;
    }

    .app-header,
    .panel,
    .preview-head,
    .preview-empty {
        display: none !important;
    }

    .preview-area {
        padding: 0;
        background: #fff;
    }

    #preview {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8mm;
    }

    .dobble-card {
        box-shadow: none;
    }
}
