/* ─────────────────────────────────────────────────────────────
   Translation Ops — Archival Paper
   Warm cream surface, ink-on-paper hierarchy, single 朱 accent.
   Aesthetic direction: a translator's ledger. Not a dashboard.
   ───────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;

  /* Surfaces — layered warm paper, tinted toward amber */
  --paper:        oklch(0.965 0.008 82);
  --paper-elev:   oklch(0.990 0.005 85);
  --paper-sunk:   oklch(0.940 0.012 80);
  --paper-deep:   oklch(0.905 0.015 78);

  /* Ink — deep warm brown-black, never pure */
  --ink:          oklch(0.235 0.018 55);
  --ink-strong:   oklch(0.155 0.022 50);
  --ink-soft:     oklch(0.420 0.016 62);
  --muted:        oklch(0.585 0.012 68);
  --muted-soft:   oklch(0.705 0.010 72);

  /* Rules — hairlines, perceptible but quiet */
  --rule:         oklch(0.860 0.012 80);
  --rule-strong:  oklch(0.780 0.015 76);
  --rule-ghost:   oklch(0.915 0.010 82);

  /* 朱 shuiro — the only hot accent. Use for demand-attention states. */
  --shu:          oklch(0.555 0.170 32);
  --shu-strong:   oklch(0.475 0.165 30);
  --shu-soft:     oklch(0.935 0.055 38);
  --shu-rule:     oklch(0.780 0.085 35);

  /* 藍 aiiro — indigo for positive/ready states. Calm counterweight. */
  --ai:           oklch(0.420 0.090 245);
  --ai-strong:    oklch(0.340 0.100 248);
  --ai-soft:      oklch(0.940 0.025 240);
  --ai-rule:      oklch(0.780 0.055 245);

  /* 墨 sumi — quiet neutral for "waiting" states */
  --sumi-soft:    oklch(0.920 0.005 70);
  --sumi-rule:    oklch(0.830 0.008 68);

  /* Type */
  --font-display: "Shippori Mincho B1", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
  --font-body:    "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Spatial scale — 4pt base */
  --space-2xs: 4px;
  --space-xs:  8px;
  --space-sm:  12px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Geometry */
  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
  --radius-xl: 10px;

  /* Safe-area insets — handle notch + home indicator on iOS */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ─────────────────────────────────────────────────────────────
   Base
   ───────────────────────────────────────────────────────────── */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.65;
  font-feature-settings: "palt" 1, "kern" 1;
  -webkit-tap-highlight-color: transparent;
}

/* Very soft paper grain. Low opacity, low chroma. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 20% 30%, oklch(0.88 0.020 78 / 0.35), transparent 55%),
    radial-gradient(circle at 85% 75%, oklch(0.86 0.025 70 / 0.28), transparent 50%);
  mix-blend-mode: multiply;
  opacity: 0.55;
}

body > * { position: relative; z-index: 1; }

::selection { background: var(--shu-soft); color: var(--ink-strong); }

*::-webkit-scrollbar { width: 12px; height: 12px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 999px;
  border: 3px solid var(--paper);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--rule-strong); background-clip: padding-box; border: 3px solid var(--paper); }

/* ─────────────────────────────────────────────────────────────
   Typography
   ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink-strong);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

/* CJK glyphs need room. Line-height 1.4+ everywhere they appear.
   Normal word-break so characters don't shear, and overflow-wrap as fallback. */
h1, h2, h3,
.kanban-card-title,
.lead-summary-header h3,
.detail-section summary h3,
pre,
.draft-box pre,
.draft-box .detail-copy,
.detail .detail-copy,
.event-item,
.reply-box {
  word-break: normal;
  overflow-wrap: anywhere;
}

.eyebrow, .section-kicker, .topbar-menu-kicker, .metric-label {
  margin: 0;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

p { margin: 0; }

a {
  color: var(--ai);
  text-decoration: underline;
  text-decoration-color: var(--ai-rule);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}
a:hover { color: var(--ai-strong); text-decoration-color: var(--ai-strong); }

code {
  font-family: "SFMono-Regular", ui-monospace, Consolas, monospace;
  font-size: 0.9em;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--ink);
}

/* ─────────────────────────────────────────────────────────────
   Buttons + Inputs
   ───────────────────────────────────────────────────────────── */

button, .button-link, input, select, textarea { font: inherit; }

button, .button-link {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--paper-elev);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 60ms ease;
}

button:hover, .button-link:hover {
  background: var(--paper-sunk);
  border-color: var(--ink-soft);
  color: var(--ink-strong);
}

