*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

@font-face {
    font-family: 'Ranade';
    src: url('/static/fonts/Ranade/Ranade-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ranade';
    src: url('/static/fonts/Ranade/Ranade-Medium.woff2') format('woff2');
    font-weight: 500 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Ranade';
    src: url('/static/fonts/Ranade/Ranade-Bold.woff2') format('woff2');
    font-weight: 700 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --canvas: #f3f1ec;
    --surface: #fbfaf7;
    --surface-strong: #ffffff;
    --surface-muted: #ebe9e3;
    --ink: #17191b;
    --ink-soft: #42464a;
    --muted: #74797c;
    --line: #d8d5cd;
    --line-strong: #bbb7ad;
    --accent: #bd563c;
    --accent-dark: #963d29;
    --accent-soft: #f4ddd6;
    --positive: #35745c;
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 9px;
    --font: 'Ranade', sans-serif;
    --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --shadow: 0 18px 50px rgba(52, 45, 35, .07), 0 2px 8px rgba(52, 45, 35, .04);
}

html { background: var(--canvas); scroll-behavior: smooth; }
body {
    min-height: 100vh;
    overflow-x: clip;
    background:
        radial-gradient(circle at 88% 8%, rgba(189, 86, 60, .08), transparent 28rem),
        var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .18;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}
button, input, textarea { font: inherit; }
button { color: inherit; }

@keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(.72); opacity: .55; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
    padding: 12px 36px;
    border-bottom: 1px solid rgba(187, 183, 173, .72);
    background: rgba(243, 241, 236, .86);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--ink);
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: -.015em;
    text-decoration: none;
}
.site-logo-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 10px;
    background: var(--ink);
    color: #fff;
    font-family: var(--mono);
    font-size: .62rem;
    letter-spacing: -.04em;
    transition: transform .3s var(--ease-out), background-color .2s;
}
.site-brand:hover .site-logo-mark { transform: rotate(-5deg) translateY(-1px); background: var(--accent); }
.site-header-tag {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 600;
}
.site-header-tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); animation: breathe 2.4s ease-in-out infinite; }

