/* InboxDetox web app — shared design system with the landing page and the
   Chrome extension popup: warm ivory background, deep teal ink, sage primary,
   peach accent, Satoshi type. Tokens mirror landing-page/index.html and
   src/popup/popup.css. */

:root {
  --bg: #F7F4EF;
  --surface: #FFFFFF;
  --surface-soft: #F3EEE7;
  --surface-hover: #EDE9E1;
  --line: rgba(16, 58, 54, 0.1);
  --line-strong: rgba(16, 58, 54, 0.2);
  --text: #103A36;
  --muted: #5E746F;
  --subtle: #879792;
  --sage: #8FB2A5;
  --sage-hover: #7EA294;
  --sage-soft: #DDE8E2;
  --sage-tint: rgba(143, 178, 165, 0.1);
  --peach: #F4B783;
  --peach-soft: #FBE7D5;
  --success: #2E7D6E;
  --success-surface: rgba(46, 125, 110, 0.08);
  --warning: #D38A47;
  --warning-surface: rgba(211, 138, 71, 0.1);
  --danger: #B95A4A;
  --danger-surface: rgba(185, 90, 74, 0.07);
  --focus-ring: rgba(143, 178, 165, 0.32);
  --shadow-sm: 0 1px 3px rgba(16, 58, 54, 0.06);
  --shadow-md: 0 6px 18px rgba(16, 58, 54, 0.08);
  --shadow-lg: 0 16px 42px rgba(16, 58, 54, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --radius-xl: 28px;
  --radius-pill: 999px;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Satoshi', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.landing-shell,
.app-shell {
  min-height: 100vh;
}

.landing-shell {
  display: grid;
  place-items: center;
  padding: 32px;
}

.landing-hero {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 28px;
}

.hero-copy,
.hero-panel,
.scan-card,
.summary-card,
.quick-win-card,
.sender-row,
.detail-card,
.filter-bar,
.settings-grid article,
.rail,
.section-block {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.hero-copy,
.hero-panel,
.scan-card,
.section-block,
.filter-bar {
  border-radius: var(--radius-xl);
}

.hero-copy,
.hero-panel {
  box-shadow: var(--shadow-md);
}

.hero-copy {
  padding: 48px;
}

.hero-panel {
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface-soft);
}

.eyebrow,
.metric-label,
.quick-type {
  margin: 0;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  font-weight: 700;
}

h1,
h2,
h3,
h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}

.hero-copy h1 {
  font-size: clamp(2.8rem, 6vw, 4.4rem);
  max-width: 14ch;
  margin-top: 16px;
}

.hero-text,
.screen-copy,
.trust-note,
.detail-note,
.sender-meta,
.filter-hint {
  color: var(--muted);
  line-height: 1.6;
}

.hero-text {
  max-width: 44ch;
  font-size: 1.05rem;
  margin: 24px 0 0;
}

.hero-actions,
.scan-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

/* Live-backend sign-in form on the landing hero */
.hero-actions.signin-form {
  display: grid;
  gap: 14px;
  max-width: 360px;
}

.signin-form .search-field span {
  font-size: 0.85rem;
  color: var(--muted);
}

.primary-btn,
.ghost-btn,
.action-chip,
.inline-link,
.rail-link {
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease,
    box-shadow 140ms ease;
}

.primary-btn {
  background: var(--sage);
  color: #FFFFFF;
  font-weight: 700;
  padding: 14px 22px;
  box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
  background: var(--sage-hover);
}

.ghost-btn,
.action-chip,
.rail-link {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line-strong);
  font-weight: 500;
  padding: 13px 18px;
}

.ghost-btn:hover,
.action-chip:hover,
.rail-link:hover {
  background: var(--surface-hover);
}

.ghost-btn.compact,
.action-chip,
.inline-link,
.rail-link {
  padding: 10px 14px;
}

.inline-link {
  background: transparent;
  color: var(--success);
  border: 0;
  padding-left: 0;
  font-weight: 600;
}

.primary-btn:hover,
.ghost-btn:hover,
.action-chip:hover,
.inline-link:hover,
.rail-link:hover {
  transform: translateY(-1px);
}

.hero-panel-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.steps {
  margin: 24px 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 24px;
}

.rail {
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-height: calc(100vh - 48px);
  position: sticky;
  top: 24px;
  box-shadow: var(--shadow-md);
}

