:root {
    --arf-primary: #6366f1;
    --arf-primary-dark: #4f46e5;
    --arf-accent: #818cf8;
    --arf-bg: #0f172a;
    --arf-surface: #1e293b;
    --arf-border: #334155;
    --page-width-mm: 210;
    --page-height-mm: 297;
    --page-margin-mm: 0;
    --input-error: #f87171;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--arf-bg);
    color: #e2e8f0;
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

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

.hidden {
    display: none !important;
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
}

.header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.22) 0%, rgba(99, 102, 241, 0.55) 100%);
    padding: 2.5rem 2rem;
    margin-bottom: 2.25rem;
    border-radius: 1.25rem;
    box-shadow: 0 18px 50px rgba(99, 102, 241, 0.28);
    border: 1px solid rgba(129, 140, 248, 0.35);
    position: relative;
    overflow: hidden;
}

.header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.35), transparent 55%);
    pointer-events: none;
    mix-blend-mode: screen;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.logo {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 1rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.22);
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    flex: 1;
    min-width: 260px;
    max-width: 720px;
}

.header-eyebrow {
    font-size: 0.88rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(226, 232, 240, 0.72);
    font-weight: 600;
}

.header-text h1 {
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    font-weight: 800;
    line-height: 1.12;
    color: #f8fafc;
}

.header-description {
    font-size: 1rem;
    color: rgba(226, 232, 240, 0.9);
    max-width: 54ch;
}

.header-highlights {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0;
    margin: 0.4rem 0 0;
}

.header-highlights li {
    padding: 0.55rem 0.85rem;
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    font-size: 0.85rem;
    color: rgba(226, 232, 240, 0.92);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.header-highlights li::before {
    content: '•';
    color: var(--arf-accent);
    font-size: 1.1rem;
    transform: translateY(-2px);
}

.header-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.8rem;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.4rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.25s ease, background 0.2s ease;
    border: 1px solid transparent;
}

.header-btn.primary {
    background: linear-gradient(135deg, var(--arf-primary-dark), var(--arf-primary));
    color: white;
    box-shadow: 0 12px 24px rgba(99, 102, 241, 0.35);
}

.header-btn.primary:hover,
.header-btn.primary:focus {
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(99, 102, 241, 0.45);
}

.header-btn.secondary {
    background: rgba(15, 23, 42, 0.35);
    border-color: rgba(148, 163, 184, 0.35);
    color: rgba(226, 232, 240, 0.9);
}

.header-btn.secondary:hover,
.header-btn.secondary:focus {
    background: rgba(15, 23, 42, 0.55);
    border-color: rgba(148, 163, 184, 0.6);
}

.main-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 2rem;
    align-items: start;
}

.control-panel {
    background: var(--arf-surface);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--arf-border);
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-panel::-webkit-scrollbar {
    width: 8px;
}

.control-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--arf-primary);
    border-radius: 4px;
}

.feedback-banner {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: rgba(248, 113, 113, 0.12);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #fecaca;
    font-size: 0.9rem;
}

.section {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0.9rem;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.25);
}

.section + .section {
    margin-top: 0.25rem;
}

.section summary {
    list-style: none;
    cursor: pointer;
}

.section summary::-webkit-details-marker {
    display: none;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    padding: 0.4rem 0.25rem 0.4rem 0.75rem;
}

.section-title::before {
    content: '';
    width: 4px;
    height: 1.2rem;
    background: var(--arf-primary);
    border-radius: 2px;
    position: absolute;
    left: 0;
}

.section[open] .section-title {
    color: #e0e7ff;
}