.tool-shell { width: min(1240px, calc(100% - 64px)); margin: 0 auto; padding: 72px 0 112px; }
.tool-header {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr);
    align-items: end;
    gap: clamp(56px, 8vw, 120px);
    padding: 0 4px 68px;
}
.tool-header-copy { opacity: 0; animation: rise .65s var(--ease-out) forwards; }
.tool-kicker {
    margin-bottom: 18px;
    color: var(--accent-dark);
    font-family: var(--mono);
    font-size: .67rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.tool-header h1 {
    max-width: 790px;
    color: var(--ink);
    font-size: clamp(2.75rem, 5.3vw, 5.25rem);
    font-weight: 700;
    line-height: .98;
    letter-spacing: -.062em;
    text-wrap: balance;
}
.tool-header-copy > p {
    max-width: 700px;
    margin-top: 24px;
    color: var(--ink-soft);
    font-size: .98rem;
    line-height: 1.7;
}
.tool-provenance { display: flex; align-items: center; gap: 22px; margin-top: 25px; color: var(--muted); font-size: .72rem; }
.tool-provenance a { color: var(--ink); font-weight: 600; text-decoration: none; }
.tool-provenance a span { display: inline-block; margin-left: 3px; transition: transform .2s var(--ease-out); }
.tool-provenance a:hover span { transform: translate(2px, -2px); }

.prompt-map {
    position: relative;
    overflow: hidden;
    border: 1px solid #292c2f;
    border-radius: var(--radius-lg);
    background: #1c1f21;
    color: #fff;
    box-shadow: 0 26px 60px rgba(35, 32, 27, .18);
    opacity: 0;
    animation: rise .65s .12s var(--ease-out) forwards;
}
.prompt-map::after { content: ''; position: absolute; right: -54px; bottom: -80px; width: 190px; height: 190px; border: 34px solid rgba(189,86,60,.18); border-radius: 50%; }
.prompt-map-head, .prompt-map-output { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
.prompt-map-head { border-bottom: 1px solid rgba(255,255,255,.1); color: #b6babd; font-family: var(--mono); font-size: .61rem; }
.prompt-map-head b { color: #fff; font-weight: 600; }
.prompt-map ol { position: relative; z-index: 1; list-style: none; padding: 8px 20px; }
.prompt-map li { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 13px; padding: 15px 0; border-bottom: 1px solid rgba(255,255,255,.09); }
.prompt-map li > span { color: #d98770; font-family: var(--mono); font-size: .61rem; }
.prompt-map li strong, .prompt-map li small { display: block; }
.prompt-map li strong { margin-bottom: 3px; font-size: .82rem; font-weight: 600; }
.prompt-map li small { color: #989da1; font-size: .67rem; }
.prompt-map-output { color: #aeb2b5; font-size: .65rem; }
.prompt-map-output code { color: #fff; font-family: var(--mono); font-size: .62rem; }

.tool-grid {
    display: grid;
    grid-template-columns: minmax(0, .87fr) minmax(0, 1.13fr);
    gap: 24px;
    align-items: start;
}
.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(251,250,247,.92);
    box-shadow: var(--shadow);
    opacity: 0;
    animation: rise .6s var(--ease-out) forwards;
}
.panel-upload { position: sticky; top: 94px; padding: 26px; animation-delay: .17s; }
.panel-form { padding: 30px; animation-delay: .25s; }
.panel-heading { display: grid; grid-template-columns: 34px 1fr; gap: 14px; align-items: start; margin-bottom: 24px; }
.step-index { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--accent-dark); font-family: var(--mono); font-size: .61rem; font-weight: 600; }
.panel-title, .output-title { color: var(--ink); font-size: 1.02rem; font-weight: 700; letter-spacing: -.025em; }
.panel-sub { max-width: 44ch; margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.5; }

.dropzone {
    position: relative;
    display: grid;
    min-height: 390px;
    place-items: center;
    overflow: hidden;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-md);
    background:
        linear-gradient(rgba(216,213,205,.32) 1px, transparent 1px),
        linear-gradient(90deg, rgba(216,213,205,.32) 1px, transparent 1px),
        #f7f5f0;
    background-size: 26px 26px;
    cursor: pointer;
    transition: border-color .24s, background-color .24s, transform .24s var(--ease-out);
}
.dropzone:hover, .dropzone.drag-over { border-color: var(--accent); background-color: var(--accent-soft); transform: translateY(-2px); }
.dropzone.drag-over { border-style: solid; }
.dropzone-empty { display: flex; flex-direction: column; align-items: center; max-width: 280px; padding: 42px 24px; text-align: center; }
.upload-glyph { display: grid; width: 58px; height: 58px; margin-bottom: 20px; place-items: center; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 12px 24px rgba(52,45,35,.08); transition: transform .3s var(--ease-out); }
.upload-glyph svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone:hover .upload-glyph { transform: translateY(-4px) rotate(-3deg); }
.dropzone-empty strong { margin-bottom: 7px; font-size: .88rem; font-weight: 700; }
.dropzone-empty p { color: var(--muted); font-size: .75rem; line-height: 1.5; }
.browse-link { color: var(--accent-dark); font-weight: 700; }
.dropzone-empty small { margin-top: 18px; color: #979b9d; font-family: var(--mono); font-size: .58rem; }
.preview-frame { display: flex; width: 100%; min-height: 390px; align-items: center; justify-content: center; padding: 20px; }
.preview-frame img { display: block; max-width: 100%; max-height: 520px; border-radius: 10px; box-shadow: 0 22px 45px rgba(36,31,25,.22); animation: rise .4s var(--ease-out) both; }
.change-image-btn { position: absolute; top: 12px; right: 12px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.26); border-radius: 9px; background: rgba(23,25,27,.84); backdrop-filter: blur(10px); color: #fff; font-size: .68rem; font-weight: 600; cursor: pointer; transition: transform .18s var(--ease-out), background-color .18s; }
.change-image-btn:hover { background: var(--accent-dark); }
.change-image-btn:active { transform: translateY(1px) scale(.98); }

.palette-card { margin-top: 20px; opacity: 0; transform: translateY(10px); transition: opacity .35s var(--ease-out), transform .35s var(--ease-out); }
.palette-card.show { opacity: 1; transform: translateY(0); }
.palette-head { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 12px; }
.palette-head h3 { font-size: .75rem; font-weight: 700; }
.palette-swatch-row { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; }
.palette-swatch { min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; }
.palette-chip { width: 100%; height: 42px; border: 1px solid rgba(23,25,27,.12); border-radius: 9px; transition: transform .2s var(--ease-out); }
.palette-swatch:hover .palette-chip { transform: translateY(-2px); }
.palette-swatch:active .palette-chip { transform: scale(.96); }
.palette-hex { display: block; overflow: hidden; margin-top: 6px; color: var(--muted); font-family: var(--mono); font-size: .52rem; text-align: center; text-overflow: ellipsis; }
.theme-pill, .source-badge, .editable-tag { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-dark); font-family: var(--mono); font-size: .52rem; font-weight: 600; }

.field { margin-bottom: 21px; }
.field label { display: block; margin-bottom: 7px; color: var(--ink); font-size: .76rem; font-weight: 700; }
.required-mark, .optional-mark { margin-left: 6px; color: var(--accent-dark); font-family: var(--mono); font-size: .5rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.optional-mark { color: var(--muted); }
.field-hint { max-width: 64ch; margin-bottom: 9px; color: var(--muted); font-size: .66rem; line-height: 1.5; }
.field input[type='text'], .field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-size: .8rem;
    transition: border-color .2s, box-shadow .2s, transform .2s var(--ease-out);
}
.field input[type='text'] { min-height: 50px; padding: 0 15px; }
.field textarea { min-height: 118px; padding: 14px 15px; resize: vertical; line-height: 1.6; }
.field input::placeholder, .field textarea::placeholder { color: #a0a3a4; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(189,86,60,.12); }
.field input.invalid { border-color: var(--accent-dark); box-shadow: 0 0 0 3px rgba(189,86,60,.12); }
.field-error { position: relative; margin-top: 7px; padding-left: 16px; color: var(--accent-dark); font-size: .64rem; font-weight: 600; }
.field-error::before { content: '!'; position: absolute; left: 0; top: 0; }

.segmented { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.segmented button { min-height: 42px; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .69rem; font-weight: 600; cursor: pointer; transition: background-color .22s, color .22s, transform .18s var(--ease-out), box-shadow .22s; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--ink); color: #fff; box-shadow: 0 5px 12px rgba(23,25,27,.15); }
.segmented button:active { transform: scale(.98); }

.generate-btn { display: flex; width: 100%; min-height: 56px; align-items: center; justify-content: space-between; gap: 16px; margin-top: 5px; padding: 0 18px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700; cursor: pointer; box-shadow: 0 12px 28px rgba(150,61,41,.2); transition: background-color .2s, transform .2s var(--ease-out), box-shadow .2s; }
.generate-btn b { font-family: var(--mono); font-size: 1rem; transition: transform .2s var(--ease-out); }
.generate-btn:not(:disabled):hover { background: var(--accent-dark); box-shadow: 0 16px 32px rgba(150,61,41,.24); transform: translateY(-2px); }
.generate-btn:not(:disabled):hover b { transform: translateX(3px); }
.generate-btn:active { transform: translateY(1px) scale(.99); }
.generate-btn:disabled { background: #cbc7bd; color: #77766f; box-shadow: none; cursor: not-allowed; }
.btn-spinner { display: inline-block; width: 14px; height: 14px; margin-right: 8px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }

.output-section { margin-top: 28px; padding: 30px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(251,250,247,.94); box-shadow: var(--shadow); opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity .45s var(--ease-out), transform .45s var(--ease-out); }
.output-section.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.output-heading { display: grid; grid-template-columns: 34px 1fr; gap: 14px; margin-bottom: 22px; }
.output-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.output-heading p { margin-top: 5px; color: var(--muted); font-size: .72rem; }
.source-badge.local { background: var(--surface-muted); color: var(--ink-soft); }
.source-badge.ai { background: #dfece6; color: #28664e; }
.next-steps { display: none; gap: 11px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid #c8ddd4; border-radius: 10px; background: #eef6f2; }
.next-steps.populated { display: flex; align-items: flex-start; }
.next-steps.warn { border-color: #e4c1b7; background: #fbefeb; }
.next-step-icon { display: grid; width: 22px; height: 22px; flex: 0 0 auto; place-items: center; border-radius: 7px; background: var(--positive); color: #fff; font-size: .65rem; font-weight: 800; }
.next-steps.warn .next-step-icon { background: var(--accent); }
.next-step-text { color: var(--ink-soft); font-size: .7rem; line-height: 1.55; }
.inline-download-link { padding: 0; border: 0; border-bottom: 1px solid currentColor; background: none; color: var(--accent-dark); font-size: inherit; font-weight: 700; cursor: pointer; }
.reference-image-card { display: none; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #f7f5f0; }
.reference-image-card.show { display: block; }
.reference-image-label { margin-bottom: 12px; color: var(--muted); font-size: .64rem; font-weight: 600; }
.reference-image-thumb { display: block; max-width: 100%; max-height: 320px; margin: 0 auto; border-radius: 9px; box-shadow: 0 16px 30px rgba(36,31,25,.16); }
.prompt-block-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 14px; border: 1px solid #303437; border-bottom: 0; border-radius: 12px 12px 0 0; background: #202326; }
.prompt-block-name { color: #b8bdc0; font-family: var(--mono); font-size: .62rem; }
.editable-tag { margin-left: 6px; background: rgba(255,255,255,.09); color: #d1d5d7; }
.prompt-block-actions { display: flex; gap: 7px; }
.copy-btn { min-height: 34px; padding: 0 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: var(--accent); color: #fff; font-size: .63rem; font-weight: 700; cursor: pointer; transition: transform .18s var(--ease-out), background-color .18s; }
.copy-btn.secondary { background: rgba(255,255,255,.06); color: #d6d9da; }
.copy-btn:hover { background: var(--accent-dark); }
.copy-btn.secondary:hover { background: rgba(255,255,255,.12); }
.copy-btn:active { transform: scale(.97); }
.copy-btn.copied { background: var(--positive); }
.prompt-code { display: block; width: 100%; min-height: 330px; max-height: 640px; padding: 20px; resize: vertical; border: 1px solid #303437; border-radius: 0 0 12px 12px; outline: 0; background: #181b1d; color: #d4d8da; font-family: var(--mono); font-size: .69rem; line-height: 1.75; white-space: pre-wrap; }
.prompt-code:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(189,86,60,.12); }
.prompt-code::-webkit-scrollbar { width: 9px; }
.prompt-code::-webkit-scrollbar-thumb { border: 2px solid #181b1d; border-radius: 9px; background: #4b5053; }
.skill-credit { margin-top: 11px; color: var(--muted); font-size: .61rem; }
.skill-credit code { color: var(--ink-soft); font-family: var(--mono); }

.doc-toast { position: fixed; top: 84px; left: 50%; z-index: 60; min-width: 190px; padding: 11px 16px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: 0 16px 36px rgba(23,25,27,.2); font-size: .7rem; font-weight: 600; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%,-12px); transition: opacity .22s, transform .22s var(--ease-out); }
.doc-toast.show { opacity: 1; transform: translate(-50%,0); }

.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 28px 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: .67rem; }
.site-footer span { color: var(--ink); font-weight: 700; }
.telegram-wrap { position: fixed; right: 24px; bottom: 24px; z-index: 30; display: flex; align-items: center; gap: 10px; opacity: 0; animation: rise .55s .55s var(--ease-out) forwards; }
.telegram-fab { order: 2; display: block; width: 48px; height: 48px; color: var(--accent); filter: drop-shadow(0 10px 18px rgba(150,61,41,.22)); transition: transform .25s var(--ease-out), color .2s; }
.telegram-fab svg { display: block; width: 100%; height: 100%; }
.telegram-fab:hover { color: var(--accent-dark); transform: translateY(-3px) rotate(-4deg); }
.telegram-fab:active { transform: scale(.94); }
.telegram-balloon { position: relative; padding: 9px 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); box-shadow: 0 10px 26px rgba(52,45,35,.1); font-size: .66rem; font-weight: 700; }
.telegram-balloon i { position: absolute; top: 50%; right: -5px; width: 9px; height: 9px; margin-top: -4px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); background: #fff; transform: rotate(45deg); }

@media (max-width: 960px) {
    .tool-shell { width: min(100% - 40px, 760px); padding-top: 50px; }
    .tool-header { grid-template-columns: 1fr; gap: 36px; padding-bottom: 48px; }
    .tool-header h1 { max-width: 760px; }
    .prompt-map { width: min(100%, 520px); margin-left: auto; }
    .tool-grid { grid-template-columns: 1fr; }
    .panel-upload { position: static; }
}

@media (max-width: 620px) {
    .site-header { min-height: 62px; padding: 10px 16px; }
    .site-header-tag { font-size: 0; gap: 0; }
    .site-header-tag i { display: block; }
    .tool-shell { width: calc(100% - 28px); padding: 38px 0 78px; }
    .tool-header { gap: 30px; padding-inline: 2px; padding-bottom: 38px; }
    .tool-header h1 { font-size: clamp(2.45rem, 13vw, 3.8rem); }
    .tool-header-copy > p { margin-top: 18px; font-size: .88rem; }
    .tool-provenance { align-items: flex-start; flex-direction: column; gap: 9px; }
    .prompt-map { width: 100%; }
    .panel-upload, .panel-form, .output-section { padding: 20px; border-radius: 17px; }
    .panel-heading, .output-heading { grid-template-columns: 30px 1fr; gap: 11px; }
    .step-index { width: 30px; height: 30px; }
    .dropzone, .preview-frame { min-height: 310px; }
    .segmented { grid-template-columns: 1fr; }
    .segmented button { min-height: 40px; }
    .prompt-block-header { align-items: flex-start; flex-direction: column; }
    .prompt-block-actions { width: 100%; }
    .copy-btn { flex: 1; }
    .prompt-code { min-height: 400px; padding: 15px; font-size: .65rem; }
    .site-footer { align-items: flex-start; flex-direction: column; gap: 6px; padding: 24px 18px 92px; }
    .telegram-wrap { right: 16px; bottom: 16px; }
    .telegram-balloon { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
