
/* --- Desktop (restored from feature/desktop-from-old) --- */
:root {
  color-scheme: light;
  --ink: #111a36;
  --muted: #69728a;
  --line: #edf0fa;
  --blue: #4452ff;
  --violet: #7a3cff;
  --teal: #20c8ad;
  --paper: #ffffff;
  --soft: #f8faff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

button {
  font: inherit;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(22px, 4vw, 48px);
}

.brief-board {
  position: relative;
  width: min(900px, 100%);
  min-height: calc(100vh - clamp(44px, 8vw, 96px));
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.site-header {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto 42px 32px;
  gap: 18px;
  align-items: center;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(16, 26, 55, 0.14));
}

.brand-lockup span {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 850;
}

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

.top-actions button,
.menu-panel button {
  height: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  padding: 0 12px;
  font-weight: 750;
}

.top-actions button:hover,
.menu-panel button:hover {
  color: var(--blue);
  background: var(--soft);
}

.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  place-content: center;
  gap: 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

.menu-button:hover {
  background: var(--soft);
}

.menu-button span {
  display: block;
  width: 15px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.menu-button span:nth-child(2) {
  width: 11px;
}

.profile-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 12px 24px rgba(68, 82, 255, 0.28);
}

.top-saved {
  height: 38px;
  border: 0;
  border-radius: 12px;
  padding: 0 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  font-weight: 800;
}

.menu-panel {
  position: absolute;
  top: 78px;
  right: 88px;
  z-index: 10;
  display: grid;
  width: 190px;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 45px rgba(30, 42, 92, 0.14);
}

.menu-panel[hidden] {
  display: none;
}

.menu-panel button {
  text-align: left;
}

.brief-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-top: clamp(42px, 7vw, 78px);
}

.headline-row {
  width: 100%;
  max-width: 760px;
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.date-label {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 650;
}

.menu-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--blue);
  font-size: 0.88rem;
  font-weight: 800;
}

.hero-badge {
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 18px;
  border: 1px solid rgba(237, 240, 250, 0.94);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(30, 42, 92, 0.06);
}

.hero-badge span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-badge strong {
  color: var(--ink);
  font-size: 1.02rem;
}

.category-tabs {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 18px;
  margin: 36px -2px 26px;
  padding: 10px 0;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  scrollbar-width: none;
}

body.detail-mode .brief-hero,
body.detail-mode .category-tabs,
body.detail-mode .archive-controls,
body.detail-mode .top-actions,
body.detail-mode .top-saved,
body.detail-mode .menu-button,
body.detail-mode .profile-dot {
  display: none;
}

.archive-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 28px 0 4px;
}

/* Desktop header compact controls (Archive pill + Saved) */
.top-compact-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.top-compact-controls .top-saved,
.top-compact-controls .archive-pill {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.98), var(--soft));
  color: var(--muted);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(23,34,72,0.04);
}

.top-compact-controls .archive-pill:hover {
  border-color: rgba(68,82,255,0.14);
  color: var(--blue);
}

.archive-controls label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.archive-controls select,
.archive-controls button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.archive-controls select {
  min-width: 150px;
  padding: 0 36px 0 12px;
}

.archive-controls button {
  padding: 0 13px;
}

.archive-controls button:hover {
  color: var(--blue);
  border-color: rgba(68, 82, 255, 0.28);
  background: var(--soft);
}

#archiveStatus {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

body.detail-mode .site-header {
  position: fixed;
  z-index: 80;
  top: 22px;
  left: clamp(22px, 4vw, 48px);
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab {
  flex: 0 0 auto;
  min-width: 42px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 750;
}

.category-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 10px 22px rgba(68, 82, 255, 0.24);
}

.story-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  width: min(760px, 100%);
}

.story-card {
  display: grid;
  gap: 16px;
  min-height: 0;
  padding: 18px 18px 16px;
  border: 1px solid rgba(237, 240, 250, 0.96);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 16px 38px rgba(30, 42, 92, 0.06);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(30, 42, 92, 0.1);
}

