:root {
  --bg: #ffffff;
  --bg-panel: #ffffff;
  --bg-soft: #f5f5f3;
  --ink: #1f1a17;
  --muted: #665d57;
  --line: rgba(61, 47, 39, 0.14);
  --accent: #c24c2c;
  --accent-deep: #7d2610;
  --shadow: 0 10px 24px rgba(63, 40, 20, 0.07);
  --headline-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --body-font: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 15px;
}

body {
  padding: 8px;
  padding-bottom: 100px;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  max-width: 560px;
  margin: 0 auto;
}

.topbar,
.panel,
.preferences-panel {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 14px;
  border-radius: 22px;
}

.topbar h1,
.panel h2,
.deck-story__title,
.mode-card__title,
.story-mini__title,
.board-section h3,
.narrate-card h3,
.saved-mini strong {
  margin: 0;
  font-family: var(--headline-font);
  line-height: 1.05;
}

.topbar h1 {
  font-size: clamp(1.65rem, 6vw, 2.25rem);
}

.kicker,
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-deep);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  font-weight: 700;
}

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

.home-stack {
  display: grid;
  gap: 12px;
}

.panel {
  padding: 14px;
  border-radius: 20px;
}

.panel--trending-home {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(249, 246, 242, 0.98)),
    linear-gradient(135deg, rgba(194, 76, 44, 0.04), rgba(93, 107, 67, 0.03));
}

body[data-consume-mode="cards"] .panel--trending-home {
  display: none;
}

body[data-consume-mode="cards"] .home-stack {
  min-height: 0;
}

body[data-consume-mode="cards"] .panel--stage {
  min-height: calc(100dvh - 148px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.panel__heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel__heading--tight {
  margin-bottom: 10px;
}

.panel__meta,
.story-mini__meta,
.mode-card__meta,
.deep-copy,
.narration-status,
.story-mini__summary,
.deck-story__summary,
.board-item__summary,
.saved-mini__summary,
.section-copy {
  color: var(--muted);
}

.button {
  padding: 11px 13px;
  border: 1px solid rgba(61, 47, 39, 0.18);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.98);
  color: var(--ink);
  cursor: pointer;
}

.button--primary {
  background: linear-gradient(135deg, var(--accent), #d77744);
  color: #fff9f5;
  border-color: transparent;
}

.button--quiet {
  background: rgba(240, 234, 228, 0.95);
}

.button--small {
  padding: 8px 11px;
  font-size: 0.84rem;
}

.icon-button {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(61, 47, 39, 0.18);
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.98);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 5px;
  cursor: pointer;
}

.icon-button span {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--ink);
}

.mode-stage {
  min-height: 62vh;
}

.mode-stage--scroll {
  max-height: 68vh;
  overflow: auto;
  padding-right: 2px;
}

.mode-stage--cards {
  min-height: calc(100dvh - 270px);
  max-height: calc(100dvh - 270px);
  overflow: hidden;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: min(calc(100% - 16px), 560px);
  padding: 10px;
  border-radius: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  z-index: 8;
}

.bottom-tab {
  border: 0;
  border-radius: 18px;
  background: transparent;
  padding: 10px 8px;
  display: grid;
  gap: 4px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}

.bottom-tab strong {
  font-size: 0.95rem;
  color: var(--ink);
}

