/* styles.css: Kaizen Weaver.
 *
 * Brand tokens (colors, type scale, font faces) live at the top, then app
 * styles for the three views and the shared chrome below. Built from the
 * design_handoff_weaver prototype, consolidated into a single stylesheet
 * because the production app loads only one CSS file.
 *
 * Voice: paper-and-ink editorial. Serif body (Cormorant Garamond),
 * sans UI (Inter), handwritten accent (Caveat). Nothing pill-shaped except
 * the gold CTA. Surfaces are warm off-white; ink is near-black.
 */

/* ===== Self-hosted variable fonts (Latin subset) ===== */

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-display: swap;
  font-weight: 300 700;
  src: url('/fonts/cormorant-garamond-latin-wght-normal.woff2') format('woff2');
  size-adjust: 105%;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-display: swap;
  font-weight: 300 700;
  src: url('/fonts/cormorant-garamond-latin-wght-italic.woff2') format('woff2');
  size-adjust: 105%;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-display: swap;
  font-weight: 400 700;
  src: url('/fonts/caveat-latin-wght-normal.woff2') format('woff2');
}

/* ===== Tokens (light) ===== */

:root {
  /* Paper surfaces */
  --paper:       #f5f2ec;
  --paper-warm:  #ede6d9;
  --paper-deep:  #e4dac8;

  /* Ink */
  --ink:         #2c2a26;
  --ink-soft:    #4e473f;
  --ink-muted:   #6e6355;
  --ink-faint:   #9a8e7c;
  --ink-rgb:     44 42 38;
  --hi-rgb:      255 255 255;

  /* Red Pen (single CTA / edit color) */
  --red-pen:         #b04040;
  --red-pen-soft:    #c4604f;
  --red-pen-bg:      rgba(176, 64, 64, 0.08);
  --red-pen-bg-hover:rgba(176, 64, 64, 0.12);

  /* Editorial mark categories: variant strand colors */
  --mark-repetition: #9c4e28;
  --mark-pacing:     #566a8e;
  --mark-style:      #7a5290;
  --mark-voice:      #6a5a36;
  --mark-continuity: #2f6e5e;
  --mark-interiority:#8e4848;

  /* Accent: gold. Sparingly. */
  --accent-gold:      #c4a24e;
  --accent-gold-soft: rgba(196, 162, 78, 0.1);

  /* Type families */
  --font-serif: 'Cormorant Garamond', Georgia, 'Iowan Old Style', serif;
  --font-body:  var(--font-serif);
  --font-ui:    'Inter', -apple-system, system-ui, sans-serif;
  --font-hand:  'Caveat', cursive;

  /* Easing */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Elevation */
  --shadow-sm: 0 1px 3px rgb(var(--ink-rgb) / 0.03);
  --shadow-md: 0 3px 12px rgb(var(--ink-rgb) / 0.05), 0 1px 3px rgb(var(--ink-rgb) / 0.03);
  --shadow-lg: 0 8px 40px rgb(var(--ink-rgb) / 0.06);
  --shadow-xl: 0 14px 50px rgb(var(--ink-rgb) / 0.1);
  --shadow-cta:0 4px 20px rgb(var(--ink-rgb) / 0.15);

  /* Radii */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 7px;
  --radius-lg: 10px;

  /* Borders */
  --border-hair:   1px solid rgb(var(--ink-rgb) / 0.06);
  --border-soft:   1px solid rgb(var(--ink-rgb) / 0.1);
  --border-strong: 1px solid rgb(var(--ink-rgb) / 0.15);

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;
  --s-9: 56px; --s-10: 80px; --s-11: 120px;

  /* Type scale */
  --tx-display: clamp(2.4rem, 6.2vw, 4.2rem);
  --tx-h1:      clamp(1.8rem, 3.6vw, 2.6rem);
  --tx-h2:      clamp(1.4rem, 2.6vw, 1.9rem);
  --tx-h3:      1.18rem;
  --tx-body:    1rem;
  --tx-ui:      0.9rem;
  --tx-ui-sm:   0.78rem;
  --tx-meta:    0.7rem;
  --tx-micro:   0.55rem;

  --lh-tight:   1.08;
  --lh-heading: 1.2;
  --lh-body:    1.6;

  --track-eyebrow: 0.14em;
  --track-label:   0.1em;
  --track-tight:  -0.01em;
}

