:root {
    --bg: #f4efe7;
    --bg-2: #e8f0e6;
    --surface: rgba(255, 252, 246, 0.95);
    --text: #1f2924;
    --muted: #5f6c64;
    --line: rgba(31, 41, 36, 0.12);
    --shadow: 0 18px 44px rgba(31, 41, 36, 0.14);
    --brand: #1b7c61;
    --brand-dark: #14533f;
    --warning: #b67a1b;
    --success: #218555;
    --danger: #c2563a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(241, 191, 98, 0.22), transparent 30%),
        radial-gradient(circle at right, rgba(27, 124, 97, 0.16), transparent 30%),
        linear-gradient(180deg, #fcfaf6 0%, var(--bg) 46%, var(--bg-2) 100%);
}

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

button,
input {
    font: inherit;
}

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

[hidden] {
    display: none !important;
}

.app-shell {
    height: 100%;
    padding: 10px;
}

.workspace {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(0, 3fr);
    gap: 10px;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 800;
    font-size: 0.72rem;
    color: var(--brand-dark);
}

.label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.78rem;
    color: var(--muted);
}

.tools-pane {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
    padding: 12px;
    gap: 10px;
}

.tools-header h1 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.tools-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.tools-scroll {
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
    display: grid;
    grid-auto-rows: min-content;
    gap: 10px;
}

.dropzone {
    padding: 12px;
    border-radius: 14px;
    border: 2px dashed rgba(27, 124, 97, 0.24);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(237, 247, 241, 0.86)),
        #fffaf4;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.dropzone h2 {
    margin: 0;
    font-size: 1.02rem;
    font-family: "Space Grotesk", sans-serif;
}

.dropzone p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.35;
}

.dropzone-badge {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(241, 191, 98, 0.2);
    color: #7b5a1a;
    font-weight: 800;
    font-size: 0.72rem;
    margin-bottom: 6px;
}

.drop-target.is-dragover,
.dropzone:hover,
.dropzone:focus-visible,
.preview-canvas:hover,
.preview-canvas:focus-visible {
    border-color: rgba(27, 124, 97, 0.52);
    box-shadow: inset 0 0 0 1px rgba(27, 124, 97, 0.2);
    transform: translateY(-1px);
}

.file-summary {
    display: grid;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(31, 41, 36, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.file-summary > div,
.weight-card {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(31, 41, 36, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.file-summary strong,
.weight-card strong {
    font-size: 0.92rem;
    overflow-wrap: anywhere;
}

.file-summary strong {
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.3;
}

.file-summary > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
}

.file-summary .label {
    display: inline;
    margin: 0;
    font-size: 0.76rem;
}

.control-group {
    display: grid;
    gap: 6px;
}

.control-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.control-head label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.9rem;
}

.control-head output {
    color: var(--brand-dark);
    font-weight: 800;
    font-size: 0.88rem;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--brand);
}

input[type="text"] {
    width: 100%;
    padding: 9px 11px;
    border-radius: 11px;
    border: 1px solid rgba(31, 41, 36, 0.14);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
}

input[type="text"]:focus {
    outline: none;
    border-color: rgba(27, 124, 97, 0.46);
    box-shadow: 0 0 0 3px rgba(27, 124, 97, 0.12);
}

select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid rgba(31, 41, 36, 0.14);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
}

select:focus {
    outline: none;
    border-color: rgba(27, 124, 97, 0.46);
    box-shadow: 0 0 0 3px rgba(27, 124, 97, 0.12);
}

input:disabled {
    opacity: 0.62;
    cursor: not-allowed;
}

.hint {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(31, 41, 36, 0.24);
    background: rgba(255, 255, 255, 0.94);
    color: var(--brand-dark);
    font-size: 0.68rem;
    font-weight: 800;
    cursor: help;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 7px;
    border-radius: 999px;
    background: rgba(241, 191, 98, 0.2);
    color: #805c18;
    font-size: 0.68rem;
    font-weight: 800;
}

