:root {
    --wp-lime: #ccff33;
    --wp-blue: #bdeeff;
    --ink: #111827;
    --muted: #5b667a;
    --border: #d9e2ef;
    --panel: rgba(255, 255, 255, 0.92);
    --shadow: 0 18px 45px rgba(31, 41, 55, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(189, 238, 255, 0.65), transparent 34rem),
        linear-gradient(180deg, #f7fbff 0%, #ffffff 55%, #f8fbff 100%);
}

#pageContent {
    flex: 1;
}

.app-shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 32px;
}

.hero-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero-card {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 28px;
    align-items: center;
    padding: 24px;
    margin-bottom: 18px;
}

.hero-logo-wrap {
    width: 190px;
    height: 190px;
    border-radius: 34px;
    overflow: hidden;
    background: var(--wp-blue);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}

.hero-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.eyebrow {
    margin: 0 0 8px;
    color: #2563eb;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 12px;
}

h1, h2, h3, h5, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: clamp(34px, 5vw, 56px);
    line-height: 0.96;
    letter-spacing: -0.05em;
}

h2 {
    margin-bottom: 8px;
    font-size: 26px;
    letter-spacing: -0.03em;
}

h3 {
    font-size: 20px;
    color: var(--muted);
}

.helper-text,
.muted {
    color: var(--muted);
    line-height: 1.45;
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.key-row,
.button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    border: 1px solid #cfe2ff;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

input,
textarea {
    width: 100%;
    border: 1px solid #c8d3e1;
    border-radius: 14px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input {
    min-width: 280px;
    flex: 1;
    padding: 14px 16px;
}

textarea {
    display: none;
    min-height: 120px;
    padding: 14px 16px;
    margin: 0 0 18px;
    resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}

button {
    appearance: none;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 800;
    letter-spacing: -0.02em;
    transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(17, 24, 39, 0.12);
}

button:disabled {
    background-color: #8f98a3 !important;
    color: #e5e7eb !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#uploadButton,
#selectButton,
#submitKeyButton {
    background-color: var(--wp-lime);
    color: #000000;
    font-size: 20px;
    padding: 16px 24px;
    min-width: 220px;
}

#submitKeyButton {
    min-width: 170px;
}

#statusBox {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 16px;
    margin: 0 0 18px;
    display: none;
    background: #eef6ff;
    border: 1px solid #cfe2ff;
    color: #183763;
}

#dk {
    color: #7a8495;
    font-style: italic;
    margin-bottom: 4px;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.image-preview {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: #f5f7fb;
    box-shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-preview .remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    padding: 0;
    background-color: rgba(239, 68, 68, 0.92);
    color: white;
    border-radius: 50%;
    font-size: 16px;
    line-height: 34px;
}

#uploadProgress {
    width: 100%;
    height: 12px;
    margin: 0 0 22px;
    display: none;
    accent-color: #2563eb;
}

footer {
    padding: 18px 24px;
    border-top: 3px solid var(--wp-lime);
    font-size: 12px;
    text-align: left;
    background: #fff;
}

.footer-inner {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

#footer-logo {
    width: 190px;
    height: auto;
    display: block;
}

footer p {
    margin: 0;
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 22px, 560px);
        padding-top: 16px;
    }

    .hero-card {
        grid-template-columns: 1fr;
        gap: 18px;
        padding: 18px;
    }

    .hero-logo-wrap {
        width: 150px;
        height: 150px;
    }

    h1 {
        font-size: 38px;
    }

    .panel {
        padding: 18px;
    }

    .section-heading,
    .key-row,
    .button-row {
        display: block;
    }

    #uploadButton,
    #selectButton,
    #submitKeyButton,
    input {
        width: 100%;
        min-width: 0;
    }

    #uploadButton,
    #selectButton,
    #submitKeyButton {
        margin-top: 10px;
    }

    .image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .footer-inner {
        width: 100%;
        align-items: flex-start;
        flex-direction: column;
    }
}

.next-step {
    display: block;
    margin: 8px 0 16px;
    padding: 14px 16px;
    border-radius: 16px;
    background: #eff6ff;
    border: 1px solid #cfe2ff;
    color: #183763;
    font-weight: 800;
    line-height: 1.35;
}

.comment-panel label {
    display: block;
    margin-bottom: 6px;
    font-weight: 900;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.comment-panel textarea {
    display: block;
    margin-bottom: 0;
}

.button-row {
    align-items: stretch;
}

#uploadButton.primary-action {
    background: #111827 !important;
    color: #ffffff !important;
    box-shadow: 0 12px 26px rgba(17, 24, 39, 0.18);
}

