@font-face {
  font-family: Melange;
  src: url(../fonts/melange-reg.woff2) format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Melange;
  src: url(../fonts/melange-semibold.woff2) format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Aime;
  src: url(../fonts/aime-400.woff2) format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Aime;
  src: url(../fonts/aime-600.woff2) format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #121212;
  --muted: #6e6a67;
  --red: #df2831;
  --red-hover: #c51f28;
  --line: #edebe8;
  --card: #fef7ed;
  --card-border: #f0e8df;
  --bg: #ffffff;
  --sans: "Manrope", "Melange", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Aime", Georgia, serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 620px;
  margin: 0 auto;
  position: relative;
  background: #fff;
}

.app-view {
  display: none;
  flex-direction: column;
  flex: 1;
  padding-bottom: 84px; /* Space for fixed bottom navigation bar */
}

.app-view.active {
  display: flex;
}

/* ===================================================
   TOPBAR & HEADER (HOME VIEW)
=================================================== */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fffffff5;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 4px;
}

.brand {
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -0.025em;
  line-height: 1;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  transition: color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  color: var(--red);
  background: rgba(223, 40, 49, 0.06);
}

/* Categories Bar with Red Active Line */
.categories-nav {
  display: flex;
  gap: 18px;
  padding: 0 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.categories-nav::-webkit-scrollbar {
  display: none;
}

.category-tab {
  background: none;
  border: 0;
  padding: 6px 0 8px;
  white-space: nowrap;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.category-tab[aria-current="true"] {
  color: var(--ink);
  border-color: var(--red);
}

[hidden] {
  display: none !important;
}

/* AI Reading Tracker Banner (disabled - background tracking only) */
.ai-reading-banner {
  display: none !important;
}

/* ===================================================
   FEED STORIES (CARDS)
=================================================== */
.feed-main {
  padding: 6px 8px 24px;
  flex: 1;
}

.status-msg {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 0;
  margin-bottom: 4px;
  min-height: 0;
}

.status-msg:empty {
  display: none;
  margin-bottom: 0;
}

.status-msg.error {
  color: #ba1a24;
}

.stories-feed {
  display: grid;
  gap: 16px;
}

.story-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}

.story-media-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 200px;
  background: #eee4dc;
  overflow: hidden;
}

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

.story-img-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 48px;
  font-weight: 700;
  color: var(--red);
  background: #faf0e6;
}

.story-content {
  padding: 12px 14px 10px;
}

