@charset "UTF-8";

:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #687382;
    --line: #d9e0e8;
    --accent: #0f8b8d;
    --accent-strong: #0b6f71;
    --accent-soft: #e8f7f7;
    --danger: #d94848;
    --shadow: 0 14px 36px rgba(31, 41, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
}

button,
input,
select {
    font: inherit;
}

button,
label.file-button {
    cursor: pointer;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

a {
    color: var(--accent-strong);
}

.site-header {
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.header-inner,
.app-shell,
.footer-inner {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
}

.header-inner {
    padding: 28px 0 24px;
}

.subtitle {
    margin: 0 0 8px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: clamp(1.7rem, 4vw, 2.5rem);
    line-height: 1.25;
}

h2 {
    margin-bottom: 14px;
    font-size: 1rem;
}

.lead {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--muted);
}

.hero-catch {
    margin-bottom: 8px;
    color: var(--ink);
    font-size: clamp(1.04rem, 2vw, 1.22rem);
    font-weight: 800;
}

.app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    padding: 22px 0 28px;
    align-items: start;
}

.workspace,
.side-panel {
    min-width: 0;
}

.upload-panel,
.panel,
.canvas-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.upload-panel {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    min-height: 118px;
    padding: 18px;
    border-style: dashed;
}

.upload-panel.is-dragover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-panel h2 {
    margin-bottom: 4px;
}

.upload-panel p {
    margin-bottom: 0;
    color: var(--muted);
}

.upload-action {
    display: grid;
    gap: 8px;
    justify-items: end;
    max-width: 320px;
}

.upload-action p {
    font-size: 0.86rem;
    text-align: right;
}

#imageInput {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.file-button,
.download-button,
.canvas-toolbar button,
.crop-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.file-button {
    padding: 0 18px;
}

.status-line {
    min-height: 28px;
    margin: 12px 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.status-line.is-error {
    color: var(--danger);
    font-weight: 700;
}

.canvas-card {
    padding: 14px;
}

.canvas-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.canvas-toolbar strong,
.canvas-toolbar span {
    display: block;
}

.canvas-toolbar span {
    color: var(--muted);
    font-size: 0.86rem;
}

.canvas-toolbar button {
    min-height: 38px;
    padding: 0 14px;
    background: #405166;
}

.canvas-wrap {
    position: relative;
    overflow: auto;
    min-height: 360px;
    max-height: calc(100vh - 280px);
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #eef2f5;
    text-align: center;
    touch-action: none;
}

#cropCanvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
    touch-action: none;
}

.empty-guide {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.hint {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.side-panel {
    display: grid;
    gap: 14px;
}

.guide-content,
.after-content {
    display: grid;
    gap: 18px;
    width: min(1180px, calc(100% - 28px));
}

.guide-content {
    grid-template-columns: 1.15fr 0.9fr 0.95fr;
    align-items: start;
    margin: 0 auto 22px;
}

.after-content {
    margin: 0 auto 28px;
}

.panel {
    padding: 16px;
}

.output-panel {
    transition: opacity 0.18s ease, border-color 0.18s ease;
}

.output-panel.is-locked {
    opacity: 0.58;
}

.output-panel.is-ready {
    border-color: rgba(15, 139, 141, 0.45);
}

.panel-note {
    margin: -4px 0 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.output-panel.is-ready .panel-note {
    color: var(--accent-strong);
    font-weight: 700;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.field label {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.field input,
.field select,
.crop-name {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink);
    padding: 8px 10px;
}

.download-button {
    width: 100%;
    min-height: 48px;
    margin-top: 4px;
    font-size: 0.98rem;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-heading a {
    font-size: 0.88rem;
    font-weight: 700;
    white-space: nowrap;
}

.section-heading span {
    color: var(--muted);
    font-size: 0.86rem;
}

.related-panel,
.guide-panel,
.comments-section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.guide-panel h2 {
    margin-bottom: 12px;
}

.steps-list,
.tips-list {
    margin: 0;
    padding-left: 1.3rem;
}

.steps-list {
    display: grid;
    gap: 12px;
}

.steps-list li {
    padding-left: 2px;
}

.steps-list strong,
.steps-list span {
    display: block;
}

.steps-list strong {
    margin-bottom: 2px;
}

.steps-list span,
.tips-list li {
    color: var(--muted);
    font-size: 0.92rem;
}

.tips-list {
    display: grid;
    gap: 9px;
}

.related-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.related-link {
    display: grid;
    gap: 4px;
    min-height: 108px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    color: var(--ink);
    text-decoration: none;
}

.related-link:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.related-link strong {
    font-size: 0.98rem;
}

.related-link span {
    color: var(--muted);
    font-size: 0.88rem;
}

.comments-section :where(.app-comments, .app-comment-form-section) {
    margin: 0;
    box-shadow: none;
}

.comments-section :where(.app-comment-form-section) {
    margin-top: 14px;
}

.crop-list,
.preview-grid {
    display: grid;
    gap: 10px;
}

.crop-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
}

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

.crop-main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.crop-meta {
    color: var(--muted);
    font-size: 0.84rem;
}

.crop-delete {
    width: 42px;
    min-height: 42px;
    background: var(--danger);
}

.preview-item {
    display: grid;
    grid-template-columns: 76px 1fr;
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.preview-item canvas {
    width: 76px;
    height: 58px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
    object-fit: contain;
}

.preview-item strong,
.preview-item span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.preview-item span,
.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

.site-footer {
    border-top: 1px solid var(--line);
    background: #ffffff;
}

.footer-inner {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0;
}

.footer-inner p {
    margin: 4px 0 0;
    color: var(--muted);
}

.footer-inner nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .related-links {
        grid-template-columns: 1fr;
    }

    .guide-content {
        grid-template-columns: 1fr;
    }

    .canvas-wrap {
        min-height: 280px;
        max-height: none;
    }

    .side-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .header-inner,
    .app-shell,
    .footer-inner,
    .guide-content,
    .after-content {
        width: min(100% - 20px, 1180px);
    }

    .upload-panel,
    .canvas-toolbar,
    .footer-inner {
        align-items: stretch;
        flex-direction: column;
    }

    .file-button,
    .canvas-toolbar button {
        width: 100%;
    }

    .upload-action {
        max-width: none;
        justify-items: stretch;
    }

    .upload-action p {
        text-align: left;
    }

    .preview-item {
        grid-template-columns: 68px 1fr;
    }

    .preview-item canvas {
        width: 68px;
        height: 52px;
    }
}
