/* MEGA TOOLS — design system
   White-first utility platform. Light default, dark + system supported. */

:root {
  --paper:        #ffffff;
  --surface:      #f6f7f9;
  --surface-2:    #eef0f3;
  --rule:         #e2e5ea;
  --rule-strong:  #c9ced6;
  --ink:          #0e1116;
  --ink-2:        #2b323b;
  --muted:        #626c77;
  --accent:       #1a4fd6;
  --accent-ink:   #12379a;
  --accent-wash:  #eef2fe;
  --ok:           #0d7a52;
  --ok-wash:      #e8f6f0;
  --warn:         #8a5a00;
  --warn-wash:    #fdf4e3;
  --danger:       #b3261e;
  --danger-wash:  #fdecea;

  --radius:       10px;
  --radius-lg:    14px;
  --radius-sm:    7px;
  --shadow:       0 1px 2px rgba(14,17,22,.05), 0 1px 3px rgba(14,17,22,.04);
  --shadow-lift:  0 2px 4px rgba(14,17,22,.06), 0 8px 20px rgba(14,17,22,.07);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --wrap: 1120px;
  --gap: 20px;
}

html[data-theme="dark"] {
  --paper:        #0f1215;
  --surface:      #161a1f;
  --surface-2:    #1e242b;
  --rule:         #262d35;
  --rule-strong:  #3a434e;
  --ink:          #eef1f4;
  --ink-2:        #c6cdd5;
  --muted:        #939da8;
  --accent:       #7ba2ff;
  --accent-ink:   #a8c1ff;
  --accent-wash:  #16203a;
  --ok:           #4fd39b;
  --ok-wash:      #10261e;
  --warn:         #e5b45c;
  --warn-wash:    #2a2113;
  --danger:       #ff8b83;
  --danger-wash:  #2c1614;
  --shadow:       0 1px 2px rgba(0,0,0,.4);
  --shadow-lift:  0 2px 4px rgba(0,0,0,.4), 0 8px 20px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.4rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.3rem, 1.15rem + .6vw, 1.6rem); margin-top: 2.2rem; }