.section-body {
    margin-top: 0.75rem;
    padding: 0 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.file-input-wrapper {
    position: relative;
}

.file-input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed var(--arf-border);
    border-radius: 0.75rem;
    font-size: 0.9rem;
    color: #cbd5e1;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.file-input:hover,
.file-input:focus {
    border-color: var(--arf-accent);
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.helper-text {
    font-size: 0.78rem;
    color: #94a3b8;
    display: block;
}

.helper-text.warning {
    color: #fca5a5;
}

.helper-text.center {
    text-align: center;
}

.info-card {
    padding: 0.75rem 0.9rem;
    border-radius: 0.75rem;
    background: rgba(99, 102, 241, 0.12);
    border: 1px dashed rgba(99, 102, 241, 0.35);
    color: #c7d2fe;
    font-size: 0.85rem;
}

.image-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-item {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 0.75rem;
    background: rgba(15, 23, 42, 0.35);
}

.image-item img {
    width: 56px;
    height: 56px;
    border-radius: 0.65rem;
    object-fit: cover;
    border: 1px solid rgba(129, 140, 248, 0.35);
}

.image-info {
    flex: 1;
    min-width: 0;
}

.image-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-id {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.image-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.quantity-input {
    width: 80px;
    padding: 0.45rem 0.6rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--arf-border);
    border-radius: 0.5rem;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.quantity-input:focus {
    outline: none;
    border-color: var(--arf-primary);
}

.remove-btn {
    padding: 0.45rem 0.75rem;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 0.5rem;
    color: #fecaca;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.22);
    transform: translateY(-1px);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #cbd5e1;
}

.select-input,
.number-input {
    width: 100%;
    padding: 0.65rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--arf-border);
    border-radius: 0.6rem;
    color: #e2e8f0;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.select-input:focus,
.number-input:focus {
    outline: none;
    border-color: var(--arf-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.number-input.input-error,
.select-input.input-error {
    border-color: rgba(248, 113, 113, 0.75);
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
}

.number-input.input-valid {
    border-color: rgba(74, 222, 128, 0.75);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

.input-feedback {
    font-size: 0.75rem;
    color: rgba(248, 113, 113, 0.9);
    min-height: 1em;
}

.input-feedback.success {
    color: rgba(74, 222, 128, 0.85);
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.88rem;
    cursor: pointer;
}

.checkbox-input {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.1rem;
    accent-color: var(--arf-primary);
}

.size-options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.size-option {
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--arf-border);
    border-radius: 0.6rem;
    color: #cbd5e1;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.size-option:hover {
    border-color: var(--arf-accent);
    background: rgba(99, 102, 241, 0.12);
}

.size-option.active {
    border-color: var(--arf-primary);
    background: rgba(99, 102, 241, 0.18);
    transform: translateY(-1px);
}

#capacity-info {
    margin-top: 0.75rem;
    padding: 0.9rem;
    border-radius: 0.75rem;
    font-size: 0.88rem;
    border: 1px solid rgba(129, 140, 248, 0.45);
    background: rgba(99, 102, 241, 0.15);
    color: #c7d2fe;
    transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
}

#capacity-info.warning {
    border-color: rgba(248, 113, 113, 0.55);
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
}

#capacity-info.success {
    border-color: rgba(34, 197, 94, 0.55);
    background: rgba(34, 197, 94, 0.18);
    color: #bbf7d0;
}

.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(135deg, var(--arf-primary-dark), var(--arf-primary));
    border: none;
    border-radius: 0.75rem;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 18px rgba(99, 102, 241, 0.35);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.45);
}

.primary-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-text {
    font-weight: 600;
}

.preview-panel {
    background: var(--arf-surface);
    border-radius: 1rem;
    padding: 1.5rem;
    border: 1px solid var(--arf-border);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 640px;
    width: 100%;
    overflow: hidden;
}

.preview-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--arf-border);
}

.preview-header-text h3 {
    font-size: 1.3rem;
    font-weight: 700;
}

.preview-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.zoom-controls {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    overflow: hidden;
    background: rgba(15, 23, 42, 0.35);
}

.zoom-btn {
    border: none;
    background: transparent;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.zoom-btn:hover,
.zoom-btn:focus {
    background: rgba(99, 102, 241, 0.18);
    outline: none;
}

.preview-canvas {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.75rem;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    max-height: calc(100vh - 250px);
    overflow: auto;
    border: 1px dashed rgba(148, 163, 184, 0.25);
    width: 100%;
}

.preview-canvas::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.preview-canvas::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.6);
    border-radius: 999px;
}

.preview-canvas::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.65);
    border-radius: 999px;
}

.page-wrapper {
    width: calc(var(--page-width-mm) * 1mm);
    height: calc(var(--page-height-mm) * 1mm);
    transform-origin: center center;
    transition: transform 0.2s ease;
    margin: auto;
    flex-shrink: 0;
}