.story-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.story-tag {
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.story-headline {
  font-family: var(--sans);
  font-size: clamp(19px, 4.8vw, 22px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 0 8px;
}

.story-desc {
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.45;
  color: #484340;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-time-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.story-time-icon {
  opacity: 0.7;
}

.story-bottom-action {
  border-top: 1px solid #ebd9c8;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.read-link {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

.feed-footer {
  text-align: center;
  padding: 28px 0 10px;
}

.load-more-btn {
  border: 1px solid var(--ink);
  background: #fff;
  padding: 10px 22px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.load-more-btn:hover {
  background: var(--ink);
  color: #fff;
}

/* Skeletons */
.skeleton-card {
  height: 480px;
  border-radius: 20px;
  background: linear-gradient(90deg, #f5f0ea, #eae3db, #f5f0ea);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

.empty-view-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}

/* ===================================================
   VIEW 2: SEARCH SCREEN
=================================================== */
.search-header {
  padding: 12px 14px 8px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.search-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.search-page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 2px;
}

.search-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #f4f3f0;
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
  margin-bottom: 8px;
}

.search-input-icon {
  color: var(--muted);
  margin-right: 8px;
  flex-shrink: 0;
}

.search-input-field {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
}

.search-input-field::placeholder {
  color: #9c9794;
}

.search-clear-btn {
  color: var(--muted);
  font-size: 15px;
  padding: 4px;
  margin-left: 6px;
}

/* Filter Pills */
.search-filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.search-filter-pills::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: #fff;
  border: 1px solid #dfdbd6;
  color: var(--ink);
  transition: all 0.15s ease;
}

.filter-pill.active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.search-main {
  padding: 10px 12px 24px;
}

.search-results-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.search-section-heading {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.search-counter {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Compact Horizontal Search Item */
.search-results-list {
  display: grid;
  gap: 18px;
}

.search-compact-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.search-item-left {
  flex: 1;
}

.search-item-cat {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 5px;
}

.search-item-title {
  font-size: 16.5px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-item-desc {
  font-size: 14.5px;
  color: #585350;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-item-source {
  font-size: 12px;
  color: var(--muted);
}

.search-item-thumb {
  width: 86px;
  height: 86px;
  border-radius: 14px;
  object-fit: cover;
  background: #eee4dc;
  flex-shrink: 0;
}

/* ===================================================
   VIEW 3: ASK AI SCREEN
=================================================== */
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-avatar-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: grid;
  place-items: center;
}

.ai-header-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.ai-header-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
}

.ai-header-actions {
  display: flex;
  gap: 8px;
}

.ai-main {
  flex: 1;
  padding: 24px 20px 20px;
  overflow-y: auto;
}

.ai-empty-container {
  max-width: 520px;
  margin: 20px auto 0;
}

.ai-hero-text {
  text-align: center;
  margin-bottom: 34px;
}

.ai-hero-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.ai-hero-desc {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.4;
  max-width: 360px;
  margin: 0 auto;
}

.prompt-cards-list {
  display: grid;
  gap: 12px;
}

.prompt-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  transition: all 0.15s ease;
}

.prompt-card:hover {
  border-color: #d1ccc5;
  background: #faf8f5;
  transform: translateY(-1px);
}

.prompt-card.highlight-card {
  background: #fbf5ee;
  border: 1.5px solid #ebd9c8;
  margin-bottom: 12px;
}

.prompt-card-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.prompt-icon {
  flex-shrink: 0;
}

.red-svg {
  color: var(--red);
}

.red-icon {
  font-size: 18px;
}

.prompt-card-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.prompt-chevron {
  font-size: 20px;
  color: var(--muted);
  margin-left: 10px;
}

/* Chat Messages */
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 540px;
  margin: 0 auto;
}

.chat-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  max-width: 88%;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.chat-bubble.assistant strong {
  font-weight: 700;
  color: #000;
}

.chat-bubble.assistant ul {
  margin: 8px 0;
  padding-left: 20px;
}

.chat-bubble.assistant li {
  margin-bottom: 4px;
}

/* AI Structured Response Styling */
.ai-response-title {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.ai-response-answer {
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.45;
  color: #2c2724;
}

.ai-response-answer p {
  margin-bottom: 8px;
}

.ai-response-answer p:last-child {
  margin-bottom: 0;
}

.ai-key-points {
  margin: 10px 0 8px;
  padding-left: 18px;
}

.ai-key-points li {
  font-size: 13.5px;
  color: #423d3a;
  line-height: 1.4;
  margin-bottom: 6px;
}

.ai-followup-container {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,0.08);
}

.ai-followup-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.ai-followup-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-followup-chip {
  background: #ffffff;
  border: 1px solid #ebd9c8;
  border-radius: 12px;
  padding: 8px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-followup-chip .chip-text {
  flex: 1;
  line-height: 1.35;
}

.ai-followup-chip:hover,
.ai-followup-chip:active {
  background: var(--red);
  color: #ffffff;
  border-color: var(--red);
}

.ai-followup-chip:hover .chip-arrow,
.ai-followup-chip:active .chip-arrow {
  color: #ffffff;
}

.ai-followup-chip.chip-clicked {
  opacity: 0.55;
  pointer-events: none;
  background: #fdf5ef;
}

.chip-arrow {
  color: var(--red);
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 6px;
}

/* Typing / Thinking indicator */
.ai-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.3s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

/* AI Bottom Fixed Input Bar */
.ai-input-bar {
  position: fixed;
  bottom: 64px; /* Sits directly on top of bottom nav */
  left: 0;
  right: 0;
  max-width: 620px;
  margin: 0 auto;
  background: #fffffff5;
  backdrop-filter: blur(14px);
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  z-index: 90;
}

.ai-input-container {
  display: flex;
  align-items: center;
  background: #f4f3f0;
  border-radius: 14px;
  padding: 4px 6px 4px 16px;
  gap: 8px;
}

.ai-input-field {
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}

.ai-input-field::placeholder {
  color: #9c9794;
}

.ai-send-button {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.ai-send-button:hover {
  background: var(--red-hover);
}

/* ===================================================
   CONVERSATIONS MODAL (BOTTOM DRAWER)
=================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 12px 24px 34px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
  animation: slide-up 0.25s ease-out;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 42px;
  height: 4.5px;
  border-radius: 999px;
  background: #d6d1cb;
  margin: 0 auto 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 21px;
  font-weight: 800;
  margin: 0;
}

.modal-close-btn {
  color: var(--ink);
  display: grid;
  place-items: center;
}

.empty-conversations {
  padding: 60px 0;
  text-align: center;
}

.empty-conv-icon {
  margin-bottom: 12px;
}

.empty-conv-text {
  font-size: 15px;
  color: var(--muted);
}

.conv-item {
  padding: 14px 16px;
  border-radius: 12px;
  background: #faf8f5;
  border: 1px solid var(--line);
  margin-bottom: 10px;
  cursor: pointer;
}

.conv-item-title {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.conv-item-time {
  font-size: 12px;
  color: var(--muted);
}

/* ===================================================
   FIXED BOTTOM NAVIGATION BAR
=================================================== */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fffffff8;
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  max-width: 620px;
  margin: 0 auto;
}

.nav-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #726d69;
  padding: 6px 16px;
  transition: color 0.15s ease;
  position: relative;
}

.nav-icon-wrap {
  display: grid;
  place-items: center;
  position: relative;
}

.nav-tab-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-tab-btn.active {
  color: var(--red);
}

.nav-tab-btn.active .nav-icon-wrap svg {
  stroke: var(--red);
}

/* ===================================================
   STABILITY FIXES (v15)
=================================================== */
/* iPhone home-indicator safe area (page uses viewport-fit=cover) */
.bottom-nav-bar {
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ai-input-bar {
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}

.app-view {
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

/* AI view: leave room for the fixed input bar + nav so answers aren't hidden */
#view-ai {
  padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

.chat-bubble {
  scroll-margin-top: 16px;
  scroll-margin-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  overflow-wrap: anywhere;
}

.chat-bubble.assistant em {
  font-style: italic;
}

.ai-send-button:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* Conversation rows are buttons now */
.conv-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}

.conv-item:hover {
  border-color: #d1ccc5;
}

.ai-retry-chip {
  margin-top: 10px;
  width: auto;
}

.empty-view-state .load-more-btn {
  margin-top: 14px;
}

.search-compact-item:focus-visible,
.prompt-card:focus-visible,
.conv-item:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}


/* Brief pop when "AI Sleeping" switches to "Ask AI" */
@keyframes ai-wake-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); }
  70% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.nav-tab-btn.ai-just-woke .nav-icon-wrap {
  animation: ai-wake-pop 0.6s ease-out 2;
}