h3 { font-size: 1.075rem; margin-top: 1.6rem; }
p { margin: 0 0 1em; }
.lede { font-size: 1.075rem; color: var(--ink-2); max-width: 68ch; }
.eyebrow {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem;
}
code, kbd, samp { font-family: var(--mono); font-size: .88em; }
:not(pre) > code {
  background: var(--surface); border: 1px solid var(--rule);
  padding: .1em .38em; border-radius: 5px; color: var(--ink-2);
}
pre {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 14px 16px; overflow: auto; font-size: .85rem; line-height: 1.55; margin: 0 0 1em;
}
kbd {
  background: var(--paper); border: 1px solid var(--rule-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: .1em .4em; font-size: .8em;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-in { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; letter-spacing: -.03em; font-size: 1.06rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: 0 0 auto;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: -.04em;
}
.header-nav { display: flex; gap: 4px; margin-left: 6px; }
.header-nav a {
  color: var(--ink-2); font-size: .9rem; font-weight: 500;
  padding: 7px 10px; border-radius: var(--radius-sm);
}
.header-nav a:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.header-spacer { flex: 1 1 auto; }

.hsearch { position: relative; width: min(300px, 38vw); }
.hsearch input {
  width: 100%; height: 36px; padding: 0 34px 0 32px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .875rem;
}
.hsearch input:focus { background: var(--paper); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-wash); }
.hsearch .mag { position: absolute; left: 10px; top: 10px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.hsearch .slash {
  position: absolute; right: 8px; top: 8px; font-family: var(--mono); font-size: .7rem;
  color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 5px; pointer-events: none;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 17px; height: 17px; }

/* search results dropdown */
.search-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); overflow: hidden; display: none; max-height: 60vh; overflow-y: auto;
}
.search-pop[data-open="true"] { display: block; }
.search-pop a { display: block; padding: 9px 13px; color: var(--ink); border-bottom: 1px solid var(--rule); }
.search-pop a:last-child { border-bottom: 0; }
.search-pop a:hover, .search-pop a[aria-selected="true"] { background: var(--surface); text-decoration: none; }
.search-pop .sr-name { font-weight: 600; font-size: .9rem; }
.search-pop .sr-cat { font-family: var(--mono); font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.search-pop .sr-empty { padding: 14px; color: var(--muted); font-size: .9rem; }

/* ---------- Layout blocks ---------- */
main { display: block; min-height: 60vh; }
.section { padding: 44px 0; }
.section + .section { padding-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tool card ---------- */
.tool-tile {
  display: block; background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 14px 15px 13px; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
  position: relative;
}
.tool-tile:hover { text-decoration: none; border-color: var(--rule-strong); box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.tool-tile .tt-top { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.tool-tile .tt-ico {
  width: 28px; height: 28px; border-radius: 7px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--rule); font-size: .95rem;
}
.tool-tile .tt-name { font-weight: 650; font-size: .95rem; letter-spacing: -.01em; }
.tool-tile .tt-desc { color: var(--muted); font-size: .83rem; line-height: 1.45; margin: 0; }
.tool-tile .tt-path { font-family: var(--mono); font-size: .68rem; color: var(--rule-strong); margin-top: 9px; }
.badge {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--rule); color: var(--muted); background: var(--surface);
}
.badge-new { color: var(--ok); background: var(--ok-wash); border-color: transparent; }
.badge-hot { color: var(--accent-ink); background: var(--accent-wash); border-color: transparent; }

/* category tile */
.cat-tile { display: block; border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; background: var(--paper); color: var(--ink); }
.cat-tile:hover { text-decoration: none; border-color: var(--rule-strong); box-shadow: var(--shadow-lift); }
.cat-tile .ct-name { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.cat-tile .ct-count { font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.cat-tile p { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }

/* ---------- Home hero ---------- */
.hero { padding: 60px 0 34px; border-bottom: 1px solid var(--rule); background:
  linear-gradient(180deg, var(--surface) 0%, var(--paper) 100%); }
.hero h1 { font-size: clamp(2.1rem, 1.4rem + 3.2vw, 3.5rem); font-weight: 800; letter-spacing: -.04em; margin-bottom: .3rem; }
.hero .tagline { font-size: clamp(1.05rem, .95rem + .6vw, 1.35rem); color: var(--ink-2); font-weight: 500; margin-bottom: .6rem; }
.hero .sub { color: var(--muted); max-width: 62ch; margin-bottom: 26px; }
.hero-search { position: relative; max-width: 640px; }
.hero-search input {
  width: 100%; height: 54px; font: inherit; font-size: 1rem; padding: 0 16px 0 46px;
  border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow);
}
.hero-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.hero-search .mag { position: absolute; left: 17px; top: 18px; width: 18px; height: 18px; color: var(--muted); }
.hero-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; font-size: .85rem; color: var(--muted); }
.hero-stats b { color: var(--ink); font-weight: 650; }

/* ---------- Tool page ---------- */
.tool-head { padding: 26px 0 0; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: 14px; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; align-items: center; }
.crumbs li::after { content: "/"; margin-left: 6px; color: var(--rule-strong); }
.crumbs li:last-child::after { content: ""; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current] { color: var(--ink-2); }

.tool-title-row { display: flex; align-items: flex-start; gap: 14px; }
.tool-title-row .th-ico {
  width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--rule); font-size: 1.3rem; margin-top: 4px;
}
.path-chip {
  font-family: var(--mono); font-size: .72rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 2px 7px; display: inline-block; margin-bottom: 10px;
}
.fav-btn { margin-left: auto; }
.fav-btn[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); background: var(--warn-wash); }

.tool-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 34px; align-items: start; padding-bottom: 50px; }
@media (max-width: 940px) { .tool-layout { grid-template-columns: 1fr; } }
.tool-aside { position: sticky; top: 76px; display: grid; gap: 18px; }
@media (max-width: 940px) { .tool-aside { position: static; } }

