html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

header {
  flex-shrink: 0;
}

body > .container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

footer.footer {
  flex-shrink: 0;
  padding: 0.35rem 0;
  font-size: 0.75rem;
  background-color: #fff;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Topic pills bar */
.topic-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0;
}

.pill-active {
  background-color: #0d6efd;
  color: #fff !important;
}

.pill-inactive {
  background-color: #e9ecef;
  color: #495057 !important;
}

.pill-inactive:hover {
  background-color: #dee2e6;
  color: #212529 !important;
}

.pill-user {
  background-color: transparent;
  color: #6f42c1 !important;
  border: 1.5px solid #c7b8ea;
}

.pill-user:hover {
  background-color: #f3effc;
  border-color: #6f42c1;
  color: #6f42c1 !important;
}

.pill-user-active {
  background-color: #6f42c1 !important;
  border-color: #6f42c1 !important;
  color: #fff !important;
}

.pill-divider {
  display: inline-block;
  width: 1px;
  height: 1.1em;
  background: #dee2e6;
  margin: 0 0.15rem;
  vertical-align: middle;
  align-self: center;
}

/* Session navigation bar */
.session-nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.2rem 0 0.4rem;
}

.session-pill {
  font-size: 0.72rem;
}

.session-pill--locked {
  opacity: 0.45;
  cursor: default;
}

/* Keyword cloud */
.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  align-items: baseline;
  line-height: 2;
}

.kw-tag {
  color: #0d6efd;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.kw-tag:hover {
  opacity: 1 !important;
  text-decoration: underline;
  color: #0a58ca;
}

/* All-view full-screen cloud */
.kw-cloud-wrapper {
/*  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);*/
  /*width: 100vw;*/
  padding: 2rem 3rem;
}

.kw-cloud-screen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.9rem;
  line-height: 2;
  min-height: calc(100vh - 160px);
  align-content: center;
}

.kw-static {
  color: #212529;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

.kw-topic-link {
  color: #0d6efd;
  text-decoration: none;
}

.kw-topic-link:hover {
  text-decoration: underline;
}

.kw-all {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.kw-topics {
  font-size: 0.6rem;
  font-weight: 400;
  color: #adb5bd;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
}

.kw-selected {
  color: #fff !important;
  background-color: #0d6efd;
  border-radius: 0.25rem;
  padding: 0.05em 0.35em;
  opacity: 1 !important;
}

/* Section labels */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #adb5bd;
  margin-bottom: 0.75rem;
}

/* Source count badge */
.source-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: #0d6efd;
  background: #e7f1ff;
  border-radius: 999px;
  padding: 0.15em 0.55em;
  white-space: nowrap;
  cursor: pointer;
  border: none;
}

.source-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.source-pill-list .source-modal-btn {
  cursor: pointer;
  border: none;
  font-size: 0.72rem;
}

/* Article cards */
.article-card {
  border-left: 3px solid #0d6efd;
  padding: 0.75rem 1rem;
  background: #f8f9fa;
  border-radius: 0 0.375rem 0.375rem 0;
}

.article-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.article-summary {
  font-size: 0.9rem;
  color: #495057;
  margin-bottom: 0.5rem;
}

.source-swipe-wrap {
  display: flex;
  align-items: stretch;
}

.source-swipe-inner {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.5rem;
}

