:root {
  --bar-bg: #9ba4ae;
  --bar-bg-dark: #88929d;
  --bar-text: #ffffff;
  --link-color: #104060;
  --link-visited: #9a9a9a;
  --source-color: #8f969e;
  --body-text: #383e45;
  --surface: #ffffff;
  --stripe-bg: #f7f7f7;
  --stripe-hover: #efefef;
  --grid-canvas: #c4c9cf;
  --card-bg: #fafafa;
  --card-hover: #f1f4f7;
  --accent: #104060;
  --accent-light: #e7f0f7;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --slate-soft: #e2e8f0;
  --border: #d8dee6;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: var(--body-text);
  font-family: Arial, Helvetica, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

.hidden { display: none !important; }
.mono { font-family: Consolas, ui-monospace, monospace; }

/* ==================== TOP BAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bar-bg);
  color: var(--bar-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.topbar-inner {
  width: 96%;
  margin: 0 auto;
  padding: 4px 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.82);
  border-radius: 6px;
  padding: 2px 6px;
  max-width: 310px;
  width: 100%;
  transition: background 0.15s ease;
}

.search-box:focus-within {
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(16, 64, 96, 0.35);
}

.search-icon {
  font-size: 12px;
  opacity: 0.65;
  margin-right: 5px;
  user-select: none;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #222;
  padding: 3px 2px;
}

.search-clear {
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

.search-clear:hover { color: #111; }

.brand-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 5px;
}

.brand-link:hover {
  background: rgba(255, 255, 255, 0.15);
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.hdr-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #ffffff;
  font-weight: 600;
  font-size: 12.5px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.hdr-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.hdr-btn-strong {
  background: rgba(16, 64, 96, 0.72);
  border-color: rgba(16, 64, 96, 0.85);
}

.hdr-btn-strong:hover {
  background: rgba(16, 64, 96, 0.92);
}

.hdr-select {
  background: rgba(255, 255, 255, 0.88);
  color: #2b3440;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.style-quick {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.style-qbtn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  width: 26px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.style-qbtn:hover { color: #fff; background: rgba(255, 255, 255, 0.16); }
.style-qbtn.active { background: #ffffff; color: var(--accent); font-weight: 700; }

/* ==================== MAIN CONTAINER ==================== */
.page-wrap {
  width: 96%;
  margin: 0 auto;
  padding: 6px 0 14px 0;
}

.search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #edf4fa;
  border: 1px solid #c9dceb;
  border-radius: 6px;
  padding: 7px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--accent);
}

.chip-btn {
  border: 1px solid #b5cee0;
  background: #ffffff;
  color: var(--accent);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn:hover { background: var(--accent); color: #fff; }

.loading-box, .empty-box {
  text-align: center;
  padding: 64px 20px;
  color: #55606e;
  font-size: 14.5px;
  background: #f4f6f8;
  border-radius: 6px;
}

/* ==================== STATUS DOTS (CRISP VECTOR) ==================== */
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}

.dot-r {
  background: #e11d48;
  box-shadow: 0 0 0 1px rgba(225, 29, 72, 0.25);
}

.dot-u {
  background: #ffffff;
  border: 2.3px solid #e11d48;
}

.dot-b {
  background: #3b82f6;
}

/* ==================== SHARED NEWS CONTROLS ==================== */
.time-txt {
  font-size: 11.5px;
  color: #484f57;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.source-link {
  font-size: 11.5px;
  color: var(--source-color);
  text-decoration: none;
  white-space: nowrap;
}

.source-link:hover {
  color: var(--link-color);
  text-decoration: underline;
}

.later-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 16px;
  padding: 0 3px;
  border: none;
  border-radius: 3px;
  background: #dfe3e8;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.12s ease;
}