.page {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 0.6rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    padding: calc(var(--page-margin-mm) * 1mm);
}

.layout-grid {
    position: absolute;
    display: grid;
    place-content: start;
    background-origin: border-box;
}

.sticker-wrapper {
    position: relative;
}

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

.sticker-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 0.2mm solid rgba(148, 163, 184, 0.7);
    pointer-events: none;
    mix-blend-mode: multiply;
}

.is-circle {
    border-radius: 50%;
    clip-path: circle(50%);
}

.is-circle-wrapper {
    border-radius: 50%;
    overflow: hidden;
}

.is-circle-wrapper::after {
    border-radius: 50%;
}

.site-footer {
    margin-top: 3rem;
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.35) 100%);
    border-radius: 1.25rem;
    border: 1px solid rgba(129, 140, 248, 0.25);
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: center;
    justify-content: space-between;
}

.footer-logo {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 0.75rem;
    padding: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
}

.footer-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.footer-info {
    flex: 1;
    min-width: 280px;
}

.footer-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f1f5f9;
    margin-bottom: 0.5rem;
}

.footer-description {
    font-size: 0.9rem;
    color: rgba(226, 232, 240, 0.8);
    line-height: 1.6;
    max-width: 600px;
}

.footer-meta {
    text-align: right;
    color: rgba(226, 232, 240, 0.7);
    font-size: 0.85rem;
}

.footer-meta p {
    margin: 0.25rem 0;
}

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

    .control-panel {
        position: relative;
        top: 0;
        max-height: none;
    }

    .preview-panel {
        min-height: 540px;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-meta {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1.25rem;
    }

    .header-content {
        justify-content: center;
        text-align: center;
    }

    .logo {
        width: 64px;
        height: 64px;
    }

    .header-text {
        align-items: center;
    }

    .header-description {
        font-size: 0.95rem;
    }

    .header-highlights {
        justify-content: center;
    }

    .header-actions {
        justify-content: center;
    }

    .two-cols {
        grid-template-columns: 1fr;
    }

    .image-item {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .image-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .preview-canvas {
        padding: 1.2rem;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 2rem 1.5rem;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .zoom-controls {
        width: 100%;
        justify-content: space-between;
    }

    .control-panel {
        padding: 1.25rem;
    }

    .site-footer {
        margin-top: 2rem;
        padding: 2rem 1.5rem;
    }

    .footer-info {
        min-width: 100%;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }

    * {
        overflow: visible !important;
    }

    html,
    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #000;
        width: 297mm !important;
        min-height: 210mm !important;
        overflow: visible !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .header,
    .control-panel,
    .preview-header,
    .preview-tools,
    .helper-text,
    .feedback-banner,
    .size-options,
    .info-card,
    .site-footer {
        display: none !important;
    }

    .container {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        width: 297mm !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .main-grid {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 297mm !important;
        height: auto !important;
        min-height: 0 !important;
    }

    .preview-panel {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        min-height: 0 !important;
        box-shadow: none !important;
        width: 297mm !important;
        height: auto !important;
        overflow: visible !important;
    }

    .preview-canvas {
        display: block !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        background: transparent !important;
        min-height: 0 !important;
        max-height: none !important;
        width: 297mm !important;
        height: auto !important;
    }

    .page-wrapper {
        position: relative !important;
        margin: 0 auto !important;
        padding: 0 !important;
        transform: none !important;
        width: 297mm !important;
        height: auto !important;
        min-height: 210mm !important;
        max-height: 210mm !important;
        page-break-before: avoid !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
    }

    .page {
        box-shadow: none !important;
        border-radius: 0 !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        page-break-inside: avoid !important;
        width: 297mm !important;
        height: auto !important;
        min-height: 210mm !important;
        max-height: 210mm !important;
        margin: 0 !important;
        padding: calc(var(--page-margin-mm) * 1mm) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    .sticker-wrapper::after {
        border-color: rgba(31, 41, 55, 0.95) !important;
        mix-blend-mode: normal !important;
    }

    .layout-grid {
        position: static !important;
        margin: 0 auto !important;
        left: auto !important;
        top: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
}
