:root {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: rgba(15, 23, 42, .72);
    --panel-strong: rgba(15, 23, 42, .9);
    --line: rgba(148, 163, 184, .22);
    --text: #f8fafc;
    --muted: #a5b4fc;
    --blue: #38bdf8;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --green: #34d399;
    --shadow: 0 24px 70px rgba(0, 0, 0, .38);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(56, 189, 248, .22), transparent 32rem),
        radial-gradient(circle at top right, rgba(236, 72, 153, .20), transparent 30rem),
        linear-gradient(135deg, #0f172a 0%, #111827 52%, #17122f 100%);
    overflow-x: hidden;
}
body.light {
    color-scheme: light;
    --bg: #eef2ff;
    --panel: rgba(255, 255, 255, .76);
    --panel-strong: rgba(255, 255, 255, .95);
    --line: rgba(15, 23, 42, .14);
    --text: #111827;
    --muted: #475569;
    background: linear-gradient(135deg, #f8fafc, #e0f2fe 48%, #fce7f3);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
main { width: min(1180px, calc(100% - 22px)); margin: 0 auto; }
.aurora {
    position: fixed;
    inset: -20%;
    pointer-events: none;
    background: conic-gradient(from 140deg, transparent, rgba(56,189,248,.08), transparent, rgba(139,92,246,.1), transparent);
    filter: blur(40px);
    animation: drift 18s linear infinite;
}
@keyframes drift { to { transform: rotate(360deg); } }
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px clamp(14px, 3vw, 36px);
    backdrop-filter: blur(18px);
    background: rgba(15, 23, 42, .68);
    border-bottom: 1px solid var(--line);
}
body.light .topbar { background: rgba(255,255,255,.68); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: 0; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--blue), var(--purple), var(--pink));
    box-shadow: 0 0 28px rgba(56, 189, 248, .5);
}
.topbar nav { display: flex; gap: 18px; color: var(--muted); font-size: .94rem; }
.glass {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}
.hero {
    min-height: calc(100vh - 78px);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, .8fr);
    gap: clamp(28px, 6vw, 88px);
    align-items: center;
    padding: 54px 0 80px;
}
.eyebrow {
    color: var(--blue);
    text-transform: uppercase;
    font-size: .75rem;
    font-weight: 800;
    letter-spacing: .12em;
    margin: 0 0 10px;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
    max-width: 820px;
    font-size: clamp(3rem, 8vw, 7.2rem);
    line-height: .9;
    letter-spacing: 0;
    margin-bottom: 24px;
}
h2 { font-size: clamp(1.25rem, 2.2vw, 1.9rem); margin-bottom: 8px; }
h3 { margin-bottom: 10px; }
.hero-text, .preview-band p, .feature p, .print-page p { color: #cbd5e1; font-size: 1.08rem; line-height: 1.7; }
body.light .hero-text, body.light .preview-band p, body.light .feature p, body.light .print-page p { color: #475569; }
.hero-actions, .export-actions, .tool-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn, .icon-btn {
    border: 1px solid rgba(56, 189, 248, .38);
    color: var(--text);
    background: rgba(15, 23, 42, .58);
    border-radius: 12px;
    padding: 13px 18px;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.btn input { display: none; }
.btn:hover, .icon-btn:hover, .dropzone:hover, .upload-drop:hover {
    transform: translateY(-2px);
    border-color: var(--blue);
    box-shadow: 0 0 30px rgba(56, 189, 248, .28);
}
.primary { background: linear-gradient(135deg, var(--blue), var(--purple)); border-color: transparent; font-weight: 800; }
.ghost { background: rgba(255, 255, 255, .06); }
.small { padding: 10px 14px; }
.upload-drop {
    min-height: 480px;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 28px;
    position: relative;
    overflow: hidden;
}
.drop-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    margin: 0 auto 16px;
    border-radius: 20px;
    font-size: 1.9rem;
    background: rgba(56, 189, 248, .12);
    border: 1px solid rgba(56, 189, 248, .45);
}
.pulse-ring {
    position: absolute;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    border: 1px solid rgba(236, 72, 153, .28);
    animation: pulse 2.8s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.25); opacity: .35; } }