button:active, .button-link:active { transform: translateY(0.5px); }

button:disabled, .button-link:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  background: var(--paper-elev);
  color: var(--muted);
  border-color: var(--rule);
}

button.primary, .button-link.primary {
  background: var(--ink-strong);
  color: var(--paper-elev);
  border-color: var(--ink-strong);
  font-weight: 600;
}
button.primary:hover, .button-link.primary:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-elev);
}

button.secondary, .button-link.secondary {
  background: var(--paper-elev);
  color: var(--ink);
  border-color: var(--rule-strong);
}
button.secondary:hover, .button-link.secondary:hover {
  background: var(--paper-sunk);
  border-color: var(--ink-soft);
}

input, select, textarea {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--paper-elev);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
textarea {
  height: auto;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.75;
}
input::placeholder, textarea::placeholder { color: var(--muted-soft); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink-soft);
  background: var(--paper-elev);
  box-shadow: 0 0 0 3px oklch(0.92 0.012 78);
}

select {
  appearance: none;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 14px) 14px, calc(100% - 9px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.checkbox-row { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.checkbox-row input { width: auto; height: auto; accent-color: var(--shu); }

/* ─────────────────────────────────────────────────────────────
   Shell + Topbar
   ───────────────────────────────────────────────────────────── */

.app-shell, .app-shell-kanban {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--space-md) var(--space-lg) var(--space-2xl);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.topbar-slim {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0 var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--rule);
}

.title-block { min-width: 0; }
.title-block .eyebrow { margin-bottom: 4px; }
.title-block h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: var(--ink-strong);
}
.topbar-slim .title-block h1 { font-size: 22px; }

.topbar-status-pills {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.topbar-actions {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  justify-content: flex-end;
}

/* "More" dropdown */
.topbar-advanced { position: relative; }
.topbar-advanced summary {
  list-style: none;
  cursor: pointer;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--paper-elev);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}
.topbar-advanced summary::-webkit-details-marker { display: none; }
.topbar-advanced summary:hover { background: var(--paper-sunk); border-color: var(--ink-soft); }

.topbar-advanced-actions {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 260px;
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--paper-elev);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 40px -20px oklch(0.30 0.02 60 / 0.22);
}
.topbar-menu-group { display: grid; gap: 6px; }
.topbar-menu-group + .topbar-menu-group {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
}
.topbar-menu-kicker { margin: 0 0 4px; font-size: 9.5px; color: var(--muted); }
.topbar-menu-group button {
  width: 100%;
  justify-content: flex-start;
  height: 30px;
  font-size: 12.5px;
}

/* ─────────────────────────────────────────────────────────────
   Status pills + Autopilot
   ───────────────────────────────────────────────────────────── */

.status-pill, .mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-elev);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.mini-pill { height: 20px; padding: 0 8px; font-size: 10.5px; }

.status-pill.ready, .mini-pill.ready {
  background: var(--ai-soft);
  color: var(--ai-strong);
  border-color: var(--ai-rule);
}
.status-pill.warn, .mini-pill.warn {
  background: var(--shu-soft);
  color: var(--shu-strong);
  border-color: var(--shu-rule);
}
.status-pill.accent, .mini-pill.accent {
  background: var(--paper-sunk);
  color: var(--ink-strong);
  border-color: var(--rule-strong);
}

.autopilot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-elev);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}
.autopilot-toggle:hover { border-color: var(--ink-soft); color: var(--ink-strong); }
.autopilot-toggle.is-on {
  background: var(--ai-soft);
  border-color: var(--ai-rule);
  color: var(--ai-strong);
}
.autopilot-toggle.is-off {
  background: var(--paper-elev);
  border-color: var(--rule);
  color: var(--muted);
}
.autopilot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-soft);
  flex-shrink: 0;
  transition: background 200ms ease, box-shadow 200ms ease;
}
.autopilot-toggle.is-on .autopilot-dot {
  background: var(--ai);
  box-shadow: 0 0 0 2px var(--ai-soft);
  animation: pulse-dot 2.8s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px var(--ai-soft); }
  50%      { box-shadow: 0 0 0 5px oklch(0.90 0.04 245 / 0.55); }
}
.autopilot-state { font-weight: 600; font-size: 10.5px; letter-spacing: 0.1em; }

/* ─────────────────────────────────────────────────────────────
   Autopilot progress strip
   ───────────────────────────────────────────────────────────── */

.autopilot-progress {
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  position: relative;
}
.autopilot-progress.is-hidden { display: none; }
.autopilot-progress.is-running { border-color: var(--shu-rule); background: var(--shu-soft); }
.autopilot-progress.is-off { opacity: 0.6; }