/* ===== Tokens (dark) ===== */

[data-theme="dark"] {
  --paper:        #1a1614;
  --paper-warm:   #221d1a;
  --paper-deep:   #2a2420;
  --ink:          #f5f2ec;
  --ink-soft:     #d0c8b8;
  --ink-muted:    #b0a595;
  --ink-faint:    #8a7e6e;
  --ink-rgb:      245 242 236;
  --hi-rgb:       40 36 32;

  --red-pen:         #d06050;
  --red-pen-soft:    #e07868;
  --red-pen-bg:      rgba(208, 96, 96, 0.1);
  --red-pen-bg-hover:rgba(208, 96, 96, 0.15);

  --mark-repetition: #eda26e;
  --mark-pacing:     #b0caf0;
  --mark-style:      #d2ace8;
  --mark-voice:      #dcbe9a;
  --mark-continuity: #82dcc4;
  --mark-interiority:#e8a0a0;

  --accent-gold:      #d4b462;
  --accent-gold-soft: rgba(212, 180, 98, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #1a1614;
    --paper-warm:   #221d1a;
    --paper-deep:   #2a2420;
    --ink:          #f5f2ec;
    --ink-soft:     #d0c8b8;
    --ink-muted:    #b0a595;
    --ink-faint:    #8a7e6e;
    --ink-rgb:      245 242 236;
    --hi-rgb:       40 36 32;

    --red-pen:         #d06050;
    --red-pen-soft:    #e07868;
    --red-pen-bg:      rgba(208, 96, 96, 0.1);
    --red-pen-bg-hover:rgba(208, 96, 96, 0.15);

    --mark-repetition: #eda26e;
    --mark-pacing:     #b0caf0;
    --mark-style:      #d2ace8;
    --mark-voice:      #dcbe9a;
    --mark-continuity: #82dcc4;
    --mark-interiority:#e8a0a0;

    --accent-gold:      #d4b462;
    --accent-gold-soft: rgba(212, 180, 98, 0.12);
  }
}

/* ===== Base ===== */

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}
body {
  background:
    radial-gradient(ellipse 80% 60% at 70% 0%, var(--accent-gold-soft), transparent 60%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: var(--font-ui); cursor: pointer; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: var(--track-tight);
  line-height: var(--lh-heading);
  margin: 0 0 0.4em;
}
h1 { font-size: var(--tx-display); font-weight: 300; line-height: var(--lh-tight); }
h2 { font-size: var(--tx-h1); font-weight: 400; }
h3 { font-size: var(--tx-h2); font-weight: 400; }
h4 { font-size: var(--tx-h3); font-weight: 500; }

h1 em, h2 em, h3 em {
  font-style: italic;
  font-weight: 400;
  color: var(--red-pen);
}

p {
  font-family: var(--font-body);
  font-size: var(--tx-body);
  color: var(--ink-soft);
  line-height: var(--lh-body);
  margin: 0 0 1em;
  max-width: 65ch;
}

.eyebrow {
  font-family: var(--font-ui);
  font-size: var(--tx-meta);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-eyebrow);
  color: var(--ink-muted);
}

.muted { color: var(--ink-muted); }
.muted.small,
p.muted.small { font-family: var(--font-ui); font-size: var(--tx-ui-sm); margin: 0; }
.italic { font-style: italic; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color 200ms var(--ease); }
a:hover { color: var(--red-pen); }

code, kbd {
  font-family: var(--font-ui);
  font-size: 0.85em;
  font-weight: 500;
  padding: 0.1em 0.35em;
  background: rgb(var(--ink-rgb) / 0.06);
  border-radius: var(--radius-xs);
  color: rgb(var(--ink-rgb) / 0.7);
}