#selectButton.secondary-action {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    border: 1px solid #cfe2ff;
}

.success-card {
    width: min(100%, 420px) !important;
    text-align: center !important;
    font-size: 28px !important;
    font-weight: 900 !important;
    margin: 0 0 16px !important;
    padding: 22px !important;
    border-radius: 18px !important;
    box-sizing: border-box !important;
    color: #000 !important;
    background: var(--wp-lime) !important;
    border: 0 !important;
}

.success-action {
    display: block;
    margin: 10px 0 0;
    background-color: var(--wp-lime);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    color: #000000;
    font-size: 18px;
    font-weight: 900;
    padding: 16px 26px;
    width: min(100%, 420px);
}

.qr-card {
    margin-top: 14px;
    text-align: left;
    background: transparent;
    display: inline-block;
    padding: 0 0 10px;
    width: min(100%, 420px);
}

.mobile-action-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
    background: rgba(17, 24, 39, 0.94);
    color: #ffffff;
    box-shadow: 0 18px 48px rgba(17, 24, 39, 0.30);
    backdrop-filter: blur(12px);
}

.mobile-action-bar span {
    font-weight: 800;
    font-size: 14px;
}

.mobile-action-bar button {
    background: var(--wp-lime);
    color: #000000;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 900;
    white-space: nowrap;
}

@media (min-width: 721px) {
    .mobile-action-bar {
        display: none !important;
    }
}

@media (max-width: 720px) {
    body {
        padding-bottom: 86px;
    }

    .button-row {
        display: flex;
        flex-direction: column;
    }

    #uploadButton.primary-action {
        order: -1;
        font-size: 22px;
        padding: 20px 24px;
    }

    #selectButton.secondary-action {
        font-size: 18px;
        padding: 14px 20px;
    }

    .next-step {
        font-size: 15px;
    }
}

/* UX fix: keep optional comment hidden until a valid key is loaded. */
#commentCard[style*="display: none"] {
    display: none !important;
}

/* UX fix: requested main CTA lime. */
#uploadButton.primary-action {
    background: #ccff33 !important;
    color: #000000 !important;
    box-shadow: 0 12px 26px rgba(204, 255, 51, 0.30);
}

/* Full-screen upload progress overlay. */
.upload-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(247, 251, 255, 0.86);
    backdrop-filter: blur(10px);
}

.upload-overlay-card {
    width: min(460px, 100%);
    padding: 28px;
    border-radius: 28px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 24px 80px rgba(17, 24, 39, 0.20);
    text-align: center;
}

.upload-overlay-card h2 {
    margin-bottom: 8px;
    font-size: 30px;
}

.upload-overlay-card p {
    margin-bottom: 14px;
}

.upload-spinner {
    width: 54px;
    height: 54px;
    margin: 0 auto 18px;
    border-radius: 50%;
    border: 6px solid #e5edf8;
    border-top-color: #111827;
    animation: wp-spin 0.8s linear infinite;
}

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

.overlay-progress-track {
    width: 100%;
    height: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5edf8;
}

.overlay-progress-bar {
    height: 100%;
    border-radius: 999px;
    background: #ccff33;
    transition: width 0.18s ease;
}

.overlay-percent {
    margin-top: 10px;
    margin-bottom: 0 !important;
    font-weight: 900;
    color: #111827;
}

/* Cleaner upload-complete state. */
.success-panel {
    text-align: center;
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
}

.success-icon {
    width: 76px;
    height: 76px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #ccff33;
    color: #000;
    font-size: 42px;
    font-weight: 900;
}

.success-panel h2 {
    font-size: clamp(34px, 6vw, 52px);
    margin-bottom: 8px;
}

.success-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 22px auto 12px;
    max-width: 420px;
}

.success-panel .success-action {
    width: 100%;
    margin: 0;
}

.primary-success {
    background: #111827 !important;
    color: #ffffff !important;
}

.secondary-success {
    background: #ccff33 !important;
    color: #000000 !important;
}

.copy-message {
    margin: 10px auto 0;
    color: #166534;
    font-weight: 800;
}

.qr-section {
    margin: 22px auto 0;
    max-width: 340px;
}

.qr-image {
    width: min(100%, 320px);
    border-radius: 18px;
    display: block;
    margin: 0 auto;
}

@media (min-width: 721px) {
    .success-actions-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 720px;
    }

    .primary-success {
        grid-column: 1 / -1;
    }
}