.autopilot-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
}
.autopilot-progress-head h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
  margin: 2px 0 0;
}
.autopilot-progress-meta {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.autopilot-progress-track {
  margin-top: 10px;
  height: 3px;
  border-radius: 999px;
  background: var(--paper-sunk);
  overflow: hidden;
}
.autopilot-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--shu);
  transition: width 240ms ease;
}
.autopilot-progress-detail {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ─────────────────────────────────────────────────────────────
   Banners
   ───────────────────────────────────────────────────────────── */

.gmail-banner {
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid var(--shu-rule);
  border-radius: var(--radius-md);
  background: var(--shu-soft);
  color: var(--shu-strong);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  gap: 10px;
  align-items: center;
}
.gmail-banner.is-hidden { display: none; }
.gmail-banner::before {
  content: "●";
  color: var(--shu);
  font-size: 16px;
  line-height: 0;
}
.gmail-banner a { color: var(--shu-strong); text-decoration-color: var(--shu-rule); font-weight: 600; }
.gmail-banner a:hover { color: var(--shu); text-decoration-color: var(--shu); }

.flash-message {
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-md);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper-elev);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.flash-message.is-hidden { display: none; }
.flash-message.success { background: var(--ai-soft); border-color: var(--ai-rule); color: var(--ai-strong); }
.flash-message.error { background: var(--shu-soft); border-color: var(--shu-rule); color: var(--shu-strong); }
.flash-message.info { background: var(--sumi-soft); border-color: var(--sumi-rule); color: var(--ink-soft); }

/* ─────────────────────────────────────────────────────────────
   Status panel (metrics strip)
   ───────────────────────────────────────────────────────────── */

.status-panel {
  overflow: hidden;
  max-height: 420px;
  transition: max-height 220ms ease, opacity 160ms ease, margin 160ms ease;
  margin-bottom: var(--space-md);
}
.status-panel.is-collapsed {
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  pointer-events: none;
}
.status-panel-body {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}
.status-panel-col .section-kicker { margin-bottom: var(--space-xs); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.metric-grid-slim { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.metric-card {
  padding: 10px 12px;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 60px;
  justify-content: space-between;
}
.metric-label { font-size: 9.5px; }
.metric-card strong {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}

/* Status / integration tiles */
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.status-grid-slim { gap: 8px; }
.status-tile, .info-item {
  padding: 10px 12px;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.status-tile span, .info-item span {
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
}
.status-tile strong, .info-item strong {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0;
  word-break: break-word;
}

/* ─────────────────────────────────────────────────────────────
   Kanban
   ───────────────────────────────────────────────────────────── */

.kanban { display: flex; flex-direction: column; gap: var(--space-sm); min-height: 0; }

.kanban-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.kanban-toolbar-left, .kanban-toolbar-right {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  flex-wrap: wrap;
}
.kanban-toolbar input[type="search"] { width: 260px; height: 32px; }
.kanban-toolbar select { height: 32px; }
.kanban-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.kanban-toggle input { accent-color: var(--shu); }

.kanban-board {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: var(--space-sm);
  min-height: 60vh;
}

.kanban-loading {
  flex: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-style: italic;
  letter-spacing: 0.04em;
  padding: var(--space-lg);
}

.kanban-column {
  flex: 0 0 320px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  max-height: calc(100dvh - 220px);
  min-height: 300px;
}

.kanban-column-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--rule-strong);
  margin-bottom: var(--space-xs);
}
.kanban-column-title {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-strong);
}
.kanban-column-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-soft);
  transform: translateY(-2px);
}
.kanban-column[data-stage="prep"]     .kanban-column-title::before { background: var(--muted); }
.kanban-column[data-stage="approval"] .kanban-column-title::before { background: var(--shu); }
.kanban-column[data-stage="ready"]    .kanban-column-title::before { background: var(--ink-strong); }
.kanban-column[data-stage="waiting"]  .kanban-column-title::before { background: var(--muted-soft); }
.kanban-column[data-stage="reply"]    .kanban-column-title::before { background: var(--ai); }
.kanban-column[data-stage="delivery"] .kanban-column-title::before { background: var(--ai-strong); }
.kanban-column[data-stage="won"]      .kanban-column-title::before { background: var(--rule-strong); }
.kanban-column[data-stage="archived"] .kanban-column-title::before { background: var(--shu-strong); }

.kanban-column-count {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  background: transparent;
  padding: 0;
}

