:root {
    --ink: #17201d;
    --muted: #66736d;
    --line: #dfe6e1;
    --paper: #f7f4ee;
    --panel: #fffdf8;
    --accent: #2f7d68;
    --accent-strong: #1f5b4b;
    --clay: #b86142;
    --shadow: 0 18px 50px rgba(26, 42, 35, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a { color: inherit; text-decoration: none; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 18px;
    background: rgba(247, 244, 238, .88);
    border-bottom: 1px solid rgba(23, 32, 29, .08);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 210px;
    margin-left: 0;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: white;
    background: var(--ink);
    border-radius: 6px;
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.top-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 253, 248, .75);
}

.top-nav a, .login-link {
    padding: 9px 15px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 14px;
}

.top-nav a.active {
    color: white;
    background: var(--accent);
}

.login-link {
    border: 1px solid var(--line);
    background: var(--panel);
}

main { min-height: calc(100vh - 150px); }

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
    align-items: center;
    gap: min(6vw, 72px);
    padding: 72px min(5vw, 64px) 56px;
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--clay);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.hero h1 {
    max-width: 760px;
    margin-bottom: 22px;
    font-size: clamp(42px, 6vw, 78px);
    line-height: 1.02;
    letter-spacing: 0;
}

.lead {
    max-width: 700px;
    color: var(--muted);
    font-size: 19px;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 34px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.btn.primary { color: white; background: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.secondary { color: var(--ink); border-color: var(--line); background: var(--panel); }

.hero-board {
    min-height: 520px;
    padding: 22px;
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(47, 125, 104, .82), rgba(23, 32, 29, .9)),
        url("https://images.unsplash.com/photo-1494526585095-c41746248156?auto=format&fit=crop&w=1200&q=80") center/cover;
    box-shadow: var(--shadow);
}

.board-grid {
    display: grid;
    align-content: end;
    gap: 12px;
    height: 100%;
}

.board-grid article, .panel, .steps article, .notice {
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 8px;
    background: rgba(255, 253, 248, .92);
}

.board-grid article { padding: 18px; }
.board-grid span, .inspire-card span { color: var(--muted); font-size: 12px; }
.board-grid strong { display: block; margin-top: 8px; font-size: 20px; }
.board-grid p { margin: 8px 0 0; line-height: 1.65; }

.workflow, .tool-shell, .gallery-shell {
    padding: 38px min(5vw, 64px) 72px;
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.section-title h1, .section-title h2 {
    margin: 0;
    font-size: clamp(28px, 4vw, 44px);
}

.section-title.compact {
    display: block;
    margin-bottom: 28px;
}

.steps, .tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.steps article, .panel {
    padding: 24px;
    background: var(--panel);
}

.steps span {
    display: block;
    margin-bottom: 42px;
    color: var(--accent);
    font-weight: 800;
}

.steps h3, .panel h2 { margin-bottom: 10px; }
.steps p, .panel p { color: var(--muted); line-height: 1.7; }

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

.panel-head {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
}

.tool-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    color: white;
    background: var(--clay);
    border-radius: 6px;
    font-weight: 800;
}

.stack-form {
    display: grid;
    gap: 12px;
}

label { color: var(--ink); font-weight: 700; }

textarea, input[type="file"] {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--ink);
    font: inherit;
}

textarea {
    min-height: 148px;
    padding: 14px;
    resize: vertical;
    line-height: 1.7;
}

input[type="file"] { padding: 12px; }

.preview {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.status {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #edf5f1;
    color: var(--accent-strong);
    font-size: 14px;
}

.status.error { background: #fff0ea; color: #9a3f20; }

.result-box {
    display: grid;
    gap: 14px;
    margin-top: 16px;
}

.result-card {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.result-card h3 {
    margin-bottom: 8px;
    font-size: 15px;
}

.result-card p {
    margin-bottom: 12px;
    white-space: pre-wrap;
}

.copy-btn {
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel);
    padding: 7px 10px;
    cursor: pointer;
}

.hidden { display: none !important; }

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

.inspire-card {
    overflow: hidden;
    border: 1px solid rgba(23, 32, 29, .1);
    border-radius: 8px;
    background: var(--panel);
}

.inspire-card img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #e4e0d6;
}

.inspire-card div { padding: 14px; }
.inspire-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.65; }