@media (prefers-reduced-motion: reduce) {
  .nav-tab-btn.ai-just-woke .nav-icon-wrap { animation: none; }
}

/* "Summarize new articles" card under an ongoing chat */
.ai-new-reads {
  max-width: 540px;
  margin: 16px auto 0;
}

/* Conversations drawer grouped by day */
.conv-day + .conv-day {
  margin-top: 18px;
}

.conv-day-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 2px 8px;
}

.conv-item.is-current {
  border-color: var(--red);
  background: #fff;
}

/* ===================================================
   v20 — PHONE LAYOUT MATCHING THE ANDROID APP
=================================================== */
:root {
  --green: #1f9a55;
  --nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* ---- Header: "Newsfull" + search + refresh, then category tabs ---- */
.app-topbar {
  background: #fff;
  backdrop-filter: none;
  border-bottom: 0;
  flex: 0 0 auto;
}

.topbar-inner {
  padding: 12px 12px 2px 18px;
}

.brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-actions {
  gap: 6px;
}

.header-actions .icon-btn {
  width: 42px;
  height: 42px;
  color: #1b1b1b;
}

.header-actions .icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
  background: none;
}

.categories-nav {
  gap: 26px;
  padding: 2px 18px 0;
}

.category-tab {
  position: relative;
  padding: 8px 0 12px;
  font-size: 16px;
  font-weight: 500;
  color: #5d5955;
  border-bottom: 0;
}

