/* Shared design tokens.

   Light is the default; dark kicks in only when the browser/OS asks
   for it. The variable names stay stable so both admin and public can
   reference them without caring about which theme is live. */

:root {
  --bg:        #ffffff;
  --bg-2:      #ffffff;
  --bg-3:      #f7f9f9;
  --fg:        #0f1419;
  --fg-2:      #3d4451;
  --muted:     #5b6470;
  --border:    #e6ecf0;
  --border-2:  #d2dbe1;
  --link:      #2563eb;
  --link-hov:  #1d4ed8;
  --good:      #16a34a;
  --warn:      #ea580c;
  --noise:     #9aa4b1;
  --shadow:    0 1px 2px rgba(15, 20, 25, 0.04);

  --accent:    var(--link);
  --fresh:     var(--good);
  --other:     var(--link);
  --pre:       #7c3aed;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #16181c;
    --bg-2:     #1c1f26;
    --bg-3:     #232730;
    --fg:       #e7e9ea;
    --fg-2:     #b6bcc4;
    --muted:    #8a929c;
    --border:   #2a2e36;
    --border-2: #3a3f49;
    --link:     #4ea3ff;
    --link-hov: #7cbcff;
    --good:     #4ade80;
    --warn:     #fb923c;
    --noise:    #535862;
    --shadow:   0 1px 2px rgba(0, 0, 0, 0.3);
    --accent: var(--link);
    --fresh:  var(--good);
    --other:  var(--link);
    --pre:    #c4b5fd;
  }
}

