:root {
    --bg: #f8f7f4;
    --surface: #ffffff;
    --ink: #1c1b19;
    --ink-2: #5c5a55;
    --muted: #706d66; /* 4.5:1+ contrast on all page backgrounds */
    --line: #e8e5df;
    --grid: rgba(28, 27, 25, 0.045);
    --accent: #f26b2a;
    --accent-ink: #ffffff;
    --accent-soft: #fdeee5;
    --ok: #1f8a4c;
    --danger: #c53b2b;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(28, 27, 25, .04), 0 4px 16px rgba(28, 27, 25, .04);
    --font: "Helvetica Neue", Helvetica, Arial, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background-color: var(--bg);
    background-image:
        linear-gradient(var(--grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 60px 60px;
    line-height: 1.6;
    overflow-x: hidden;
}
img, canvas { max-width: 100%; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }
code { background: var(--accent-soft); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.section { margin-top: 48px; margin-bottom: 48px; } /* keep .container's auto side margins */
.hidden { display: none !important; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(248, 247, 244, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--ink); font-size: 18px; }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: -0.03em; }
.site-nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.site-nav a { white-space: nowrap; text-decoration: none; color: var(--ink-2); font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.site-nav a:hover, .site-nav a.active { background: var(--surface); color: var(--ink); }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 18px; width: 40px; height: 40px; cursor: pointer; }
@media (max-width: 960px) {
    .nav-toggle { display: block; }
    .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--bg); border-bottom: 1px solid var(--line); padding: 8px 16px 16px; }
    .site-nav.open { display: flex; }
    .site-nav a { padding: 10px; }
}

/* Hero */
.hero { text-align: center; padding: 64px 0 32px; position: relative; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 14px; margin: 0 0 12px; }
.hero-title { font-size: clamp(40px, 8vw, 84px); margin: 0; letter-spacing: -0.045em; line-height: 1.02; }
.hero-title .accent { display: block; }
.hero-lead { max-width: 640px; margin: 20px auto 40px; color: var(--ink-2); font-size: clamp(16px, 2.2vw, 20px); }

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.tool-grid.small { grid-template-columns: repeat(4, 1fr); }
.tool-grid.cols-3 { grid-template-columns: repeat(3, 1fr); max-width: 860px; margin: 0 auto; }
@media (max-width: 860px) { .tool-grid, .tool-grid.small, .tool-grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
.tool-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; text-align: center; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.tool-icon { font-size: 32px; line-height: 1; }
.tool-name { font-size: 15px; font-weight: 600; }
.tool-tagline { font-size: 13px; color: var(--muted); line-height: 1.35; }

.badges { list-style: none; padding: 0; margin: 36px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; color: var(--ink-2); font-size: 15px; }
.badges li::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }

.chip-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 15px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

.feature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 40px; }
@media (max-width: 700px) { .feature-grid { grid-template-columns: 1fr; } }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px; }
.feature h3 { margin: 0 0 8px; font-size: 18px; }
.feature p { margin: 0; color: var(--ink-2); }

