:root {
  --bg: #f7f7f5; --surface: #ffffff; --surface-2: #f0f0ec; --border: #e3e3dd;
  --text: #1c1c1a; --muted: #6b6b64; --accent: #2f6fed; --accent-soft: #e8efff;
  --good: #1a8f4a; --good-soft: #e3f5ea; --warn: #b26a00; --star: #c98a00;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --surface: #19191c; --surface-2: #222226; --border: #2c2c31;
    --text: #ececea; --muted: #9a9a94; --accent: #7aa2ff; --accent-soft: #1d2740;
    --good: #4cc982; --good-soft: #15291e; --warn: #e5a84a; --star: #f0b93a;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --surface: #19191c; --surface-2: #222226; --border: #2c2c31;
  --text: #ececea; --muted: #9a9a94; --accent: #7aa2ff; --accent-soft: #1d2740;
  --good: #4cc982; --good-soft: #15291e; --warn: #e5a84a; --star: #f0b93a;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); letter-spacing: -.02em; }
h2 { font-size: 1.25rem; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { font-weight: 800; font-size: 1.1rem; color: var(--text); white-space: nowrap; }
.logo span { color: var(--accent); }
.logo:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); text-decoration: none; }
.header-search { margin-left: auto; position: relative; flex: 0 1 280px; }
.header-search input { width: 100%; }
.icon-btn { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px;
  width: 36px; height: 36px; cursor: pointer; flex: none; font-size: 1.25rem; line-height: 1; }
@media (max-width: 760px) {
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .header-search { order: 3; flex: 1 1 100%; }
  .icon-btn { margin-left: auto; }
  .nav { order: 4; flex: 1 1 100%; }
}

/* forms */
input[type=text], input[type=search], input[type=url], input[type=password], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; min-height: 90px; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.danger { color: #d23c3c; }

/* hero */
.hero { padding: 48px 0 28px; text-align: center; }
.hero p { color: var(--muted); font-size: 1.1rem; max-width: 640px; margin: 0 auto 22px; }
.hero form { display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.hero input { flex: 1; font-size: 1.05rem; padding: 12px 16px; }
.stats { display: flex; justify-content: center; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.stats div { text-align: center; }
.stats b { display: block; font-size: 1.5rem; }
.stats span { color: var(--muted); font-size: .85rem; }

/* sections */
section { margin: 36px 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }

/* grids & cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); flex: none; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; border-radius: 14px; }
.avatar.ph { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.card h3 { margin: 0; font-size: 1.02rem; overflow-wrap: anywhere; }
.card h3 a { color: var(--text); }
.card h3 a::after { content: ""; position: absolute; inset: 0; }  /* whole card clickable */
.card .tagline { color: var(--muted); margin: 0; font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: auto; }
.card .save { position: relative; z-index: 1; margin: -4px -6px 0 auto; flex: none; }
.stars { color: var(--star); font-weight: 600; }
.delta { color: var(--good); background: var(--good-soft); border-radius: 999px; padding: 0 8px; font-weight: 600; font-size: .8rem; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 10px; font-size: .8rem;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: nowrap; }
a.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.cat { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-archived { color: var(--warn); font-weight: 600; }
.lang-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-right: 4px; }
.save-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--muted); padding: 2px 4px; line-height: 1; }
.save-btn[aria-pressed="true"] { color: var(--star); }

/* categories */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cat-tile { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.cat-tile:hover { text-decoration: none; border-color: var(--accent); }
.cat-tile .icon { font-size: 1.5rem; }
.cat-tile b { display: block; font-size: .95rem; }
.cat-tile span { color: var(--muted); font-size: .82rem; }

/* browse layout */
.browse { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; margin-top: 24px; }
.filters { position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.filters label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filters select, .filters input { width: 100%; }
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
@media (max-width: 860px) {
  .browse { grid-template-columns: 1fr; }
  .filters { position: static; }
}
.page-head { margin-top: 28px; }
.page-head p { color: var(--muted); max-width: 720px; }

/* pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 28px 0; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* tool page */
.crumbs { font-size: .85rem; color: var(--muted); margin: 20px 0 8px; }
.tool-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.tool-head .title { flex: 1 1 320px; min-width: 0; }
.tool-head .tagline { font-size: 1.15rem; color: var(--muted); margin: 0 0 10px; }
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; margin-top: 24px; align-items: start; }
@media (max-width: 900px) { .tool-layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel h2 { font-size: 1.05rem; }
.panel ul { margin: 0; padding-left: 20px; }
.panel li { margin: 4px 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .9rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.clone { display: flex; gap: 6px; }
.clone code { flex: 1; font: .8rem var(--mono); background: var(--surface-2); padding: 8px 10px; border-radius: 8px;
  overflow-x: auto; white-space: nowrap; }
.spark { width: 100%; height: 48px; }
.spark polyline { fill: none; stroke: var(--good); stroke-width: 2; }

/* videos */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.yt { position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; border: 0; padding: 0; width: 100%; display: block; }
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.yt::after { content: "▶"; position: absolute; inset: 0; margin: auto; width: 64px; height: 44px; border-radius: 12px;
  background: rgba(220,0,0,.9); color: #fff; display: grid; place-items: center; font-size: 1.3rem; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-title { font-weight: 600; font-size: .92rem; margin: 6px 0 0; }

/* tables (channels, admin) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: none; }

.notice { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin: 14px 0; }
.notice.error { background: #fde8e8; color: #9b1c1c; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.prose { max-width: 720px; }
.inline-form { display: inline; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 56px; padding: 28px 0; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); margin-right: 14px; }