html[data-theme="light"] {
  --bg: #ffffff; --bg-2: #ffffff; --bg-3: #f7f9f9;
  --fg: #0f1419; --fg-2: #3d4451; --muted: #5b6470;
  --border: #e6ecf0; --border-2: #d2dbe1;
  --link: #2563eb; --link-hov: #1d4ed8;
  --good: #16a34a; --warn: #ea580c; --noise: #9aa4b1;
  --shadow: 0 1px 2px rgba(15, 20, 25, 0.04);
  --accent: var(--link); --fresh: var(--good); --other: var(--link);
  --pre: #7c3aed;
}
html[data-theme="dark"] {
  --bg: #16181c; --bg-2: #1c1f26; --bg-3: #232730;
  --fg: #e7e9ea; --fg-2: #b6bcc4; --muted: #8a929c;
  --border: #2a2e36; --border-2: #3a3f49;
  --link: #4ea3ff; --link-hov: #7cbcff;
  --good: #4ade80; --warn: #fb923c; --noise: #535862;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --accent: var(--link); --fresh: var(--good); --other: var(--link);
  --pre: #c4b5fd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: 14px 20px 16px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
h1 .accent { color: var(--link); }
h1 .navlink {
  font-size: 12px; margin-left: 12px;
  color: var(--muted); text-decoration: none; font-weight: 400;
}
h1 .navlink:hover { color: var(--link); }

.stats { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 3px 9px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px;
}
.stat .label {
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-size: 10px;
}
.stat b { font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.fresh b { color: var(--good); }
.stat.other b { color: var(--link); }
.stat.noise b { color: var(--noise); }

#conn { font-size: 11px; color: var(--muted); }
#conn.online  { color: var(--good); }
#conn.online::before  { content: "● "; }
#conn.offline::before { content: "○ "; }

.filters {
  margin-top: 8px;
  display: flex; gap: 14px; align-items: center;
  font-size: 12px; color: var(--muted); flex-wrap: wrap;
}
.filters label { cursor: pointer; user-select: none; }
.filters input { vertical-align: middle; margin-right: 4px; }
.filters .sep { width: 1px; height: 14px; background: var(--border); display: inline-block; }
.filters .mode-label { display: inline-flex; align-items: center; gap: 6px; }
.filters select, .stats select {
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; font: inherit;
}

main { padding: 12px 20px 60px; max-width: 1100px; margin: 0 auto; }

body:not(.public) .card {
  display: grid; grid-template-columns: 6px 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 14px; margin-bottom: 6px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px;
  animation: slidein 200ms cubic-bezier(.2,.7,.2,1) both;
}
body:not(.public) .card::before {
  content: ""; display: block;
  width: 4px; height: 100%; border-radius: 2px; background: var(--link);
}
body:not(.public) .card.fresh::before { background: var(--good); }
body:not(.public) .card.noise::before { background: var(--noise); }
body:not(.public) .card.noise        { opacity: 0.65; }
body:not(.public) .card-link {
  display: contents; color: inherit; text-decoration: none;
}
body:not(.public) .card-domain {
  font-size: 14px; font-weight: 600;
  color: var(--fg); word-break: break-all;
}
body:not(.public) a.card-link:hover .card-domain { color: var(--link); }
body:not(.public) .card-meta {
  margin-top: 2px; font-size: 11px; color: var(--muted);
  display: flex; gap: 10px;
}

.card.hidden { display: none; }

@keyframes slidein {
  from { transform: translateY(-4px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.new-pill {
  position: fixed;
  top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 100;
  padding: 8px 16px;
  background: var(--link); color: #ffffff;
  border: none; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow), 0 6px 20px rgba(37, 99, 235, 0.35);
  animation: pillin 200ms ease-out both;
}
.new-pill:hover { background: var(--link-hov); }
.new-pill[hidden] { display: none; }
.new-pill [data-count] {
  font-variant-numeric: tabular-nums;
  display: inline-block; transform-origin: center;
}
.new-pill [data-count].bumped { animation: bump 380ms ease-out; }
@keyframes pillin {
  from { transform: translate(-50%, -8px); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.panel {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px 14px; margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 4px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--link);
}
.panel .hint { margin: 0 0 10px; font-size: 11px; color: var(--muted); }
.bar, .ngram {
  display: grid; grid-template-columns: 110px 1fr 60px;
  gap: 10px; align-items: center;
  padding: 3px 0; font-variant-numeric: tabular-nums;
}
.bar-label { font-size: 12px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label.gram { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; color: var(--link); }
.bar-track { background: var(--bg-3); border-radius: 3px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--link); border-radius: 3px; }
.bar-count { text-align: right; font-size: 11px; color: var(--muted); }
.ngram-examples {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px 0 6px 110px; font-size: 11px; color: var(--muted);
}
.ngram-examples .ex { background: var(--bg-3); padding: 1px 6px; border-radius: 3px; border: 1px solid var(--border); }
.empty { color: var(--muted); font-style: italic; font-size: 12px; padding: 6px 0; }

.public-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.public-header.two-row {
  display: block;
  padding: 8px 20px 10px;
}
.public-header.two-row .ph-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.public-header.two-row .ph-row-search { margin-top: 6px; }
.ph-brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.ph-actions {
  display: flex; align-items: center; gap: 10px;
}
.info-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: #ffd400; color: #1a1a1a;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic; font-weight: 700; font-size: 14px; line-height: 1;
  text-decoration: none;
  box-shadow: 0 0 6px rgba(255, 212, 0, 0.55);
  flex: 0 0 auto;
}
.info-dot:hover { box-shadow: 0 0 10px rgba(255, 212, 0, 0.9); }
.wordmark-link { text-decoration: none; color: inherit; }

.about-main {
  max-width: 720px; margin: 0 auto;
  padding: 24px 20px 80px; line-height: 1.55;
}
.about-main section { margin-bottom: 28px; }
.about-main h2 {
  font-size: 16px; margin: 0 0 8px;
  color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.about-main p { margin: 0 0 10px; color: var(--fg); }
.about-main p.muted { color: var(--muted); }
.about-main code {
  background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 90%;
}
.about-main a { color: var(--link); }
.about-main a:hover { color: var(--link-hov); }

.search-box {
  display: flex; align-items: center;
  flex: 3 1 0; min-width: 0;
  background: var(--surface, rgba(127,127,127,0.08));
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0 8px; height: 32px;
}
.search-box:focus-within { border-color: var(--link, #19d3d3); }
.search-glyph { opacity: 0.55; font-size: 15px; margin-right: 6px; line-height: 1; }
.search-box input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: inherit; font: inherit; font-size: 14px;
  padding: 4px 0; min-width: 0;
  -webkit-appearance: none; appearance: none;
}
.search-box input::-webkit-search-decoration,
.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-results-button,
.search-box input::-webkit-search-results-decoration {
  -webkit-appearance: none; appearance: none; display: none;
}
.search-clear {
  background: transparent; border: 0; color: inherit;
  opacity: 0.5; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 4px;
}
.search-clear:hover { opacity: 0.9; }
.search-not-label {
  opacity: 0.55; font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 0 2px;
}
.search-box.search-not {
  flex: 1 1 0; min-width: 80px;
  transition: flex-grow 180ms ease;
}
.search-box.search-not:focus-within { flex-grow: 2; }

.public-header h1 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
}
.public-header h1 .accent { color: var(--link); }
.public-header h1.wordmark { font-size: 22px; letter-spacing: 0; }
.public-header h1.wordmark .wm-left  { color: #ff3aa5; }
.public-header h1.wordmark .wm-right { color: #19d3d3; }
.public-header h1.wordmark .wm-star {
  color: #ffd400; margin: 0 2px;
  text-shadow: 0 0 6px rgba(255, 212, 0, 0.85),
               0 0 14px rgba(255, 212, 0, 0.55);
}
.public-header h1.wordmark .wm-version {
  margin-left: 8px; font-size: 11px; font-weight: 400;
  color: var(--muted, #888); letter-spacing: 0.02em; vertical-align: middle;
}
.public-header .tagline { display: none; }
.public-stats {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.public-stats .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); transition: background 200ms ease;
}
.public-stats .dot.online { background: var(--good); }
.public-stats b { color: var(--fg); font-weight: 600; font-variant-numeric: tabular-nums; }

.public-feed {
  max-width: 600px; margin: 0 auto;
  padding: 14px 16px 60px;
}

.public-header .new-pill {
  position: static; transform: none;
  margin: 0; padding: 5px 12px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
  animation: none;
}
.public-header .new-pill[hidden] { display: none; }

.pcard {
  position: relative;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; margin: 0 0 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: slidein 320ms cubic-bezier(.2,.7,.2,1) both;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}
.pcard:hover { border-color: var(--border-2); transform: translateY(-1px); }

.pcard-link {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  padding: 16px 48px 18px 20px;
  text-decoration: none; color: inherit; align-items: start;
}
.pcard-link:not(:has(.pcard-icon)) { grid-template-columns: 1fr; }
.pcard-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  overflow: hidden; display: inline-block; flex: none;
}
.pcard-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-body { min-width: 0; }
.pcard-title {
  font-size: 17px; font-weight: 700; line-height: 1.3;
  color: var(--fg); word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
a.pcard-link:hover .pcard-title { color: var(--link); }
a.pcard-link:visited .pcard-title { color: var(--muted); }

.pcard-desc {
  margin-top: 6px; font-size: 14px; line-height: 1.45;
  color: var(--fg-2);
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

.pcard-meta {
  margin-top: 12px; font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.pcard-domain { color: var(--fg-2); }
.pcard-sep    { opacity: 0.6; }

@media (max-width: 480px) {
  .public-header { padding: 28px 16px 18px; }
  .public-header h1 { font-size: 22px; }
  .public-feed { padding: 14px 12px 60px; }
  .pcard-link { padding: 14px 44px 16px 16px; }
  .pcard-title { font-size: 16px; }
  .pcard-desc { font-size: 13px; }
}

.cog-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  padding: 0; border: 0; background: transparent;
  color: var(--fg); cursor: pointer;
  border-radius: 6px; text-decoration: none; flex: 0 0 auto;
}
.cog-btn:hover { background: var(--bg-3); }
.cog-btn svg { display: block; }
html.i18n-translating .cog-btn svg { animation: cog-spin 2s linear infinite; }
@keyframes cog-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ---- favorites ---- */
.fav-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  color: var(--muted); text-decoration: none; flex: 0 0 auto;
  transition: color 140ms ease;
}
.fav-nav:hover { color: #ffd400; }
.fav-nav svg { display: block; }

.fav-btn {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  cursor: pointer; z-index: 2;
  transition: color 140ms ease, background 140ms ease, transform 140ms ease;
}
.fav-btn:hover { background: var(--bg-3); color: #ffd400; }
.fav-btn:active { transform: scale(0.9); }
.fav-btn.on {
  color: #ffd400;
  filter: drop-shadow(0 0 4px rgba(255, 212, 0, 0.7));
}
.fav-btn svg { display: block; pointer-events: none; }

.fav-status {
  margin: 0; font-size: 12px; color: var(--muted);
}
.fav-empty {
  text-align: center; color: var(--muted);
  font-size: 14px; padding: 48px 16px;
}

.settings-field {
  display: block; margin: 0 0 12px;
  font-size: 13px; color: var(--fg-2);
}
.settings-field span { display: block; margin-bottom: 4px; }

.settings-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.settings-header h1 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
}
.back-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--fg); text-decoration: none; cursor: pointer;
  flex: 0 0 auto;
}
.back-arrow:hover { border-color: var(--border-2); background: var(--bg-3); }
.back-arrow svg { display: block; }

.settings-main {
  max-width: 640px; margin: 0 auto;
  padding: 24px 20px 80px;
}
.settings-section {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.settings-section h2 {
  margin: 0 0 4px; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--link);
}
.settings-section .hint {
  margin: 0 0 12px; font-size: 12px; color: var(--muted); line-height: 1.45;
}
.settings-radio-group { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-radio {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); cursor: pointer;
  font-size: 14px; user-select: none;
}
.settings-radio input { margin: 0; }
.settings-radio:hover { border-color: var(--border-2); }
.settings-radio.checked { border-color: var(--link); background: var(--bg-3); }
.settings-select {
  width: 100%; padding: 8px 10px;
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 14px;
}
.settings-status {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 10px; font-size: 12px; color: var(--muted);
  min-height: 18px;
}
.settings-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-2); border-top-color: var(--link);
  border-radius: 50%;
  animation: cog-spin 0.8s linear infinite;
}

/* Adult-content challenge: rendered below the toggle when the user
   asks to enable it. Inline (not modal) so the keyboard pop-up on
   mobile doesn't fight a floating dialog. */
.adult-challenge {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.adult-challenge-prompt {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--fg-2);
}
.adult-challenge-prompt strong {
  color: var(--fg);
  font-style: italic;
}
.adult-challenge-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.adult-challenge-row input {
  flex: 1 1 120px; min-width: 80px;
}
.adult-challenge-row button { cursor: pointer; }