.brand-block {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #FFFFFF;
  background: linear-gradient(135deg, var(--sage), var(--sage-hover));
}

.brand-block h1 {
  font-size: 1.6rem;
}

.rail-nav {
  display: grid;
  gap: 10px;
}

.rail-link {
  text-align: left;
  border-color: transparent;
  background: transparent;
}

.rail-link:hover {
  background: var(--sage-tint);
}

.rail-link.active {
  background: var(--sage-soft);
  border-color: transparent;
  color: var(--text);
  font-weight: 700;
}

.rail-note {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.stage {
  padding: 20px 8px 60px;
}

.screen-header {
  margin-bottom: 24px;
}

.screen-header h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  max-width: 16ch;
  margin-top: 14px;
}

.summary-grid,
.quick-win-grid,
.detail-grid,
.settings-grid {
  display: grid;
  gap: 18px;
}

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
}

.summary-card {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.summary-card span {
  color: var(--muted);
}

.summary-card strong {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 10px;
}

.section-block {
  padding: 24px;
  margin-bottom: 24px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.section-head h3 {
  font-size: 1.7rem;
  margin-top: 10px;
}

.quick-win-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.suggestions-list {
  display: grid;
  gap: 16px;
}

.suggestions-list .quick-win-card {
  background: var(--surface);
}

.lens-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.lens-row-home {
  margin-bottom: 0;
}

.lens-card {
  text-align: left;
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.lens-card strong {
  font-size: 1.05rem;
}

.lens-card span {
  color: var(--muted);
  line-height: 1.5;
}

.lens-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.lens-card.active {
  background: var(--sage-soft);
  border-color: rgba(143, 178, 165, 0.55);
}

.quick-win-card,
.sender-row,
.detail-card,
.filter-bar {
  border-radius: var(--radius-lg);
}

.quick-win-card,
.detail-card,
.filter-bar {
  padding: 20px;
}

.quick-win-card {
  background: var(--surface-soft);
}

.quick-win-card h4 {
  font-size: 1.25rem;
  margin: 10px 0;
}

.sender-table {
  display: grid;
  gap: 14px;
}

.sender-row {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 14px;
  align-items: center;
}

.sender-row:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.sender-name {
  font-weight: 700;
  margin: 0 0 4px;
}

.sender-metrics,
.sender-actions,
.progress-meta,
.scan-stats,
.impact-strip {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.sender-metrics,
.impact-strip {
  color: var(--muted);
}

.filter-bar {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.search-field {
  display: grid;
  gap: 8px;
}

.search-field input {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: 14px 16px;
}

.search-field input::placeholder {
  color: var(--subtle);
}

.scan-card {
  padding: 28px;
  max-width: 860px;
  box-shadow: var(--shadow-md);
}

.progress-track {
  height: 16px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  margin: 14px 0 18px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--success));
  border-radius: inherit;
}

.stat-pill {
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.stat-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.detail-grid {
  grid-template-columns: 1.2fr 0.9fr;
}

.detail-card.spotlight {
  grid-column: 1 / -1;
}

.detail-card h3 {
  font-size: 1.8rem;
  margin: 10px 0 14px;
}

.action-stack,
.subject-list {
  display: grid;
  gap: 12px;
}

.subject-list {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-card h3 {
  font-size: 1.35rem;
  margin: 10px 0 6px;
}

.history-row,
.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.history-sender,
.history-time {
  margin: 0;
  color: var(--muted);
}

.history-time {
  font-weight: 600;
}

.history-meta {
  margin-top: 14px;
}

.history-pill {
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 14px 18px;
  border-radius: var(--radius-pill);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  box-shadow: var(--shadow-lg);
}

.toast.error {
  background: var(--danger);
  color: #FFFFFF;
}

.toast .toast-action {
  margin-left: 12px;
  padding: 4px 12px;
  border: 1.5px solid rgba(247, 244, 239, 0.55);
  border-radius: var(--radius-pill);
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.redeem-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.redeem-row input {
  flex: 1;
  max-width: 240px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  text-transform: uppercase;
}

.redeem-row input::placeholder {
  text-transform: none;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--muted);
}

.settings-toggle select {
  font: inherit;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* --- Senders batch selection --- */

.row-select {
  width: 18px;
  height: 18px;
  accent-color: var(--sage);
  cursor: pointer;
  flex: none;
}

.sender-row.selected {
  border-color: var(--sage);
  background: var(--sage-tint);
}

/* Rows on the Senders screen carry a leading checkbox column and toggle
   selection on click */
.sender-row:has(.row-select) {
  grid-template-columns: 24px 1.4fr 0.8fr 0.8fr;
  cursor: pointer;
}

.select-all-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-label {
  color: var(--subtle);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  align-self: center;
  margin-right: 2px;
}

.batch-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  z-index: 40;
}

.batch-bar .batch-count {
  font-weight: 700;
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.batch-bar .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
  animation: pill-pulse 1.4s ease-in-out infinite;
}

.batch-bar .ghost-btn.danger-tint {
  background: var(--danger-surface);
  color: var(--danger);
  border-color: rgba(185, 90, 74, 0.35);
  font-weight: 600;
}

.batch-bar .ghost-btn.danger-tint:hover {
  background: rgba(185, 90, 74, 0.14);
}

.batch-bar .danger-solid,
.primary-btn.danger-solid {
  background: var(--danger);
  color: #fff;
}

.batch-bar .bar-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.batch-bar .bar-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.list-summary {
  color: var(--subtle);
  font-size: 0.85rem;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

/* --- Senders filter bar: segmented tabs + labeled dropdowns --- */

.tabs-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.view-tabs {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  overflow: hidden;
}

.view-tab {
  border: 0;
  padding: 11px 20px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.view-tab + .view-tab {
  border-left: 1px solid var(--line);
}

.view-tab:hover {
  background: var(--surface-hover);
}

.view-tab.active {
  background: var(--sage-soft);
  color: var(--text);
}

.list-controls {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
}

.list-controls .search-field.grow {
  flex: 1;
  min-width: 220px;
}

.control {
  display: grid;
  gap: 6px;
}

.control > span {
  font-size: 0.8rem;
  color: var(--muted);
}

.control select {
  font: inherit;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

/* The list dropdowns render at one uniform size, matched to the search box */
.list-controls .control select {
  width: 190px;
  height: 47px;
}

.list-controls .search-field input {
  height: 47px;
  box-sizing: border-box;
}

.control.inline {
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
}

.control.inline select {
  padding: 8px 12px;
}

.toggle-chip {
  align-self: end;
  padding: 12px 16px;
}

.unread-pct {
  font-style: normal;
  font-size: 0.78rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
}

.unread-pct.high {
  background: var(--warning-surface);
  color: var(--warning);
  font-weight: 700;
}

.chip.accent.active {
  background: var(--peach-soft);
  border-color: var(--peach);
  color: var(--text);
}

.rail-scan-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 14px;
  border: 1px solid var(--sage);
  border-radius: var(--radius-pill);
  background: var(--sage-tint);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.rail-scan-pill .pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
  animation: pill-pulse 1.4s ease-in-out infinite;
}

@keyframes pill-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* --- UI state primitives (loading / empty / error) --- */

.state-block {
  padding: 28px;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--line-strong);
  background: var(--surface-soft);
  margin-bottom: 24px;
}

.state-block h3 {
  font-size: 1.6rem;
  margin: 10px 0 12px;
}

.state-copy {
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 6px;
}

.state-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.empty-block.calm {
  border-color: rgba(46, 125, 110, 0.35);
  background: var(--success-surface);
}

.empty-block.calm .eyebrow {
  color: var(--success);
}

.error-block {
  border-color: rgba(185, 90, 74, 0.45);
  background: var(--danger-surface);
}

.error-block .eyebrow {
  color: var(--danger);
}

.error-code {
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.loading-block {
  border-style: solid;
  border-color: var(--line);
  background: var(--surface);
  display: grid;
  gap: 14px;
}

.skeleton-line {
  height: 16px;
  border-radius: var(--radius-pill);
  background: linear-gradient(
    90deg,
    rgba(16, 58, 54, 0.05),
    rgba(16, 58, 54, 0.11),
    rgba(16, 58, 54, 0.05)
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton-line.w-40 {
  width: 40%;
}

.skeleton-line.w-55 {
  width: 55%;
}

.skeleton-line.w-70 {
  width: 70%;
}

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

/* --- Status badges + chips --- */

.status-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  vertical-align: middle;
}

.status-badge.approved {
  color: var(--success);
  border-color: rgba(46, 125, 110, 0.4);
  background: var(--success-surface);
}

.status-badge.unsubscribed {
  color: var(--warning);
  border-color: rgba(211, 138, 71, 0.45);
  background: var(--warning-surface);
}

.status-badge.failed {
  color: var(--danger);
  border-color: rgba(185, 90, 74, 0.5);
  background: var(--danger-surface);
}

.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 8px 13px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.chip:hover {
  color: var(--text);
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.chip.active {
  background: var(--sage-soft);
  border-color: var(--sage);
  color: var(--text);
  font-weight: 700;
}

.filter-chips,
.scenario-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.scenario-row {
  margin-top: 12px;
}

.rail-note-copy {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 8px 0 0;
}

.category-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: -6px 0 24px;
}

.category-pill {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
}

.category-pill strong {
  color: var(--text);
}

/* --- Action affordances --- */

button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none !important;
}

.ghost-btn.danger {
  border-color: rgba(185, 90, 74, 0.4);
  color: var(--danger);
}

.ghost-btn.armed,
.action-chip.armed {
  background: rgba(185, 90, 74, 0.14);
  border-color: rgba(185, 90, 74, 0.55);
  color: var(--danger);
  font-weight: 700;
}

.detail-banner {
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 18px;
  border: 1px solid rgba(185, 90, 74, 0.4);
  background: var(--danger-surface);
  color: var(--danger);
  line-height: 1.5;
}

.support-copy {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  line-height: 1.5;
}

.scan-note {
  color: var(--muted);
  margin: 16px 0 0;
  line-height: 1.5;
}

.success-text {
  color: var(--success);
}

.danger-text {
  color: var(--danger);
}

.back-link {
  margin-bottom: 12px;
}

@media (max-width: 1080px) {
  .landing-hero,
  .app-shell,
  .summary-grid,
  .quick-win-grid,
  .detail-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes a horizontal top bar */
  .rail {
    min-height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 18px;
    margin-bottom: 18px;
  }

  .rail .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .rail .brand-block h1 {
    font-size: 1.25rem;
  }

  .rail-nav {
    display: flex;
    gap: 6px;
    margin-left: auto;
  }

  .rail-note {
    display: none;
  }

  .rail-scan-pill {
    margin-top: 0;
  }

  .sender-row,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  /* The :has(.row-select) desktop grid outranks plain .sender-row here */
  .sender-row:has(.row-select) {
    grid-template-columns: 24px 1fr;
    row-gap: 8px;
  }

  .sender-row:has(.row-select) .sender-metrics,
  .sender-row:has(.row-select) .sender-actions {
    grid-column: 2;
  }

  .stage {
    padding-top: 0;
    padding-bottom: 140px; /* room for the fixed batch bar */
  }
}

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

  .hero-copy,
  .hero-panel,
  .section-block,
  .scan-card,
  .detail-card,
  .filter-bar {
    padding: 20px;
  }

  .hero-copy h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 640px) {
  /* Tabs scroll horizontally instead of wrapping into a blob */
  .view-tabs {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-tab {
    flex: none;
    padding: 10px 14px;
  }

  /* Search + dropdowns stack full-width */
  .list-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .list-controls .control select {
    width: 100%;
  }

  /* Batch bar becomes a full-width bottom sheet */
  .batch-bar {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    flex-wrap: wrap;
    white-space: normal;
    justify-content: center;
    row-gap: 8px;
  }

  .batch-bar .batch-count {
    border-right: 0;
    padding-right: 0;
    flex-basis: 100%;
    text-align: center;
  }

  .toast {
    left: 12px;
    right: 12px;
    text-align: center;
  }

  .select-all-bar {
    flex-wrap: wrap;
    row-gap: 4px;
    padding: 6px 8px;
  }

  .list-summary {
    border-left: 0;
    padding-left: 0;
    flex-basis: 100%;
  }

  .scan-stats .stat-pill {
    flex: 1;
  }

  .hero-actions .primary-btn,
  .hero-actions .ghost-btn,
  .action-stack .primary-btn,
  .action-stack .ghost-btn {
    width: 100%;
    text-align: center;
  }
}

/* Auth mode switching (sign in / create account / forgot password) */
.auth-switch {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  opacity: 0.8;
}

/* "Filtered · clear" affordance when category/opened/search narrow the list */
.filters-clear {
  color: var(--warning);
  font-weight: 600;
}

.empty-clear {
  margin-top: 12px;
}