.story-card {
  cursor: pointer;
}

.story-image-frame {
  display: block;
  width: 100%;
  height: clamp(190px, 34vw, 320px);
  overflow: hidden;
  border-radius: 16px;
  background: var(--soft);
}

.story-image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.story-card:hover .story-image-frame img {
  transform: scale(1.025);
}

.story-topline,
.story-source {
  display: flex;
  align-items: center;
}

.story-topline {
  justify-content: space-between;
  gap: 14px;
}

.story-card-actions {
  position: relative;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.story-source > div {
  display: grid;
  gap: 3px;
}

.story-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.story-icon span {
  position: relative;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 5px;
  box-shadow: none;
}

.story-icon span::before,
.story-icon span::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 999px;
}

.story-icon span::before {
  left: 50%;
  top: -7px;
  bottom: -7px;
  width: 3px;
  transform: translateX(-50%);
}

.story-icon span::after {
  top: 50%;
  left: -7px;
  right: -7px;
  height: 3px;
  transform: translateY(-50%);
}

.story-icon.blue {
  background: linear-gradient(135deg, #3f49ff, #6e38ff);
}

.story-icon.teal {
  background: linear-gradient(135deg, #16c2a7, #49d98e);
}

.story-icon.violet {
  background: linear-gradient(135deg, #8a42ff, #5e39e8);
}

.story-icon.slate {
  background: linear-gradient(135deg, #eef1f8, #dce2ef);
}

.story-icon.slate span {
  border-color: #aeb7c8;
}

.story-icon.slate span::before,
.story-icon.slate span::after {
  background: #aeb7c8;
}

.story-copy {
  min-width: 0;
}

.story-copy h2 {
  margin: 10px 0 0;
  font-size: clamp(1.24rem, 3vw, 1.7rem);
  line-height: 1.28;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.story-copy p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue);
  background: rgba(68, 82, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 850;
}

.category-chip.Crypto {
  color: var(--violet);
  background: rgba(122, 60, 255, 0.08);
}

.category-chip.Sports {
  color: var(--teal);
  background: rgba(32, 200, 173, 0.1);
}

.category-chip.Anime {
  color: var(--violet);
  background: rgba(122, 60, 255, 0.08);
}

.source-button,
.back-button,
.card-source-button {
  border: 0;
  text-decoration: none;
}

.source-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  font-size: 0.84rem;
  font-weight: 850;
}

.card-action-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.card-source-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  font-size: 0.84rem;
  font-weight: 850;
}

.back-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 18px 0 12px;
  border: 1px solid rgba(224, 230, 246, 0.8);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(23, 34, 72, 0.05);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease, color 140ms ease;
  margin-bottom: 24px;
}

.back-button:hover {
  color: var(--blue);
  background: #fff;
  border-color: rgba(68, 82, 255, 0.2);
  box-shadow: 0 6px 22px rgba(68, 82, 255, 0.12);
  transform: translateY(-1px);
}

.back-button:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.8);
}

.story-detail {
  width: min(760px, 100%);
}

/* Fullscreen detail overlay used when opening AI summary as a dedicated page */
.story-detail.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: clamp(22px, 4vw, 48px);
  padding-top: 96px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  overflow: auto;
  box-shadow: none;
}