.kanban-column-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 2px 4px;
}
.kanban-column-body:empty::after {
  content: "—";
  display: block;
  text-align: center;
  color: var(--muted-soft);
  font-size: 14px;
  padding: 24px 8px;
  letter-spacing: 0.2em;
}

/* Kanban card */
.kanban-card {
  width: 100%;
  text-align: left;
  height: auto;
  padding: 12px 14px;
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  display: grid;
  gap: 6px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.kanban-card:hover {
  background: var(--paper-elev);
  border-color: var(--ink-soft);
  transform: none;
  color: var(--ink-strong);
}
.kanban-card.active {
  background: var(--paper-elev);
  border-color: var(--ink-strong);
  box-shadow: inset 2px 0 0 var(--shu);
}
.kanban-card-title {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink-strong);
  letter-spacing: 0.005em;
  padding: 1px 0 0;
}
.kanban-card-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.kanban-card-meta .dot { color: var(--rule-strong); }
.kanban-card-score {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.kanban-card-next {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* ─────────────────────────────────────────────────────────────
   Detail drawer
   ───────────────────────────────────────────────────────────── */

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  border-left: 1px solid var(--rule-strong);
  z-index: 40;
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 280ms cubic-bezier(0.2, 0.9, 0.2, 1);
  overflow: hidden;
  box-shadow: -18px 0 40px -24px oklch(0.30 0.02 60 / 0.25);
}
.detail-drawer.is-hidden { transform: translateX(100%); pointer-events: none; }

.detail-drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-elev);
}

.detail-drawer .detail {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg) var(--space-lg) var(--space-2xl);
}

.icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--paper-sunk); border-color: var(--ink-soft); color: var(--ink-strong); }

.detail { display: grid; gap: var(--space-lg); }

.detail.empty {
  align-content: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2xl);
  font-style: italic;
}

/* Next-action banner */
.next-action-banner {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  letter-spacing: 0.005em;
}
.next-action-banner::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.next-action-amber { background: var(--shu-soft); color: var(--shu-strong); border-color: var(--shu-rule); }
.next-action-amber::before { background: var(--shu); }
.next-action-green { background: var(--ai-soft); color: var(--ai-strong); border-color: var(--ai-rule); }
.next-action-green::before { background: var(--ai); }
.next-action-grey  { background: var(--sumi-soft); color: var(--ink-soft); border-color: var(--sumi-rule); }
.next-action-grey::before { background: var(--muted-soft); }

/* Lead summary — type on paper, hairline rule, no nested card */
.lead-summary {
  padding: 0 0 var(--space-md);
  border: 0;
  background: transparent;
  border-bottom: 1px solid var(--rule);
  position: relative;
  overflow: visible;
}
.lead-summary::before { display: none; }

.lead-summary-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: flex-start;
}

.lead-summary-header { min-width: 0; flex: 1; }

.lead-summary-header h3 {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.2vw, 1.85rem);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.005em;
  color: var(--ink-strong);
  margin: 0;
  padding: 3px 0 0;
}

.lead-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.lead-summary-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
}
.lead-summary-link a { color: var(--ai); }

.lead-summary-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mini-link {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  background: var(--paper-elev);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  letter-spacing: 0.02em;
}
.mini-link:hover {
  border-color: var(--ink-soft);
  color: var(--ink-strong);
  background: var(--paper-sunk);
  text-decoration: none;
}

.lead-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

/* Action cluster (typographic, no chrome) */
.action-cluster { padding: 0; border: 0; background: transparent; }

.action-cluster-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.action-cluster-head h3 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-strong);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.action-note, .summary-hint, .helper-text {
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  font-style: italic;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-xs);
}

/* Primary approval — filled 朱. The attention color. */
[data-action="approve-outreach"],
[data-action="approve-reply"],
[data-action="approve-final-deliverable"] {
  background: var(--shu);
  border-color: var(--shu);
  color: oklch(0.98 0.01 80);
  font-weight: 600;
}
[data-action="approve-outreach"]:hover,
[data-action="approve-reply"]:hover,
[data-action="approve-final-deliverable"]:hover {
  background: var(--shu-strong);
  border-color: var(--shu-strong);
  color: oklch(0.98 0.01 80);
}

/* Send — commitment color (ink) */
[data-action="send-outreach"],
[data-action="send-reply"],
[data-action="send-preview-link"] {
  background: var(--ink-strong);
  border-color: var(--ink-strong);
  color: var(--paper-elev);
  font-weight: 600;
}

