:root {
  color-scheme: light;
  --bg: #fdfce8;
  --bg-accent: #f8f2d9;
  --surface: #fffef6;
  --surface-strong: #fffdf2;
  --border: #e0dac0;
  --text: #2b271f;
  --muted: #6a6554;
  --accent: #9d7040;
  --accent-soft: #f2ead0;
  --success: #61774f;
  --warning: #9c6541;
  --shadow: 0 18px 40px rgba(111, 95, 51, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-display: "Roboto", "Segoe UI", sans-serif;
  --font-body: "Roboto", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #181614;
  --bg-accent: #23201d;
  --surface: #221f1b;
  --surface-strong: #2b2722;
  --border: #4c4338;
  --text: #f3ebd7;
  --muted: #c3b8a1;
  --accent: #d6b27b;
  --accent-soft: #3a3127;
  --success: #9dca90;
  --warning: #e0a576;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-body);
  background:
    linear-gradient(180deg, #fffef4 0%, var(--bg) 52%, var(--bg-accent) 100%);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(214, 178, 123, 0.08), transparent 24%),
    linear-gradient(180deg, #11100f 0%, var(--bg) 52%, var(--bg-accent) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(157, 112, 64, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(157, 112, 64, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.18), transparent 88%);
}

:root[data-theme="dark"] body::before {
  background-image:
    linear-gradient(rgba(214, 178, 123, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 178, 123, 0.05) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 88%);
}

.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  height: 100vh;
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-shrink: 0;
  position: relative;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  color: var(--accent);
}

.hero-copy-block {
  min-width: 0;
  text-align: left;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}

.menu-icon {
  display: inline-grid;
  gap: 4px;
}

.menu-icon span {
  width: 14px;
  height: 1.5px;
  background: currentColor;
  border-radius: 999px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1;
}

.hero-copy {
  max-width: 520px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

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

.control-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 120px;
  padding: 10px 14px;
  min-height: 66px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
}

.control-chip strong,
.control-chip select {
  font: inherit;
  color: var(--text);
}

.control-chip-select {
  min-width: 190px;
}

.select-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.control-chip-status {
  min-width: 220px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.control-chip-toggle {
  min-width: 110px;
  align-items: center;
  justify-content: space-between;
  flex-direction: row;
  text-align: left;
  cursor: pointer;
}

.switch {
  display: inline-flex;
  align-items: center;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 46px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  transition: background 140ms ease, border-color 140ms ease;
}

.switch-thumb {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 140ms ease, background 140ms ease;
}

.switch input:checked + .switch-track {
  background: rgba(157, 112, 64, 0.26);
  border-color: rgba(157, 112, 64, 0.35);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background: var(--text);
}

.chip-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.control-chip select {
  border: 0;
  padding: 0;
  background: transparent;
  outline: none;
  appearance: none;
  cursor: pointer;
  min-width: 0;
  flex: 1;
}

.select-arrow {
  width: 10px;
  height: 10px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  flex-shrink: 0;
  margin-right: 2px;
  pointer-events: none;
}

.meta-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
  flex-shrink: 0;
}

.chip-button:hover,
.control-chip-toggle:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 0;
  flex: 1;
}

.panel {
  grid-column: 1 / -1;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 16px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.panel-note {
  margin: 0;
  color: var(--muted);
  max-width: 300px;
  text-align: right;
}

#status-banner {
  font-size: 0.92rem;
}

.control-chip[data-tone="loading"] {
  border-color: rgba(157, 112, 64, 0.22);
}

.control-chip[data-tone="success"] {
  color: var(--success);
  border-color: rgba(97, 119, 79, 0.24);
}

.control-chip[data-tone="warning"] {
  color: var(--warning);
  border-color: rgba(156, 101, 65, 0.24);
}

.rss-grid {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: minmax(320px, 360px);
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 0;
  flex: 1;
  padding-right: 6px;
  padding-bottom: 4px;
  align-content: stretch;
  scroll-snap-type: x proximity;
}

.rss-grid.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}

.rss-card {
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-snap-align: start;
}

.rss-card[data-state="loading"] .rss-card-header {
  border-bottom-color: transparent;
}

.rss-card[data-state="error"] {
  border-color: rgba(156, 101, 65, 0.28);
}

.rss-source-link,
.rss-item {
  color: inherit;
  text-decoration: none;
}

.rss-item span {
  margin: 0;
  color: var(--muted);
}

.rss-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}

.rss-card-header h3 {
  min-width: 0;
  flex: 1;
  font-size: 1.32rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rss-source-link {
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text);
}

.rss-source-link::before {
  content: "";
  width: 100%;
  height: 100%;
  display: block;
  background-color: currentColor;
  -webkit-mask: url("../icons/rss.svg") center / contain no-repeat;
  mask: url("../icons/rss.svg") center / contain no-repeat;
}

.rss-items {
  display: grid;
  gap: 10px;
  padding: 14px 16px 16px;
  overflow-y: auto;
  min-height: 0;
  align-content: start;
}

.rss-loading-state {
  display: grid;
  gap: 12px;
  align-content: start;
  padding-top: 2px;
}

.rss-loading-state p {
  margin: 0;
  color: var(--muted);
}

.rss-progress-track {
  position: relative;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
}

.rss-progress-bar {
  position: absolute;
  inset: 0 auto 0 -35%;
  width: 35%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent 0%, var(--accent) 45%, transparent 100%);
  animation: rss-progress-slide 1.2s ease-in-out infinite;
}

.rss-item {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  transition: transform 140ms ease, background 140ms ease;
  min-width: 0;
}

.rss-item:hover {
  transform: translateX(3px);
  background: #eee3be;
}

:root[data-theme="dark"] .rss-item:hover {
  background: #4a3d2d;
}

.rss-item strong,
.rss-item span,
.rss-item time {
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
}

.rss-item strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  font-size: 1.05rem;
  line-height: 1.35;
}

.rss-item time {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.2;
  text-align: right;
}

.rss-item span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-clamp: 3;
}

.empty-state,
.error-state {
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--muted);
}

.empty-state-rich {
  width: min(760px, 100%);
  min-height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: clamp(28px, 6vw, 56px);
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.empty-state-rich h3 {
  max-width: 18ch;
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
  line-height: 1.05;
}

.empty-state-rich p {
  margin: 0;
  max-width: 52ch;
  font-size: 1.02rem;
  line-height: 1.65;
}

.empty-state-welcome {
  background: transparent;
}

:root[data-theme="dark"] .empty-state-welcome {
  background: transparent;
}

.error-state {
  color: var(--warning);
}

@keyframes rss-progress-slide {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(320%);
  }
}

@media (max-width: 960px) {
  .panel-header {
    flex-direction: column;
  }

  .panel-note {
    text-align: left;
  }

  .hero-meta {
    width: 100%;
    justify-content: flex-start;
  }

  .control-chip-status {
    width: 100%;
  }
}

@media (max-width: 1100px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .hero-copy-block {
    width: 100%;
    grid-column: 1 / 2;
  }

  .menu-toggle {
    display: inline-flex;
    grid-column: 2 / 3;
    justify-self: end;
  }

  .hero-meta {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 3;
    width: min(280px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
  }

  .hero-meta.is-open {
    display: flex;
  }

  .control-chip,
  .control-chip-select,
  .control-chip-toggle,
  .control-chip-status {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 16px;
  }

  .panel {
    padding: 16px;
  }

  .control-chip,
  .control-chip-select,
  .control-chip-toggle {
    width: 100%;
  }
}