.seo-preview {
    margin-top: 2px;
    padding: 8px 10px;
    border-radius: 11px;
    border: 1px solid rgba(31, 41, 36, 0.12);
    background: rgba(255, 255, 255, 0.78);
}

.seo-preview strong {
    display: block;
    color: var(--brand-dark);
    font-size: 0.86rem;
    overflow-wrap: anywhere;
}

.crop-group {
    gap: 8px;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text);
}

.checkbox-line input[type="checkbox"] {
    accent-color: var(--brand);
}

.crop-grid {
    display: grid;
    gap: 8px;
}

.crop-field {
    display: grid;
    gap: 5px;
}

.crop-field label {
    font-size: 0.78rem;
    color: var(--muted);
}

.crop-field input[type="text"] {
    padding: 7px 9px;
    font-size: 0.8rem;
}

.crop-help {
    margin: 2px 0 0;
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--muted);
}

.crop-ratio-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.crop-mode-left {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    padding: 2px 0;
    white-space: nowrap;
}

.crop-mode-left .label {
    display: inline;
    margin: 0;
    font-size: 0.72rem;
}

.crop-mode-left strong {
    min-width: 0;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crop-head label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.crop-head output {
    font-size: 0.78rem;
}

.weight-card {
    display: grid;
    gap: 8px;
}

.weight-card[data-status="great"] {
    background: rgba(228, 247, 236, 0.9);
    border-color: rgba(33, 133, 85, 0.2);
}

.weight-card[data-status="okay"] {
    background: rgba(255, 246, 226, 0.9);
    border-color: rgba(182, 122, 27, 0.2);
}

.weight-card[data-status="heavy"] {
    background: rgba(255, 232, 226, 0.9);
    border-color: rgba(194, 86, 58, 0.2);
}

.render-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(31, 41, 36, 0.08);
    background: rgba(255, 255, 255, 0.78);
}

.render-status p {
    margin: 0;
    font-size: 0.84rem;
    line-height: 1.35;
}

.render-status[data-state="draft"] {
    background: rgba(255, 246, 226, 0.9);
    border-color: rgba(182, 122, 27, 0.2);
}

.render-status[data-state="final"] {
    background: rgba(228, 247, 236, 0.9);
    border-color: rgba(33, 133, 85, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 auto;
    background: var(--brand);
    box-shadow: 0 0 0 6px rgba(27, 124, 97, 0.1);
}

.pedago-card {
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid rgba(31, 41, 36, 0.1);
    background: rgba(255, 255, 255, 0.72);
}

.pedago-title {
    margin: 0;
    font-weight: 800;
    color: var(--brand-dark);
    font-size: 0.88rem;
    cursor: pointer;
}

.pedago-card ul {
    margin: 8px 0 0;
    padding-left: 16px;
    display: grid;
    gap: 4px;
    font-size: 0.83rem;
    line-height: 1.35;
}

.action-stack {
    display: grid;
    gap: 8px;
}

.primary-button,
.secondary-button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.primary-button {
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand), #145d47);
    box-shadow: 0 12px 24px rgba(20, 93, 71, 0.23);
}