/* Reject — ghost with shu */
[data-action="reject-outreach"],
[data-action="reject-reply"],
[data-action="reject-final-deliverable"] {
  background: transparent;
  color: var(--shu-strong);
  border-color: var(--shu-rule);
}
[data-action="reject-outreach"]:hover,
[data-action="reject-reply"]:hover,
[data-action="reject-final-deliverable"]:hover {
  background: var(--shu-soft);
  border-color: var(--shu);
  color: var(--shu-strong);
}

/* Note panel (decision block) */
.action-cluster-compact { padding: 0; border: 0; background: transparent; }
.decision-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}
.decision-block { display: grid; gap: 6px; }
.decision-block label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 700;
}
.decision-block label strong { color: var(--ink-soft); }

/* ─────────────────────────────────────────────────────────────
   Detail sections (collapsible)
   ───────────────────────────────────────────────────────────── */

.detail-section {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule);
  border-radius: 0;
  overflow: clip;
  padding-top: var(--space-md);
  margin-top: 0;
}

.detail-section > *:not(summary) { padding: 0; }

.detail-section summary {
  list-style: none;
  cursor: default;
  padding: 0 0 var(--space-sm);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
}
.detail-section summary::-webkit-details-marker { display: none; }
.detail-section summary::after { content: ""; }
.detail-section summary h3 {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.detail-collapsible summary { cursor: pointer; }
.detail-collapsible summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.2px solid var(--muted);
  border-bottom: 1.2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 200ms ease;
}
.detail-collapsible[open] summary::after { transform: rotate(225deg); }

.detail-section-body { display: grid; gap: var(--space-md); }

/* Draft box */
.draft-box {
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: grid;
  gap: 10px;
}
.draft-box strong {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin: 0;
}
.draft-box .detail-copy {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--ink-strong);
  letter-spacing: 0.01em;
}
.draft-box .detail-hint {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 2px solid var(--rule);
  background: var(--paper-sunk);
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.draft-box input, .draft-box textarea {
  width: 100%;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.75;
  padding: 10px 12px;
}

/* The draft letter itself. Body-font, generous leading. */
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 2.0;
  letter-spacing: 0.015em;
  color: var(--ink);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-feature-settings: "palt" 0;
}

/* Reply + event boxes */
.reply-box, .event-item {
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.75;
}
.reply-list { display: grid; gap: var(--space-xs); grid-template-columns: 1fr; }
.reply-box strong {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}
.reply-next-step {
  margin-top: var(--space-xs);
  padding: 8px 10px;
  background: var(--ai-soft);
  border: 1px solid var(--ai-rule);
  border-radius: var(--radius-sm);
  color: var(--ai-strong);
  font-size: 12px;
  line-height: 1.65;
}

.event-list { display: grid; gap: 6px; }
.compact-list .event-item { padding: 8px 12px; font-size: 12px; }
.event-item strong { color: var(--ink-strong); font-weight: 600; }

/* Preview */
.preview-shell {
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  display: grid;
  gap: var(--space-sm);
}
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.preview-frame {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
}

/* ─────────────────────────────────────────────────────────────
   Modal
   ───────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: oklch(0.30 0.015 60 / 0.42);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh var(--space-md);
  overflow-y: auto;
}
.modal-overlay.is-hidden { display: none; }
.modal-card {
  width: min(640px, 100%);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -24px oklch(0.25 0.02 60 / 0.32);
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--rule);
}
.modal-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-strong);
}
.modal-tabs {
  display: flex;
  gap: 2px;
  padding: 0 var(--space-md);
  border-bottom: 1px solid var(--rule);
}
.modal-tab {
  background: transparent;
  border: 0;
  height: 42px;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  position: relative;
  border-radius: 0;
}
.modal-tab:hover { color: var(--ink-strong); background: transparent; border: 0; }
.modal-tab.is-active { color: var(--ink-strong); background: transparent; }
.modal-tab.is-active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--shu);
}
.modal-body { padding: var(--space-lg); }
.modal-panel { display: none; }
.modal-panel.is-active { display: block; }
.modal-lede {
  color: var(--ink-soft);
  font-size: 13px;
  margin-bottom: var(--space-md);
  line-height: 1.75;
}
.modal-field-grid {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.modal-field-grid label {
  display: grid;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: var(--space-sm);
}
.modal-panel textarea { width: 100%; min-height: 200px; font-family: var(--font-body); font-size: 13px; line-height: 1.7; }

.modal-form { display: grid; gap: var(--space-xs); grid-template-columns: 1fr 1fr; }
.modal-form textarea { grid-column: 1 / -1; }
.modal-form .modal-actions { grid-column: 1 / -1; }

/* Auto-source block inside modal */
.auto-source-box {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}
.auto-source-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}
.auto-source-head h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-strong);
}
.auto-source-controls { display: flex; gap: 6px; flex-shrink: 0; }
.auto-source-controls button { height: 28px; padding: 0 10px; font-size: 12px; }