.swipe-nav-btn {
  flex-shrink: 0;
  width: 36px;
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #adb5bd;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.swipe-nav-btn:hover:not(:disabled) { color: #212529; }
.swipe-nav-btn:disabled { opacity: 0.25; cursor: default; }

.source-swipe {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0.25rem 0;
  scrollbar-width: none;
}

.source-swipe::-webkit-scrollbar { display: none; }

.source-swipe-card {
  flex: 0 0 240px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.source-swipe-card-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: #0d6efd;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-swipe-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #212529;
  text-decoration: none;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-swipe-card-title:hover { color: #0a58ca; text-decoration: underline; }

.source-swipe-card-desc {
  font-size: 0.78rem;
  color: #6c757d;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.navbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* Raw feed items */
.raw-item {
  border-bottom: 1px solid #e9ecef;
  padding: 0.75rem 0;
}

.raw-item:last-child {
  border-bottom: none;
}

.raw-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0d6efd;
  text-decoration: none;
  display: block;
  margin-bottom: 0.15rem;
  overflow-wrap: break-word;
}

.raw-item-title:hover {
  text-decoration: underline;
  color: #0a58ca;
}

.raw-item-title--plain {
  color: #212529;
}

.raw-item-desc {
  font-size: 0.85rem;
  color: #6c757d;
  margin: 0;
  line-height: 1.45;
}

.raw-item-source {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0d6efd;
  background: #e7f1ff;
  border-radius: 999px;
  padding: 0.1em 0.5em;
  white-space: nowrap;
  display: inline-block;
}

.raw-item-date {
  font-size: 0.73rem;
  color: #adb5bd;
  margin-top: 0.25rem;
  white-space: nowrap;
}

/* Sources screen */
.sources-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.source-chip {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
  padding: 0.45rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
  max-width: 260px;
}

.source-chip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
}

.source-row-group-pill {
  font-size: 0.65rem;
}

.source-chip-time {
  font-size: 0.65rem;
  color: #adb5bd;
  width: 100%;
}

.source-chip-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: #212529;
  line-height: 1.3;
  text-decoration: none;
}
.source-chip-name:hover { color: #0d6efd; text-decoration: underline; }

.src-grp-btn {
  background: none;
  border: 1px solid #dee2e6;
  border-radius: 50%;
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  color: #6c757d;
}
.src-grp-add:hover  { background: #d1e7dd; border-color: #198754; color: #198754; }
.src-grp-remove:hover { background: #f8d7da; border-color: #dc3545; color: #dc3545; }

/* Source detail page */
.source-section-toggle {
  background: none;
  border: none;
  border-bottom: 1px solid #dee2e6;
  padding: .5rem 0;
  color: inherit;
}
.source-section-toggle:hover h2 { color: #0d6efd; }
.source-chevron { font-size: 1.1rem; color: #6c757d; transition: transform .2s; display: inline-block; transform: rotate(-90deg); }
.source-chevron.open { transform: rotate(0deg); }

.source-detail-article, .source-detail-item {
  padding: .5rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.source-detail-article:last-child, .source-detail-item:last-child { border-bottom: none; }

.source-detail-article-title {
  font-size: .9rem;
  font-weight: 600;
  color: #212529;
  text-decoration: none;
}
.source-detail-article-title:hover { color: #0d6efd; text-decoration: underline; }

.source-detail-article-date, .source-detail-item-date {
  font-size: .7rem;
  color: #adb5bd;
  margin-top: .15rem;
}

.source-detail-item-title {
  font-size: .875rem;
  color: #212529;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  display: block;
}
.source-detail-item-title:hover { color: #0d6efd; text-decoration: underline; }

/* Article detail page */
.article-detail-back {
  font-size: 0.85rem;
  color: #6c757d;
  text-decoration: none;
}

.article-detail-back:hover {
  color: #0d6efd;
  text-decoration: underline;
}

.article-detail-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  color: #212529;
}

@media (max-width: 576px) {
  .article-detail-title {
    font-size: 1.3rem;
  }
}

.article-detail-summary {
  font-size: 1rem;
  color: #495057;
  line-height: 1.65;
}

.article-detail-sources {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.article-detail-source-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
}

.article-detail-source-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0d6efd;
  text-decoration: none;
  line-height: 1.35;
  margin-bottom: 0.4rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.article-detail-source-title:hover {
  color: #0a58ca;
  text-decoration: underline;
}

.article-detail-source-title--plain {
  color: #212529;
}

.article-detail-source-desc {
  font-size: 0.875rem;
  color: #6c757d;
  line-height: 1.5;
  margin: 0;
}

/* Time page */
.time-tree {
  padding: 0.25rem 0;
}

details.time-node {
  margin: 0;
}

details.time-node > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

details.time-node > summary::-webkit-details-marker { display: none; }

details.time-node > summary::before {
  content: '▸';
  font-size: 0.75em;
  color: #adb5bd;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  width: 0.9rem;
  text-align: center;
}

details.time-node[open] > summary::before {
  transform: rotate(90deg);
}

.time-year > summary {
  padding: 0.6rem 0 0.4rem;
  border-bottom: 2px solid #e9ecef;
  margin-bottom: 0.25rem;
}

.time-year-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: #212529;
}

.time-year-body {
  padding-left: 1.25rem;
  border-left: 2px solid #e9ecef;
  margin-left: 0.45rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

.time-quarter > summary {
  padding: 0.4rem 0;
}

.time-quarter-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: #495057;
}

.time-quarter-body {
  padding-left: 1.1rem;
  border-left: 1px solid #dee2e6;
  margin-left: 0.45rem;
  margin-top: 0.1rem;
  margin-bottom: 0.25rem;
}

.time-month > summary {
  padding: 0.3rem 0;
}

.time-month-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #495057;
}

.time-month-body {
  padding-left: 1rem;
  border-left: 1px solid #e9ecef;
  margin-left: 0.45rem;
  margin-top: 0.05rem;
  margin-bottom: 0.15rem;
}

.time-week-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
}

.time-session-badge {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2em 0.55em;
  border-radius: 0.3rem;
  white-space: nowrap;
}

.time-session-badge--completed  { background: #d1e7dd; color: #0a3622; }
.time-session-badge--running    { background: #cfe2ff; color: #052c65; }
.time-session-badge--pending    { background: #fff3cd; color: #664d03; }
.time-session-badge--failed     { background: #f8d7da; color: #58151c; }
.time-session-badge--needs-recluster { background: #e2d9f3; color: #3d0a91; }

.time-session-label {
  font-size: 0.8rem;
  color: #495057;
}

/* Session selector */
.session-selector-btn {
  font-size: 0.8rem;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-modal-dialog {
  max-width: 360px;
}

.session-sel-latest {
  background: none;
  border: none;
  text-align: left;
  color: #0d6efd;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-radius: 0.3rem;
  width: 100%;
  display: block;
  cursor: pointer;
}

.session-sel-latest:hover {
  background: #e7f1ff;
}

button.time-session-badge {
  border: none;
  cursor: pointer;
}

/* Article detail map */
.article-map-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.article-map-chevron {
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}

.article-map-toggle[aria-expanded="true"] .article-map-chevron {
  transform: rotate(180deg);
}

.article-map {
  height: 320px;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid #e9ecef;
}

/* Clickable article title in cards */
.article-title-link {
  color: inherit;
  text-decoration: none;
}

.article-title-link:hover {
  color: #0d6efd;
  text-decoration: underline;
}

/* ── Personalization ──────────────────────────────────────────────────────── */

.note-textarea {
  width: 100%;
  border: 1px solid #dee2e6;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 80px;
  color: #212529;
  background: #fff;
  transition: border-color 0.15s;
}

.note-textarea:focus {
  outline: none;
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,.15);
}

.note-save-status {
  font-size: 0.78rem;
  color: #adb5bd;
  min-height: 1.2em;
}

.note-save-status.saved  { color: #198754; }
.note-save-status.saving { color: #adb5bd; }
.note-save-status.error  { color: #dc3545; }

.fav-btn {
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  font-size: 1.1rem;
  color: #adb5bd;
  transition: color 0.15s, transform 0.1s;
}

.fav-btn:hover        { color: #fd7e14; transform: scale(1.15); }
.fav-btn.fav-active   { color: #fd7e14; }

.notes-list-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid #f0f0f0;
}

.notes-list-item:last-child { border-bottom: none; }

.notes-list-article-title {
  font-weight: 600;
  color: #212529;
  text-decoration: none;
}

.notes-list-article-title:hover { color: #0d6efd; text-decoration: underline; }

.notes-list-preview {
  font-size: 0.875rem;
  color: #6c757d;
  margin-top: 0.2rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.notes-list-date {
  font-size: 0.78rem;
  color: #adb5bd;
  margin-top: 0.15rem;
}

.my-groups-card {
  border: 1px solid #e9ecef;
  border-radius: 0.6rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.my-groups-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.my-groups-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.my-groups-source-check {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.65rem;
}

.my-groups-source-check label {
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}


/* Shared modal (ad interstitial / login wall) */
.kx-modal {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.6);
  align-items: center; justify-content: center;
}
.kx-modal.kx-modal-open {
  display: flex;
}
.kx-modal-card {
  position: relative; background: #fff; border-radius: 12px;
  padding: 1.75rem 1.75rem 1.5rem; max-width: 500px; width: 90%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
.kx-modal-close {
  position: absolute; top: 0.65rem; right: 0.9rem;
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  color: #888; cursor: pointer; padding: 0;
}
.kx-modal-close:hover { color: #212529; }
.kx-modal-item { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid #e9ecef; text-align: left; }
.kx-modal-item-title { font-weight: 600; font-size: 0.95rem; line-height: 1.4; margin-bottom: 0.35rem; padding-right: 1.5rem; }
.kx-modal-item-desc  { font-size: 0.83rem; color: #555; line-height: 1.5; margin-bottom: 0.75rem; }
.kx-modal-source-btn {
  background: #0d6efd; color: #fff; border: none; border-radius: 6px;
  padding: 7px 18px; font-size: 0.85rem; font-weight: 500; cursor: pointer;
}
.kx-modal-source-btn:disabled { opacity: 0.6; cursor: default; }
.kx-modal-article-title { font-weight: 600; font-size: 1rem; line-height: 1.4; margin-bottom: 0.9rem; }
.kx-modal-ad-wrap { margin-bottom: 1rem; }
.kx-modal-ad-label { font-size: 0.65rem; color: #adb5bd; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.kx-modal-login-btn {
  display: block; margin-top: 1.1rem; padding: 0.5rem 1.5rem;
  background: #0d6efd; color: #fff; border-radius: 6px;
  text-decoration: none; font-size: 0.9rem; font-weight: 500; text-align: center;
}
.kx-modal-login-btn:hover { background: #0a58ca; color: #fff; }
.kx-modal-countdown { margin-top: 0.75rem; font-size: 0.85rem; color: #6c757d; text-align: center; }