.notice {
    grid-column: 1 / -1;
    padding: 18px;
    color: var(--muted);
}

.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 24px min(5vw, 64px);
    color: var(--muted);
    border-top: 1px solid rgba(23, 32, 29, .08);
}

@media (max-width: 900px) {
    .site-header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .top-nav { width: 100%; justify-content: center; }
    .login-link { text-align: center; }
    .hero, .tool-grid, .steps, .gallery { grid-template-columns: 1fr; }
    .hero { padding-top: 38px; }
    .hero-board { min-height: 420px; }
    .site-footer { flex-direction: column; }
}

/* Compact prompt workspace */
.tool-shell {
    padding: 18px;
    background: #f4f3f0;
}

.compact-tool {
    grid-template-columns: minmax(0, 1.06fr) minmax(380px, .94fr);
    gap: 14px;
    align-items: stretch;
}

.prompt-workbench,
.reverse-workbench {
    height: 650px;
    min-height: 650px;
}

.prompt-workbench,
.reverse-dropzone {
    border: 1px solid #d8d8d8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(18, 28, 24, .05);
}

.prompt-workbench {
    display: flex;
    flex-direction: column;
    padding: 18px;
}

.compact-form {
    display: grid;
    gap: 14px;
}

.tool-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.tool-card-head strong,
.result-title strong {
    display: block;
    color: #1f2933;
    font-size: 16px;
}

.tool-card-head span {
    display: block;
    margin-top: 4px;
    color: #7a8288;
    font-size: 12px;
}

.tool-card-head select {
    flex: 0 0 156px;
    height: 38px;
    padding: 0 34px 0 12px;
    border: 1px solid #d7d7d7;
    border-radius: 6px;
    background: #fafafa;
    color: #24313b;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.prompt-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 132px;
    gap: 10px;
}

.compact-form input {
    width: 100%;
    height: 42px;
    border: 1px solid #d7d7d7;
    border-radius: 6px;
    background: #fbfbfb;
    color: #1f2933;
    font: inherit;
    padding: 0 12px;
}

.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.compact-form input:focus,
.tool-card-head select:focus {
    outline: 2px solid rgba(255, 120, 40, .18);
    border-color: #ffb06d;
    background: #fff;
}

.compact-form.is-busy input,
.compact-form.is-busy select,
.compact-form.is-busy button {
    cursor: wait;
    opacity: .68;
}

.wide-action {
    width: 100%;
    height: 42px;
    border: 1px solid #ffbf7a;
    border-radius: 6px;
    background: #ff9f43;
    color: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.wide-action:hover {
    background: #f58d25;
}

.result-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 18px 0 10px;
    color: #344052;
}

.result-title em {
    color: #7a8288;
    font-size: 12px;
    font-style: normal;
}

.expand-result {
    flex: 1;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fafafa;
}

.expand-result.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa0a6;
}

.expand-result.loading {
    padding: 18px;
    background: #f8f8f8;
}

.expand-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    height: 100%;
    padding: 12px;
}

.expand-result article {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #dedede;
    border-radius: 8px;
    background: #fff;
}

.expand-result h3 {
    margin: 0 0 8px;
    color: #344052;
    font-size: 15px;
}

.expand-result p {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    margin-bottom: 10px;
    color: #222;
    white-space: pre-wrap;
    line-height: 1.65;
    font-size: 13px;
}

.expand-result .copy-btn,
.reverse-result .copy-btn {
    flex: 0 0 auto;
}

.compact-status {
    min-height: 20px;
    margin: 10px 0 0;
    color: #747474;
    font-size: 12px;
}

.expand-log {
    width: 100%;
    max-height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #344052;
    font-size: 13px;
    line-height: 1.65;
}

.expand-result.empty .expand-log {
    width: auto;
    color: #9aa0a6;
    text-align: center;
}

