:root {
  color-scheme: light;
  --bs-primary: #2b8fd8;
  --bs-primary-rgb: 43, 143, 216;
  --page-bg: #eef8ff;
  --surface: #ffffff;
  --surface-soft: #f7fbff;
  --border: #cfe7f8;
  --ink: #123047;
  --muted: #668196;
}

body {
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.bg-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(98, 188, 247, 0.22), transparent 34rem),
    linear-gradient(180deg, #f6fcff 0%, var(--page-bg) 100%);
}

.btn {
  border-radius: 8px;
  min-height: 42px;
}

.btn-primary {
  --bs-btn-bg: #2b8fd8;
  --bs-btn-border-color: #2b8fd8;
  --bs-btn-hover-bg: #1d79bd;
  --bs-btn-hover-border-color: #1d79bd;
  --bs-btn-active-bg: #1768a5;
  --bs-btn-active-border-color: #1768a5;
}

.btn-outline-primary {
  --bs-btn-color: #1d79bd;
  --bs-btn-border-color: #8dcaf0;
  --bs-btn-hover-bg: #e8f6ff;
  --bs-btn-hover-border-color: #65b6e8;
  --bs-btn-hover-color: #155d93;
  --bs-btn-active-bg: #d8f0ff;
  --bs-btn-active-border-color: #65b6e8;
  --bs-btn-active-color: #155d93;
}

.app-header {
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  padding: 18px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(145deg, #62bcf7, #2b8fd8);
  border-radius: 14px;
  color: white;
  display: inline-flex;
  height: 48px;
  justify-content: center;
  width: 48px;
  box-shadow: 0 10px 24px rgba(43, 143, 216, 0.28);
}

.brand-mark .bi {
  font-size: 1.45rem;
}

.action-panel,
.thread-card,
.empty-state,
.login-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.action-panel {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr auto;
  padding: 20px;
}

.action-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.fallback-input {
  min-width: min(440px, 70vw);
}

.status-message {
  color: var(--muted);
  grid-column: 1 / -1;
  min-height: 1.5rem;
}

.error-text {
  color: #b42318;
}

.thread-list {
  display: grid;
  gap: 16px;
}

.thread-card {
  overflow: hidden;
}

.thread-header {
  align-items: flex-start;
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr auto;
  padding: 18px 20px;
}

.thread-title {
  min-width: 0;
}

.site-pill {
  background: #e1f3ff;
  border: 1px solid #bae0f8;
  border-radius: 999px;
  color: #1768a5;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
  padding: 4px 10px;
}

.thread-title-link {
  color: var(--ink);
  text-decoration: none;
}

.thread-title-link:hover {
  color: #155d93;
  text-decoration: underline;
}

.page-list {
  padding: 6px 20px 14px;
}

.page-item-row {
  align-items: flex-start;
  border-bottom: 1px solid #edf6fc;
  display: grid;
  gap: 12px;
  grid-template-columns: 32px 1fr;
  padding: 12px 0;
}

.page-item-row:last-child {
  border-bottom: 0;
}

.page-number {
  align-items: center;
  background: #eff9ff;
  border: 1px solid #d3ecfb;
  border-radius: 8px;
  color: #277fbf;
  display: inline-flex;
  font-size: 0.85rem;
  font-weight: 700;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.page-item-row a {
  color: #155d93;
  display: inline-block;
  font-weight: 700;
  text-decoration: none;
}

.page-item-row a:hover {
  color: #0f4e7d;
  text-decoration: underline;
}

.page-item-row span {
  color: var(--muted);
  display: block;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 42px 24px;
  text-align: center;
}

.pager {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 28px;
}

.app-footer {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 28px;
  text-align: center;
}

.page-count {
  color: var(--muted);
  min-width: 112px;
  text-align: center;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
}

.login-card {
  padding: 28px;
}

.form-control {
  border-color: #b8dff7;
  border-radius: 8px;
}

.form-control:focus {
  border-color: #62bcf7;
  box-shadow: 0 0 0 0.25rem rgba(43, 143, 216, 0.16);
}

.min-w-0 {
  min-width: 0;
}

@media (max-width: 760px) {
  .action-panel,
  .thread-header {
    grid-template-columns: 1fr;
  }

  .action-controls,
  .thread-header .btn,
  .fallback-input {
    justify-content: stretch;
    width: 100%;
  }

  .pager {
    flex-wrap: wrap;
  }
}
