:root {
    --bg0: #101814;
    --bg1: #17241c;
    --surface: rgba(220, 245, 230, 0.06);
    --line: rgba(160, 210, 175, 0.2);
    --text: #eef7f1;
    --muted: #9fb8a8;
    --accent: #3d9b6a;
    --accent-deep: #2a704c;
    --radius: 18px;
    --font: "Segoe UI", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(61, 155, 106, 0.3), transparent 60%),
        radial-gradient(700px 420px at 100% 0%, rgba(30, 80, 50, 0.4), transparent 55%),
        linear-gradient(165deg, var(--bg1), var(--bg0) 55%, #0a100d);
}

.page {
    width: min(640px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2.5rem 0 3rem;
    display: grid;
    gap: 1.1rem;
}

.page-wide {
    width: min(920px, calc(100% - 2rem));
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand img {
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(61, 155, 106, 0.4);
}
.brand-home {
    display: block;
    line-height: 0;
    border-radius: 50%;
    text-decoration: none;
}

.brand-home:hover img {
    filter: brightness(1.08);
}

.brand-home:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.brand-name {
    margin: 0;
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}

h1 {
    margin: 0.15rem 0 0;
    font-size: clamp(1.6rem, 4vw, 2.1rem);
    font-weight: 650;
    letter-spacing: -0.02em;
}

.lede {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.banner {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    line-height: 1.45;
    margin-bottom: 1rem;
}

.banner code {
    font-size: 0.9em;
    color: var(--text);
}

.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tab {
    appearance: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.5rem 0.95rem;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    text-decoration: none;
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.tab.is-active {
    color: #0a100d;
    border-color: transparent;
    background: linear-gradient(180deg, #55b882, var(--accent-deep));
}

.tab-link {
    display: inline-flex;
    align-items: center;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1.1rem 1.15rem 1.25rem;
}

.field-label {
    display: block;
    margin: 0.75rem 0 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.panel .field-label:first-of-type {
    margin-top: 0;
}

input[type="text"],
input[type="file"],
select {
    width: 100%;
    font: inherit;
    color: var(--text);
}

select {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
}

select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: none;
}

.btn-ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.1);
    filter: none;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.image-drop {
    border: 1.5px dashed var(--line);
    border-radius: 14px;
    padding: 1.35rem 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.image-drop:hover,
.image-drop:focus-visible,
.image-drop.is-drag {
    border-color: var(--accent);
    background: rgba(61, 155, 106, 0.1);
    outline: none;
}

.image-drop-title {
    margin: 0 0 0.25rem;
    font-weight: 650;
}

.image-drop-sub {
    margin: 0 0 0.85rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.booklet-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.85rem 1rem;
    margin-top: 1rem;
}

.toolbar-field .field-label {
    margin-top: 0;
}

.toolbar-check {
    grid-column: 1 / -1;
}

.check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    cursor: pointer;
}

.check-label input {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
}

.hint {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.1rem;
    margin-bottom: 0.5rem;
}

.image-list {
    display: grid;
    gap: 0.55rem;
}

.empty-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.image-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.22);
    cursor: grab;
}

.image-row.dragging {
    opacity: 0.55;
}

.image-row.drop-target {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(61, 155, 106, 0.35);
}

.image-thumb {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.04);
}

.image-meta strong {
    display: block;
    font-size: 0.92rem;
    word-break: break-word;
}

.image-meta small {
    color: var(--muted);
}

.image-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(6, 12, 9, 0.72);
}

.crop-modal[hidden] {
    display: none !important;
}

.crop-dialog {
    width: min(720px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #152019;
    padding: 1rem 1.1rem 1.15rem;
}

.crop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.crop-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.crop-stage-wrap {
    position: relative;
    overflow: auto;
    max-height: min(55vh, 480px);
    border-radius: 12px;
    background: #0a100d;
    border: 1px solid var(--line);
}

#cropCanvas {
    display: block;
    max-width: 100%;
    cursor: crosshair;
    touch-action: none;
}

input[type="text"] {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="file"] {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 0.65rem 1.15rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    color: #0a100d;
    background: linear-gradient(180deg, #55b882, var(--accent-deep));
}

.btn:hover { filter: brightness(1.06); }

.status {
    margin: 0;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.status.is-error {
    border-color: rgba(224, 122, 106, 0.45);
    background: rgba(224, 122, 106, 0.12);
    color: #f2c2ba;
}

.status.is-ok {
    border-color: rgba(125, 190, 116, 0.4);
    background: rgba(125, 190, 116, 0.1);
    color: #c8e4c3;
}

.foot {
    margin-top: 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.foot a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.foot a:hover {
    color: var(--text);
    border-bottom-color: var(--accent);
}

@media (max-width: 560px) {
    .page { padding-top: 1.5rem; }
}
