/* Theme: follows the device unless Settings → Appearance sets data-theme on <html>. */
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --text: #1f1f1f;
  --muted: #5f6368;
  --border: #e0e3e7;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --on-accent: #ffffff;
  --danger: #c5221f;
  --err-bg: #fce8e6;
  --err-text: #a50e0e;
  --ok-bg: #e6f4ea;
  --ok-text: #137333;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 64, 67, .12), 0 1px 3px 1px rgba(60, 64, 67, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316;
    --surface: #1c1d21;
    --surface-2: #26272c;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #33353a;
    --accent: #8ab4f8;
    --accent-soft: #23324a;
    --on-accent: #10213d;
    --danger: #f28b82;
    --err-bg: #4a1e1c;
    --err-text: #f6aea9;
    --ok-bg: #1e3a28;
    --ok-text: #a8dab5;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1c1d21;
  --surface-2: #26272c;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --border: #33353a;
  --accent: #8ab4f8;
  --accent-soft: #23324a;
  --on-accent: #10213d;
  --danger: #f28b82;
  --err-bg: #4a1e1c;
  --err-text: #f6aea9;
  --ok-bg: #1e3a28;
  --ok-text: #a8dab5;
  --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.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* Top bar ---------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  display: flex; align-items: center; gap: 16px;
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 20px; }
.search { flex: 1; max-width: 560px; }
.search input {
  width: 100%; padding: 9px 16px; border-radius: 999px;
  border: 1px solid transparent; background: var(--surface-2); outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.tools { display: flex; gap: 4px; margin-left: auto; }
.tools a { padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tools a:hover { background: var(--surface-2); }
.tools a.active { color: var(--accent); background: var(--accent-soft); }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  max-width: 1100px; margin: 0 auto; padding: 0 16px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px; white-space: nowrap; color: var(--muted); font-weight: 500;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 80px; outline: none; }
.view-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.view-head h1 { font-size: 24px; margin: 0; font-weight: 600; }
.view-head .spacer { flex: 1; }
.subtle { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* Stories ---------------------------------------------------------------- */
.story {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); margin-bottom: 14px; overflow: hidden;
  transition: opacity .2s, transform .2s;
}
.story.focused { outline: 2px solid var(--accent); outline-offset: 2px; }
.story.leaving { opacity: 0; transform: translateX(24px); }
.story-body { padding: 14px 16px 6px; }
.lead { display: flex; gap: 16px; align-items: flex-start; }
.lead .art { flex: 1; min-width: 0; }
.thumb {
  width: 132px; height: 96px; object-fit: cover; border-radius: 10px; flex-shrink: 0;
  background: var(--surface-2);
}
.lead .title { font-size: 19px; font-weight: 600; line-height: 1.3; }
.lead .summary {
  color: var(--muted); margin: 6px 0 0; font-size: 14px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.more { border-top: 1px solid var(--border); margin-top: 12px; }
.more .art { padding-top: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.more .art:last-child { border-bottom: 0; }
.more .title { font-size: 15px; font-weight: 500; }

/* Article: leaning border on the left + dot before the source name */
.art {
  position: relative; padding-left: 12px; border-left: 4px solid var(--lean, #9e9e9e);
  padding-right: 92px;
}
.lead .art { padding-right: 0; }
.art.read { opacity: .45; }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--lean, #9e9e9e); flex-shrink: 0; }
.src { font-weight: 600; color: var(--text); }
.own {
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; color: #fff; background: var(--own, #616161);
}
.pw { font-size: 12px; }
.flag { font-size: 14px; line-height: 1; }
.lang {
  font-size: 10.5px; font-weight: 700; padding: 0 5px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--muted);
}
.abroad { color: var(--accent); font-weight: 500; white-space: nowrap; }
.abroad:hover { text-decoration: underline; }
.section-title { font-size: 18px; margin: 24px 0 4px; }
.country-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 14px 0 8px; }
.title:hover { text-decoration: underline; }
.title:visited { color: var(--muted); }
.dupes { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.dupes a { text-decoration: underline; }
.acts {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; gap: 2px;
}
.lead .acts { position: static; transform: none; margin-top: 8px; }
.icon-btn {
  border: 0; background: transparent; width: 30px; height: 30px; border-radius: 50%;
  color: var(--muted); display: inline-grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: #f9ab00; }

.story-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px 12px; font-size: 13px; color: var(--muted);
}
.coverage { display: flex; width: 120px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.coverage span { display: block; height: 100%; }
.blindspot { color: #b06000; font-weight: 600; }
.story-foot .spacer { flex: 1; }
.chip-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--text); white-space: nowrap;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip-btn.danger { color: var(--danger); }
.load-more { display: block; margin: 20px auto; }

/* Plain article lists (saved, search, history, full coverage) */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.list .art { padding-top: 12px; padding-bottom: 12px; margin: 0 16px; border-bottom: 1px solid var(--border); }
.list .row { border-bottom: 1px solid var(--border); }
.list .row:last-child, .list .art:last-child { border-bottom: 0; }
.list .title { font-weight: 500; }
.coverage-big { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 6px 0 4px; }
.coverage-big span { display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* Panels, forms ---------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.panel h2 { font-size: 16px; margin: 0 0 4px; }
.panel > p.subtle { margin: 0 0 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, .inline input, .inline select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 14px;
  color: var(--text); min-width: 0;
}
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.check input { margin-top: 4px; }
.check small { display: block; color: var(--muted); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline input[type=text], .inline input[type=search], .inline input:not([type]) { flex: 1; min-width: 180px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px;
}
.chip button { border: 0; background: transparent; color: var(--muted); padding: 0 4px; }

.result { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.result:last-child { border-bottom: 0; }
.result .grow { flex: 1; min-width: 0; }
.result .name { font-weight: 600; }
.result .url { font-size: 12px; color: var(--muted); word-break: break-all; }
.result .desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.result img.favicon { width: 24px; height: 24px; border-radius: 4px; }

.source-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.source-row:last-child { border-bottom: 0; }
.source-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.source-head .name { font-weight: 600; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.err { background: var(--err-bg); color: var(--err-text); }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
}
.feeds { margin: 8px 0 0 18px; font-size: 13px; }
.feed { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.feed .url { color: var(--muted); word-break: break-all; flex: 1; min-width: 200px; }
.feed .error { color: var(--danger); width: 100%; font-size: 12px; }
.feed select { padding: 2px 4px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }

.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 10px; border-radius: 5px; }

/* Menu, toast, dialog ---------------------------------------------------------- */
.menu {
  position: absolute; z-index: 30; min-width: 220px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.18); padding: 6px 0;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 14px; }
.menu button:hover { background: var(--surface-2); }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: #303134; color: #fff; padding: 10px 16px; border-radius: 10px; display: flex; gap: 16px; align-items: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: calc(100vw - 32px);
}
.toast button { border: 0; background: transparent; color: #8ab4f8; font-weight: 600; }
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 32px)); padding: 20px; max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.preview { font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; max-height: 180px; overflow: auto; }
.preview li { margin: 2px 0; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 12px; }

@media (max-width: 720px) {
  .topbar-row { flex-wrap: wrap; gap: 8px 12px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .brand span { display: none; }
  .tools a { padding: 6px 9px; font-size: 14px; }
  main { padding: 12px 10px 80px; }
  .thumb { width: 92px; height: 72px; }
  .lead .title { font-size: 17px; }
  .art { padding-right: 70px; }
  .acts .icon-btn { width: 28px; height: 28px; }
  .coverage { width: 80px; }
}
