:root {
  --color-bg: #f6f9ff;
  --color-surface: #ffffff;
  --color-surface-strong: #edf5ff;
  --color-primary: #0757b8;
  --color-primary-strong: #063f86;
  --color-secondary: #008c8c;
  --color-accent: #ffd447;
  --color-text: #102033;
  --color-muted: #4f6278;
  --color-border: #c9d9ee;
  --color-danger: #a61b1b;
  --shadow-soft: 0 18px 50px rgba(7, 87, 184, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --focus-ring: 0 0 0 4px rgba(0, 140, 140, 0.28);
  --max-width: 1120px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #071526;
    --color-surface: #0f2238;
    --color-surface-strong: #132b46;
    --color-primary: #6fb0ff;
    --color-primary-strong: #9bccff;
    --color-secondary: #62d6d0;
    --color-accent: #ffe06a;
    --color-text: #edf6ff;
    --color-muted: #bdd0e4;
    --color-border: #284764;
    --shadow-soft: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(0, 140, 140, 0.16), transparent 32rem), var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}
button, input { font: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 50;
  transform: translateY(-150%);
  background: var(--color-primary-strong);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}
.skip-link:focus { transform: translateY(0); outline: none; box-shadow: var(--focus-ring); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(100%, var(--max-width));
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
  padding-bottom: 6rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.brand { display: flex; gap: 0.875rem; align-items: center; min-width: 0; }
.brand-mark {
  width: 3.1rem;
  height: 3.1rem;
  display: grid;
  place-items: center;
  border-radius: 1.1rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  font-weight: 900;
  letter-spacing: -0.05em;
  box-shadow: var(--shadow-soft);
}
.eyebrow, .hero-kicker, .panel-label {
  margin: 0;
  color: var(--color-secondary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand h1 {
  margin: 0.1rem 0 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.1;
}

.icon-button, .text-button, .search button, .favorite-toggle {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  min-height: 44px;
}
.icon-button, .search button {
  background: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1rem;
}
.text-button {
  background: var(--color-surface-strong);
  color: var(--color-primary-strong);
  padding: 0.65rem 0.9rem;
}
button:focus-visible, input:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus-ring); }
button:active { transform: translateY(1px); }

.hero {
  background: linear-gradient(135deg, var(--color-primary-strong), var(--color-primary));
  color: #fff;
  border-radius: var(--radius-xl);
  padding: clamp(1.35rem, 5vw, 3rem);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -8rem -9rem auto;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
}
.hero-kicker { color: #aef1ea; }
.hero h2 {
  margin: 0.45rem 0 1.2rem;
  max-width: 16ch;
  font-size: clamp(2rem, 8vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}
.search {
  display: flex;
  gap: 0.65rem;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  padding: 0.45rem;
  border-radius: 999px;
  max-width: 48rem;
  position: relative;
  z-index: 1;
}
.search input {
  min-width: 0;
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 0.85rem 1rem;
  color: var(--color-text);
  background: #fff;
}
.search button { background: var(--color-accent); color: #1b2b3e; }

.quick-actions {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding: 1rem 0 0.2rem;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  padding: 0.72rem 1rem;
  min-height: 44px;
  white-space: nowrap;
  cursor: pointer;
  font-weight: 800;
}
.chip.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.panel {
  margin-top: 1rem;
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: clamp(1rem, 3vw, 1.45rem);
  backdrop-filter: blur(16px);
}
@media (prefers-color-scheme: dark) {
  .panel { background: rgba(15,34,56,0.82); }
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-head h2 { margin: 0.12rem 0 0; font-size: clamp(1.25rem, 3vw, 1.75rem); }
.status { color: var(--color-muted); margin: 0.5rem 0 1rem; }
.status.error { color: var(--color-danger); font-weight: 700; }

.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.posts-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.post-card {
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(9, 40, 82, 0.08);
}
.post-link { display: block; text-decoration: none; height: 100%; }
.post-image {
  aspect-ratio: 16 / 10;
  background: var(--color-surface-strong);
  width: 100%;
  object-fit: cover;
  display: block;
}
.post-body { padding: 1rem; }
.post-category {
  display: inline-flex;
  color: var(--color-primary-strong);
  background: var(--color-surface-strong);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 900;
  margin-bottom: 0.6rem;
}
.post-title { margin: 0; font-size: 1rem; line-height: 1.25; letter-spacing: -0.02em; }
.post-excerpt { margin: 0.65rem 0 0; color: var(--color-muted); font-size: 0.92rem; }
.card-actions { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-top: 1rem; }
.read-more { color: var(--color-primary-strong); font-weight: 900; font-size: 0.92rem; }
.favorite-toggle {
  background: var(--color-surface-strong);
  color: var(--color-primary-strong);
  padding: 0.4rem 0.65rem;
  min-height: 38px;
}
.favorite-toggle[aria-pressed="true"] { background: var(--color-accent); color: #1b2b3e; }

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: none;
  width: min(calc(100% - 1.5rem), 34rem);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  padding: 0.45rem;
  z-index: 10;
}
.bottom-nav button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  border-radius: 999px;
  min-height: 44px;
  font-weight: 900;
}
.bottom-nav button[aria-current="page"] { background: var(--color-primary); color: #fff; }
.noscript { padding: 1rem; background: var(--color-danger); color: #fff; }

@media (max-width: 860px) {
  .posts-grid, .posts-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .app-shell { padding: 0.9rem; padding-bottom: 6rem; }
  .app-header { align-items: flex-start; }
  .search { flex-direction: column; border-radius: var(--radius-lg); }
  .search input, .search button { width: 100%; border-radius: var(--radius-md); }
  .posts-grid, .posts-grid.compact { grid-template-columns: 1fr; }
  .bottom-nav { display: flex; }
  .text-button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
