:root {
  --red: #d63b3b; --red-2: #b92d2d; --red-soft: #fdecec;
  --bg: #f3f4f6; --card: #ffffff; --card-2: #f7f7f9; --text: #1f2328; --muted: #6b7280; --line: #e5e7eb;
  --chip: #ffffff; --chip-hover: #f3f4f6; --badge: #6b7280; --badge-text: #fff;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.06);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);
  --radius: 16px; --radius-sm: 10px;
  --accent: #2563eb; --ok: #16a34a;
  --code-bg: #f6f7f9;
  --series-1: #2a78d6; --series-2: #eb6834; --grid: #eceef1; --axis: #c9ccd1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b; --card: #1e2126; --card-2: #24282e; --text: #e8eaed; --muted: #9aa1ab; --line: #30353c;
    --chip: #24282e; --chip-hover: #2c3138; --badge: #3a4049; --red-soft: #3a1f21; --code-bg: #171a1e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); --shadow-lg: 0 10px 30px rgba(0,0,0,.45); --series-1: #3987e5; --series-2: #d95926; --grid: #2a2e34; --axis: #454b53;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171b; --card: #1e2126; --card-2: #24282e; --text: #e8eaed; --muted: #9aa1ab; --line: #30353c;
  --chip: #24282e; --chip-hover: #2c3138; --badge: #3a4049; --red-soft: #3a1f21; --code-bg: #171a1e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); --shadow-lg: 0 10px 30px rgba(0,0,0,.45); --series-1: #3987e5; --series-2: #d95926; --grid: #2a2e34; --axis: #454b53;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--red); }
button, input, select, textarea { font: inherit; color: inherit; }
img, canvas { display: block; }
.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 16px; }
main.container { flex: 1; padding-top: 20px; padding-bottom: 40px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
svg.i, .ico svg, [data-icon] svg { width: 1.1em; height: 1.1em; vertical-align: -0.18em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- nav ---------- */
.nav { background: linear-gradient(135deg, #e04848, #c22f2f); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(150,20,20,.25); }
.nav-in { display: flex; align-items: center; gap: 18px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.3px; color: #fff; white-space: nowrap; }
.logo:hover { color: #fff; }
.logo b { font-weight: 800; color: #ffe1e1; }
.nav-search { position: relative; flex: 1; max-width: 520px; }
.nav-search input { width: 100%; height: 40px; border-radius: 12px; border: 0; padding: 0 14px 0 40px; background: rgba(255,255,255,.18); color: #fff; outline: none; transition: background .15s; }
.nav-search input::placeholder { color: rgba(255,255,255,.75); }
.nav-search input:focus { background: #fff; color: #1f2328; }
.nav-search input:focus::placeholder { color: #9aa1ab; }
.nav-search .ico { position: absolute; left: 13px; top: 10px; opacity: .85; pointer-events: none; }
.nav-search:focus-within .ico { color: #6b7280; }
.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-links a, .theme-btn { display: flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: #fff; background: none; border: 0; cursor: pointer; position: relative; }
.nav-links a:hover, .nav-links a.active, .theme-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.nav-links .badge { position: absolute; top: 2px; right: 0; font-style: normal; background: #fff; color: var(--red); border-radius: 10px; font-size: 10px; padding: 0 5px; line-height: 15px; }
.suggest { position: absolute; top: 46px; left: 0; right: 0; background: var(--card); color: var(--text); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--line); }
.suggest a { display: flex; align-items: center; gap: 10px; padding: 7px 12px; }
.suggest a.sel, .suggest a:hover { background: var(--chip-hover); color: var(--text); }
.suggest .sg-head canvas { width: 30px; height: 30px; }
.suggest .sg-tag .tg { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--red-soft); color: var(--red); }
.suggest .sub { font-size: 12px; color: var(--muted); }
.suggest .sg-note { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.suggest .sg-all { justify-content: center; font-weight: 600; color: var(--red); border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .nav-links a span:not([data-icon]) { display: none; }
  .nav-in { gap: 10px; }
  .logo span { display: none; }
}
@media (max-width: 560px) {
  .nav-in { height: auto; flex-wrap: wrap; padding: 8px 0; }
  .logo span { display: inline; font-size: 18px; }
  .nav-search { order: 3; flex-basis: 100%; max-width: none; }
  .nav-links a, .theme-btn { padding: 7px 8px; }
}

/* ---------- generic ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 18px; }
h1 { font-size: 30px; line-height: 1.2; margin: 6px 0 6px; font-weight: 800; letter-spacing: -.5px; }
h2 { font-size: 21px; margin: 0 0 14px; font-weight: 800; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 16px; margin: 0 0 10px; font-weight: 700; }
.section { margin-top: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.link-more { color: var(--muted); font-weight: 600; white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; }
.btn:hover { background: var(--chip-hover); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-2); color: #fff; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 38px; padding: 0; }
.btn.on { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
input.inp, select.inp, textarea.inp { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); padding: 0 12px; outline: none; min-width: 0; }
textarea.inp { height: auto; padding: 10px 12px; resize: vertical; }
input.inp:focus, select.inp:focus, textarea.inp:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(214,59,59,.15); }
.notice { padding: 10px 14px; border-radius: 12px; background: var(--red-soft); margin-bottom: 14px; font-size: 14px; }
.notice.info { background: rgba(37,99,235,.09); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty b { display: block; font-size: 18px; color: var(--text); margin-bottom: 6px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- chips & badges ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border-radius: 12px; background: var(--chip); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; cursor: pointer; border: 1px solid transparent; }
.chip:hover { background: var(--chip-hover); color: var(--text); }
.chip.plain { padding: 5px 11px; }
.chip.on { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.chip canvas { width: 24px; height: 24px; }
.chip .n { background: var(--badge); color: var(--badge-text); border-radius: 8px; font-size: 11px; padding: 0 6px; line-height: 18px; font-weight: 700; }
.chip .x { opacity: .6; margin-left: 2px; }
.cbadge { display: inline-block; padding: 2px 10px; border-radius: 8px; background: var(--badge); color: #fff; font-size: 13px; font-weight: 700; }
.cbadge.red { background: var(--red); }

/* ---------- head grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.hcard { position: relative; display: flex; flex-direction: column; align-items: center; padding: 12px 8px 10px; border-radius: 14px; text-align: center; transition: background .12s, transform .12s, box-shadow .12s; }
.hcard:hover { background: var(--card); box-shadow: var(--shadow); transform: translateY(-2px); color: var(--text); }
.hcard canvas { width: 88px; height: 88px; transition: transform .15s; }
.hcard:hover canvas { transform: scale(1.06) rotate(-1deg); }
.hcard .nm { margin-top: 6px; font-size: 13px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.hcard .fav { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px; border: 0; background: var(--card-2); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; color: var(--muted); }
.hcard:hover .fav, .hcard .fav.on { opacity: 1; }
.hcard .fav.on { color: #f59e0b; }
.hcard .fav.on svg { fill: currentColor; }
.grid-sentinel { height: 40px; }
.card .grid { margin: -4px; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 26px 0 8px; }
.hero h1 { font-size: 38px; }
.hero .lead { font-size: 17px; color: var(--muted); margin: 0 auto 18px; max-width: 720px; }
.hero-search { max-width: 680px; margin: 0 auto; position: relative; }
.hero-search input { width: 100%; height: 56px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); padding: 0 130px 0 50px; font-size: 17px; outline: none; box-shadow: var(--shadow); }
.hero-search input:focus { border-color: var(--red); }
.hero-search .ico { position: absolute; left: 18px; top: 17px; color: var(--muted); font-size: 18px; }
.hero-search .btn { position: absolute; right: 8px; top: 8px; height: 40px; }
.hero-hints { margin-top: 12px; font-size: 13px; color: var(--muted); }
.hero-hints a { color: var(--red); font-weight: 600; margin: 0 4px; cursor: pointer; }
.stats { display: flex; justify-content: center; gap: 26px; margin: 18px 0 6px; flex-wrap: wrap; }
.stats div { text-align: center; }
.stats b { display: block; font-size: 22px; font-weight: 800; }
.stats span { font-size: 13px; color: var(--muted); }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: flex; flex-direction: column; align-items: center; text-align: center; transition: transform .12s, box-shadow .12s; }
.cat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: var(--text); }
.cat canvas { width: 84px; height: 84px; }
.cat b { margin-top: 6px; }
.cat span { font-size: 12px; color: var(--muted); }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.feature { display: flex; gap: 12px; }
.feature .fi { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-size: 20px; }
.feature b { display: block; }
.feature p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- search page ---------- */
.search-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.filters { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; padding: 16px; scrollbar-width: thin; }
.filters h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 16px 0 8px; }
.filters h3:first-child { margin-top: 0; }
.flist { display: flex; flex-direction: column; gap: 2px; }
.flist label { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.flist label:hover { background: var(--chip-hover); }
.flist input { accent-color: var(--red); }
.flist .n { margin-left: auto; font-size: 12px; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); cursor: pointer; position: relative; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--red); }
.sw.on::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.sw.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; }
.sw.custom input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchips .chip { font-size: 12px; padding: 4px 9px; box-shadow: none; background: var(--card-2); }
.fchips .chip.on { background: var(--red-soft); }
.results-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.results-head h1 { font-size: 24px; margin: 0; }
.results-head .count { color: var(--muted); font-size: 14px; }
.results-head .sort { margin-left: auto; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter-toggle { display: none; }
@media (max-width: 900px) {
  .search-layout { grid-template-columns: 1fr; }
  .filters { position: fixed; inset: 0 0 0 auto; width: min(340px, 92vw); max-height: none; z-index: 80; border-radius: 0; transform: translateX(105%); transition: transform .2s; top: 0; }
  .filters.open { transform: none; box-shadow: var(--shadow-lg); }
  .filter-toggle { display: inline-flex; }
}
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 70; }

/* ---------- head page ---------- */
.head-layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); gap: 20px; align-items: start; }
.head-layout > *, .search-layout > * { min-width: 0; }
@media (max-width: 980px) { .head-layout { grid-template-columns: 1fr; } }
.viewer-card { position: sticky; top: 76px; }
@media (max-width: 980px) { .viewer-card { position: static; } }
.viewer { height: 340px; display: grid; place-items: center; perspective: 900px; cursor: grab; touch-action: none; user-select: none; border-radius: 12px; background: radial-gradient(circle at 50% 40%, var(--card-2), transparent 70%); }
.viewer:active { cursor: grabbing; }
.cube3d { position: relative; transform-style: preserve-3d; }
.cube3d .layer { position: absolute; inset: 0; transform-style: preserve-3d; }
.cube3d canvas.face { position: absolute; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; }
.cube3d .inner canvas.face { backface-visibility: hidden; }
.cube3d .outer canvas.face { pointer-events: none; }
.cube3d.paint-outer .outer canvas.face { pointer-events: auto; }
.cube3d.no-outer .outer { display: none; }
.viewer-tools { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.head-title { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head-title h1 { margin: 0; flex: 1; min-width: 200px; }
.head-sub { color: var(--muted); margin: 4px 0 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin-top: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-all; }
.color-dots { display: flex; gap: 6px; align-items: center; }
.color-dots a { width: 22px; height: 22px; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }

/* ---------- commands ---------- */
.cmd-versions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { padding: 6px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; cursor: pointer; }
.pill:hover { background: var(--chip-hover); }
.pill.on { background: var(--red); border-color: var(--red); color: #fff; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 9px 13px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--red); border-bottom-color: var(--red); }
.tab:hover { color: var(--text); }
.cmd-opts { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.cmd-opts label { display: inline-flex; align-items: center; gap: 6px; }
.cmd-opts input[type=checkbox] { accent-color: var(--red); }
.cmd-opts .inp { height: 32px; }
.codebox { position: relative; }
.codebox pre { margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 54px 12px 14px; font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
.codebox .copy { position: absolute; right: 8px; top: 8px; }
.codebox .len { font-size: 12px; color: var(--muted); margin-top: 6px; }
.dev-list { display: grid; gap: 12px; }
.dev-list .lbl { font-size: 13px; font-weight: 700; margin-bottom: 5px; display: flex; justify-content: space-between; gap: 8px; }
.dev-list .lbl span { color: var(--muted); font-weight: 400; }
.dev-list pre { max-height: 140px; }

/* ---------- tags page ---------- */
.tags-letters { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 16px; }
.tags-letters a { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--card); font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.tag-group { margin-bottom: 18px; }
.tag-group h3 { color: var(--red); font-size: 18px; }

/* ---------- editor ---------- */
.editor { display: grid; grid-template-columns: 64px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ed-side { min-width: 0; }
@media (max-width: 1100px) {
  .editor { grid-template-columns: 56px minmax(0, 1fr); }
  .ed-side { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  .ed-side .card + .card { margin-top: 0 !important; }
  .ed-main { grid-column: 2; }
}
@media (max-width: 640px) {
  .editor { grid-template-columns: 1fr; }
  .ed-side, .ed-main { grid-column: 1; }
  .ed-side { grid-template-columns: 1fr; }
  .ed-tools { flex-direction: row !important; flex-wrap: wrap; position: static !important; }
  .ed-tools hr { display: none; }
}
.ed-tools { display: flex; flex-direction: column; gap: 6px; padding: 8px; position: sticky; top: 76px; }
.ed-tools .btn { width: 46px; height: 46px; padding: 0; font-size: 18px; }
.ed-tools hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.ed-main { min-width: 0; }
.ed-canvas-wrap { overflow: auto; border-radius: 12px; background: repeating-conic-gradient(#d9dce1 0% 25%, #f1f2f4 0% 50%) 0 0 / 16px 16px; display: flex; justify-content: center; padding: 10px; touch-action: none; }
:root[data-theme="dark"] .ed-canvas-wrap { background: repeating-conic-gradient(#2a2e34 0% 25%, #22262b 0% 50%) 0 0 / 16px 16px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ed-canvas-wrap { background: repeating-conic-gradient(#2a2e34 0% 25%, #22262b 0% 50%) 0 0 / 16px 16px; } }
#ed-canvas { image-rendering: pixelated; cursor: crosshair; max-width: 100%; height: auto; touch-action: none; }
.ed-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--red); color: #fff; }
.ed-side .card { padding: 16px; }
.ed-side .viewer { height: 260px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(24px, 1fr)); gap: 4px; margin-top: 10px; max-width: 360px; }
.palette button { aspect-ratio: 1; border-radius: 6px; border: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); cursor: pointer; padding: 0; }
.palette button:hover { transform: scale(1.12); }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 46px; height: 38px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: var(--card); cursor: pointer; }
.color-row .inp { width: 110px; font-family: ui-monospace, monospace; }
.cur-color { width: 38px; height: 38px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.ed-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.dropzone.over { border-color: var(--red); color: var(--red); }
body.dragging .ed-canvas-wrap { outline: 3px dashed var(--red); }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #1f2328; color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- footer ---------- */
.footer { background: var(--card); border-top: 1px solid var(--line); padding: 22px 0; font-size: 14px; margin-top: 30px; }
.footer-in { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer a { color: var(--red); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.footer-social { display: flex; gap: 8px; flex-wrap: wrap; }
.footer .footer-social a { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-weight: 600; text-decoration: none; }
.footer .footer-social a:hover { border-color: var(--red); color: var(--red); }
.footer-social svg { width: 17px; height: 17px; fill: currentColor; flex: none; }
@media (max-width: 700px) { .footer-right { align-items: flex-start; } }

/* ---------- admin ---------- */
.admin { padding-top: 18px; }
.adm-login { max-width: 460px; margin: 40px auto; padding: 26px; }
.adm-login h1 { margin: 0 0 6px; font-size: 24px; }
.adm-login .gh-btn { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0; }
.adm-login .tok { margin-top: 12px; }
.adm-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.adm-head h1 { margin: 0; font-size: 26px; }
.adm-online { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); }
.adm-online i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.adm-online b { color: var(--text); }
.adm-user { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.adm-user img { border-radius: 50%; }
.adm-notrack { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }
.adm-tabs { margin-top: 6px; }
.adm-periods { margin: 4px 0 14px; }
.adm-note { margin: -4px 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
@media (max-width: 1150px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 14px 16px; }
.tiles > .card + .card, .adm-grid > .card + .card { margin-top: 0; }
.tile .t { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 30px; font-weight: 800; line-height: 1.15; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile .d { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.tile .chg { color: var(--text); font-weight: 700; }
.adm-sec { margin-bottom: 14px; min-width: 0; }
.adm-sec h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; margin: 0 0 10px; }
.adm-sec .more { display: inline-block; margin-top: 10px; }
.adm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.adm-grid > .adm-sec { margin-bottom: 0; }
.adm-grid + .adm-grid, .adm-grid + .adm-sec, .adm-sec + .adm-grid { margin-top: 14px; }
.adm-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.adm-grid.wide-first { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1000px) { .adm-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .adm-grid, .adm-grid.three, .adm-grid.wide-first { grid-template-columns: 1fr; } .tile .v { font-size: 24px; } }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.metric-pills { margin: 0; }
.viz-host { position: relative; margin-top: 10px; min-height: 270px; }
.viz { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.viz .grid { stroke: var(--grid); stroke-width: 1; }
.viz .base { stroke: var(--axis); stroke-width: 1; }
.viz .ax { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .peak { fill: var(--text); font-size: 12px; font-weight: 700; }
.viz .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .area { stroke: none; opacity: .14; }
.viz .line.s1, .viz .dot.s1, .viz .cross circle.s1 { stroke: var(--series-1); }
.viz .line.s2, .viz .dot.s2, .viz .cross circle.s2 { stroke: var(--series-2); }
.viz .area.s1, .viz .dot.s1, .viz .cross circle.s1 { fill: var(--series-1); }
.viz .area.s2, .viz .dot.s2, .viz .cross circle.s2 { fill: var(--series-2); }
.viz .dot { stroke: var(--card); stroke-width: 2; paint-order: stroke; }
.viz .dot.s1, .viz .dot.s2 { stroke: var(--card); }
.viz .cross line { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.viz .cross circle { stroke: var(--card); stroke-width: 2; }
.viz .hit { fill: transparent; cursor: crosshair; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 10px; padding: 8px 10px; font-size: 13px; min-width: 170px; }
.viz-tip b { display: block; margin-bottom: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.viz-tip div { display: flex; align-items: center; gap: 7px; }
.viz-tip span { margin-left: auto; padding-left: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.viz-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.viz-legend span { display: inline-flex; align-items: center; gap: 7px; }
.viz-legend b { color: var(--text); }
.sw-line { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.sw-line.s1 { background: var(--series-1); }
.sw-line.s2 { background: var(--series-2); }
.viz-table { margin-top: 8px; font-size: 13px; }
.viz-table summary { cursor: pointer; color: var(--muted); }
.viz-table .tbl-wrap { max-height: 320px; overflow: auto; margin-top: 8px; }
.tbl-wrap { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.adm-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.adm-table .mono, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.nowrap { white-space: nowrap; }
.hrow { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.hrow canvas { flex: none; }
.hrow span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blist { display: flex; flex-direction: column; gap: 9px; }
.bl-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: 14px; }
.bl-l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-v { font-weight: 700; font-variant-numeric: tabular-nums; }
.bl-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.bl-bar i { display: block; height: 100%; border-radius: 3px; background: var(--series-1); }
.adm-edit .inp { min-width: 0; }
.admin-card { border: 1px dashed var(--line); }
