:root {
    --ink: #211910;
    --ink-soft: #5a4a3c;
    --paper: #f3ead8;
    --paper-2: #efe3cc;
    --card: #fffaf1;
    --line: #d8c8af;
    --slot: #b0b0b0;
    --slot-deep: #9a9a9a;
    --copper: #b3471e;
    --copper-deep: #8d3314;
    --moss: #3d5340;
    --danger: #9c2a24;
    --shadow: 0 18px 40px rgba(64, 42, 22, 0.12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 10% -10%, #ffe7c4 0%, transparent 55%),
        radial-gradient(900px 420px at 100% 0%, #e7d3b0 0%, transparent 50%),
        var(--paper);
}

.app {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 22px;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background:
        linear-gradient(160deg, #f4c48a, #b3471e 62%, #3d5340);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.brand-kicker {
    margin: 0 0 2px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

h1,
h2,
h3 {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 640;
    margin: 0;
}

h1 {
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    letter-spacing: -0.03em;
}

h2 {
    font-size: 1.45rem;
}

.topbar-note {
    margin: 0;
    max-width: 280px;
    text-align: right;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 20px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.panel-head p,
.dropzone-label span,
.dropzone-label em,
.thumbs-head p,
.page-label,
.empty-sheets {
    color: var(--ink-soft);
}

.panel-head p {
    margin: 8px 0 0;
    line-height: 1.5;
}

.dropzone {
    position: relative;
    margin-top: 18px;
}

.file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-label {
    display: grid;
    justify-items: center;
    gap: 6px;
    text-align: center;
    padding: 32px 18px;
    border: 1.5px dashed #c7ad86;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 247, 232, 0.8), rgba(247, 234, 208, 0.55));
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.dropzone.is-over .dropzone-label,
.dropzone-label:hover {
    border-color: var(--copper);
    transform: translateY(-1px);
}

.dropzone-icon {
    color: var(--copper);
}

.dropzone-label strong {
    font-size: 1.05rem;
}

.dropzone-label em {
    font-style: normal;
    font-size: 0.82rem;
}

.status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f4e1c4;
    color: var(--ink);
}

.status.is-error {
    background: #f4d4cf;
    color: var(--danger);
}

.thumbs-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin: 22px 0 10px;
}

.thumb-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 12px;
}

.thumb-card {
    position: relative;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
    background: #ece5d5;
    aspect-ratio: 3 / 2;
    box-shadow: 0 8px 18px rgba(58, 38, 18, 0.08);
}

.thumb-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb-card figcaption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 18px 10px 8px;
    background: linear-gradient(transparent, rgba(24, 14, 8, 0.72));
    color: #fff;
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumb-card button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 250, 242, 0.94);
    color: var(--danger);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.sheet-stage {
    display: grid;
    gap: 18px;
    margin-top: 16px;
}

.empty-sheets {
    margin: 28px 0;
    text-align: center;
}

.sheet {
    width: min(100%, 360px);
    margin: 0 auto;
    aspect-ratio: 210 / 297;
    background: #fff;
    border: 1px solid #e4d6bf;
    box-shadow: 0 16px 30px rgba(70, 46, 22, 0.12);
    display: grid;
    grid-template-columns: 30fr 150fr 30fr;
    grid-template-rows: 26fr 100fr 45fr 100fr 26fr;
}

.sheet .slot:nth-child(1) {
    grid-column: 2;
    grid-row: 2;
}

.sheet .slot:nth-child(2) {
    grid-column: 2;
    grid-row: 4;
}

.sheet-label {
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.slot {
    width: 100%;
    height: 100%;
    background: #cccccc;
    outline: 1px solid #888;
    overflow: hidden;
}

.slot img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 13px 20px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn.primary {
    background: linear-gradient(180deg, #c85a2c, var(--copper-deep));
    color: #fff7ed;
    box-shadow: 0 10px 20px rgba(141, 51, 20, 0.22);
}

.btn.ghost {
    background: #fff;
    color: var(--ink);
    box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn.primary:disabled,
.btn.ghost:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    box-shadow: none;
}

.busy {
    position: fixed;
    inset: 0;
    background: rgba(33, 25, 16, 0.38);
    display: grid;
    place-items: center;
    z-index: 20;
}

.busy[hidden] {
    display: none;
}

.busy-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid #e4d3b6;
    border-top-color: var(--copper);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 880px) {
    .layout,
    .topbar {
        grid-template-columns: 1fr;
        display: grid;
    }

    .topbar-note {
        text-align: left;
        max-width: none;
    }
}