.category-tab[aria-current="true"] {
  color: var(--ink);
  font-weight: 700;
}

.category-tab[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 2px;
  height: 3px;
  border-radius: 3px;
  background: var(--red);
}

/* ---- Home: a fixed screen; only the feed scrolls, one story at a time ---- */
#view-home.active {
  flex: 0 0 auto;     /* a flex item would otherwise grow to fit all cards */
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  padding-bottom: var(--nav-h);
  overflow: hidden;
}

#view-home .feed-main {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 16px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#view-home .feed-main::-webkit-scrollbar {
  display: none;
}

/* Status text is for screen readers only; the cards themselves show state */
#view-home .status-msg {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#view-home .stories-feed {
  display: block;
}

.story-card,
#view-home .skeleton-card,
.feed-message-card {
  height: var(--card-h, calc(100dvh - 210px));
  margin: 14px 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  scroll-margin-top: 14px;
}

.story-card {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid #f1e6da;
  background: #fdf6ee;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: none;
}

.story-card:hover {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.story-media-wrap {
  flex: 0 0 35%;
  max-height: none;
  aspect-ratio: auto;
  background: #ece6e0;
}

.story-content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 12px;
}

.story-meta-row {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 500;
  gap: 7px;
  margin-bottom: 9px;
  color: #6b6763;
  white-space: nowrap;
  overflow: hidden;
}

.story-meta-row span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-tag {
  font-weight: 800;
  letter-spacing: 0.06em;
}

.story-headline {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: clamp(19px, 5vw, 21px);
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Fills the room left in the card; JS sets the line count (≥7 on phones) */
.story-desc {
  flex: 1 1 auto;
  min-height: 0;
  font-size: 15.5px;
  line-height: 1.55;
  color: #57524e;
  margin: 0 0 6px;
  -webkit-line-clamp: 7;
}

.story-time-row {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: #7c7773;
  margin: 2px 0 10px;
}

.story-bottom-action {
  flex: 0 0 auto;
  border-top: 1px solid #eadccd;
  padding-top: 12px;
}

.read-link {
  font-size: 15px;
  font-weight: 700;
  gap: 8px;
}

.read-link:hover {
  text-decoration: none;
}

.read-link-chevron {
  flex: 0 0 auto;
}

/* Loading: one full-screen shimmer card, like the app */
#view-home .skeleton-card {
  border-radius: 18px;
  background: linear-gradient(110deg, #f1f1f1 20%, #f9f9f9 40%, #f1f1f1 60%);
  background-size: 250% 100%;
  animation: shimmer 1.4s linear infinite;
}

.feed-message-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: #fdf6ee;
  border: 1px solid #f1e6da;
  padding: 24px;
}

#view-home .feed-footer {
  padding: 0;
  scroll-snap-align: end;
}

#view-home .feed-footer .load-more-btn {
  margin: 4px auto 18px;
}

/* Small round spinner while the next stories load in the background */
.feed-more-spinner {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 26px);
  transform: translateX(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  display: grid;
  place-items: center;
  z-index: 60;
}

.feed-more-ring {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(223, 40, 49, 0.18);
  border-top-color: var(--red);
  animation: feed-spin 0.8s linear infinite;
}

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

/* ---- Bottom navigation ---- */
.bottom-nav-bar {
  background: #fff;
  backdrop-filter: none;
  border-top: 1px solid #ecebe9;
}

.nav-tab-btn {
  gap: 5px;
  min-width: 96px;
  color: #3d3a38;
}

.nav-tab-label {
  font-size: 12.5px;
  font-weight: 500;
}

.nav-tab-btn.active .nav-tab-label {
  font-weight: 700;
}

.nav-tab-btn.active .nav-icon-wrap svg {
  stroke: currentColor;
}

/* AI tab: one icon per state + three progress dots (top-right), like the app */
#tab-ai-icon-wrap svg {
  display: none;
}