.later-btn:hover { background: #7b8490; }
.later-btn.saved { background: #16a34a; color: #fff; }
.later-btn.remove { background: #d6d9de; color: #555; }
.later-btn.remove:hover { background: #dc2626; color: #fff; }

.valvur-btn {
  min-width: 20px;
  height: 16px;
  padding: 0 3px;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  background: #f8fafc;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.valvur-btn.is-hidden {
  background: #cbd5e1;
  color: #1e293b;
  border-color: #94a3b8;
}

/* ==================== STYLE 1: READ (COMPACT ROWS) ==================== */
.news-container.style-read {
  background: #ffffff;
  border: 1px solid #eceff2;
  border-radius: 3px;
  padding: 2px 0;
}

.read-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 8px;
  border-bottom: 1px solid #f5f6f8;
}

.read-row:last-child { border-bottom: none; }
.read-row:hover { background: #f4f7fa; }

.read-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.read-meta .time-txt {
  min-width: 42px;
  text-align: right;
}

.read-content {
  flex: 1;
  min-width: 0;
}

.read-title {
  color: var(--link-color);
  text-decoration: none;
  font-size: 13px;
  margin-right: 6px;
  word-break: break-word;
}

.read-title:visited { color: var(--link-visited); }
.read-title:hover { text-decoration: underline; }

/* ==================== STYLE 2: TRIIBUD (HORIZONTAL STRIPES) ==================== */
.news-container.style-triibud {
  background: var(--stripe-bg);
  border: 1px solid #e5e8ec;
  border-radius: 3px;
  overflow: hidden;
}

.triibud-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 4px 8px;
  border-bottom: 1px solid #ffffff;
  transition: background 0.1s ease;
}

.triibud-row:hover { background: var(--stripe-hover); }

.triibud-thumb-wrap {
  width: 42px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: #ebedf0;
}

.triibud-thumb-wrap.no-img {
  background: transparent;
}

.triibud-thumb {
  width: 42px;
  height: 40px;
  object-fit: cover;
  display: block;
}

.triibud-body {
  flex: 1;
  min-width: 0;
}

.triibud-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 1px;
}

.triibud-title {
  color: var(--link-color);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
}

.triibud-title:visited { color: var(--link-visited); }
.triibud-title:hover { text-decoration: underline; }

.triibud-snippet {
  margin: 1px 0 0 0;
  font-size: 11px;
  color: #40464d;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==================== STYLE 3: KASTID (CARDS GRID) ==================== */
.news-container.style-kastid {
  background: var(--grid-canvas);
  padding: 4px;
  border-radius: 3px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 4px;
}

.kast-card {
  background: var(--card-bg);
  border-radius: 3px;
  padding: 6px 8px;
  height: 146px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.12s ease;
}

.kast-card:hover {
  background: var(--card-hover);
}

.kast-top {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  margin-bottom: 4px;
  min-width: 0;
}

.kast-top .source-link {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.kast-top .later-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.kast-main {
  flex: 1;
  overflow: hidden;
}

.kast-thumb {
  float: left;
  width: 60px;
  height: 56px;
  object-fit: cover;
  border-radius: 5px;
  margin: 1px 8px 3px 0;
  background: #e6eaef;
}

.kast-title {
  display: block;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.24;
  color: var(--link-color);
  text-decoration: none;
  margin-bottom: 4px;
}

.kast-title:visited { color: var(--link-visited); }
.kast-title:hover { text-decoration: underline; }

.kast-snippet {
  margin: 0;
  font-size: 11px;
  line-height: 1.28;
  color: #40464d;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==================== FOOTER & PAGINATION ==================== */
.footer-bar {
  margin-top: 8px;
  background: var(--bar-bg);
  color: #ffffff;
  border-radius: 4px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.pager {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px;
}

.pg-btn {
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #f8fafc;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.pg-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
  color: #162332;
}

.pg-btn.active {
  background: #ffffff;
  color: var(--accent);
}

.pg-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pg-ellipsis {
  padding: 0 4px;
  color: rgba(255, 255, 255, 0.75);
}

.pg-meta {
  margin-left: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.9);
}

.footer-tip {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  color: #1f2d3d;
  font-weight: 600;
  text-align: center;
}

.android-link {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 5px;
  background: rgba(16, 64, 96, 0.45);
}

.android-link:hover {
  background: rgba(16, 64, 96, 0.75);
}

/* ==================== SETTINGS VIEW ==================== */
.settings-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 40px 16px;
}

.settings-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.settings-title {
  margin: 0;
  font-size: 20px;
  color: var(--accent);
}

.settings-top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.save-toast {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #86efac;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 700;
}

.set-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(16, 64, 96, 0.04);
}

.set-card-title {
  margin: 0 0 14px 0;
  font-size: 15.5px;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid #edf1f5;
}

.style-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.style-option {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  background: #fafbfc;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.style-option:hover { border-color: #88a9c3; }

.style-option.active {
  border-color: var(--accent);
  background: #f2f8fc;
  box-shadow: 0 4px 14px rgba(16, 64, 96, 0.12);
}

.style-thumb-wrap {
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  margin-bottom: 10px;
}

.style-thumb {
  width: 100%;
  height: auto;
  display: block;
}

.style-opt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.style-name {
  font-weight: 700;
  color: #1e293b;
}

.style-active-tag {
  display: none;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
}

.style-option.active .style-active-tag { display: inline-block; }

.count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: #475569;
}

.num-input, .text-input {
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13.5px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
}

.num-input { width: 72px; text-align: center; font-weight: 600; }
.num-input:focus, .text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(16, 64, 96, 0.14); }

.legend-strip {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #edf1f5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: #475569;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* UUID & QR */
.uuid-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: start;
}

.field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.uuid-input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.uuid-input-row .text-input {
  flex: 1;
  min-width: 260px;
  max-width: 380px;
}

.uuid-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px 0;
}

.btn-primary, .btn-secondary {
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover { background: #0c314a; }

.btn-secondary {
  background: #f1f5f9;
  color: #1e293b;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #e8f1f8;
}

.err-msg {
  margin-top: 6px;
  color: var(--red);
  font-weight: 600;
  font-size: 12.5px;
}

.help-text {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.5;
}

.uuid-qr-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.qr-img {
  display: block;
  width: 176px;
  height: 176px;
  border-radius: 6px;
  background: #ffffff;
}

.qr-caption {
  margin-top: 8px;
  font-size: 11.5px;
  color: #64748b;
  font-weight: 600;
}

/* Modern Source Channels Selector */
.feeds-help {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 14px;
}

.feeds-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
}

.feed-search {
  flex: 1;
  min-width: 210px;
  max-width: 340px;
}

.feed-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fpill {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  border-radius: 99px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.fpill:hover { border-color: var(--accent); color: var(--accent); }
.fpill.active { background: var(--accent); color: #ffffff; border-color: var(--accent); }

.feeds-list {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  overflow: hidden;
}

.feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 14px;
  border-bottom: 1px solid #edf1f5;
  background: #ffffff;
}

.feed-row:last-child { border-bottom: none; }
.feed-row:hover { background: #f8fafc; }

.feed-info {
  flex: 1;
  min-width: 0;
}

.feed-title-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.feed-name {
  font-weight: 700;
  color: #1e293b;
  text-decoration: none;
  font-size: 13.5px;
}

.feed-name:hover { color: var(--accent); text-decoration: underline; }

.feed-descr {
  color: #64748b;
  font-size: 12.5px;
}

.def-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.def-badge.vis {
  background: #ecfdf5;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.def-badge.hid {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* 3-way segmented status toggle */
.seg-ctrl {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.seg-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.12s ease;
}

.seg-btn:hover { background: rgba(255, 255, 255, 0.75); color: #0f172a; }

.seg-btn.active-white {
  background: var(--green);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(21, 128, 61, 0.3);
}

.seg-btn.active-none {
  background: #475569;
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(71, 85, 105, 0.25);
}

.seg-btn.active-black {
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(185, 28, 28, 0.3);
}

.seg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.seg-dot.vis { background: #22c55e; }
.seg-dot.hid { background: #f87171; }

.settings-bottom-bar {
  text-align: right;
  margin-top: 12px;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 900px) {
  .topbar-inner {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 6px;
  }
  .brand-link {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
    padding-left: 0;
  }
  .topbar-right {
    grid-column: 2;
    grid-row: 1;
  }
  .search-box {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
  }
  .style-cards {
    grid-template-columns: 1fr;
  }
  .uuid-grid {
    grid-template-columns: 1fr;
  }
  .uuid-qr-box {
    justify-self: start;
  }
  .feeds-help {
    grid-template-columns: 1fr;
  }
  .feed-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .seg-ctrl {
    width: 100%;
  }
  .seg-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .topbar-inner {
    width: 100%;
    padding: 5px 10px;
  }
  .page-wrap {
    width: 100%;
    padding: 6px 8px 14px 8px;
  }
  .news-container.style-kastid {
    grid-template-columns: 1fr;
  }
  .kast-card {
    height: auto;
    min-height: 120px;
    padding: 9px 10px;
  }
  .kast-title, .triibud-title {
    font-size: 13px;
  }
  .kast-snippet, .triibud-snippet {
    font-size: 12px;
  }
  .read-row {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
  }
  .read-meta .time-txt {
    min-width: auto;
    text-align: left;
  }
  .style-quick {
    display: none;
  }
  .footer-tip {
    text-align: left;
    order: 3;
    flex-basis: 100%;
  }
}