.detail-container {
  width: min(760px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.story-detail.fullscreen .detail-card {
  width: 100%;
}

.detail-card {
  display: grid;
  gap: 18px;
  padding-bottom: 38px;
}

.detail-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.detail-card h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.detail-image {
  width: 100%;
  max-height: 470px;
  object-fit: cover;
  border-radius: 22px;
  background: var(--soft);
  box-shadow: 0 18px 44px rgba(30, 42, 92, 0.08);
}

.detail-summary {
  display: grid;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}

.detail-summary strong {
  font-size: 0.86rem;
}

.detail-summary p {
  margin: 0;
  color: #26314d;
  font-family: "Comic Relief", system-ui, "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive;
  font-size: clamp(1.05rem, 2.3vw, 1.24rem);
  font-weight: 700;
  line-height: 1.62;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.source-button {
  justify-self: start;
}

.save-button,
.bookmark-button,
.export-button {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.save-button:hover,
.bookmark-button:hover,
.export-button:hover {
  background: var(--soft);
}

.save-button span,
.bookmark-button span {
  position: absolute;
  inset: 8px 8px;
  border: 2px solid #aab2c5;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
}

.save-button span::after,
.bookmark-button span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 10px;
  height: 10px;
  border-left: 2px solid #aab2c5;
  border-bottom: 2px solid #aab2c5;
  background: #fff;
  transform: translateX(-50%) rotate(-45deg);
}

.save-button.saved span,
.save-button.saved span::after,
.bookmark-button[aria-pressed="true"] span,
.bookmark-button[aria-pressed="true"] span::after {
  border-color: var(--blue);
}

.bookmark-button[aria-pressed="true"] {
  background: rgba(68, 82, 255, 0.08);
}

.share-control {
  position: relative;
  z-index: 4;
}

.export-button {
  background: rgba(245, 248, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(214, 221, 239, 0.8);
}

.export-button span {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 14px;
  height: 20px;
  border: 2px solid #9fa9bf;
  border-top: 0;
  border-radius: 0 0 4px 4px;
  transform: translateX(-50%);
}

.export-button span::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 11px;
  height: 11px;
  border-right: 2px solid #9fa9bf;
  border-bottom: 2px solid #9fa9bf;
  transform: translateX(-50%) rotate(45deg);
}

.export-button span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  width: 2px;
  height: 16px;
  border-radius: 999px;
  background: #9fa9bf;
  transform: translateX(-50%);
}

.export-button:hover span,
.export-button:hover span::before {
  border-color: var(--blue);
}

.export-button:hover span::after {
  background: var(--blue);
}

.share-menu {
  position: absolute;
  top: 43px;
  right: 0;
  display: grid;
  width: 138px;
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(224, 230, 244, 0.94);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(23, 34, 72, 0.14);
}

.share-menu[hidden] {
  display: none;
}

.share-menu button {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
}

.share-menu button:hover {
  color: var(--blue);
  background: var(--soft);
}

.action-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(320px, calc(100vw - 32px));
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid rgba(224, 230, 246, 0.92);
  border-radius: 999px;
  color: #071229;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(23, 34, 72, 0.18);
  font-size: 0.88rem;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.action-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 820px) {
  .app-shell {
    padding: 22px;
  }

  .brief-board {
    min-height: calc(100vh - 44px);
  }

  .site-header {
    grid-template-columns: minmax(0, 1fr) 42px 32px;
  }

  .top-actions {
    display: none;
  }

  .menu-button {
    display: grid;
  }

  .menu-panel {
    top: 74px;
    right: 70px;
  }

  .brief-hero {
    align-items: start;
    flex-direction: column;
    margin-top: 46px;
  }

  .hero-badge {
    width: 100%;
  }

}

@media (max-width: 520px) {
  .brand-lockup span {
    display: none;
  }

  h1 {
    font-size: 3.2rem;
  }

  .category-tabs {
    gap: 12px;
  }

  .story-card {
    padding: 14px;
  }

  .story-icon {
    width: 42px;
    height: 42px;
  }
}

/* Visual refresh */
:root {
  --ink: #071229;
  --muted: #657089;
  --line: #e7ecf6;
  --blue: #4257ff;
  --violet: #6f3cff;
  --teal: #23c9a7;
  --paper: #ffffff;
  --soft: #f4f7ff;
  --shadow-sm: 0 10px 28px rgba(23, 34, 72, 0.06);
  --shadow-md: 0 18px 46px rgba(23, 34, 72, 0.1);
  --shadow-lg: 0 28px 80px rgba(23, 34, 72, 0.14);
}

html {
  background: #f7f9fd;
}

body {
  background:
    radial-gradient(circle at 50% -10%, rgba(68, 82, 255, 0.08), transparent 34rem),
    linear-gradient(180deg, #fbfcff 0%, #f4f7fb 100%);
}

.app-shell {
  padding: clamp(18px, 3.4vw, 44px);
}

.brief-board {
  width: min(900px, 100%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 10px 0 14px;
  background: linear-gradient(180deg, rgba(251, 252, 255, 0.96), rgba(251, 252, 255, 0.76));
  backdrop-filter: blur(18px);
}

.brand-lockup {
  gap: 10px;
}

.brand-lockup img {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #fff;
  filter: drop-shadow(0 12px 22px rgba(7, 18, 41, 0.12));
}

.brand-lockup span {
  font-size: 1.18rem;
  letter-spacing: 0;
}

.top-saved,
.menu-button {
  height: 42px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.top-saved {
  padding: 0 16px;
  background: linear-gradient(135deg, #4357ff, #7040ff);
}

.brief-hero {
  align-items: end;
  margin-top: clamp(34px, 6vw, 62px);
  padding-bottom: 4px;
}

h1 {
  max-width: 760px;
  font-size: clamp(3.15rem, 8vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.date-label {
  color: #6a7489;
  font-size: 0.98rem;
}

.archive-controls {
  gap: 9px;
  margin: 26px 0 6px;
  padding: 10px;
  border: 1px solid rgba(231, 236, 246, 0.86);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(16px);
}

.archive-controls select,
.archive-controls button {
  min-height: 40px;
  border-color: rgba(209, 217, 235, 0.8);
  border-radius: 13px;
  box-shadow: inset 0 -1px 0 rgba(7, 18, 41, 0.03);
}

.archive-controls select:focus,
.archive-controls button:focus-visible,
.category-tab:focus-visible,
.story-card:focus-visible,
.card-source-button:focus-visible,
.source-button:focus-visible {
  outline: 3px solid rgba(68, 82, 255, 0.16);
  outline-offset: 2px;
}

.category-tabs {
  top: 66px;
  gap: 10px;
  margin: 18px -4px 18px;
  padding: 10px 4px;
  background: rgba(247, 249, 253, 0.86);
}

.category-tab {
  height: 40px;
  min-width: 52px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.category-tab:hover {
  color: var(--ink);
  border-color: rgba(209, 217, 235, 0.72);
  background: #fff;
}

.category-tab.active {
  box-shadow: 0 12px 26px rgba(68, 82, 255, 0.22);
}

.story-list {
  width: min(720px, 100%);
  margin: 0 auto;
  gap: 18px;
}

.story-card {
  position: relative;
  gap: 15px;
  padding: clamp(15px, 3vw, 20px);
  border-color: rgba(224, 230, 244, 0.88);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.story-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent 34%);
}

.story-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.story-image-frame {
  height: clamp(220px, 38vw, 345px);
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.story-image-frame img {
  filter: saturate(1.06) contrast(1.02);
}

.story-topline,
.story-copy,
.card-action-row {
  position: relative;
  z-index: 1;
}

.story-source strong {
  color: #071229;
  font-size: 0.96rem;
}

.story-source span {
  color: #7a8497;
}

.story-icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  box-shadow: 0 10px 22px rgba(23, 34, 72, 0.12);
}

.story-copy h2 {
  margin-top: 12px;
  color: #06122f;
  font-size: clamp(1.32rem, 3.4vw, 1.82rem);
  line-height: 1.22;
}

.story-copy p {
  color: #748099;
}

.category-chip {
  min-height: 30px;
  border: 1px solid rgba(68, 82, 255, 0.08);
  font-size: 0.76rem;
}

.card-source-button,
.source-button {
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 24px rgba(68, 82, 255, 0.22);
}

.save-button,
.export-button {
  border-radius: 13px;
}

.story-detail.fullscreen {
  background:
    radial-gradient(circle at 50% -12%, rgba(68, 82, 255, 0.08), transparent 34rem),
    linear-gradient(180deg, #fbfcff 0%, #f4f7fb 100%);
}

.story-detail.fullscreen .detail-card,
.story-detail.fullscreen .back-button {
  width: min(800px, 100%);
}

.detail-card {
  gap: 20px;
}

.detail-card h2 {
  color: #06122f;
  font-size: clamp(2.15rem, 6vw, 4.35rem);
}

.detail-image {
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}

.detail-summary {
  gap: 10px;
  padding: clamp(18px, 3vw, 24px);
  border-color: rgba(224, 230, 244, 0.92);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
}

.detail-summary strong {
  color: #071229;
}

.detail-summary p {
  color: #23304a;
}

/* Final UI tuning */
.app-shell {
  padding-top: clamp(14px, 2.4vw, 28px);
}

.brief-board {
  width: min(900px, 100%);
}

.site-header {
  padding: 6px 0 10px;
}

.brief-hero {
  width: min(760px, 100%);
  margin: clamp(18px, 3.6vw, 38px) auto 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(3.35rem, 7vw, 5.7rem);
  line-height: 0.98;
}

.archive-controls {
  width: min(760px, 100%);
  margin: 22px auto 0;
  padding: 9px 10px;
  border-radius: 18px;
}

.archive-controls label {
  padding-left: 0;
  color: #5f6b84;
}

.archive-controls select {
  min-width: 150px;
}

#archiveStatus {
  margin-left: 2px;
}

.category-tabs {
  width: min(760px, 100%);
  margin: 16px auto 18px;
  padding: 8px 0;
  background: transparent;
}

.category-tab {
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 20px rgba(23, 34, 72, 0.045);
}

.detail-summary p {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 650;
}

.detail-summary.Crypto p {
  font-family: "Space Grotesk", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1.04rem, 2.1vw, 1.2rem);
  font-weight: 600;
  line-height: 1.64;
}

/* Mobile-only refinements to match mock (≤ 640px) */
@media (max-width: 640px) {
  /* Ensure mobile-only blocks are visible */
  .mobile-only { display: block; }
  .desktop-only { display: none; }

  .story-card {
    padding: 14px;
    border-radius: 14px;
    gap: 8px;
  }


  .mobile-card-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .mobile-card-body {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
  }

  .mobile-card-text {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .mobile-card-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }

  .mobile-icons {
    display: flex;
    gap: 8px;
  }

  .mobile-card-image {
    width: 88px;
    min-width: 88px;
    height: 88px;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 0;
    align-self: flex-start;
    display: block;
  }

  .mobile-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    display: block;
  }

  .mobile-card-text h2 {
    margin: 0 0 6px;
    font-size: 1.06rem;
    line-height: 1.18;
    font-weight: 800;
  }

  .mobile-card-time {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
  }

  .mobile-card-image img {
    width: 88px;
    height: 88px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
  }

  /* Ensure image container is positioned for icon overlays */
  .mobile-card-image {
    position: relative;
    min-width: 88px;
    min-height: 88px;
    display: block;
  }

  .mobile-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
  }

  .mobile-action-btn {
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    border: 1px solid rgba(230,235,248,0.9);
    font-weight: 800;
    opacity: 0.9;
  }

  /* Make AI summary and Open source visually smaller and muted on mobile */
  .detail-summary strong { font-size: 0.82rem; }
  .detail-summary p { font-size: 0.96rem; opacity: 0.9; font-weight: 600; }

  /* Small bookmark and export icons - default styles (non-overlay) */
  .mobile-bookmark-btn,
  .mobile-export-icon {
    position: relative;
    top: auto;
    right: auto;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    border: 0;
    box-shadow: 0 8px 20px rgba(23,34,72,0.06);
    z-index: 2;
    color: #fff;
  }

  /* Give distinct colors: bookmark (teal/green), export/save (blue/violet) */
  .mobile-bookmark-btn,
  .mobile-export-icon {
    background: #f3eaff;
    color: #7040ff;
  }

  .mobile-bookmark-btn:active,
  .mobile-export-icon:active {
    background: #e3d6ff;
  }

  .story-card { position: relative; padding-top: 8px; }

  /* Archive button moved visually to header area on mobile */
  .mobile-archive-card { display: none; }
  .top-saved { margin-left: 8px; }

  /* Compact archive/date selector pill - shown in header area */
  .archive-controls { display: none; }

  /* Safe-area at bottom */
  .brief-board { padding-bottom: calc(env(safe-area-inset-bottom, 16px) + 20px); }
}

/* Compact header controls for mobile */
@media (max-width: 640px) {
  .top-compact-controls {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .top-compact-controls .top-saved,
  .top-compact-controls .archive-pill {
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid rgba(230,235,248,0.9);
    background: #fff;
    font-weight: 800;
    color: var(--muted);
    box-shadow: 0 8px 20px rgba(23,34,72,0.05);
  }

  .archive-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .archive-pill::after {
    content: '\25BE';
    font-size: 0.7rem;
    opacity: 0.7;
  }
}

.detail-summary.Sports p {
  font-family: "Barlow Condensed", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(1.26rem, 2.6vw, 1.48rem);
  font-weight: 600;
  line-height: 1.38;
}

.detail-summary.Anime p {
  font-family: "Comic Relief", system-ui, "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive;
  font-size: clamp(1.05rem, 2.3vw, 1.24rem);
  font-weight: 700;
  line-height: 1.62;
}

@media (max-width: 820px) {
  .brief-hero {
    margin-top: 30px;
  }
}

@media (max-width: 520px) {
  .brief-hero {
    margin-top: 22px;
  }

  .archive-controls {
    gap: 8px;
  }

  #archiveStatus {
    flex-basis: 100%;
    padding-left: 2px;
  }

  .category-tabs {
    margin-top: 12px;
  }
}

@media (max-width: 820px) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .brief-hero {
    margin-top: 34px;
  }

  .archive-controls {
    padding: 9px;
  }
}

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

  h1 {
    font-size: 3.4rem;
  }

  .top-saved {
    padding: 0 12px;
  }

  .archive-controls {
    align-items: stretch;
  }

  .archive-controls select {
    flex: 1 1 140px;
    min-width: 0;
  }

  .story-image-frame {
    height: clamp(205px, 62vw, 280px);
  }

  .detail-card h2 {
    font-size: 2.25rem;
  }
}

/* Mobile: inline icons next to category chip and ensure image is pushed down */
@media (max-width: 640px) {
  .mobile-card-text {
    display: block;
    gap: 8px;
  }

  .mobile-card-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .mobile-icons {
    display: inline-flex;
    gap: 8px;
    align-items: center;
  }

  .mobile-icons button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    display: inline-grid;
    place-items: center;
  }

  .mobile-card-image {
    margin-top: 12px;
  }
}


/* ============================================================
   MOBILE REDESIGN -- matches the premium app mockup
   Applies at <= 640px
   ============================================================ */

/* Show/hide helpers */
.desktop-only { display: block; }
.mobile-only  { display: none; }

.story-topline.desktop-only {
  display: flex;
}

.card-action-row.desktop-only {
  display: flex;
}

@media (max-width: 640px) {
  .desktop-only { display: none !important; }
  .mobile-only  { display: revert; }

  body {
    background:
      radial-gradient(circle at 72% 8%, rgba(68, 120, 255, 0.07), transparent 48%),
      radial-gradient(circle at 14% 88%, rgba(110, 60, 255, 0.05), transparent 42%),
      linear-gradient(180deg, #f8faff 0%, #f1f5fb 100%);
  }

  .app-shell {
    padding: 0 0 32px;
  }

  .brief-board {
    width: 100%;
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 18px 12px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(224, 230, 246, 0.6);
    box-shadow: 0 4px 24px rgba(23, 34, 72, 0.06);
  }

  .brand-lockup img {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .brand-lockup span {
    font-size: 1.22rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    display: block;
  }

  .top-saved {
    height: 36px;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 0.86rem;
    font-weight: 800;
    background: linear-gradient(135deg, #4357ff, #7040ff);
    box-shadow: 0 8px 18px rgba(68, 82, 255, 0.26);
  }

  .brief-hero {
    display: none;
  }

  .archive-controls {
    display: none;
    width: calc(100% - 36px);
    margin: 0 18px 16px;
    padding: 11px 12px;
    border-radius: 16px;
  }

  .archive-controls.mobile-open {
    display: flex;
  }

  .category-tabs {
    top: 66px;
    gap: 0;
    margin: 0;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1.5px solid rgba(224, 230, 246, 0.7);
    overflow-x: auto;
  }

  .category-tab {
    position: relative;
    height: 46px;
    min-width: auto;
    padding: 0 14px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #8a93ab;
    font-size: 0.92rem;
    font-weight: 700;
    box-shadow: none;
    white-space: nowrap;
    transition: color 180ms ease;
  }

  .category-tab::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 12px;
    right: 12px;
    height: 2.5px;
    border-radius: 999px;
    background: var(--blue);
    opacity: 0;
    transform: scaleX(0.4);
    transition: opacity 200ms ease, transform 200ms ease;
  }

  .category-tab.active {
    color: var(--blue);
    background: transparent;
    box-shadow: none;
  }

  .category-tab.active::after {
    opacity: 1;
    transform: scaleX(1);
  }

  .category-tab:hover:not(.active) {
    color: var(--ink);
    border-color: transparent;
    background: transparent;
  }

  .story-list {
    width: 100%;
    margin: 0;
    gap: 0;
    padding: 10px 0 0;
  }

  .story-card {
    gap: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    border-bottom: 1px solid rgba(224, 230, 246, 0.7);
    background: transparent;
    box-shadow: none;
    overflow: visible;
    transition: background 140ms ease;
  }

  .story-card::before {
    display: none;
  }

  .story-card:hover {
    transform: none;
    box-shadow: none;
    background: rgba(68, 82, 255, 0.025);
  }

  .story-card:active {
    background: rgba(68, 82, 255, 0.05);
  }

  .mobile-card-inner {
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  .mobile-card-body {
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* top-align text with image */
    gap: 12px;
    padding: 15px 18px 8px;
  }

  .mobile-card-actions {
    display: flex;
    gap: 10px;
    padding: 0 18px 15px;
  }

  .mobile-action-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
    border: 0;
    transition: background 180ms ease, transform 100ms ease;
  }

  .mobile-action-btn.source-btn {
    background: var(--soft);
    color: var(--ink);
    border: 1px solid rgba(224, 230, 246, 0.8);
  }

  .mobile-action-btn.source-btn:active {
    background: #eef2fa;
    transform: scale(0.97);
  }

  .mobile-action-btn.summary-btn {
    background: linear-gradient(135deg, var(--blue), var(--violet));
    color: #fff;
    box-shadow: 0 4px 14px rgba(68, 82, 255, 0.2);
  }

  .mobile-action-btn.summary-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 6px rgba(68, 82, 255, 0.15);
  }

  .mobile-card-text {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    justify-content: flex-start; /* force content to the top */
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
  }

  /* Top-line: category chip left, icons right */
  .mobile-card-topline {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* chip and icons aligned left */
    width: 100%;
    gap: 8px;
    flex-wrap: nowrap; /* keep chip and icons on same row */
  }

  .mobile-icons {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: 8px; /* sit next to the chip */
  }

  .mobile-bookmark-btn,
  .mobile-export-icon {
    width: 36px;
    height: 36px;
    padding: 6px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent; /* keep existing color/design untouched */
    box-shadow: none;
  }

  /* When a story is saved, show active color on the bookmark icon */
  .mobile-bookmark-btn[aria-pressed="true"] {
    color: var(--violet);
  }

  .mobile-card-text .category-chip {
    align-self: flex-start;
    min-height: 22px;
    padding: 0 8px;
    border: 0;
    font-size: 0.66rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 6px;
  }

  .mobile-card-text .category-chip.Crypto {
    color: #5b4fff;
    background: rgba(91, 79, 255, 0.1);
  }

  .mobile-card-text .category-chip.Sports {
    color: #0eaa8c;
    background: rgba(14, 170, 140, 0.1);
  }

  .mobile-card-text .category-chip.Anime {
    color: #8b35e0;
    background: rgba(139, 53, 224, 0.1);
  }

  .mobile-card-text h2 {
    margin: 0;
    color: #06122f;
    font-size: 1.0rem;
    font-weight: 750;
    line-height: 1.35;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
  }

  .mobile-card-time {
    display: block;
    margin-top: 2px;
    color: #8a93ab;
    font-size: 0.8rem;
    font-weight: 650;
  }

  .mobile-card-image {
    flex: 0 0 105px;
    width: 105px;
    height: 105px;
    border-radius: 16px;
    overflow: hidden;
    background: #eef1fa;
    box-shadow: 0 8px 20px rgba(23, 34, 72, 0.1);
    align-self: flex-start; /* ensure image stays top-aligned */
  }

  /* Action buttons should sit below the top row and span full width */
  .mobile-card-actions {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    width: 100%;
  }

  .mobile-action-btn {
    flex: 1 1 0;
  }

  .mobile-card-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 180ms ease;
  }

  .story-card:active .mobile-card-image img {
    transform: scale(1.04);
  }

  .mobile-archive-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: calc(100% - 36px);
    margin: 18px 18px 0;
    padding: 16px 16px 16px 14px;
    border: 1px solid rgba(224, 230, 246, 0.9);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(23, 34, 72, 0.07);
    backdrop-filter: blur(12px);
    text-align: left;
    cursor: pointer;
    transition: box-shadow 160ms ease, transform 160ms ease;
  }

  .mobile-archive-card:hover {
    box-shadow: 0 14px 34px rgba(23, 34, 72, 0.11);
    transform: translateY(-1px);
  }

  .mobile-archive-card:active {
    transform: scale(0.98);
    box-shadow: 0 4px 12px rgba(23, 34, 72, 0.08);
  }

  .mobile-archive-icon {
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    color: var(--blue);
    background: rgba(68, 82, 255, 0.08);
  }

  .mobile-archive-text {
    flex: 1 1 0;
    min-width: 0;
  }

  .mobile-archive-text strong {
    display: block;
    color: #06122f;
    font-size: 1.0rem;
    font-weight: 800;
    letter-spacing: -0.01em;
  }

  .mobile-archive-text span {
    display: block;
    margin-top: 2px;
    color: #8a93ab;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.4;
  }

  .mobile-archive-chevron {
    display: flex;
    align-items: center;
    color: var(--blue);
    opacity: 0.85;
  }

  body.detail-mode .site-header {
    display: none !important;
  }

  .story-detail.fullscreen {
    padding: 18px 16px 40px;
    background: #f8faff;
  }

  .story-detail.fullscreen .detail-card {
    width: 100%;
    padding: 0;
    gap: 16px;
  }

  .detail-card h2 {
    font-size: 1.7rem;
    line-height: 1.15;
  }

  .detail-image {
    border-radius: 18px;
    max-height: 240px;
  }

  .detail-summary {
    padding: 16px;
    border-radius: 18px;
  }

  .detail-summary p {
    font-size: 1.0rem;
    line-height: 1.58;
  }

  .source-button {
    min-height: 46px;
    font-size: 0.94rem;
    border-radius: 14px;
    justify-self: stretch;
    text-align: center;
  }

  #archiveStatus {
    display: none;
  }

  .empty-state {
    margin: 28px 18px;
    border-radius: 18px;
  }
}