::selection { background: var(--accent-gold-soft); color: var(--ink); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== Buttons ===== */

.btn-primary {
  font-family: var(--font-ui);
  font-size: var(--tx-ui);
  font-weight: 500;
  background: var(--red-pen);
  color: #fffaf0;
  border: 0;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  transition: all 200ms var(--ease);
  box-shadow: var(--shadow-cta);
}
.btn-primary:hover:not(:disabled) {
  background: var(--red-pen-soft);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  font-family: var(--font-ui);
  font-size: var(--tx-ui);
  background: transparent;
  border: var(--border-soft);
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 150ms var(--ease);
}
.btn-ghost:hover { background: rgb(var(--ink-rgb) / 0.04); color: var(--ink); }
.btn-ghost.small { padding: 4px 10px; font-size: var(--tx-ui-sm); }

.btn-danger {
  font-family: var(--font-ui);
  font-size: var(--tx-ui);
  font-weight: 500;
  background: var(--red-pen);
  color: #fffaf0;
  border: 1px solid var(--red-pen);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.01em;
  transition: all 150ms var(--ease);
}
.btn-danger:hover { filter: brightness(0.95); transform: translateY(-1px); }

.link-btn {
  font-family: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--red-pen);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}
.link-btn:hover { color: var(--red-pen-soft); }

.icon-btn {
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 150ms var(--ease);
}
.icon-btn:hover { background: rgb(var(--ink-rgb) / 0.06); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.back-link {
  background: none;
  border: 0;
  color: var(--ink-muted);
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0;
  cursor: pointer;
}
.back-link:hover { color: var(--red-pen); }

/* ===== Topbar ===== */

.suite-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-7);
  background: rgb(var(--hi-rgb) / 0.82);
  backdrop-filter: saturate(1.1) blur(4px);
  border-bottom: var(--border-hair);
  position: sticky;
  top: 0;
  z-index: 50;
}
.suite-mark { display: flex; align-items: center; gap: var(--s-3); }
.suite-mark-glyph {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-serif); font-weight: 500;
  border-radius: var(--radius-xs);
  font-size: 16px;
}
.suite-mark-name {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink);
  font-weight: 500;
}
.suite-nav {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
}
.suite-nav-item.is-current {
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1.5px solid var(--red-pen);
  padding-bottom: 2px;
}
.suite-nav-item.is-future { color: var(--ink-faint); }
.suite-nav-sep { color: var(--ink-faint); }

/* ===== Landing ===== */

.landing-main {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--s-10) var(--s-7) var(--s-11);
}
.landing-hero { text-align: center; margin-bottom: var(--s-10); }
.landing-hero .eyebrow { display: block; margin-bottom: var(--s-4); }
.landing-hero h1 { font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 300; }
.landing-hero h1 em { font-style: italic; color: var(--red-pen); font-weight: 400; }
.landing-hero .lede {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--ink-soft);
  max-width: 560px;
  margin: var(--s-5) auto 0;
  line-height: 1.5;
}

.drop-zone {
  position: relative;
  background: rgb(var(--hi-rgb) / 0.7);
  border: 1.5px dashed rgb(var(--ink-rgb) / 0.18);
  border-radius: var(--radius-md);
  padding: var(--s-8) var(--s-7);
  text-align: center;
  cursor: pointer;
  transition: all 200ms var(--ease);
  min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-4);
}
.drop-zone:hover, .drop-zone.is-over {
  background: rgb(var(--hi-rgb) / 0.92);
  border-color: var(--red-pen);
}
.drop-zone-copy h3 { font-size: 1.6rem; margin: 0 0 var(--s-2); font-weight: 400; }
.drop-zone-copy p { margin: 0; color: var(--ink-muted); font-family: var(--font-ui); font-size: var(--tx-ui); }
.thread-ornament { display: block; }

.paste-form {
  background: rgb(var(--hi-rgb) / 0.85);
  border: var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.paste-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 400;
  background: transparent;
  border: 0;
  border-bottom: var(--border-hair);
  padding: var(--s-2) 0;
  color: var(--ink);
  outline: none;
}
.paste-title:focus { border-bottom-color: var(--red-pen); }
.paste-body {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.7;
  background: transparent;
  border: 0;
  resize: vertical;
  min-height: 200px;
  outline: none;
  color: var(--ink);
  padding: var(--s-2) 0;
}
.paste-actions { display: flex; justify-content: flex-end; gap: var(--s-3); }

