:root {
    --bg: #f3f7fb;
    --panel: #ffffff;
    --text: #10243e;
    --muted: #68798d;
    --line: #dce5ef;
    --line-strong: #c8d5e2;
    --blue: #0d5fc7;
    --blue-2: #137edf;
    --teal: #16b5a9;
    --green: #39b95b;
    --shadow: 0 18px 50px rgba(33, 60, 91, .09);
    --radius: 18px;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 10% 0%, rgba(31, 152, 230, .08), transparent 25rem),
        radial-gradient(circle at 94% 10%, rgba(25, 185, 156, .07), transparent 22rem),
        var(--bg);
    color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.topbar {
    background: rgba(255,255,255,.92);
    border-bottom: 1px solid rgba(214,225,235,.9);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}
.brand-wrap {
    width: min(1500px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.brand-logo { width: 286px; height: auto; display: block; }
.privacy-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #3b526d;
    font-size: 13px;
    font-weight: 650;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
}
.privacy-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(57,185,91,.12); }
.app-shell { width: min(1500px, calc(100% - 40px)); margin: 34px auto 60px; }
.welcome-card {
    background: var(--panel);
    border: 1px solid #e0e8f1;
    border-radius: 26px;
    box-shadow: var(--shadow);
    padding: clamp(28px, 5vw, 64px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(370px, .78fr);
    gap: clamp(28px, 5vw, 70px);
    align-items: center;
}
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .14em; }
.welcome-copy h1 { margin: 12px 0 16px; font-size: clamp(34px, 4vw, 58px); line-height: 1.04; letter-spacing: -.035em; max-width: 900px; }
.welcome-copy p { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.7; max-width: 740px; }
.dropzone {
    min-height: 330px;
    border: 2px dashed #a9bfd5;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 34px;
    background: linear-gradient(180deg, #fbfdff, #f5f9fd);
    transition: .2s ease;
    outline: none;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover { border-color: var(--blue-2); background: #f1f8ff; transform: translateY(-1px); box-shadow: 0 14px 32px rgba(18, 109, 203, .09); }
.drop-icon { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(13,95,199,.12), rgba(22,181,169,.14)); margin-bottom: 20px; }
.drop-icon svg { width: 44px; fill: none; stroke: var(--blue); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.dropzone strong { font-size: 20px; }
.dropzone span { margin-top: 5px; color: var(--muted); }
.dropzone small { margin-top: 18px; color: #8797a8; line-height: 1.5; max-width: 390px; }
.editor { display: flex; flex-direction: column; gap: 18px; }
.editor-toolbar {
    background: var(--panel);
    border: 1px solid #e0e8f1;
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    box-shadow: 0 8px 24px rgba(33,60,91,.05);
}
.toolbar-file { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 10px; font-weight: 900; letter-spacing: .08em; color: #fff; background: linear-gradient(135deg, var(--blue), var(--teal)); flex: 0 0 auto; }
.toolbar-file div:last-child { min-width: 0; }
.toolbar-file strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 650px; }
.toolbar-file span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.toolbar-actions { display: flex; gap: 8px; }
.workspace { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 18px; align-items: start; }
.controls { display: flex; flex-direction: column; gap: 14px; }
.control-card, .preview-panel {
    background: var(--panel);
    border: 1px solid #e0e8f1;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(33,60,91,.055);
}
.control-card { padding: 19px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-heading > div { display: flex; align-items: center; gap: 9px; }
.card-heading h2 { margin: 0; font-size: 17px; }
.step { width: 25px; height: 25px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: var(--blue); font-size: 12px; font-weight: 800; }
.summary { color: var(--muted); font-size: 12px; }
.field-row { display: grid; gap: 10px; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.field-row.four { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { width: 100%; margin-top: 12px; }
.field > span:first-child, .range-label { color: #50657a; font-size: 12px; font-weight: 700; }
.field small { font-size: 10px; font-weight: 600; color: #94a2b0; }
input[type="number"], input[type="text"], select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fbfdff;
    color: var(--text);
    padding: 0 11px;
    outline: none;
    transition: .16s ease;
}
input:focus, select:focus { border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(19,126,223,.1); background: #fff; }
.toggle-row { margin-top: 13px; display: flex; align-items: center; gap: 10px; color: #53677c; font-size: 13px; cursor: pointer; user-select: none; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 34px; height: 19px; border-radius: 999px; background: #c9d5df; position: relative; transition: .2s; }
.toggle-ui::after { content: ""; width: 13px; height: 13px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: .2s; }
.toggle-row input:checked + .toggle-ui { background: var(--blue); }
.toggle-row input:checked + .toggle-ui::after { transform: translateX(15px); }
.preset-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.preset-row button { border: 1px solid var(--line); background: #fff; color: #50657a; border-radius: 8px; padding: 7px 3px; font-size: 11px; font-weight: 700; }
.preset-row button:hover { border-color: #9fc1e5; color: var(--blue); background: #f5faff; }
.mini-action { border: 1px solid #b8cbe0; background: #f8fbff; color: var(--blue); border-radius: 9px; padding: 7px 9px; font-size: 11px; font-weight: 750; }
.mini-action[aria-pressed="true"] { background: var(--blue); color: #fff; border-color: var(--blue); }
.crop-values { margin-top: 10px; }
.crop-values input { padding: 0 7px; }
.help-text { color: #8090a0; font-size: 11px; line-height: 1.55; margin: 12px 0; }
.btn { border: 1px solid transparent; border-radius: 10px; height: 42px; padding: 0 14px; font-weight: 750; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: .17s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--blue), #147bd4); box-shadow: 0 9px 20px rgba(13,95,199,.18); }
.btn-primary:hover { box-shadow: 0 12px 26px rgba(13,95,199,.24); }
.btn-secondary { color: #35536f; border-color: var(--line); background: #f8fbfd; }
.btn-ghost { color: #6d7d8d; background: transparent; border-color: transparent; }
.btn-small { height: 36px; font-size: 12px; }
.full-width { width: 100%; }
.color-input-wrap { height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fbfdff; display: flex; align-items: center; padding: 5px 8px; gap: 8px; }
.color-input-wrap input { width: 30px; height: 28px; padding: 0; border: 0; background: transparent; }
.color-input-wrap code { color: #53677c; font-size: 11px; }
.range-label { display: flex; justify-content: space-between; align-items: center; }
.range-label strong { color: var(--blue); }
input[type="range"] { accent-color: var(--blue); width: 100%; }
.export-note { margin: 12px 0; border-radius: 9px; padding: 10px 11px; background: #f5f8fb; color: #708196; font-size: 11px; line-height: 1.45; }
.download-btn { height: 47px; margin-top: 4px; font-size: 14px; }
.download-btn svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status { min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 11px; text-align: center; }
.preview-panel { overflow: hidden; min-width: 0; position: sticky; top: 96px; }
.preview-head, .preview-foot { padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.preview-head { border-bottom: 1px solid #e8eef4; }
.preview-head strong { display: block; font-size: 14px; }
.preview-head span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.pointer-readout { color: #5e7185; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.stage {
    min-height: 560px;
    max-height: calc(100vh - 250px);
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background-color: #e9eef3;
    background-image:
        linear-gradient(45deg, #dfe5ea 25%, transparent 25%),
        linear-gradient(-45deg, #dfe5ea 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dfe5ea 75%),
        linear-gradient(-45deg, transparent 75%, #dfe5ea 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
    position: relative;
}
#previewCanvas { display: block; max-width: 100%; max-height: 100%; box-shadow: 0 12px 38px rgba(25,43,66,.18); touch-action: none; cursor: crosshair; }
#previewCanvas.crop-off { cursor: default; }
.empty-preview { color: #8b9bac; font-size: 14px; }
.preview-foot { border-top: 1px solid #e8eef4; color: #7b8c9e; font-size: 11px; }
.footer { width: min(1500px, calc(100% - 40px)); margin: 0 auto 28px; display: flex; justify-content: space-between; gap: 20px; color: #7a8b9c; font-size: 11px; }
.footer strong { color: #4c6176; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 380px; background: #12283f; color: #fff; padding: 12px 15px; border-radius: 11px; box-shadow: 0 16px 40px rgba(0,0,0,.2); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .22s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #842d37; }
@media (max-width: 1050px) {
    .workspace { grid-template-columns: 340px minmax(0,1fr); }
    .stage { min-height: 480px; }
}
@media (max-width: 860px) {
    .brand-wrap, .app-shell, .footer { width: min(100% - 24px, 1500px); }
    .brand-logo { width: 230px; }
    .privacy-pill { display: none; }
    .welcome-card { grid-template-columns: 1fr; }
    .dropzone { min-height: 260px; }
    .workspace { grid-template-columns: 1fr; }
    .preview-panel { position: static; order: -1; }
    .stage { min-height: 360px; max-height: 65vh; }
    .editor-toolbar { align-items: flex-start; }
    .toolbar-file strong { max-width: 52vw; }
    .footer { flex-direction: column; }
}
@media (max-width: 560px) {
    .topbar .brand-wrap { min-height: 68px; }
    .brand-logo { width: 205px; }
    .app-shell { margin-top: 18px; }
    .welcome-card { padding: 24px; border-radius: 20px; }
    .welcome-copy h1 { font-size: 34px; }
    .welcome-copy p { font-size: 15px; }
    .dropzone { min-height: 240px; padding: 24px 18px; }
    .editor-toolbar { flex-direction: column; }
    .toolbar-actions { width: 100%; }
    .toolbar-actions .btn { flex: 1; }
    .toolbar-file strong { max-width: calc(100vw - 100px); }
    .field-row.four { grid-template-columns: 1fr 1fr; }
    .preview-head, .preview-foot { align-items: flex-start; flex-direction: column; gap: 7px; }
    .stage { min-height: 300px; padding: 12px; }
}