.preview-band, .features {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    align-items: center;
    padding: 28px 0 80px;
}
.features { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.feature { min-height: 180px; padding: 26px; border-radius: 20px; }
.mock-sheet {
    width: min(100%, 460px);
    aspect-ratio: 210 / 297;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 8px;
    box-shadow: var(--shadow);
}
.mock-sheet span { border-radius: 4px; background: linear-gradient(160deg, #bae6fd, #fbcfe8); border: 1px solid #94a3b8; }
.studio-shell {
    display: grid;
    grid-template-columns: 250px minmax(360px, 1fr) 286px;
    gap: 12px;
    padding-top: 16px;
}
.panel { border-radius: 16px; padding: 14px; min-width: 0; }
.upload-panel .panel-title {
    margin-bottom: 10px;
}
.upload-panel h2 {
    margin-bottom: 0;
}
.panel-title.inline { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.dropzone {
    display: grid;
    place-items: center;
    min-height: 118px;
    border: 1px dashed rgba(56, 189, 248, .55);
    border-radius: 18px;
    cursor: pointer;
    text-align: center;
    background: rgba(56, 189, 248, .06);
    transition: .2s ease;
    padding: 12px;
}
.dropzone .drop-icon {
    margin-bottom: 8px;
}
.dropzone strong {
    font-size: .9rem;
}
.dropzone small {
    color: #c4b5fd;
    font-size: .74rem;
}
.dropzone input { display: none; }
.photo-list {
    display: grid;
    gap: 9px;
    margin-top: 10px;
    max-height: 430px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}
.upload-panel {
    overflow: hidden;
}
.photo-card {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 7px;
    align-items: center;
    padding: 7px;
    width: 100%;
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .06);
    cursor: grab;
    min-width: 0;
    overflow: hidden;
}
.photo-card > div {
    min-width: 0;
    overflow: hidden;
}
.photo-card.active { border-color: var(--blue); box-shadow: 0 0 20px rgba(56,189,248,.22); }
.photo-card img { width: 42px; height: 54px; object-fit: cover; border-radius: 7px; background: #fff; }
.photo-card strong {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .82rem;
}
.qty-row {
    display: grid;
    grid-template-columns: 22px minmax(38px, 1fr) 22px 22px 22px;
    gap: 3px;
    align-items: center;
    margin-top: 6px;
    max-width: 100%;
    min-width: 0;
}
.qty-row input {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    text-align: center;
    padding: 3px;
    border-radius: 8px;
    font-size: .9rem;
}
.qty-row input::-webkit-outer-spin-button,
.qty-row input::-webkit-inner-spin-button {
    margin: 0;
    appearance: none;
}
.qty-row input[type="number"] {
    appearance: textfield;
}

.photo-card .qty-row input[type="number"] {
    width: 100%;
    min-width: 0;
    min-height: 26px;
    height: 26px;
    padding: 2px 3px;
    border-radius: 8px;
    font-size: .82rem;
    line-height: 1;
}
.photo-card .mini-btn {
    width: 22px;
    height: 26px;
    min-height: 26px;
    font-size: .84rem;
}
.mini-btn {
    width: 22px;
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: rgba(255,255,255,.08);
    cursor: pointer;
    display: grid;
    place-items: center;
    padding: 0;
    line-height: 1;
}
.remove-btn {
    color: #fecaca;
    border-color: rgba(248, 113, 113, .36);
}
.crop-wrap {
    position: relative;
    min-height: 0;
    height: min(52vh, 430px);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(2, 6, 23, .72);
    border: 1px solid var(--line);
}
#cropImage { display: block; max-width: 100%; max-height: min(52vh, 430px); opacity: 0; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.icon-btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; font-size: 1.05rem; }
.tool-row { margin-top: 10px; }
.hidden { display: none !important; }
.crop-modal {
    position: fixed;
    inset: 70px 12px 12px;
    z-index: 60;
    width: min(760px, calc(100vw - 24px));
    max-height: calc(100vh - 82px);
    margin: auto;
    overflow: auto;
    padding: 14px;
    border-radius: 22px;
    background: rgba(15, 23, 42, .96);
    border: 1px solid rgba(56, 189, 248, .45);
    box-shadow: 0 30px 120px rgba(0,0,0,.72), 0 0 42px rgba(56,189,248,.2);
    backdrop-filter: blur(24px);
}
body.crop-open { overflow: hidden; }
.crop-modal .panel-title.inline {
    align-items: center;
    margin-bottom: 8px;
}
.crop-modal h2 {
    font-size: 1.55rem;
    line-height: 1.05;
}
.crop-modal .eyebrow {
    margin-bottom: 5px;
}
.crop-modal .tool-row {
    position: sticky;
    bottom: 0;
    padding-top: 8px;
    background: rgba(15, 23, 42, .92);
}
.crop-modal .btn.small {
    min-height: 36px;
    padding: 8px 13px;
}
.crop-modal::before {
    content: "";
    position: fixed;
    inset: -18px;
    z-index: -1;
    background: rgba(2, 6, 23, .64);
}
.sheet-editor-view { min-height: 100%; }
.sheet-toolbar.compact {
    align-items: center;
    margin-bottom: 14px;
}
.sheet-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sheet-actions input[type="range"] {
    width: 160px;
}
select, input[type="number"], input[type="text"], input[type="color"] {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 7px 10px;
    color: var(--text);
    background: rgba(2, 6, 23, .48);
    outline: none;
}
body.light select, body.light input { background: rgba(255,255,255,.75); color: #111827; }
select:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,189,248,.18); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.form-grid label, .switches label { color: var(--muted); font-size: .85rem; display: grid; gap: 7px; }
.switches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.switches label { display: flex; align-items: center; gap: 8px; }
.export-actions { display: grid; grid-template-columns: 1fr 1fr; }
.sheet-section { padding: 24px 0 80px; }
.sheet-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 16px; }
.sheet-stage {
    overflow: auto;
    min-height: 520px;
    border-radius: 22px;
    padding: 16px;
    background: rgba(2, 6, 23, .42);
    border: 1px solid var(--line);
}
.crop-panel .sheet-stage {
    min-height: 500px;
    max-height: 72vh;
}
.sheet-preview {
    width: 476px;
    height: 673px;
    margin: 0 auto;
    background: #fff;
    color: #111827;
    position: relative;
    box-shadow: 0 30px 80px rgba(0,0,0,.45);
    transform-origin: top center;
    overflow: hidden;
}
.sheet-photo {
    position: absolute;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
}
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-placeholder { background: #050816; }
.sheet-photo .label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,.86);
    font-size: 9px;
    line-height: 1.2;
    text-align: center;
    padding: 2px;
}
.cut::before, .cut::after {
    content: "";
    position: absolute;
    background: #94a3b8;
}
.cut::before { width: 18px; height: 1px; left: -20px; top: -1px; box-shadow: calc(100% + 22px) 0 #94a3b8; }
.cut::after { height: 18px; width: 1px; left: -1px; top: -20px; box-shadow: 0 calc(100% + 22px) #94a3b8; }
.gridline { outline: 1px dashed rgba(15, 23, 42, .22); }
.footer {
    width: min(1480px, calc(100% - 32px));
    margin: 0 auto;
    padding: 26px 0 36px;
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border-top: 1px solid var(--line);
}
.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateY(140%);
    transition: transform .25s ease;
    z-index: 30;
}
.toast.show { transform: translateY(0); }
.print-page { margin: 40px auto 80px; padding: 32px; border-radius: 24px; max-width: 800px; }

@media (max-width: 1180px) {
    .studio-shell { grid-template-columns: 1fr 1fr; }
    .settings-panel { grid-column: 1 / -1; }
    .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
    main { width: min(100% - 20px, 1480px); }
    .topbar { align-items: flex-start; }
    .topbar nav { display: none; }
    .hero, .preview-band, .studio-shell, .features { grid-template-columns: 1fr; }
    .hero { min-height: auto; padding-top: 34px; }
    .upload-drop { min-height: 300px; }
    .crop-wrap { min-height: 360px; }
    .crop-modal { inset: 10px; width: calc(100vw - 20px); max-height: calc(100vh - 20px); padding: 14px; }
    .form-grid, .export-actions { grid-template-columns: 1fr; }
    .sheet-stage { padding: 14px; min-height: 460px; }
    .crop-panel .sheet-stage { max-height: none; }
    .sheet-toolbar.compact, .sheet-actions { align-items: stretch; flex-direction: column; }
    .sheet-actions input[type="range"] { width: 100%; }
    .footer { flex-direction: column; }
}

@media print {
    .topbar, .studio-shell, .sheet-toolbar, .footer, .toast { display: none !important; }
    main { width: 100%; margin: 0; }
    .sheet-section { padding: 0; }
    .sheet-stage { padding: 0; border: 0; background: transparent; overflow: visible; }
    .sheet-preview { width: 210mm !important; height: 297mm !important; margin: 0; box-shadow: none; }
    @page { size: A4; margin: 0; }
}