.landing-recents { margin-top: var(--s-10); }
.landing-recents .eyebrow { margin-bottom: var(--s-5); display: block; }
.recents-list { display: flex; flex-direction: column; gap: var(--s-3); }
.recent-item {
  background: rgb(var(--hi-rgb) / 0.6);
  border: var(--border-hair);
  border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-5);
  cursor: pointer;
  transition: all 150ms var(--ease);
  position: relative;
}
.recent-item:hover {
  background: rgb(var(--hi-rgb) / 0.92);
  border-color: rgb(var(--ink-rgb) / 0.15);
  transform: translateY(-1px);
}
.recent-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-1);
}
.recent-title { font-family: var(--font-serif); font-size: 1.25rem; margin: 0; font-weight: 500; }
.recent-meta { font-family: var(--font-ui); font-size: var(--tx-ui-sm); color: var(--ink-muted); }
.recent-excerpt { font-style: italic; color: var(--ink-muted); margin: 0; font-size: 0.98rem; }
.recent-remove {
  position: absolute;
  top: 12px;
  right: 12px;
  opacity: 0;
  transition: opacity 150ms var(--ease);
}
.recent-item:hover .recent-remove { opacity: 0.6; }
.recent-item:hover .recent-remove:hover { opacity: 1; }

/* ===== Work view ===== */

.work-main {
  max-width: 920px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-7) var(--s-11);
}
.work-header { margin-bottom: var(--s-9); }
.work-header .eyebrow { display: block; margin-bottom: var(--s-2); margin-top: var(--s-4); }
.work-title { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 300; margin: 0 0 var(--s-2); }
.work-sub { font-family: var(--font-ui); font-size: var(--tx-ui-sm); color: var(--ink-muted); margin: 0; }

.work-section { margin-bottom: var(--s-9); }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  gap: var(--s-4);
}
.section-head .eyebrow { display: block; margin-bottom: var(--s-1); }
.section-head p { margin: var(--s-1) 0 0; }

/* Variant cards */
.variant-list { display: flex; flex-direction: column; gap: var(--s-3); }
.variant-card {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: var(--s-4);
  background: rgb(var(--hi-rgb) / 0.7);
  border: var(--border-hair);
  border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-5) var(--s-4) 0;
  cursor: pointer;
  transition: all 150ms var(--ease);
  align-items: center;
  position: relative;
  overflow: hidden;
}
.variant-card:hover { background: rgb(var(--hi-rgb) / 0.92); }
.variant-card.is-picked {
  border-color: var(--variant-color);
  background: rgb(var(--hi-rgb) / 0.95);
}
.variant-edge {
  background: var(--variant-color);
  height: 100%;
  width: 4px;
  align-self: stretch;
}
.variant-card .variant-body { padding: var(--s-1) 0; }
.variant-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-1);
}
.variant-label { font-family: var(--font-serif); font-size: 1.18rem; margin: 0; font-weight: 500; }
.variant-meta { font-family: var(--font-ui); font-size: var(--tx-ui-sm); color: var(--ink-muted); }
.variant-snippet {
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}
.variant-actions { display: flex; align-items: center; gap: var(--s-1); padding-right: var(--s-2); }
.pick-circle {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border: 1.5px solid rgb(var(--ink-rgb) / 0.2);
  border-radius: 50%;
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
  font-weight: 500;
  color: var(--ink-muted);
  transition: all 150ms var(--ease);
}
.variant-card.is-picked .pick-circle {
  border-color: var(--variant-color);
  background: var(--variant-color);
  color: #fff;
}

.rename-input {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 500;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid rgb(var(--ink-rgb) / 0.18);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  outline: none;
  width: 100%;
  max-width: 320px;
}
.rename-input:focus { border-color: var(--red-pen); }

.weave-cta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: var(--border-hair);
  gap: var(--s-4);
}