/* Prose */
.prose { max-width: 760px; }
.prose h2 { font-size: 26px; margin: 40px 0 12px; }
.prose p, .prose li { color: var(--ink-2); font-size: 17px; }
.prose strong { color: var(--ink); }
.steps { padding-left: 22px; }
.steps li { margin-bottom: 8px; padding-left: 4px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
details summary { cursor: pointer; font-weight: 600; color: var(--ink); }
details p { margin: 10px 0 0; }
.page { padding: 48px 16px 64px; }
.page h1 { font-size: clamp(32px, 5vw, 44px); }
.contact-email { font-size: 22px; font-weight: 600; }

/* Tool page */
.tool-page { padding-bottom: 48px; }
.breadcrumb { font-size: 14px; color: var(--muted); padding: 20px 0 0; }
.breadcrumb a { color: var(--ink-2); text-decoration: none; }
.tool-header { text-align: center; padding: 28px 0 24px; }
.tool-header-icon { font-size: 44px; }
.tool-header h1 { font-size: clamp(32px, 5.5vw, 52px); margin: 8px 0 12px; letter-spacing: -0.04em; }
.tool-header .lead { max-width: 680px; margin: 0 auto; color: var(--ink-2); font-size: 18px; }
.tool-app { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 24px; }
@media (max-width: 600px) { .tool-app { padding: 16px; } }
.privacy-note { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* Ads */
.ad-wrap { margin: 32px auto; min-height: 90px; text-align: center; }
.ad-placeholder { display: grid; place-items: center; border: 2px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; background: rgba(255, 255, 255, .5); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 48px 0 24px; margin-top: 48px; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 1fr 2fr 0.8fr; gap: 32px; }
.footer-popular ul { columns: 2; column-gap: 24px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-popular { grid-column: 1 / -1; } }
.site-footer h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 12px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer li a { color: var(--ink-2); text-decoration: none; font-size: 15px; }
.site-footer li a:hover { color: var(--accent); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* ---------- Tool UI components ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 220px; border: 2px dashed #d9d4cb; border-radius: var(--radius); background: #fcfbf9; cursor: pointer; text-align: center; padding: 24px; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { font-size: 40px; }
.dropzone .dz-title { font-size: 18px; font-weight: 600; }
.dropzone .dz-sub { font-size: 14px; color: var(--muted); }
.dropzone input { display: none; }
.dropzone.compact { min-height: 0; flex-direction: row; padding: 14px; }
.dropzone.compact .dz-icon { font-size: 22px; }
.dropzone.compact .dz-title { font-size: 15px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; background: var(--accent); color: var(--accent-ink); transition: filter .15s; }
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink-2); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin: 20px 0; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.field input[type=text], .field input[type=number], .field input[type=url], .field input[type=email], .field input[type=tel], .field input[type=password], .field select, .field textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 15px; background: var(--surface); color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.field input[type=color] { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface); cursor: pointer; }
.field .hint { font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }
.inline-fields { display: flex; gap: 8px; align-items: center; }
.inline-fields > * { flex: 1; min-width: 0; }

.segmented { display: inline-flex; flex-wrap: wrap; background: #f1eee9; border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.file-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.file-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.file-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #f1eee9; }
.file-meta { min-width: 0; }
.file-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sizes { font-size: 14px; color: var(--ink-2); }
.saving { font-weight: 700; color: var(--ok); }
.saving.bad { color: var(--danger); }
@media (max-width: 520px) {
    .file-row { grid-template-columns: 48px 1fr; }
    .file-row img { width: 48px; height: 48px; }
    .file-row .btn { grid-column: 1 / -1; }
}
.summary-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding: 14px 16px; background: var(--accent-soft); border-radius: 12px; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .workspace { grid-template-columns: 1fr; } }
.workspace .controls { grid-template-columns: 1fr 1fr; margin-top: 0; }
@media (max-width: 400px) { .workspace .controls { grid-template-columns: 1fr; } }
.workspace .controls .full { grid-column: 1 / -1; }
.preview-box { background-color: #f1eee9; background-image: linear-gradient(45deg, #e6e2db 25%, transparent 25%), linear-gradient(-45deg, #e6e2db 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e2db 75%), linear-gradient(-45deg, transparent 75%, #e6e2db 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; border-radius: 12px; padding: 12px; display: grid; place-items: center; min-height: 260px; }
.preview-box canvas, .preview-box img { display: block; max-height: 560px; width: auto; height: auto; box-shadow: 0 2px 12px rgba(0, 0, 0, .12); }
.preview-info { font-size: 14px; color: var(--muted); margin-top: 8px; text-align: center; }

.status { font-size: 14px; color: var(--ink-2); }
.error-msg { color: var(--danger); font-size: 14px; margin-top: 8px; }

/* Passport */
.passport-stage { position: relative; touch-action: none; cursor: grab; user-select: none; }
.passport-stage:active { cursor: grabbing; }
.passport-stage canvas { max-height: 480px; }

/* Color picker */
.picker-stage { position: relative; cursor: crosshair; }
.picker-stage canvas { display: block; max-height: 560px; }
.loupe { position: fixed; pointer-events: none; width: 120px; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .3); overflow: hidden; z-index: 50; image-rendering: pixelated; }
.color-result { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.color-swatch-big { width: 84px; height: 84px; border-radius: 14px; border: 1px solid var(--line); flex: none; }
.color-values { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.color-value { display: flex; gap: 8px; align-items: center; }
.color-value code { flex: 1; font-size: 15px; padding: 6px 10px; background: #f6f4f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.palette button { height: 64px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; display: flex; align-items: flex-end; justify-content: center; font-size: 11px; font-family: ui-monospace, monospace; padding: 4px; }
.history { display: flex; flex-wrap: wrap; gap: 6px; }
.history button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }

/* QR */
.qr-output { display: grid; place-items: center; background: #f6f4f0; border-radius: 12px; padding: 20px; }
.qr-output canvas { width: 100%; max-width: 300px; height: auto; image-rendering: pixelated; }

/* Favicon */
.favicon-previews { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; justify-content: center; padding: 20px; background: #f6f4f0; border-radius: 12px; }
.favicon-previews figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.favicon-previews canvas { display: block; margin: 0 auto 6px; image-rendering: pixelated; }
.browser-tab { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px 10px 0 0; padding: 8px 14px; font-size: 13px; max-width: 220px; margin: 0 auto 16px; }
.browser-tab canvas { width: 16px; height: 16px; }
pre.snippet { background: var(--ink); color: #f1eee9; padding: 16px; border-radius: 12px; overflow-x: auto; font-size: 13px; line-height: 1.5; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Watermark position picker */
.pos-grid { display: grid; grid-template-columns: repeat(3, 36px); gap: 6px; }
.pos-grid button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; position: relative; }
.pos-grid button::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--line); }
.pos-grid button.active { border-color: var(--accent); background: var(--accent-soft); }
.pos-grid button.active::after { background: var(--accent); }

/* Background remover */
.bg-stage { position: relative; }
.bg-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(248, 247, 244, .72); backdrop-filter: blur(2px); border-radius: 12px; }
.bg-overlay-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; text-align: center; box-shadow: var(--shadow); width: min(320px, 85%); font-size: 15px; }
.spinner { width: 28px; height: 28px; margin: 0 auto 10px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: #f1eee9; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.model-bar { margin-bottom: 16px; }