.expand-result.loading .expand-log {
    height: 100%;
    padding: 14px 16px;
    overflow: hidden;
}

.expand-log p {
    margin: 0;
}

.expand-log p + p {
    margin-top: 4px;
}

.compact-status.error,
.reverse-status.error {
    color: #d83700;
}

.reverse-workbench form,
.reverse-dropzone {
    height: 100%;
}

.reverse-workbench input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.reverse-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 650px;
    min-height: 650px;
    overflow: hidden;
    border-radius: 10px;
    background-position: center;
    background-size: cover;
    cursor: pointer;
}

.reverse-dropzone.dragging {
    border-color: #ff9b3d;
    box-shadow: inset 0 0 0 2px rgba(255, 155, 61, .28);
}

.reverse-dropzone.is-busy {
    cursor: wait;
}

.reverse-dropzone.is-busy input,
.reverse-dropzone.is-busy .reverse-pick {
    pointer-events: none;
}

.reverse-tab {
    position: absolute;
    left: 20px;
    top: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    background: #fff4e8;
    color: #f06b00;
    font-size: 13px;
    font-weight: 700;
}

.reverse-pick {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 285px;
    padding: 18px 32px;
    border-radius: 10px;
    background: #ff9f43;
    color: #fff;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
}

.reverse-dropzone.has-image .reverse-pick {
    top: 72px;
    padding: 11px 20px;
    font-size: 14px;
}

.reverse-status {
    position: absolute;
    left: 24px;
    right: 24px;
    bottom: 18px;
    color: #111;
    text-align: center;
    font-size: 14px;
}

.reverse-loading {
    display: flex;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 36px;
    background: rgba(255, 255, 255, .72);
    z-index: 2;
}

.reverse-dots {
    display: flex;
}

.reverse-loading i {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin: 0 26px;
    border-radius: 50%;
    animation: pulse-dot 1s ease-in-out infinite alternate;
}

.reverse-loading i:nth-child(1) { background: #6ed1bd; }
.reverse-loading i:nth-child(2) { background: #fff22a; animation-delay: .16s; }
.reverse-loading i:nth-child(3) { background: #ef1d24; animation-delay: .32s; }

.reverse-log {
    width: min(560px, calc(100% - 80px));
    max-height: 160px;
    overflow: hidden;
    padding: 14px 18px;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 8px;
    background: rgba(255, 255, 255, .78);
    color: #111;
    text-align: left;
    font-size: 14px;
    line-height: 1.8;
}

.reverse-log p {
    margin: 0;
}

.reverse-log p + p {
    margin-top: 6px;
}

.reverse-result {
    position: absolute;
    inset: 64px 24px 54px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: none;
    overflow: auto;
    padding: 16px;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, .9);
    color: #17201d;
    cursor: default;
}

.reverse-result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    min-height: 0;
    flex: 1;
}

.reverse-result article {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    padding: 14px;
    border: 1px solid #dedede;
    border-radius: 6px;
    background: rgba(255, 255, 255, .72);
}

.reverse-result h3,
.reverse-result .result-label {
    margin: 0 0 10px;
    color: #344052;
    font-size: 15px;
    font-weight: 400;
}

.reverse-result p {
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: auto;
    margin-bottom: 12px;
    white-space: pre-wrap;
    line-height: 1.65;
    font-weight: 400;
}

.reverse-again {
    align-self: center;
    min-width: 160px;
    height: 38px;
    border: 1px solid #ffd59d;
    border-radius: 4px;
    background: #ffddb0;
    color: #ff4b00;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.reverse-again:hover {
    background: #ffd39c;
}

@keyframes pulse-dot {
    from { transform: translateY(0); opacity: .72; }
    to { transform: translateY(-12px); opacity: 1; }
}

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

    .prompt-workbench,
    .reverse-workbench,
    .reverse-dropzone {
        height: auto;
        min-height: 520px;
    }

    .expand-result {
        min-height: 360px;
    }

    .reverse-result-grid {
        grid-template-columns: 1fr;
    }

    .expand-result-grid {
        grid-template-columns: 1fr;
    }
}