/* Saved weaves */
.weave-list { display: flex; flex-direction: column; gap: var(--s-3); }
.weave-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-4);
  align-items: center;
  background: rgb(var(--hi-rgb) / 0.7);
  border: var(--border-hair);
  border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-5);
}
.weave-strands { display: flex; flex-direction: column; gap: 3px; width: 18px; }
.weave-strands .strand { height: 2px; border-radius: 1px; }
.weave-body { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.weave-label { font-family: var(--font-serif); font-size: 1.1rem; margin: 0; font-weight: 500; }
.weave-meta { font-family: var(--font-ui); font-size: var(--tx-ui-sm); color: var(--ink-muted); }
.weave-snippet {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-soft);
  margin: var(--s-1) 0 0;
  line-height: 1.5;
  font-size: 0.95rem;
}
.weave-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 130px;
}
.weave-actions .icon-btn { align-self: flex-end; }

/* ===== Weaver view ===== */

.weaver-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.weaver-topbar { gap: var(--s-5); }
.weaver-progress {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex: 1;
  max-width: 340px;
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: rgb(var(--ink-rgb) / 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--red-pen);
  transition: width 300ms cubic-bezier(0.2, 0, 0, 1);
}
.progress-label { white-space: nowrap; }
.weaver-actions { display: flex; align-items: center; gap: var(--s-3); }
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}
.kbd-hint kbd {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  background: var(--paper-deep);
  border: 1px solid rgb(var(--ink-rgb) / 0.12);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ink-soft);
  margin: 0 1px;
}
.inline-kbd {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  background: var(--paper-deep);
  border: 1px solid rgb(var(--ink-rgb) / 0.12);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  color: var(--ink-muted);
  font-weight: 400;
}

.weaver-main {
  flex: 1;
  padding: var(--s-6) var(--s-5) var(--s-9);
  position: relative;
}
.weaver-grid {
  display: grid;
  gap: var(--s-5);
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}
.weaver-grid.cols-2 { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(280px, 1.2fr); }
.weaver-grid.cols-3 { grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr) minmax(200px, 1fr) minmax(280px, 1.3fr); }
@media (min-width: 1400px) {
  .weaver-grid.cols-2 { grid-template-columns: 1fr 1fr 1.2fr; }
  .weaver-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr 1.4fr; }
}

/* Variant column */
.variant-column {
  background: rgb(var(--hi-rgb) / 0.55);
  border: var(--border-hair);
  border-top: 3px solid var(--variant-color);
  border-radius: var(--radius-md);
  padding: var(--s-5) var(--s-2) var(--s-5) var(--s-5);
  min-height: 300px;
  min-width: 0;
}
.column-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: var(--border-hair);
}
.strand { display: inline-block; width: 24px; height: 2px; border-radius: 1px; }
.strand.large { width: 40px; height: 3px; }
.column-head-text { flex: 1; min-width: 0; }
.column-head .eyebrow { display: block; margin-bottom: 2px; }
.variant-title, .merge-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  margin: 0;
  font-weight: 500;
}
.variant-similarity { margin: 2px 0 0; }

.merge-strands { display: flex; flex-direction: column; gap: 3px; width: 28px; }
.merge-strands .strand { width: 100%; }

.variant-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-2);
  border-radius: var(--radius-sm);
  transition: background 150ms var(--ease);
  position: relative;
  align-items: start;
  cursor: pointer;
}
.variant-line:hover { background: rgb(var(--ink-rgb) / 0.03); }
.variant-line.is-focused { background: rgb(var(--ink-rgb) / 0.05); }
.variant-line.is-taken { background: var(--red-pen-bg); }
.line-num {
  font-family: var(--font-ui);
  font-size: var(--tx-meta);
  color: var(--ink-faint);
  padding-top: 4px;
  letter-spacing: var(--track-label);
}
.line-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
}
.tk-changed {
  color: var(--variant-color);
  background: color-mix(in oklch, var(--variant-color) 10%, transparent);
  border-radius: 2px;
  padding: 0 1px;
}

