:root {
    --bg: #f6f7f4;
    --panel: #ffffff;
    --ink: #18201b;
    --muted: #65706a;
    --line: #dfe4dd;
    --accent: #13795b;
    --accent-strong: #0e5e47;
    --warn: #a8481f;
    --soft: #e8f3ee;
    --shadow: 0 18px 48px rgba(25, 32, 27, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(232, 243, 238, 0.9), rgba(246, 247, 244, 0) 340px),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px clamp(18px, 4vw, 48px);
}

.brand img {
    display: block;
    width: min(282px, 58vw);
    height: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.status-pill,
.ghost-link {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--muted);
    text-decoration: none;
}

.workspace {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 12px 0 48px;
}

.tool-panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel-heading,
.queue-header,
.dialog-head,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.panel-heading {
    padding: 24px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: 0.98;
    letter-spacing: 0;
}

.dropzone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px;
    min-height: 156px;
    padding: 24px;
    border: 2px dashed #b8c6bd;
    border-radius: 8px;
    background: #fbfcfa;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease;
}

.dropzone.is-over {
    border-color: var(--accent);
    background: var(--soft);
}

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-mark {
    display: grid;
    place-items: center;
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
}

.dropzone strong,
.dropzone span {
    display: block;
}

.dropzone strong {
    font-size: 1.35rem;
}

.dropzone span {
    margin-top: 4px;
    color: var(--muted);
}

.controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 0 24px 18px;
}

label span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

select,
input[type="number"] {
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}

.ratio-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 24px;
}

.chip,
.button,
.icon-button {
    border: 0;
    cursor: pointer;
}

.chip {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
}

.chip.is-active {
    border-color: var(--accent);
    background: var(--soft);
    color: var(--accent-strong);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 6px;
    font-weight: 800;
    text-decoration: none;
}

.button.primary {
    background: var(--accent);
    color: #fff;
}

.button.secondary {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

.button.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.queue-shell {
    border-top: 1px solid var(--line);
    background: #fbfcfa;
}

.queue-header {
    min-height: 72px;
    padding: 14px 24px;
}

.queue-actions {
    display: flex;
    gap: 10px;
}

.queue-list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0 24px 24px;
    list-style: none;
}

.queue-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    min-height: 78px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.thumb {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    background: #eef1ec;
}

.item-name {
    display: block;
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-button {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.mini-button[disabled] {
    cursor: not-allowed;
    opacity: 0.45;
}

.status-error {
    color: var(--warn);
}

.empty-state {
    padding: 0 24px 28px;
    color: var(--muted);
}

.empty-state.is-hidden {
    display: none;
}

.crop-dialog {
    width: min(940px, calc(100vw - 28px));
    padding: 0;
    border: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.crop-dialog::backdrop {
    background: rgba(24, 32, 27, 0.58);
}

.crop-dialog form {
    margin: 0;
}

.dialog-head,
.dialog-actions {
    padding: 16px;
}

.dialog-head {
    border-bottom: 1px solid var(--line);
}

.dialog-actions {
    border-top: 1px solid var(--line);
}

.icon-button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eef1ec;
    color: var(--ink);
    font-weight: 900;
}

.crop-stage {
    display: grid;
    place-items: center;
    min-height: 320px;
    padding: 18px;
    background: #111813;
}

#cropCanvas {
    max-width: 100%;
    height: auto;
    cursor: crosshair;
}

@media (max-width: 820px) {
    .app-header,
    .panel-heading,
    .queue-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        align-items: stretch;
        width: 100%;
        flex-direction: column;
    }

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

    .queue-item {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .thumb {
        width: 48px;
        height: 48px;
    }

    .item-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 540px) {
    .workspace {
        width: min(100% - 20px, 1180px);
    }

    .dropzone,
    .panel-heading,
    .queue-header {
        padding: 18px;
    }

    .dropzone {
        margin: 18px;
    }

    .controls {
        grid-template-columns: 1fr;
        padding: 0 18px 18px;
    }

    .ratio-bar,
    .queue-list {
        padding-left: 18px;
        padding-right: 18px;
    }
}
