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

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

:root {
    --ink: #15191d;
    --ink-soft: #505860;
    --muted: #798087;
    --paper: #f8f9f9;
    --canvas: #edf0f2;
    --line: #d5dadd;
    --line-dark: #afb6bc;
    --accent: #2458d6;
    --accent-dark: #1949bd;
    --white: #fff;
    --danger: #c34545;
    --ease: cubic-bezier(.22, 1, .36, 1);
}

html { background: var(--canvas); }
body { min-width: 320px; overflow-x: hidden; color: var(--ink); background: var(--canvas); font-family: "Ranade", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button:focus-visible, a:focus-visible, .dropzone:focus-within { outline: 3px solid rgba(36,88,214,.28); outline-offset: 3px; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 64px;
    padding: 0 max(24px, calc((100vw - 1240px) / 2));
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(248,249,249,.9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(15px);
}
.site-brand { display: inline-flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 700; }
.site-logo-mark { width: 30px; height: 30px; display: grid; place-items: center; color: var(--white); background: var(--ink); font-size: 9px; letter-spacing: .05em; }
.site-header-actions { display: flex; align-items: center; gap: 22px; color: var(--ink-soft); font-size: 12px; }
.site-header-actions > a:hover { color: var(--ink); }
.site-header-tag { display: inline-flex; align-items: center; gap: 8px; }
.site-header-tag i { width: 7px; height: 7px; background: #1c9c68; border-radius: 50%; box-shadow: 0 0 0 4px rgba(28,156,104,.1); }

.tool-shell { max-width: 1240px; margin: 0 auto; padding: 60px 24px 120px; }
.tool-header {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 80px;
    align-items: end;
    margin-bottom: 48px;
    animation: fade-up 600ms var(--ease) both;
}
.tool-kicker { margin-bottom: 17px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.tool-header h1 { max-width: 650px; font-size: clamp(40px, 5vw, 64px); font-weight: 500; letter-spacing: -.055em; line-height: .98; }
.tool-header-aside { padding-bottom: 4px; }
.tool-header-aside p { margin-bottom: 16px; color: var(--ink-soft); font-size: 13px; line-height: 1.65; }
.tool-header-aside a { display: inline-flex; gap: 7px; padding-bottom: 4px; color: var(--ink); border-bottom: 1px solid var(--line-dark); font-size: 11px; font-weight: 700; }

.workspace {
    display: grid;
    grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
    border-top: 1px solid var(--line-dark);
    border-left: 1px solid var(--line-dark);
    animation: fade-up 600ms 80ms var(--ease) both;
}
.panel { padding: 25px; background: var(--paper); border-right: 1px solid var(--line-dark); border-bottom: 1px solid var(--line-dark); }
.panel-upload { min-height: 548px; }
.panel-settings { min-width: 0; }
.panel-heading { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.step-index { width: 28px; padding-top: 3px; color: var(--accent); font: 500 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.panel-title, .output-title { font-size: 15px; font-weight: 700; line-height: 1.4; }
.panel-sub { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.5; }

.dropzone {
    position: relative;
    min-height: 246px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--white);
    border: 1px dashed var(--line-dark);
    cursor: pointer;
    transition: background 170ms ease, border-color 170ms ease;
}
.dropzone:hover, .dropzone.drag-over { background: #f1f5ff; border-color: var(--accent); }
.dropzone-empty { padding: 34px 20px; text-align: center; }
.upload-icon { width: 42px; height: 42px; margin: 0 auto 16px; display: grid; place-items: center; color: var(--accent); border: 1px solid #b9c8ed; background: #f4f7ff; border-radius: 50%; }
.dropzone-empty strong { display: block; margin-bottom: 6px; font-size: 13px; }
.dropzone-empty p { color: var(--ink-soft); font-size: 11px; }
.browse-link { color: var(--accent); font-weight: 700; }
.dropzone-empty small { display: block; margin-top: 14px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }

.upload-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.upload-item { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--white); border: 1px solid var(--line); animation: fade-up 260ms var(--ease) both; }
.upload-item-thumb { width: 40px; height: 40px; flex: 0 0 auto; object-fit: cover; background: var(--canvas); }
.upload-item-info { min-width: 0; flex: 1; }
.upload-item-name { overflow: hidden; color: var(--ink); font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-meta { margin-top: 3px; color: var(--muted); font: 400 9px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
.upload-item-remove { width: 30px; height: 30px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 16px; transition: color 150ms ease, background 150ms ease; }
.upload-item-remove:hover { color: var(--danger); background: #fff1f1; }

.size-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.size-item { min-height: 86px; padding: 15px; display: flex; align-items: flex-start; gap: 11px; background: var(--white); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; transition: background 150ms ease; }
.size-item:hover { background: #f4f6f7; }
.size-item:has(input:checked) { background: #f1f5ff; box-shadow: inset 3px 0 0 var(--accent); }
.size-item input[type="checkbox"] { width: 15px; height: 15px; margin-top: 1px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.size-item-body { min-width: 0; }
.size-item-label { margin-bottom: 4px; font-size: 11px; font-weight: 700; line-height: 1.3; }
.size-item-dims { color: var(--muted); font: 400 9px/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
.size-item-note { margin-top: 5px; color: var(--accent); font-size: 9px; }

.settings-footer { margin-top: 23px; display: grid; grid-template-columns: minmax(240px, .72fr) minmax(150px, .38fr); gap: 18px 24px; align-items: end; }
.field label { display: block; margin-bottom: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.segmented { display: flex; padding: 3px; background: var(--canvas); border: 1px solid var(--line); }
.segmented button { flex: 1; min-height: 34px; padding: 6px 10px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 10px; font-weight: 700; }
.segmented button.active { color: var(--white); background: var(--ink); }
.field-hint { margin-top: 8px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.bg-color-row { display: flex; align-items: center; gap: 8px; }
.bg-color-row input[type="color"] { width: 42px; height: 36px; padding: 3px; background: var(--white); border: 1px solid var(--line-dark); cursor: pointer; }
.format-note { grid-column: 1 / -1; padding-top: 15px; display: flex; align-items: flex-start; gap: 8px; color: var(--muted); border-top: 1px solid var(--line); font-size: 9px; line-height: 1.5; }
.format-note i { margin-top: 2px; color: var(--accent); }

.output-section { margin-top: 46px; opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity 380ms var(--ease), transform 380ms var(--ease); }
.output-section.show { opacity: 1; transform: none; pointer-events: auto; }
.output-head { padding: 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line-dark); border-bottom: 1px solid var(--line-dark); }
.output-head .panel-heading { margin: 0; }
.output-title { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.source-badge { display: inline-flex; padding: 4px 7px; color: var(--accent); background: #f1f5ff; border: 1px solid #c4d0ee; font-size: 9px; }

.copy-btn { min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--white); background: var(--accent); border: 1px solid var(--accent); cursor: pointer; font-size: 10px; font-weight: 700; transition: background 150ms ease, transform 150ms var(--ease); }
.copy-btn:hover { background: var(--accent-dark); }
.copy-btn:active { transform: scale(.97); }
.copy-btn.secondary { color: var(--ink); background: var(--white); border-color: var(--line-dark); }
.copy-btn.secondary:hover { background: #f1f3f4; }
.copy-btn.copied { color: var(--white); background: #1c9c68; border-color: #1c9c68; }

.results-grid { display: flex; flex-direction: column; gap: 36px; padding-top: 28px; }
.result-group { animation: fade-up 360ms var(--ease) both; }
.result-group-title { margin-bottom: 12px; display: flex; align-items: center; gap: 9px; overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.result-group-title::before { content: ""; width: 7px; height: 7px; flex: 0 0 auto; background: var(--accent); }
.result-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line-dark) transparent; }
.result-card { width: 174px; flex: 0 0 174px; padding: 10px; background: var(--paper); border: 1px solid var(--line); scroll-snap-align: start; animation: fade-up 340ms var(--ease) both; }
.result-card-preview { width: 100%; aspect-ratio: 9 / 16; margin-bottom: 10px; display: grid; place-items: center; overflow: hidden; background: var(--canvas); border: 1px solid var(--line); }
.result-card-preview img { width: 100%; height: 100%; object-fit: contain; }
.result-card-dims { margin-bottom: 9px; color: var(--ink-soft); font: 500 9px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; }
.result-card .copy-btn { width: 100%; }

.site-footer { min-height: 78px; padding: 0 max(24px, calc((100vw - 1192px) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; }
.site-footer > span { color: var(--ink); font-weight: 700; }
.doc-toast { position: fixed; top: 20px; left: 50%; z-index: 100; padding: 10px 16px; color: var(--white); background: var(--ink); border: 1px solid #394047; opacity: 0; transform: translate(-50%, -10px); pointer-events: none; font-size: 11px; transition: opacity 180ms var(--ease), transform 180ms var(--ease); }
.doc-toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
    .tool-header { grid-template-columns: 1fr; gap: 24px; }
    .tool-header-aside { max-width: 620px; }
    .workspace { grid-template-columns: 1fr; }
    .panel-upload { min-height: 0; }
}

@media (max-width: 640px) {
    .site-header { height: 58px; padding: 0 16px; }
    .site-brand > span:last-child, .site-header-actions > a { display: none; }
    .site-header-actions { gap: 0; }
    .tool-shell { padding: 42px 16px 84px; }
    .tool-header { margin-bottom: 34px; }
    .tool-header h1 { font-size: clamp(38px, 10.5vw, 48px); }
    .panel { padding: 19px 16px; }
    .size-list { grid-template-columns: 1fr; }
    .size-item { min-height: 74px; }
    .settings-footer { grid-template-columns: 1fr; }
    .format-note { grid-column: auto; }
    .output-head { align-items: flex-start; }
    .output-head .panel-heading { max-width: calc(100% - 110px); }
    .site-footer { padding: 24px 16px; flex-direction: column; align-items: flex-start; }
}

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