.take-btn {
  font-family: var(--font-ui);
  font-size: var(--tx-meta);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  background: transparent;
  border: var(--border-soft);
  color: var(--ink-muted);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  opacity: 0;
  transition: all 150ms var(--ease);
  margin-top: 4px;
  white-space: nowrap;
}
.variant-line:hover .take-btn,
.variant-line.is-focused .take-btn { opacity: 1; }
.take-btn:hover {
  border-color: var(--variant-color);
  color: var(--variant-color);
  background: rgb(var(--hi-rgb) / 0.9);
}
.variant-line.is-taken .take-btn {
  opacity: 1;
  color: var(--variant-color);
  border-color: var(--variant-color);
}
.variant-line.is-taken .take-btn::after { content: " \2713"; }

/* Merge column */
.merge-column {
  background: rgb(var(--hi-rgb) / 0.95);
  border: var(--border-soft);
  border-top: 3px solid var(--red-pen);
  border-radius: var(--radius-md);
  padding: var(--s-5);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.merge-head-text { flex: 1; min-width: 0; }
.merge-head-text .eyebrow { display: block; margin-bottom: 2px; }
.merge-head-actions { display: flex; gap: 4px; }

.merge-body {
  flex: 1;
  overflow-y: auto;
  margin: 0 calc(var(--s-2) * -1);
  padding: 0 var(--s-2);
}
.merge-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 22px;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-1);
  border-radius: var(--radius-sm);
  transition: background 150ms var(--ease);
  align-items: start;
  position: relative;
}
.merge-line.is-focused { background: rgb(var(--ink-rgb) / 0.04); }
.merge-line-body { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.merge-input-wrap { position: relative; min-width: 0; }
.merge-input {
  width: 100%;
  min-width: 0;
  display: block;
  box-sizing: border-box;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.6;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  resize: none;
  padding: 0;
  min-height: 1.6em;
}
.merge-input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}
.merge-line.has-content .merge-input {
  box-shadow: inset 2px 0 0 var(--line-source-color, var(--red-pen));
  padding-left: var(--s-3);
}
.merge-line.is-edited .merge-input {
  box-shadow: inset 2px 0 0 var(--red-pen);
  padding-left: var(--s-3);
}
.merge-line.is-from-synth .merge-input {
  box-shadow: inset 2px 0 0 var(--accent-gold);
  padding-left: var(--s-3);
}

.merge-source {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}
.source-pip {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.source-edited {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--red-pen);
}
.source-synth {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--accent-gold);
}

/* Ghost / synth suggestion line */
.ghost-line {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  padding: var(--s-2) var(--s-3);
  background: var(--accent-gold-soft);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 150ms var(--ease);
  margin-top: var(--s-1);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--ink-soft);
  border-left: 2px solid var(--accent-gold);
}
.ghost-line:hover {
  background: color-mix(in oklch, var(--accent-gold) 18%, transparent);
}
.ghost-icon {
  font-family: var(--font-serif);
  color: var(--accent-gold);
  font-size: 1.1rem;
  line-height: 1;
}
.ghost-text { flex: 1; }
.ghost-take {
  font-family: var(--font-ui);
  font-size: var(--tx-meta);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--accent-gold);
  white-space: nowrap;
  font-style: normal;
  align-self: center;
}
.caret {
  display: inline-block;
  width: 1px;
  height: 1em;
  background: var(--accent-gold);
  margin-left: 1px;
  animation: caret-blink 0.8s steps(2) infinite;
  vertical-align: text-bottom;
}
@keyframes caret-blink { 50% { opacity: 0; } }

/* Synth rail */
.synth-rail {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: var(--border-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.btn-suggest {
  font-family: var(--font-ui);
  font-size: var(--tx-ui);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  background: rgb(var(--hi-rgb) / 0.8);
  border: 1px solid var(--accent-gold);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all 150ms var(--ease);
  cursor: pointer;
}
.btn-suggest:hover { background: var(--accent-gold-soft); }
.btn-suggest svg { color: var(--accent-gold); }
.synth-status { display: flex; align-items: center; gap: var(--s-3); flex: 1; }
.synth-status .link-btn { margin-left: auto; }
.synth-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  animation: synth-pulse 1.4s ease-in-out infinite;
}
@keyframes synth-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.4); }
}
.synth-warn {
  color: var(--red-pen);
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
}

