:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --surface-2: #f3eee7;
  --text: #2b2622;
  --muted: #6b625a;
  --border: #e4dcd2;
  --accent: #b5476b;
  --accent-ink: #ffffff;
  --accent-soft: #f6e3ea;
  --focus: #2f6fdb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(43, 38, 34, .06), 0 4px 16px rgba(43, 38, 34, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1816; --surface: #24201d; --surface-2: #2d2824; --text: #f1ebe4; --muted: #b3a89d;
    --border: #3a342f; --accent: #e07a9b; --accent-ink: #1b1816; --accent-soft: #3b2730; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1816; --surface: #24201d; --surface-2: #2d2824; --text: #f1ebe4; --muted: #b3a89d;
  --border: #3a342f; --accent: #e07a9b; --accent-ink: #1b1816; --accent-soft: #3b2730; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 17px; line-height: 1.6; }
img, canvas { max-width: 100%; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.3rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--accent); }

/* Hero */
.hero { padding: 56px 0 32px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin: 0; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin: 24px 0 48px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 8px; transition: transform .15s ease, border-color .15s ease; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card h2, .card h3 { margin: 0; font-size: 1.2rem; }
.card p { margin: 0; color: var(--muted); font-size: .97rem; }
.card .tag { align-self: flex-start; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 999px; }
.card .icon { font-size: 1.8rem; line-height: 1; }

/* Tool layout */
.tool-head { padding: 36px 0 8px; }
.tool-head h1 { margin: 0 0 8px; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; letter-spacing: -.02em; }
.tool-head p { margin: 0; color: var(--muted); max-width: 720px; }
.tool { display: grid; grid-template-columns: 340px 1fr; gap: 24px; margin: 24px 0 40px; align-items: start; }
@media (max-width: 860px) { .tool { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel h2 { font-size: 1.05rem; margin: 0 0 14px; }
.field { margin-bottom: 16px; }
.field label, .field .label { display: block; font-weight: 700; font-size: .92rem; margin-bottom: 6px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type="number"], input[type="text"], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: .95rem;
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 42px; height: 38px; border: 1px solid var(--border); border-radius: 10px; padding: 2px; background: var(--bg); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .93rem; font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 700; font-size: .95rem; cursor: pointer; background: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-item { display: flex; align-items: center; gap: 4px; }
.swatch-item button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 0 4px; }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: var(--bg); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--text); }

.preview-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); max-height: 70vh; }
.preview-wrap canvas { display: block; max-width: none; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 16px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: .9rem; background: var(--surface-2); padding: 8px 10px; border-radius: 10px; }
.legend-item .chip { width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(0,0,0,.15); flex: none; display: grid; place-items: center; font-weight: 800; font-size: .8rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 12px; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 700; }
.table-wrap { max-height: 360px; overflow: auto; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0 0; }
.stat { background: var(--surface-2); padding: 8px 12px; border-radius: 10px; font-size: .9rem; }
.stat b { display: block; font-size: 1.1rem; }

/* Article content */
.prose { max-width: 760px; margin: 0 0 48px; }
.prose h2 { margin-top: 36px; font-size: 1.45rem; letter-spacing: -.01em; }
.prose h3 { margin-top: 24px; font-size: 1.15rem; }
.prose li { margin-bottom: 6px; }
.prose .note { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 8px; }

/* Support */
.support { background: var(--accent-soft); border-radius: var(--radius); padding: 22px; margin: 0 0 48px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.support p { margin: 0; max-width: 620px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px 0 40px; color: var(--muted); font-size: .9rem; background: var(--surface); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

@media print {
  .site-header, .site-footer, .support, .panel.controls, .tool-head p, .no-print { display: none !important; }
  .tool { display: block; }
  .preview-wrap { max-height: none; overflow: visible; border: 0; }
  body { background: #fff; }
}
