:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --fg: #1a1d21;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-soft: #e6f2f0;
  --accent-fg: #ffffff;
  --warn-bg: #fef3c7;
  --warn-fg: #92400e;
  --danger: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 1px 3px rgb(0 0 0 / 6%);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.5;
}
a { color: var(--accent); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
main.wrap { padding-top: 28px; padding-bottom: 20px; }

/* top bar */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand {
  font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--fg);
  display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em;
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
nav { display: flex; align-items: center; gap: 4px; }
.navlink { text-decoration: none; color: var(--muted); padding: 6px 12px;
  border-radius: 8px; font-size: 0.92rem; font-weight: 500; }
.navlink:hover { color: var(--fg); background: var(--bg); }
.lang-toggle { margin-left: 8px; text-decoration: none; color: var(--accent);
  border: 1px solid var(--line); padding: 5px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; background: var(--card); }
.lang-toggle:hover { border-color: var(--accent); }

h1, h2, h3 { letter-spacing: -0.01em; }
.rail-title { font-size: 1.15rem; margin: 0 0 14px; }
.rail-title-row { display: flex; align-items: baseline; justify-content: space-between; }
.more-link { font-size: 0.85rem; text-decoration: none; font-weight: 500; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 20px 0 36px; }

/* briefs */
.brief {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 10px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.brief-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
details.brief > summary { cursor: pointer; list-style: none; }
details.brief > summary::-webkit-details-marker { display: none; }
details.brief > summary::before { content: "▸"; color: var(--muted); font-size: 0.8rem; }
details.brief[open] > summary::before { content: "▾"; }
.brief .when { color: var(--muted); font-size: 0.8rem; margin-left: auto; }
.brief-body { margin: 4px 0 8px; font-size: 0.92rem; white-space: pre-line; }
.brief-day { display: flex; align-items: center; gap: 8px; margin: 8px 0 2px;
  padding-top: 8px; border-top: 1px dashed var(--line); font-size: 0.8rem; color: var(--muted); }
.brief-foot { border-top: 1px dashed var(--line); padding-top: 7px; font-size: 0.82rem; }
.brief-foot a { text-decoration: none; color: var(--muted); }
.brief-foot a:hover { color: var(--accent); }
.brief-body .brief-line { color: inherit; text-decoration: none; border-radius: 4px; }
.brief-body .brief-line:hover { color: var(--accent); text-decoration: underline; }

/* search bar above the articles overview */
.search {
  width: 100%; max-width: 420px; padding: 8px 14px; margin-bottom: 12px;
  font-size: 0.95rem; color: var(--text, #222); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; outline: none;
}
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, rgba(61, 155, 233, .15)); }

/* view options + settings form */
.viewopts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.viewopts .search { margin-bottom: 0; max-width: 320px; }
.viewopts select {
  padding: 7px 10px; font-size: 0.9rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: inherit;
}

/* home briefs controls: search field, sort segments, country chips */
.brief-opts { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.brief-search { flex: 1; min-width: 200px; max-width: none; background: none;
  border: none; padding: 0; box-shadow: none; }
.brief-search .search { margin-bottom: 0; max-width: none; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; }
.seg a { padding: 7px 14px; font-size: 0.85rem; font-weight: 550; color: var(--muted);
  text-decoration: none; border-left: 1px solid var(--line); }
.seg a:first-child { border-left: 0; }
.seg a:hover { background: var(--bg); color: var(--fg); }
.seg a.active { background: var(--accent); color: var(--accent-fg); }
.brief-opts .filters { margin: 0; }

/* home briefs list; group headers appear in the country view */
.briefs-list { list-style: none; margin: 0; padding: 0; }
.briefs-list li { display: block; }
.briefs-list li.group-head { font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--accent); margin: 20px 0 8px; }
.briefs-list li.group-head:first-child { margin-top: 0; }
.section-title { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); margin: 26px 0 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.settings-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 0.86rem; color: var(--muted); }
.settings-grid input, .settings-grid select {
  padding: 8px 10px; font-size: 0.92rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: inherit; width: 100%;
}
#settings-form .btn { margin-top: 12px; }
#settings-flash { margin: 10px 0 0; color: #1a7f37; font-weight: 600; }
.statusbar { margin: 0 0 14px; padding: 8px 12px; border-radius: 8px;
  background: var(--panel, #f0f2f5); font-size: 0.85rem; }
.statusbar.done { background: #e2f3e9; color: #1a7f37; font-weight: 600; }

/* pills and badges */
.src-pill {
  font-size: 0.78rem; font-weight: 650; padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.t0 { background: #e8ecff; color: #4353d9; } .t1 { background: #e6f2f0; color: #0f766e; }
.t2 { background: #fdeedd; color: #b45309; } .t3 { background: #ffe9ec; color: #be3646; }
.t4 { background: #edeafd; color: #6d4bd9; } .t5 { background: #e7f5ea; color: #237a3d; }
.cat-pill { font-size: 0.78rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.lang-badge {
  flex: none; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 4px; background: var(--bg); text-transform: uppercase;
}
.badge { font-size: 0.7rem; font-weight: 600; border-radius: 4px; padding: 1px 6px; }
.b-trans { background: #e8ecff; color: #4353d9; }
.b-orig { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* headline lists (home + articles) */
.headlines, .feed { list-style: none; margin: 0; padding: 0; }
.headlines li, .feed li {
  display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line);
}
.headlines li { align-items: flex-start; }
.feed li { border-bottom: none; padding: 12px 12px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.hl-main { display: flex; flex-direction: column; min-width: 0; }
.hl-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.hl-row .hl-title { flex: 1 1 auto; min-width: 0; }
.hl-row .cat-pill { flex: none; }
.hl-title {
  font-weight: 600; text-decoration: none; color: var(--fg); font-size: 0.94rem;
  line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.hl-title:hover { color: var(--accent); }
.feed-excerpt { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.feed-sum { color: var(--muted); font-size: 0.85rem; margin: 3px 0 0; font-style: italic; }
.meta { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 3px; }
.src-mini { font-weight: 600; color: var(--muted); }

/* article detail */
.back { display: inline-block; margin-bottom: 14px; text-decoration: none;
  color: var(--muted); font-size: 0.88rem; }
.back:hover { color: var(--accent); }
.single {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 30px; max-width: 820px; margin: 0 auto;
}
.single-title { font-size: 1.55rem; line-height: 1.25; margin: 10px 0 8px; }
.single .body, .single .ai { margin-top: 20px; }
.single .body {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px; white-space: pre-wrap; font-size: 0.95rem;
}
.single-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0; }
.ai-title { font-size: 0.95rem; margin: 0 0 6px; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; }
.ai-text { margin: 6px 0 0; font-size: 0.98rem; }
.ai-img { max-width: 100%; max-height: 420px; border-radius: 10px; margin: 4px 0 10px;
  border: 1px solid var(--line); display: block; }

/* toolbar */
.toolbar { margin-bottom: 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.warn { background: var(--warn-bg); color: var(--warn-fg);
  padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; }
.empty, .muted { color: var(--muted); }

/* filters */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.filters a { text-decoration: none; padding: 4px 11px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.84rem; color: var(--muted); background: var(--card); }
.filters a.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: var(--accent-fg);
  border: none; border-radius: 8px; padding: 7px 14px; cursor: pointer;
  font-size: 0.9rem; text-decoration: none; font-weight: 550; }
.btn:hover { filter: brightness(1.05); }
.btn.sm { padding: 4px 10px; font-size: 0.8rem; }
.btn.danger { background: var(--danger); }
button.btn:disabled, button:disabled { opacity: 0.6; cursor: wait; }

/* sources table & forms */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
table.sources { width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); font-size: 0.9rem; }
table.sources th, table.sources td { text-align: left; padding: 9px 12px;
  border-bottom: 1px solid var(--line); vertical-align: top; }
table.sources th { background: var(--bg); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); }
table.sources tr:last-child td { border-bottom: none; }
table.sources tr.off { opacity: 0.5; }
table.sources td code.url { display: inline-block; max-width: 320px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 0.74rem; color: var(--muted); }

form { max-width: 560px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
form label { display: block; margin: 12px 0; font-weight: 600; font-size: 0.9rem; }
form small { font-weight: 400; color: var(--muted); display: block; margin-top: 2px; }
form input, form select, form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  margin-top: 4px; font: inherit; font-weight: 400; background: var(--card);
}
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-actions .btn.danger { margin-left: auto; }

/* settings sub tabs + sources-tab controls */
.tabs { margin-bottom: 18px; }
.src-hint { margin: 0 0 10px; }
.drag-handle { cursor: grab; color: var(--muted); width: 26px; text-align: center;
  user-select: none; font-size: 1rem; }
.sources tr.dragging { opacity: 0.35; }
.keep-input { width: 76px !important; padding: 5px 7px !important; font-size: 0.85rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card); }

/* labels tab */
.label-add { display: flex; gap: 8px; margin-bottom: 14px; max-width: 420px; }
.label-add input { flex: 1; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 999px; font: inherit; background: var(--card); }
.labels-list { list-style: none; margin: 0; padding: 0; max-width: 560px; }
.labels-list li { display: flex; align-items: center; gap: 8px; padding: 7px 2px;
  border-bottom: 1px solid var(--line); }
.used-count { font-size: 0.8rem; }
.label-actions { margin-left: auto; display: flex; gap: 4px; }

/* statistics tab */
.stats { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0 28px; }
.stat-row { display: flex; justify-content: space-between; gap: 16px; padding: 7px 2px;
  border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.stat-row dt { color: var(--muted); }
.stat-row dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere;
  max-width: 60%; }