/* ===== Dialogs ===== */

.dialog-backdrop {
  position: fixed; inset: 0;
  background: rgb(var(--ink-rgb) / 0.18);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 200;
  padding: var(--s-5);
  animation: fade-in 200ms var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  background: var(--paper);
  border: var(--border-soft);
  border-radius: var(--radius-lg);
  padding: var(--s-7);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: dialog-rise 250ms var(--ease);
  color: var(--ink);
}
@keyframes dialog-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.dialog.dialog-large { max-width: 620px; }
.dialog.is-over { border-color: var(--red-pen); background: var(--red-pen-bg); }
.dialog .eyebrow { display: block; margin-bottom: var(--s-3); }
.dialog h3 { font-size: 1.6rem; margin: 0 0 var(--s-2); font-weight: 400; }
.dialog h3 em { font-style: italic; color: var(--red-pen); }
.dialog-strands { display: flex; gap: 3px; margin-bottom: var(--s-4); }
.dialog-strands .strand { width: 32px; height: 3px; }
.dialog-input {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  background: rgb(var(--hi-rgb) / 0.7);
  border: var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--s-3);
  color: var(--ink);
  outline: none;
  margin-top: var(--s-2);
}
.dialog-input:focus { border-color: var(--red-pen); }
.dialog-textarea { font-family: var(--font-serif); resize: vertical; line-height: 1.6; }
.field { display: block; margin-top: var(--s-4); }
.field-label {
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
  color: var(--ink-muted);
  display: block;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  margin-top: var(--s-6);
}

/* Native confirm dialog (kept for confirmDestructive) */
.confirm-dialog {
  border: 1px solid var(--rule, var(--border-soft));
  border-radius: var(--radius-lg);
  padding: var(--s-7);
  background: var(--paper);
  color: var(--ink);
  max-width: 460px;
  box-shadow: var(--shadow-xl);
}
.confirm-dialog::backdrop { background: rgb(var(--ink-rgb) / 0.2); backdrop-filter: blur(2px); }
.confirm-dialog .eyebrow { display: block; margin-bottom: var(--s-3); }
.confirm-dialog h3 { font-size: 1.4rem; margin: 0 0 var(--s-2); font-weight: 400; }
.confirm-dialog p { margin: 0 0 var(--s-5); color: var(--ink-soft); }
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
}

/* Settings dialog */
.settings-dialog .settings-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0 0 var(--s-2);
}
.settings-field { margin-bottom: var(--s-4); }
.settings-label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--tx-ui-sm);
  color: var(--ink-muted);
  margin-bottom: var(--s-1);
}
.settings-actions { margin-top: var(--s-2); }

/* ===== Toasts ===== */

