:root {
  --bg: #e3e8f0;
  --card-bg: #e9eef5;
  --text: #0e2233;
  --muted: #6f7f90;
  --border: #cad3de;
  --topbar-bg: #d5dce7;
  --brand: #4a6176;
  --nav: #335c87;
  --nav-active: #123b63;
  --date: #233f5b;
  --card-title-grad-start: #08283f;
  --card-title-grad-end: #09314f;
  --switch-bg: #0f0f0f;
  --switch-text: #f5f5f5;
  --chip-bg: #ffffff;
  --chip-text: #32597f;
  --chip-border: #c6d1de;
  --chip-active-bg: #0f2f4b;
  --chip-active-text: #f3f8ff;
}

body[data-theme="dark"] {
  --bg: #141414;
  --card-bg: #111111;
  --text: #e7e7e7;
  --muted: #a3a3a3;
  --border: #2a2a2a;
  --topbar-bg: #0f0f0f;
  --brand: #e5e5e5;
  --nav: #bdbdbd;
  --nav-active: #ffffff;
  --date: #c4c4c4;
  --card-title-grad-start: #121212;
  --card-title-grad-end: #1a1a1a;
  --switch-bg: #171717;
  --switch-text: #e5e5e5;
  --chip-bg: #1b1b1b;
  --chip-text: #c9c9c9;
  --chip-border: #2f2f2f;
  --chip-active-bg: #2a2a2a;
  --chip-active-text: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.topbar-left {
  justify-self: start;
}

.topbar-center {
  justify-self: center;
}

.topbar-right {
  justify-self: end;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
  text-decoration: none;
  display: inline-block;
}

.brand:hover {
  color: var(--nav-active);
}

.theme-nav {
  display: flex;
  align-items: center;
}

.theme-nav a {
  color: var(--chip-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.theme-nav a:first-child {
  margin-left: 0;
}

.theme-nav a.active {
  color: var(--chip-active-text);
  background: var(--chip-active-bg);
  border-color: var(--chip-active-bg);
}

.tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tool-btn {
  border: 1px solid var(--border);
  background: var(--switch-bg);
  color: var(--switch-text);
  font-size: 13px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
}

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-switch__checkbox {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.theme-switch__container {
  width: 62px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #7bc8ff 0%, #4a9ee2 100%);
  position: relative;
  overflow: hidden;
  transition: background 0.25s ease;
}

.theme-switch__sun-moon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffd76a;
  position: absolute;
  top: 3px;
  left: 4px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  transition: transform 0.25s ease, background 0.25s ease;
}

.theme-switch__moon-spot {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: rgba(87, 96, 109, 0.35);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.theme-switch__moon-spot:nth-child(1) {
  width: 6px;
  height: 6px;
  top: 5px;
  left: 13px;
}

.theme-switch__moon-spot:nth-child(2) {
  width: 4px;
  height: 4px;
  top: 12px;
  left: 7px;
}

.theme-switch__moon-spot:nth-child(3) {
  width: 5px;
  height: 5px;
  top: 14px;
  left: 15px;
}

.theme-switch__clouds {
  position: absolute;
  bottom: 2px;
  left: 8px;
  width: 20px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 10px -2px 0 0 rgba(255, 255, 255, 0.92), 22px 0 0 0 rgba(255, 255, 255, 0.92);
  transition: opacity 0.2s ease;
}

.theme-switch__stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.theme-switch__stars::before,
.theme-switch__stars::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

.theme-switch__stars::before {
  top: 8px;
  right: 15px;
}

.theme-switch__stars::after {
  top: 14px;
  right: 24px;
}

.theme-switch__checkbox:checked + .theme-switch__container {
  background: linear-gradient(180deg, #1f2937 0%, #0b1220 100%);
}

.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__sun-moon {
  transform: translateX(30px);
  background: #dce2ee;
}

.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__moon-spot {
  opacity: 1;
}

.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__clouds {
  opacity: 0;
}

.theme-switch__checkbox:checked + .theme-switch__container .theme-switch__stars {
  opacity: 1;
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 20px;
  padding: 22px;
}

.list-layout {
  display: none;
  padding: 22px;
}

body[data-view="source"] .source-layout {
  display: grid;
}

body[data-view="source"] .list-layout {
  display: none;
}

body[data-view="list"] .source-layout {
  display: none;
}

body[data-view="list"] .list-layout {
  display: block;
}

.feed-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px 14px;
}

.feed-card h2 {
  margin: 0 -14px 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--card-title-grad-start), var(--card-title-grad-end));
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.feed-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px;
}

.feed-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed-card li {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 6px;
  margin: 2px 0;
  align-items: start;
}

.feed-card .news-empty {
  display: block;
  grid-template-columns: none;
  margin: 6px 0 2px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.mixed-card {
  max-width: 1200px;
  margin: 0 auto;
}

.mixed-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mixed-item {
  display: grid;
  grid-template-columns: 54px 180px 1fr;
  gap: 8px;
  margin: 3px 0;
  align-items: start;
}

.mixed-source {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.date {
  font-size: 13px;
  color: var(--date);
}

.date.older {
  color: var(--muted);
}

.news-link {
  display: inline;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 300;
  color: var(--text);
  text-decoration: none;
}

.news-link:hover {
  text-decoration: underline;
}

.news-link.today {
  font-weight: 600;
}

.news-link.older,
.news-link.read {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    justify-items: stretch;
  }

  .topbar-left,
  .topbar-center,
  .topbar-right {
    justify-self: stretch;
  }

  .topbar-center {
    overflow-x: auto;
  }

  .topbar-right {
    justify-self: end;
  }

  .mixed-item {
    grid-template-columns: 54px 1fr;
  }

  .mixed-source {
    grid-column: 2;
    margin-top: -2px;
  }
}

.site-footer {
  margin: 6px 22px 24px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.site-footer p {
  margin: 2px 0;
}

.home-vercel {
  min-height: calc(100vh - 92px);
  display: grid;
  place-items: center;
  padding: 24px 18px;
}

.home-vercel-inner {
  width: min(880px, 100%);
  text-align: center;
}

.home-brand {
  display: inline-flex;
  margin-bottom: 18px;
  text-decoration: none;
}

#theme-toggle-home {
  border: 1px solid #2a2a2a;
  background: #171717;
  color: #e5e5e5;
  font-size: 17px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  margin: 0 auto 14px;
}

.home-site-logo {
  display: block;
  width: clamp(92px, 12vw, 132px);
  height: auto;
  margin: 0 auto 16px;
  border-radius: 16px;
}

.home-vercel h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
}

.home-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  text-align: left;
  max-width: 520px;
  margin: 0 auto;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease;
  position: relative;
}

.theme-card:hover {
  border-color: var(--chip-active-bg);
  transform: translateY(-1px);
}

.theme-status {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}

.theme-dot-offline {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.theme-card-offline {
  opacity: 0.86;
}

.theme-name {
  font-weight: 600;
  font-size: 16px;
}

.theme-link {
  font-size: 12px;
  color: var(--muted);
}

body.home-page[data-theme="dark"] {
  background: #0a0a0a;
  color: #f5f5f5;
}

body.home-page[data-theme="dark"] .home-brand {
  color: #f5f5f5;
}

body.home-page[data-theme="dark"] .home-subtitle {
  color: #a3a3a3;
}

body.home-page[data-theme="dark"] .theme-card {
  background: #111111;
  border-color: #2a2a2a;
  color: #f5f5f5;
}

body.home-page[data-theme="dark"] .theme-card:hover {
  border-color: #3b3b3b;
}

body.home-page[data-theme="dark"] .theme-link {
  color: #9a9a9a;
}

body.home-page[data-theme="dark"] .site-footer {
  border-top-color: #2a2a2a;
  color: #8a8a8a;
}
