:root {
  color-scheme: light dark;
  --bg: #efeee9;
  --surface: #ffffff;
  --text: #16181d;
  --text-soft: #3a3f47;
  --muted: #646b75;
  --border: #e4e3de;
  --accent: #ea580c;
  --accent-text: #c2410c;
  --accent-soft: #ffedd5;
  --chip-active-bg: #16181d;
  --chip-active-text: #ffffff;
  --placeholder-from: #fed7aa;
  --placeholder-to: #fdba74;
  --placeholder-text: #7c2d12;
  --skeleton: #ecebe6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d0f;
    --surface: #17191c;
    --text: #eceef1;
    --text-soft: #c9cdd3;
    --muted: #9aa1ab;
    --border: #2a2d32;
    --accent: #fb923c;
    --accent-text: #fdba74;
    --accent-soft: #3a2314;
    --chip-active-bg: #eceef1;
    --chip-active-text: #17191c;
    --placeholder-from: #431407;
    --placeholder-to: #7c2d12;
    --placeholder-text: #fed7aa;
    --skeleton: #24272b;
  }
}

/* Dark chosen in Settings, whatever the system says. Same values as above. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0d0f;
  --surface: #17191c;
  --text: #eceef1;
  --text-soft: #c9cdd3;
  --muted: #9aa1ab;
  --border: #2a2d32;
  --accent: #fb923c;
  --accent-text: #fdba74;
  --accent-soft: #3a2314;
  --chip-active-bg: #eceef1;
  --chip-active-text: #17191c;
  --placeholder-from: #431407;
  --placeholder-to: #7c2d12;
  --placeholder-text: #fed7aa;
  --skeleton: #24272b;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

@media (min-width: 560px) {
  .app {
    border-inline: 1px solid var(--border);
  }
}

/* Top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 2px 16px;
}

.brand {
  background: none;
  border: 0;
  padding: 4px 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  cursor: pointer;
}

.brand-dot {
  color: var(--accent);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--bg);
}

/* Category chips */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--chip-active-bg);
  border-color: var(--chip-active-bg);
  color: var(--chip-active-text);
}

/* Feed: one card per screen, swipe or scroll to the next */

.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  outline: none;
}

.card {
  height: 100%;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  border-bottom: 1px solid var(--border);
}

.card-media {
  position: relative;
  flex: 0 0 34%;
  min-height: 120px;
  overflow: hidden;
  background: var(--skeleton);
}

.card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  background: linear-gradient(135deg, var(--placeholder-from), var(--placeholder-to));
  color: var(--placeholder-text);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.badge {
  position: absolute;
  left: 16px;
  bottom: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.68);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
}

.card-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px 12px;
  overflow: hidden;
}

.card-title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.card-summary {
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1.6;
  hyphens: auto;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.pill {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
}

.card-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  color: var(--accent-text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

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

/* Loading and empty states */

.status-card {
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* Short phones: give the text more room */

@media (max-height: 700px) {
  .card-media {
    flex-basis: 28%;
  }
  .card-body {
    gap: 8px;
    padding-top: 14px;
  }
  .card-title {
    font-size: 1.125rem;
  }
  .card-summary {
    font-size: 0.9375rem;
    line-height: 1.5;
  }
}

/* Settings */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  background: rgb(0 0 0 / 0.4);
}

.sheet[hidden] {
  display: none;
}

.sheet-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  height: 100%;
  background: var(--surface);
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px;
  border-bottom: 1px solid var(--border);
}

.sheet-title {
  flex: 1;
  margin: 0;
  padding-inline-start: 8px;
  font-size: 1.25rem;
}

.icon-button[hidden] {
  display: none;
}

.menu {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 16px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: start;
  cursor: pointer;
}

.menu-row:hover {
  background: var(--bg);
}

.menu-label {
  font-weight: 600;
}

.menu-value {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 0.9375rem;
}

.menu-row svg {
  flex: none;
  color: var(--muted);
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}

.section-title {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.search:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.option-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 12px 4px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: start;
  cursor: pointer;
}

.option:hover {
  background: var(--bg);
}

.option-label {
  font-weight: 600;
}

.language-native {
  font-weight: 600;
}

.language-english {
  color: var(--muted);
  font-size: 0.875rem;
}

.option-check {
  margin-inline-start: auto;
  align-self: center;
  color: var(--accent-text);
  visibility: hidden;
}

.option[aria-selected="true"] .option-check {
  visibility: visible;
}

.about {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.875rem;
}

.notice {
  margin-top: 16px;
  line-height: 1.55;
}

/* Install row and guide (same layout as TuteNest's install sheet) */

.row-icon,
.step-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.menu-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.menu-desc {
  color: var(--muted);
  font-size: 0.8125rem;
}

.guide-title {
  margin: 16px 0 4px;
  font-size: 1.125rem;
  line-height: 1.3;
}

.guide-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-text {
  flex: 1;
  min-width: 0;
  padding-top: 7px;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.step-number {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.guide-note {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.guide-small {
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.primary-button,
.secondary-button {
  display: block;
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:disabled {
  opacity: 0.6;
}

.secondary-button {
  margin-top: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent-text);
}

/* Loading screen: the logo, until the first news is in. */

.splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: opacity 0.25s ease;
}

.splash[hidden] {
  display: none;
}

.splash.is-leaving {
  opacity: 0;
}

.splash-logo {
  width: 96px;
  height: 96px;
  animation: splash-pulse 1.4s ease-in-out infinite;
}

@keyframes splash-pulse {
  50% {
    transform: scale(0.92);
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-logo {
    animation: none;
  }
}

/* The first-launch "turn on alerts" ask: a sheet from the bottom on phones. */

.ask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 0.45);
}

.ask[hidden] {
  display: none;
}

.ask-panel {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: var(--surface);
}

@media (min-width: 560px) {
  .ask {
    align-items: center;
  }
  .ask-panel {
    border-radius: 20px;
  }
}

.ask-bell {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
}

.ask-title {
  margin: 0 0 4px;
  font-size: 1.25rem;
  line-height: 1.3;
}

.ask-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.ask-error {
  margin: 0 0 12px;
  color: #dc2626;
  font-size: 0.875rem;
}

.secondary-button[hidden] {
  display: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