.toast-host {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 220;
  pointer-events: none;
}
.toast {
  background: rgb(var(--ink-rgb) / 0.92);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgb(var(--ink-rgb) / 0.18);
  animation: toast-in 200ms var(--ease);
  pointer-events: auto;
}
.toast-warn {
  background: var(--red-pen);
  color: #fffaf0;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ============================================================
   Kaizen Suite cross-app navigation strip (canonical, v2).
   Mirrors suite/components.jsx ProductMark + suite/colors_and_type.css
   accent system. K is rendered in the product accent; the trailing
   lowercase letter(s) sit in default ink. Same palette across all sites.
   ============================================================ */
.kw-suite-strip {
  margin: 0;
  padding: 8px 24px;
  background: #ede6d9;
  border-bottom: 1px solid rgba(44, 42, 38, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6e6355;
  position: relative;
  z-index: 100;
}
.kw-suite-strip a, .kw-suite-strip .kw-tool {
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}
.kw-suite-strip a:hover, .kw-suite-strip a:focus-visible,
.kw-suite-strip .kw-tool:not(.is-current):hover { color: #2c2a26; }
.kw-suite-home { display: inline-flex; align-items: center; gap: 10px; }
.kw-suite-glyph {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 19px; font-weight: 500; letter-spacing: -0.04em;
  color: #4e473f; line-height: 1; text-transform: none;
}
.kw-suite-text strong { font-weight: 600; color: #4e473f; }
.kw-suite-arrow {
  margin-left: 2px; opacity: 0.5;
  transition: transform 160ms ease, opacity 160ms ease;
}
.kw-suite-home:hover .kw-suite-arrow { transform: translateX(-2px); opacity: 1; }
.kw-suite-sibs { display: inline-flex; align-items: center; gap: 16px; font-size: 10.5px; letter-spacing: 0.12em; }
.kw-tool { display: inline-flex; align-items: baseline; gap: 6px; }
.kw-tool-glyph {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px; font-weight: 500; letter-spacing: -0.04em;
  line-height: 1; color: #4e473f; text-transform: none;
}
.kw-tool-glyph .kw-acc { color: var(--kw-tool-accent, #4e473f); }
.kw-is-kw  { --kw-tool-accent: #566a8e; }
.kw-is-kr  { --kw-tool-accent: #7a5290; }
.kw-is-krw { --kw-tool-accent: #b04040; }
.kw-tool.is-current { cursor: default; }
.kw-tool.is-current .kw-tool-name { color: #2c2a26; font-weight: 500; }
.kw-tool.is-current .kw-tool-glyph { color: #2c2a26; }
@media (max-width: 720px) {
  .kw-suite-strip { padding: 7px 16px; font-size: 10px; }
  .kw-tool-name { display: none; }
  .kw-suite-text { display: none; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(.theme-light) .kw-suite-strip {
    background: #221d1a; border-bottom-color: rgba(245, 242, 236, 0.08); color: #b0a595;
  }
  :root:not([data-theme="light"]):not(.theme-light) .kw-suite-strip a:hover,
  :root:not([data-theme="light"]):not(.theme-light) .kw-suite-strip strong,
  :root:not([data-theme="light"]):not(.theme-light) .kw-tool.is-current .kw-tool-name,
  :root:not([data-theme="light"]):not(.theme-light) .kw-tool.is-current .kw-tool-glyph,
  :root:not([data-theme="light"]):not(.theme-light) .kw-suite-glyph,
  :root:not([data-theme="light"]):not(.theme-light) .kw-tool-glyph { color: #f5f2ec; }
  :root:not([data-theme="light"]):not(.theme-light) .kw-is-kw  { --kw-tool-accent: #b0caf0; }
  :root:not([data-theme="light"]):not(.theme-light) .kw-is-kr  { --kw-tool-accent: #d2ace8; }
  :root:not([data-theme="light"]):not(.theme-light) .kw-is-krw { --kw-tool-accent: #d06050; }
}
[data-theme="dark"] .kw-suite-strip, .theme-dark .kw-suite-strip {
  background: #221d1a; border-bottom-color: rgba(245, 242, 236, 0.08); color: #b0a595;
}
[data-theme="dark"] .kw-suite-strip a:hover, .theme-dark .kw-suite-strip a:hover,
[data-theme="dark"] .kw-suite-strip strong, .theme-dark .kw-suite-strip strong,
[data-theme="dark"] .kw-tool.is-current .kw-tool-name, .theme-dark .kw-tool.is-current .kw-tool-name,
[data-theme="dark"] .kw-tool.is-current .kw-tool-glyph, .theme-dark .kw-tool.is-current .kw-tool-glyph,
[data-theme="dark"] .kw-suite-glyph, .theme-dark .kw-suite-glyph,
[data-theme="dark"] .kw-tool-glyph, .theme-dark .kw-tool-glyph { color: #f5f2ec; }
[data-theme="dark"] .kw-is-kw, .theme-dark .kw-is-kw   { --kw-tool-accent: #b0caf0; }
[data-theme="dark"] .kw-is-kr, .theme-dark .kw-is-kr   { --kw-tool-accent: #d2ace8; }
[data-theme="dark"] .kw-is-krw, .theme-dark .kw-is-krw { --kw-tool-accent: #d06050; }