#tab-ai-btn:not([data-ai-state]) #nav-icon-sleeping,
#tab-ai-btn[data-ai-state="sleeping"] #nav-icon-sleeping,
#tab-ai-btn[data-ai-state="listening"] #nav-icon-listening,
#tab-ai-btn[data-ai-state="ready"] #nav-icon-ready,
#tab-ai-btn[data-ai-state="ask"] #nav-icon-askai {
  display: block;
}

#tab-ai-btn[data-ai-state="listening"],
#tab-ai-btn[data-ai-state="ask"] {
  color: var(--red);
}

#tab-ai-btn[data-ai-state="ready"] {
  color: var(--green);
}

#tab-ai-btn[data-ai-state="listening"] .nav-tab-label,
#tab-ai-btn[data-ai-state="ready"] .nav-tab-label,
#tab-ai-btn[data-ai-state="ask"] .nav-tab-label {
  font-weight: 700;
}

.ai-dots {
  position: absolute;
  top: -3px;
  right: -14px;
  display: flex;
  gap: 2.5px;
}

.ai-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #cfcdcb;
  transition: background 0.25s ease;
}

#tab-ai-btn[data-dots="1"] .ai-dots i:nth-child(1),
#tab-ai-btn[data-dots="2"] .ai-dots i:nth-child(-n+2),
#tab-ai-btn[data-ai-state="ask"] .ai-dots i {
  background: var(--red);
}

#tab-ai-btn[data-ai-state="ready"] .ai-dots i {
  background: var(--green);
}

/* ---- Assistant: "Your reading insights" card (pink, like the app) ---- */
.ai-insights {
  display: block;
  background: #fde8e6;
  border-radius: 24px;
  padding: 22px 20px 18px;
  margin: 4px 0 26px;
}

.ai-insights[hidden] {
  display: none;
}

.ai-insights-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.ai-insights-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #fff;
  color: var(--red);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.ai-insights-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.ai-insights-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: #5d5753;
  margin-bottom: 14px;
}

.ai-insights-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.ai-insights-topic {
  background: #fff;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  padding: 7px 14px;
}

.ai-insights-actions {
  display: grid;
  gap: 10px;
}

.insight-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  background: #fff;
  border-radius: 13px;
  text-align: left;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 600;
}

.insight-action-icon {
  color: var(--red);
  flex: 0 0 auto;
}

.insight-action-text {
  flex: 1 1 auto;
}

.insight-action-chevron {
  color: var(--red);
  font-size: 24px;
  line-height: 1;
}

.insight-action:focus-visible,
.ai-clear-reading:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.ai-clear-reading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 4px 2px;
  font-size: 13.5px;
  font-weight: 500;
  color: #5d5753;
}

.ai-hero-text {
  margin-top: 4px;
}

/* ---- Publisher article viewer ---- */
.article-view {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: #fff;
  display: flex;
  flex-direction: column;
  max-width: 620px;
  margin: 0 auto;
}

.article-view[hidden] {
  display: none;
}

body.article-open {
  overflow: hidden;
}

.article-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
  border-bottom: 1px solid #ecebe9;
  flex: 0 0 auto;
}

.article-bar-titles {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.article-source {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-kind {
  font-size: 11.5px;
  color: #6b6763;
  margin-top: 2px;
}

.article-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  overflow: hidden;
  background: rgba(223, 40, 49, 0.12);
}

.article-progress span {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  background: var(--red);
  animation: article-progress 1.1s ease-in-out infinite;
}

@keyframes article-progress {
  from { left: -35%; }
  to { left: 100%; }
}

.article-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

.article-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.article-fallback {
  padding: 48px 28px;
  text-align: center;
}

.article-fallback-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 10px;
}

.article-fallback-text {
  font-size: 14.5px;
  line-height: 1.55;
  color: #5d5753;
  margin-bottom: 22px;
}

.article-fallback-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.article-btn {
  min-width: 128px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid #d9d4cf;
  background: #fff;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

.article-btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  #view-home .skeleton-card,
  .feed-more-ring,
  .article-progress span { animation-duration: 3s; }
}