.panel {
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-bottom: 1px solid var(--rule); background: var(--surface);
  font-family: var(--mono); font-size: .7rem; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.panel-bar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.panel-bar .pb-right { margin-left: auto; text-transform: none; letter-spacing: 0; }
.panel-body { padding: 16px; }
@media (max-width: 520px) { .panel-body { padding: 13px; } }

/* prose sections */
.prose { max-width: 74ch; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: 1.25em; margin: 0 0 1em; }
.prose li { margin-bottom: .4em; }
.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 0 0 1em; }
.prose th, .prose td { border: 1px solid var(--rule); padding: 7px 10px; text-align: left; }
.prose th { background: var(--surface); font-weight: 650; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li {
  counter-increment: s; position: relative; padding-left: 38px; margin-bottom: 12px; color: var(--ink-2);
}
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 25px; height: 25px; border-radius: 7px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--rule);
  font-family: var(--mono); font-size: .75rem; color: var(--ink-2); font-weight: 600;
}

.faq-item { border-bottom: 1px solid var(--rule); }
.faq-item summary {
  cursor: pointer; padding: 13px 0; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 1.2rem; line-height: 1; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-item .faq-a { padding: 0 0 14px; color: var(--ink-2); }
.faq-item .faq-a p:last-child { margin-bottom: 0; }

/* ---------- Form controls ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label, .lbl {
  display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: -.005em;
}
.hint { font-size: .78rem; color: var(--muted); margin-top: 5px; }

input[type="text"], input[type="number"], input[type="date"], input[type="time"],
input[type="datetime-local"], input[type="email"], input[type="url"], input[type="search"],
input[type="password"], select, textarea {
  width: 100%; font: inherit; font-size: .93rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 150px; resize: vertical; font-family: var(--mono); font-size: .84rem; line-height: 1.55; }
textarea.plain { font-family: var(--font); font-size: .93rem; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash);
}
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="color"] { width: 100%; height: 42px; padding: 3px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 150px; min-width: 0; }
.row.tight > * { flex: 0 0 auto; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: .89rem; font-weight: 600; letter-spacing: -.005em;
  padding: 9px 15px; min-height: 40px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2);
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
html[data-theme="dark"] .btn-primary { background: var(--ink); color: #0f1215; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .8rem; }
.btn svg { width: 15px; height: 15px; }

.checkline { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; font-size: .9rem; color: var(--ink-2); }
.checkline input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); flex: 0 0 auto; }
.checkline label { margin: 0; font-weight: 500; font-size: .9rem; }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: .83rem; font-weight: 600; padding: 7px 13px; min-height: 36px;
  background: var(--paper); color: var(--muted); border: 0; border-right: 1px solid var(--rule); cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
html[data-theme="dark"] .seg button[aria-pressed="true"] { color: #0f1215; }

/* ---------- Output / feedback ---------- */
.out {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 12px 13px; font-family: var(--mono); font-size: .84rem; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; overflow-x: auto; min-height: 44px; margin: 0;
}
.out:empty::before { content: attr(data-empty); color: var(--muted); font-family: var(--font); }

.msg { border-radius: var(--radius-sm); padding: 10px 13px; font-size: .87rem; margin-top: 12px; display: none; border: 1px solid transparent; }
.msg[data-show="true"] { display: block; }
.msg-err { background: var(--danger-wash); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.msg-ok { background: var(--ok-wash); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.msg-warn { background: var(--warn-wash); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.msg-info { background: var(--accent-wash); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden; }
.stat { background: var(--paper); padding: 12px 13px; }
.stat .sv { font-size: 1.35rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .sl { font-size: .73rem; color: var(--muted); margin-top: 3px; letter-spacing: -.005em; }

.result-hero {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 18px; text-align: center;
}
.result-hero .rv { font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.3rem); font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.result-hero .rl { font-size: .8rem; color: var(--muted); }

.kv { width: 100%; border-collapse: collapse; font-size: .89rem; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.kv tr:last-child td { border-bottom: 0; }
.kv td:first-child { color: var(--muted); }
.kv td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* drop zone */
.drop {
  border: 1.5px dashed var(--rule-strong); border-radius: var(--radius);
  padding: 30px 18px; text-align: center; cursor: pointer; background: var(--surface);
  transition: border-color .12s ease, background .12s ease;
}
.drop:hover, .drop[data-over="true"] { border-color: var(--accent); background: var(--accent-wash); }
.drop .dz-icon { font-size: 1.6rem; margin-bottom: 6px; }
.drop .dz-main { font-weight: 650; font-size: .95rem; margin-bottom: 3px; }
.drop .dz-sub { color: var(--muted); font-size: .8rem; }
.drop input[type="file"] { display: none; }

.filelist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 7px; }
.filelist li {
  display: flex; align-items: center; gap: 10px; font-size: .87rem;
  border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 8px 11px; background: var(--paper);
}
.filelist .fname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filelist .fsize { color: var(--muted); font-family: var(--mono); font-size: .76rem; flex: 0 0 auto; }
.filelist .fx { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 0 2px; line-height: 1; }
.filelist .fx:hover { color: var(--danger); }
.filelist .fdrag { cursor: grab; color: var(--rule-strong); font-size: .9rem; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.preview-grid figure { margin: 0; border: 1px solid var(--rule); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.preview-grid img, .preview-grid canvas { width: 100%; display: block; background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--paper) 0% 50%) 50%/14px 14px; }
.preview-grid figcaption { font-size: .74rem; color: var(--muted); padding: 6px 8px; font-family: var(--mono); word-break: break-all; }

.progress { height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 12px; display: none; }
.progress[data-show="true"] { display: block; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s ease; }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Aside cards ---------- */
.aside-card { border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 15px; background: var(--paper); }
.aside-card h3 { margin: 0 0 10px; font-size: .78rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.aside-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.aside-links a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; color: var(--ink-2); font-size: .885rem; }
.aside-links a:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.aside-links .al-ico { width: 20px; text-align: center; flex: 0 0 auto; }

/* ---------- Ads ---------- */
.ad-slot { margin: 26px 0; text-align: center; }
.ad-slot .ad-label {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px; display: block; text-align: left;
}
.ad-slot .ad-box {
  border: 1px dashed var(--rule); border-radius: var(--radius); background: var(--surface);
  display: grid; place-items: center; color: var(--rule-strong);
  font-family: var(--mono); font-size: .72rem; min-height: 90px;
}
.ad-slot[data-size="leaderboard"] .ad-box { min-height: 90px; }
.ad-slot[data-size="rectangle"] .ad-box { min-height: 250px; }
.ad-slot[data-size="inline"] .ad-box { min-height: 100px; }
@media (max-width: 640px) { .ad-slot[data-size="leaderboard"] .ad-box { min-height: 100px; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); background: var(--surface); margin-top: 20px; padding: 44px 0 28px; font-size: .89rem; }
.foot-grid { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 26px; }
@media (max-width: 860px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .foot-grid { grid-template-columns: 1fr; } }
.site-footer h4 { font-size: .74rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 11px; font-weight: 600; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .foot-about p { color: var(--muted); max-width: 34ch; font-size: .85rem; }
.foot-bottom { border-top: 1px solid var(--rule); margin-top: 30px; padding-top: 18px; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }

/* ---------- Filter bar (category / index pages) ---------- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.filterbar input[type="search"] { max-width: 300px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: .82rem; font-weight: 550; padding: 6px 12px; min-height: 34px;
  border: 1px solid var(--rule); border-radius: 99px; background: var(--paper); color: var(--ink-2); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { background: var(--surface); text-decoration: none; }
.chip[aria-current="page"], .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
html[data-theme="dark"] .chip[aria-current="page"], html[data-theme="dark"] .chip[aria-pressed="true"] { color: #0f1215; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--rule); border-radius: var(--radius); }

.notice {
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: .87rem; color: var(--ink-2); margin: 0 0 16px;
}
.notice strong { color: var(--ink); }
.notice.privacy { border-left-color: var(--ok); }

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

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 99px;
  font-size: .85rem; font-weight: 550; opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 90;
}
.toast[data-show="true"] { opacity: 1; transform: translateX(-50%) translateY(0); }

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