.bottom-tab span {
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bottom-tab--active {
  background: rgba(255, 239, 230, 0.96);
  color: var(--accent-deep);
}

.cards-shell,
.bulletin-shell,
.narrate-shell,
.board-shell {
  display: grid;
  gap: 12px;
}

.cards-shell {
  min-height: 100%;
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto auto;
}

.deck-stack {
  position: relative;
  min-height: 100%;
  height: 100%;
  display: grid;
  align-items: stretch;
}

.deck-stack__ghost {
  position: absolute;
  left: 50%;
  width: calc(100% - 18px);
  height: 100%;
  border-radius: 24px;
  background: rgba(255, 248, 240, 0.82);
  border: 1px solid rgba(61, 47, 39, 0.1);
  transform: translateX(-50%);
}

.deck-stack__ghost--back {
  top: 20px;
  opacity: 0.5;
  width: calc(100% - 32px);
}

.deck-stack__ghost--front {
  top: 10px;
  opacity: 0.75;
  width: calc(100% - 22px);
}

.deck-story {
  position: relative;
  z-index: 2;
  min-height: 0;
  height: 100%;
  border-radius: 24px;
  border: 1px solid rgba(61, 47, 39, 0.14);
  background: #ffffff;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  touch-action: pan-y;
  transform: translate3d(var(--swipe-x, 0), var(--swipe-y, 0), 0) rotate(var(--swipe-rotate, 0deg));
  opacity: var(--swipe-opacity, 1);
  transition: transform 180ms ease, opacity 180ms ease;
  box-shadow: var(--shadow);
}

.deck-story--dragging {
  transition: none;
}
.deck-story__scroll {
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.deck-story__scroll::-webkit-scrollbar {
  width: 6px;
}

.deck-story__scroll::-webkit-scrollbar-thumb {
  background: rgba(61, 47, 39, 0.16);
  border-radius: 999px;
}

.deck-dock-wrap {
  position: relative;
}

.deck-dock-coachmark {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: calc(100% + 10px);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(61, 47, 39, 0.12);
  background: rgba(255, 252, 247, 0.98);
  box-shadow: 0 10px 22px rgba(63, 40, 20, 0.08);
  text-align: center;
}

.deck-dock-coachmark span,
.deck-swipe-dock span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
}

.deck-dock-coachmark strong {
  font-size: 0.84rem;
  font-weight: 600;
}

.deck-swipe-dock {
  display: grid;
  gap: 2px;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(61, 47, 39, 0.1);
  background: var(--bg-soft);
  text-align: center;
  touch-action: none;
}

.deck-swipe-dock strong {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.panel__heading--stage {
  align-items: start;
}

.panel__meta--stage {
  display: inline-block;
  margin-bottom: 10px;
}

.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.panel__actions--stage {
  justify-content: flex-end;
}

.topic-selector-panel {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: min(calc(100% - 16px), 560px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: var(--shadow);
  z-index: 11;
}

.saved-mini__header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.saved-mini__status {
  color: var(--accent-deep);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.deck-story__visual,
.story-mini__visual {
  min-height: 170px;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  color: #fff9f4;
}

.deck-story__visual span,
.story-mini__visual span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.deck-story__visual strong,
.story-mini__visual strong {
  font-family: var(--headline-font);
  font-size: 1.35rem;
}

.deck-story__meta,
.story-mini__meta,
.board-item__meta {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
}

.deck-story__title,
.story-mini__title,
.mode-card__title {
  font-size: 1.16rem;
}

.deck-story__summary,
.story-mini__summary,
.board-item__summary,
.saved-mini__summary,
.deep-copy,
.section-copy {
  line-height: 1.42;
  font-size: 0.94rem;
}



.story-actions,
.drawer-actions,
.quick-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-toggles--stacked {
  display: grid;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle input {
  width: auto;
}

.mode-card,
.board-section,
.narrate-card,
.story-mini,
.saved-mini,
.source-item {
  border: 1px solid rgba(61, 47, 39, 0.14);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.98);
}

.mode-card,
.board-section,
.narrate-card,
.story-mini,
.saved-mini,
.source-item {
  padding: 12px;
}

.mode-card__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  padding: 10px;
  border-radius: 14px;
  background: var(--bg-soft);
}

.metric-box span,
.metric-box strong {
  display: block;
}

.metric-box span {
  color: var(--muted);
  font-size: 0.78rem;
}

.metric-box strong {
  font-family: var(--headline-font);
  font-size: 1.28rem;
}

.board-section {
  display: grid;
  gap: 10px;
}

.board-section__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.board-item {
  padding-top: 10px;
  border-top: 1px solid rgba(61, 47, 39, 0.1);
}

.board-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.story-mini {
  display: grid;
  gap: 10px;
}

.chip-row,
.token-grid,
.source-list,
.saved-shelf,
.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  border: 1px solid rgba(61, 47, 39, 0.14);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.96);
  color: var(--ink);
  padding: 8px 12px;
  cursor: pointer;
}

.filter-chip--active {
  background: rgba(255, 239, 230, 0.94);
  border-color: rgba(194, 76, 44, 0.42);
  color: var(--accent-deep);
}

.filter-chip--muted {
  color: var(--muted);
}

.trend-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 84%);
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.trend-strip::-webkit-scrollbar {
  display: none;
}

.chip,
.token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(61, 47, 39, 0.14);
  background: rgba(255, 252, 247, 0.96);
  font-size: 0.86rem;
}

.chip--accent {
  background: rgba(255, 239, 230, 0.94);
  color: var(--accent-deep);
}

.token--muted {
  background: rgba(240, 234, 228, 0.88);
}

.token small {
  color: var(--muted);
}

.token button,
.source-item button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-deep);
  cursor: pointer;
}

.stacked-form,
label {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid rgba(61, 47, 39, 0.18);
  border-radius: 12px;
  background: rgba(255, 252, 247, 0.98);
  color: var(--ink);
}

.narration-status {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(61, 47, 39, 0.18);
}

.preferences-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 23, 18, 0.3);
  backdrop-filter: blur(2px);
  z-index: 9;
}

.preferences-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(100%, 420px);
  height: 100dvh;
  padding: 14px;
  overflow: auto;
  background: #ffffff;
  border-left: 1px solid var(--line);
  z-index: 10;
}

.preferences-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.menu-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.menu-nav__item {
  border: 1px solid rgba(61, 47, 39, 0.14);
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.98);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.menu-nav__item--active {
  background: rgba(255, 239, 230, 0.94);
  border-color: rgba(194, 76, 44, 0.42);
  color: var(--accent-deep);
}

.menu-section {
  display: none;
}

.menu-section--active {
  display: block;
}

.panel--drawer {
  margin-bottom: 12px;
}

.panel__heading--subsection {
  margin-top: 18px;
}

.drawer-actions--top-gap {
  margin-top: 14px;
}

.empty-state {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed rgba(61, 47, 39, 0.2);
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 560px) {
  body {
    padding: 8px;
    padding-bottom: 98px;
  }

  .topbar {
    padding: 12px;
  }

  .topbar__actions {
    align-self: stretch;
  }

  .button {
    width: 100%;
  }

  .topbar__actions .button,
  .story-actions .button,
  .drawer-actions .button {
    width: auto;
  }

  .bottom-nav {
    width: calc(100% - 16px);
    bottom: 8px;
  }

  .mode-card__grid,
  .menu-nav {
    grid-template-columns: 1fr;
  }

  .panel__actions--stage {
    width: 100%;
    justify-content: flex-start;
  }

  .topic-selector-panel {
    bottom: 8px;
    width: calc(100% - 16px);
  }
}

@media print {
  body {
    padding: 0;
    background: #fff;
  }

  .topbar__actions,
  .preferences-panel,
  .preferences-overlay,
  .narration-status,
  .bottom-nav,
  .story-actions,
  .deck-dock-coachmark {
    display: none !important;
  }

  .topbar,
  .panel,
  .deck-story,
  .mode-card,
  .story-mini,
  .board-section,
  .narrate-card,
  .saved-mini {
    box-shadow: none;
    background: #fff;
    border-color: rgba(0, 0, 0, 0.14);
  }
}