/* ─────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .status-panel-body { grid-template-columns: 1fr; }
  .metric-grid-slim { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 880px) {
  .app-shell, .app-shell-kanban { padding: var(--space-sm) var(--space-md) var(--space-lg); }
  .topbar-slim { grid-template-columns: 1fr; }
  .topbar-slim .topbar-actions { flex-wrap: wrap; justify-content: flex-start; }
  .topbar-status-pills { justify-content: flex-start; }
  .kanban-column { flex-basis: 280px; max-width: 280px; }
  .modal-form, .modal-field-grid { grid-template-columns: 1fr; }
  .detail-drawer { width: 100vw; }
  .lead-summary-head { flex-direction: column; }
  .lead-summary-actions { justify-content: flex-start; }
  .lead-summary-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────
   Phone (≤640px) — touch-first reflow
   - Kanban becomes single-column-at-a-time with snap scroll
   - Detail drawer slides up from the bottom (full-screen sheet)
   - Modals fill the viewport, scroll within
   - Form inputs ≥16px (iOS no-zoom), buttons ≥44px tall
   - Safe-area insets respected on every fixed/edge surface
   ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* Shell padding shrinks + respects safe-area on left/right */
  .app-shell,
  .app-shell-kanban {
    padding: var(--space-xs) var(--space-sm) var(--space-2xl);
    padding-left: max(var(--space-sm), var(--safe-left));
    padding-right: max(var(--space-sm), var(--safe-right));
  }

  /* Topbar: stack title / pills / actions vertically; sticky on scroll */
  .topbar-slim {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
    padding: max(var(--space-xs), var(--safe-top)) 0 var(--space-xs);
    margin-bottom: var(--space-sm);
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--paper);
  }
  .topbar-slim .title-block h1 { font-size: 20px; }
  .title-block .eyebrow { letter-spacing: 0.18em; }

  .topbar-status-pills {
    justify-content: flex-start;
    gap: 6px;
  }
  .topbar-actions {
    flex-wrap: wrap;
    justify-content: stretch;
    width: 100%;
    gap: 6px;
  }
  .topbar-actions > .primary { flex: 1; min-width: 0; }
  .topbar-advanced { width: 100%; }
  .topbar-advanced summary { width: 100%; justify-content: center; }
  .topbar-advanced-actions {
    position: fixed;
    left: var(--space-sm);
    right: var(--space-sm);
    top: auto;
    bottom: max(var(--space-sm), var(--safe-bottom));
    min-width: 0;
    max-height: 70dvh;
    overflow-y: auto;
    box-shadow: 0 -8px 28px -10px oklch(0.25 0.02 60 / 0.30);
  }

  /* Touch targets — every button at least 44px on phone */
  button,
  .button-link,
  .topbar-advanced summary {
    min-height: 44px;
    height: auto;
    padding: 10px 16px;
    font-size: 14px;
  }
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
  .topbar-menu-group button { min-height: 40px; height: auto; font-size: 13.5px; }

  /* Inputs: 16px to prevent iOS auto-zoom on focus.
     Higher-specificity selectors below to beat existing component rules. */
  input,
  select,
  textarea,
  .modal-panel textarea,
  .draft-box input,
  .draft-box textarea,
  .settings-field input,
  .autopilot-cap-control input,
  .campaign-field textarea {
    font-size: 16px;
  }
  input,
  select {
    height: 44px;
    padding: 10px 12px;
  }
  textarea,
  .modal-panel textarea {
    min-height: 120px;
    line-height: 1.7;
    padding: 10px 12px;
  }
  .autopilot-cap-control input { width: 88px; height: 40px; }

  /* Status pills stay readable but don't need to be huge */
  .status-pill,
  .autopilot-toggle {
    height: 32px;
    font-size: 12px;
    padding: 0 12px;
  }

  /* Autopilot progress strip: stack head, full-width cap input */
  .autopilot-progress { padding: var(--space-sm); }
  .autopilot-progress-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }
  .autopilot-progress-meta { white-space: normal; }
  .autopilot-cap-control {
    margin-left: 0;
    justify-content: space-between;
  }
  .autopilot-cap-control input { width: 96px; }

  /* Kanban toolbar: stack search above filter row */
  .kanban-toolbar { flex-direction: column; align-items: stretch; gap: var(--space-xs); }
  .kanban-toolbar-left,
  .kanban-toolbar-right { width: 100%; }
  .kanban-toolbar input[type="search"] {
    width: 100%;
    height: 44px;
  }
  .kanban-toolbar select { height: 44px; flex: 1; }
  .kanban-toolbar-right { justify-content: space-between; }
  .kanban-toolbar-right button { flex: 1; }

  /* Kanban: snap-scroll columns, one mostly-full-width column at a time */
  .kanban-board {
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    scroll-snap-type: x mandatory;
    scroll-padding-left: var(--space-sm);
    -webkit-overflow-scrolling: touch;
    min-height: 50dvh;
  }
  .kanban-column {
    flex: 0 0 86vw;
    max-width: 86vw;
    max-height: none;
    scroll-snap-align: start;
  }
  .kanban-column-body { overflow-y: visible; }
  .kanban-column-head { padding: 8px 4px 10px; }

  /* Cards: bigger tap area, slightly larger title for legibility */
  .kanban-card {
    padding: 14px 14px;
    gap: 8px;
  }
  .kanban-card-title { font-size: 15.5px; }
  .kanban-card-meta { font-size: 12px; }
  .kanban-card-next { font-size: 12px; }

  /* Detail drawer = full-screen bottom sheet on phone.
     Slides up from below; close button is in the persistent top bar. */
  .detail-drawer {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-left: 0;
    border-top: 1px solid var(--rule-strong);
    border-radius: 14px 14px 0 0;
    transform: translateY(0);
    box-shadow: 0 -22px 48px -24px oklch(0.25 0.02 60 / 0.35);
  }
  .detail-drawer.is-hidden { transform: translateY(100%); }
  .detail-drawer-head {
    padding: max(var(--space-sm), var(--safe-top)) var(--space-md) var(--space-sm);
    position: sticky;
    top: 0;
    z-index: 2;
    /* Drag-handle affordance — purely visual, the close button is the actual control */
    background:
      linear-gradient(to bottom,
        transparent 0,
        transparent 6px,
        var(--paper-elev) 14px) ;
  }
  .detail-drawer-head::before {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--rule-strong);
  }
  .detail-drawer .detail {
    padding: var(--space-md) var(--space-md) calc(var(--space-2xl) + var(--safe-bottom));
  }

  .lead-summary-head { flex-direction: column; }
  .lead-summary-header h3 { font-size: 1.4rem; }
  .lead-summary-actions { justify-content: flex-start; }
  .lead-summary-grid { grid-template-columns: 1fr; }

  /* Action grid → single column so each CTA is a full-width tap target */
  .action-grid { grid-template-columns: 1fr; gap: 8px; }
  .action-grid button { width: 100%; min-height: 48px; font-size: 14.5px; }

  /* Collapsible section toggles: bigger tap surface */
  .detail-section summary {
    min-height: 44px;
    align-items: center;
    padding: 12px 0;
  }
  .detail-collapsible summary::after {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
  }

  /* Modal: become a near-full-screen sheet that scrolls internally */
  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .modal-card,
  .modal-card-wide {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    border-radius: 0;
    border: 0;
    border-top: 1px solid var(--rule-strong);
  }
  .modal-head {
    padding: max(var(--space-md), var(--safe-top)) var(--space-md) var(--space-sm);
    position: sticky;
    top: 0;
    background: var(--paper);
    z-index: 2;
  }
  .modal-head h2 { font-size: 17px; }
  .modal-tabs {
    padding: 0 var(--space-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: calc(max(var(--space-md), var(--safe-top)) + 44px);
    background: var(--paper);
    z-index: 1;
  }
  .modal-tab { white-space: nowrap; height: 44px; font-size: 13px; }
  .modal-body {
    padding: var(--space-md) var(--space-md) calc(var(--space-2xl) + var(--safe-bottom));
  }
  .modal-form,
  .modal-field-grid { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .modal-actions button { width: 100%; }

  /* Status panel — when expanded, ensure cards stack readably */
  .metric-grid-slim { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid { grid-template-columns: 1fr; }

  /* Auto-source block: stack head + controls */
  .auto-source-head { flex-direction: column; align-items: stretch; }
  .auto-source-controls button { flex: 1; min-height: 40px; }

  /* Settings + campaigns action rows */
  .settings-actions { flex-direction: column-reverse; align-items: stretch; }
  .settings-actions button { width: 100%; }
  .campaign-card-actions button { flex: 1; min-width: calc(50% - 4px); }

  /* Banners: more breathing room on small text */
  .gmail-banner,
  .flash-message { font-size: 13.5px; line-height: 1.55; }

  /* Pre-formatted draft letters — reduce to fit */
  pre { font-size: 13.5px; line-height: 1.85; padding: var(--space-sm); }
  .draft-box { padding: var(--space-sm); }
  .draft-box .detail-copy { font-size: 14.5px; line-height: 1.7; }

  /* Preview iframe — make height respect viewport */
  .preview-frame { min-height: 60dvh; }

  /* Honor reduced-motion: kill the autopilot pulse + heavy transitions */
  @media (prefers-reduced-motion: reduce) {
    .autopilot-toggle.is-on .autopilot-dot { animation: none; }
    .detail-drawer,
    .status-panel { transition: none; }
  }
}

/* Campaigns modal (bulk outreach plan Phase 1) */
.modal-card-wide { width: min(780px, 100%); }
.campaigns-status {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  background: oklch(0.97 0.01 60);
  border: 1px solid var(--rule);
  margin-bottom: var(--space-md);
  font-size: 13px;
  line-height: 1.6;
}
.campaigns-list { display: flex; flex-direction: column; gap: var(--space-md); }
.campaign-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.campaign-card-head h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.campaign-meta { color: var(--ink-soft); font-size: 12px; margin: 4px 0 0; }
.campaign-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.campaign-field > span { color: var(--ink-soft); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; font-size: 11px; }
.campaign-field textarea {
  font-family: "Shippori Mincho B1", serif;
  font-size: 14px;
  line-height: 1.7;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
  resize: vertical;
}
.campaign-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.settings-form { display: flex; flex-direction: column; gap: var(--space-md); }
.settings-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.settings-field-label { color: var(--ink-soft); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; font-size: 11px; }
.settings-field input { padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: #fff; font: inherit; }
.settings-field-hint { color: var(--ink-soft); font-size: 12px; }
.settings-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.settings-status { margin-top: var(--space-md); }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill-ok { background: oklch(0.94 0.07 150); color: oklch(0.34 0.09 150); }
.pill-warn { background: oklch(0.94 0.09 70); color: oklch(0.38 0.13 60); }

/* Autopilot daily-cap control in the progress bar (bulk outreach Phase 4) */
.autopilot-cap-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-left: auto;
}
.autopilot-cap-control input {
  width: 64px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: #fff;
  font: inherit;
  text-align: right;
}

/* ─────────────────────────────────────────────────────────────
   Phone overrides — declared last so they beat later component
   rules of equal specificity (e.g. .settings-field input,
   .autopilot-cap-control input). Keeps iOS from auto-zooming
   on input focus by guaranteeing every editable field is ≥16px.
   ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .autopilot-cap-control input,
  .settings-field input,
  .draft-box input,
  .draft-box textarea,
  .modal-panel textarea,
  .campaign-field textarea,
  .lead-form input,
  .lead-form textarea {
    font-size: 16px;
    height: auto;
    min-height: 44px;
    padding: 10px 12px;
  }
  .autopilot-cap-control input { width: 96px; min-height: 40px; }
  .modal-panel textarea,
  .campaign-field textarea,
  .lead-form textarea {
    min-height: 120px;
    line-height: 1.7;
  }
}

/* === v2 additions === */
.hidden { display: none; }
.error { color: #c0392b; }
.login-shell { max-width: 360px; margin: 8rem auto; padding: 2rem; border: 1px solid #e1e1e3; border-radius: 8px; }

/* Drag-drop visual feedback (paper-theme — additive, doesn't redefine geometry). */
.kanban-card.dragging { opacity: 0.4; }
.kanban-column.drag-over { background: var(--paper-sunk); }

/* === v1-style kanban additions (2026-05-19) === */

/* Card sub-elements that weren't part of the original v1 lift. */
.kanban-card-state {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

/* "+N more" chip at the bottom of overflowing columns; also used for graveyard CTA. */
.kanban-more {
  display: block;
  text-align: center;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius-md);
  transition: color 120ms ease, border-color 120ms ease;
}
.kanban-more:hover {
  color: var(--ink-strong);
  border-color: var(--ink-soft);
}

.kanban-graveyard-hint {
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 4px 2px;
}

/* Graveyard column visually de-emphasised vs active spine. */
.kanban-column-graveyard { opacity: 0.78; }

/* Tone down the loud "—" empty state for our kanban scope (preserves the rule
   elsewhere in the app — only scoped to `.kanban`). */
.kanban .kanban-column-body:empty::after {
  content: "";
}