.secondary-button {
    color: var(--brand-dark);
    background: linear-gradient(180deg, #fffdfa, #eef7f1);
    border: 1px solid rgba(27, 124, 97, 0.16);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.preview-pane {
    min-height: 0;
    padding: 12px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 6px;
    overflow: hidden;
}

.preview-toolbar {
    display: flex;
    align-items: stretch;
    gap: 4px;
    min-width: 0;
}

.preview-toolbar .zoom-switch {
    flex: 0 0 auto;
}

.preview-toolbar .preview-meta {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.preview-toolbar .preview-meta > div {
    min-width: 0;
}

.preview-toolbar .preview-meta strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zoom-switch {
    display: inline-flex;
    gap: 4px;
    padding: 2px;
    border-radius: 999px;
    background: rgba(27, 124, 97, 0.1);
    width: fit-content;
}

.zoom-button {
    border: 0;
    border-radius: 999px;
    background: transparent;
    padding: 5px 9px;
    font-weight: 800;
    font-size: 0.86rem;
    color: var(--brand-dark);
    cursor: pointer;
}

.zoom-button.is-active {
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(20, 83, 63, 0.12);
}

.zoom-step-button {
    min-width: 28px;
    padding: 5px 7px;
    font-size: 0.9rem;
    line-height: 1;
}

.preview-meta {
    display: flex;
    flex: 1 1 auto;
    gap: 4px;
    min-width: 0;
    align-items: stretch;
}

.preview-meta > div {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 8px;
    border-radius: 10px;
    border: 1px solid rgba(31, 41, 36, 0.08);
    background: rgba(255, 255, 255, 0.78);
    display: flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
}

.preview-meta strong {
    font-size: 0.76rem;
    line-height: 1.2;
}

.preview-meta .label {
    display: inline;
    margin: 0;
    font-size: 0.66rem;
    line-height: 1.2;
}

.meta-inline-note {
    display: inline;
    margin: 0 0 0 4px;
    color: var(--muted);
    font-size: 0.62rem;
    line-height: 1.2;
    white-space: nowrap;
}

.preview-meta-compact > div:first-child {
    max-width: 240px;
}

.preview-shell {
    min-height: 0;
    border-radius: 14px;
    border: 1px solid rgba(31, 41, 36, 0.1);
    background:
        linear-gradient(45deg, rgba(244, 239, 231, 0.9) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(244, 239, 231, 0.9) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(244, 239, 231, 0.9) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(244, 239, 231, 0.9) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    overflow: auto;
}

.preview-canvas {
    min-width: 100%;
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 16px;
    border: 2px dashed transparent;
    border-radius: 14px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.crop-viewport {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 2px solid rgba(27, 124, 97, 0.6);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.7),
        0 12px 24px rgba(31, 41, 36, 0.22);
    cursor: grab;
    background: rgba(0, 0, 0, 0.06);
}

.crop-viewport.is-draw-mode {
    cursor: crosshair;
}

.crop-viewport:active {
    cursor: grabbing;
}

.crop-viewport.is-draw-mode:active {
    cursor: crosshair;
}

.crop-image {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    user-select: none;
    pointer-events: none;
}

.crop-draw-box {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.94);
    outline: 2px dashed rgba(27, 124, 97, 0.95);
    outline-offset: -2px;
    border-radius: 8px;
    background: rgba(27, 124, 97, 0.12);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.preview-placeholder {
    max-width: 28ch;
    text-align: center;
}

.preview-placeholder h3 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
}

.preview-placeholder p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.45;
    font-size: 0.9rem;
}

#previewImage {
    height: auto;
    max-width: none;
    box-shadow: 0 14px 34px rgba(31, 41, 36, 0.2);
}

@media (max-width: 1180px) {
    body {
        height: auto;
        overflow: auto;
    }

    .app-shell {
        height: auto;
        padding: 10px;
    }

    .workspace {
        height: auto;
        grid-template-columns: 1fr;
    }

    .tools-pane,
    .preview-pane {
        min-height: 0;
    }

    .tools-scroll {
        overflow: visible;
    }

    .preview-shell {
        height: 56vh;
        min-height: 360px;
    }
}

@media (max-width: 760px) {
    .preview-toolbar {
        display: grid;
        align-items: stretch;
    }

    .preview-meta {
        display: grid;
        grid-template-columns: 1fr;
    }

    .preview-meta > div {
        white-space: normal;
        display: block;
    }

    .preview-meta .label {
        display: block;
        margin-bottom: 4px;
    }

    .meta-inline-note {
        display: block;
        margin: 4px 0 0;
    }

    .crop-ratio-row {
        grid-template-columns: 1fr;
    }

    .crop-mode-left {
        white-space: normal;
    }
}
