/* Clarguments — paper diary aesthetic */

:root {
  --paper: oklch(97% 0.015 85);
  --paper-2: oklch(95% 0.02 82);
  --paper-3: oklch(93% 0.025 80);
  --paper-edge: oklch(88% 0.03 75);
  --ink: oklch(22% 0.02 60);
  --ink-2: oklch(35% 0.02 60);
  --ink-3: oklch(50% 0.02 60);
  --ink-4: oklch(68% 0.015 60);
  --rule: oklch(80% 0.02 70);
  --rule-soft: oklch(88% 0.02 75);

  --red: oklch(50% 0.14 25);
  --red-soft: oklch(88% 0.06 25);
  --yellow: oklch(92% 0.12 95);
  --yellow-deep: oklch(82% 0.14 90);
  --blue: oklch(45% 0.1 240);
  --blue-soft: oklch(90% 0.04 235);
  --green: oklch(50% 0.09 145);
  --green-soft: oklch(90% 0.05 140);
  --purple: oklch(45% 0.09 310);
  --purple-soft: oklch(90% 0.04 310);

  --font-prose: "Spectral", "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --font-hand: "Caveat", "Bradley Hand", cursive;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-prose);
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* paper texture — subtle fibers via layered gradients + noise */
.paper-bg {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 15% 22%, oklch(90% 0.04 70 / 0.35) 0, transparent 0.6px),
    radial-gradient(circle at 78% 63%, oklch(85% 0.05 60 / 0.25) 0, transparent 0.7px),
    radial-gradient(circle at 44% 88%, oklch(92% 0.03 80 / 0.3) 0, transparent 0.5px),
    radial-gradient(circle at 88% 12%, oklch(88% 0.05 55 / 0.3) 0, transparent 0.6px),
    radial-gradient(circle at 32% 55%, oklch(94% 0.02 85 / 0.4) 0, transparent 0.5px),
    linear-gradient(105deg, oklch(96% 0.02 80) 0%, oklch(97% 0.018 85) 50%, oklch(95% 0.025 78) 100%);
  background-size: 7px 7px, 11px 11px, 13px 13px, 9px 9px, 5px 5px, 100% 100%;
  position: relative;
}
.paper-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.25  0 0 0 0 0.15  0 0 0 0.08 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
}

.paper-card {
  background: var(--paper);
  position: relative;
  box-shadow:
    0 1px 0 oklch(85% 0.03 70 / 0.7),
    0 2px 4px oklch(40% 0.04 60 / 0.08),
    0 8px 24px -6px oklch(40% 0.05 60 / 0.12);
  border: 1px solid oklch(85% 0.03 70);
}

.deckle {
  --deckle-color: var(--paper);
  position: relative;
  background: var(--deckle-color);
}
.deckle::before,
.deckle::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='6' preserveAspectRatio='none'><path d='M0 3 Q 3 0, 6 2 T 12 3 T 18 2 T 24 3 T 30 2 T 36 3 T 40 2 L 40 6 L 0 6 Z' fill='%23f4eedd'/></svg>");
  background-size: 40px 6px;
  background-repeat: repeat-x;
}
.deckle::before { top: -5px; transform: scaleY(-1); }
.deckle::after { bottom: -5px; }

/* ink rules */
.rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 1em 0;
}
.rule-soft {
  border-top: 1px solid var(--rule-soft);
}

/* typography helpers */
.mono { font-family: var(--font-mono); font-size: 0.78em; letter-spacing: 0.02em; }
.hand { font-family: var(--font-hand); }
.tiny { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-family: var(--font-mono); }
.micro { font-size: 0.68rem; font-family: var(--font-mono); color: var(--ink-3); letter-spacing: 0.04em; }

h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 2.2rem; line-height: 1.1; }
h2 { font-size: 1.5rem; line-height: 1.2; }
h3 { font-size: 1.1rem; line-height: 1.3; }

/* highlighter for established truths */
.highlight {
  background: linear-gradient(180deg, transparent 0 10%, var(--yellow) 10% 88%, transparent 88% 100%);
  padding: 0 0.15em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.highlight-deep {
  background: linear-gradient(180deg, transparent 0 12%, var(--yellow-deep) 12% 88%, transparent 88% 100%);
  padding: 0 0.15em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* buttons */
.btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: oklch(15% 0.02 60); color: var(--paper); }
.btn-ghost {
  border: 1px dashed var(--rule);
  color: var(--ink-3);
}
.btn-ghost:hover { background: var(--paper-3); color: var(--ink); border-color: var(--ink-3); }
.btn-sm { padding: 5px 10px; font-size: 0.7rem; }
.btn-red { border-color: var(--red); color: var(--red); }
.btn-red:hover { background: var(--red); color: var(--paper); }

/* stamp */
.stamp {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1.5px solid currentColor;
  transform: rotate(-2deg);
  color: var(--ink-3);
  opacity: 0.75;
}
.stamp-red { color: var(--red); border-color: var(--red); }
.stamp-green { color: var(--green); border-color: var(--green); }
.stamp-blue { color: var(--blue); border-color: var(--blue); }

/* pin */
.pin {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, oklch(70% 0.15 25), oklch(40% 0.18 25) 70%, oklch(25% 0.1 25));
  box-shadow: 0 1px 2px oklch(30% 0.05 30 / 0.4), inset -1px -2px 3px oklch(20% 0.1 25 / 0.4);
}
.pin-blue { background: radial-gradient(circle at 35% 30%, oklch(70% 0.12 240), oklch(40% 0.14 240) 70%, oklch(25% 0.08 240)); }
.pin-green { background: radial-gradient(circle at 35% 30%, oklch(70% 0.12 140), oklch(40% 0.14 140) 70%, oklch(25% 0.08 140)); }
.pin-yellow { background: radial-gradient(circle at 35% 30%, oklch(85% 0.15 95), oklch(65% 0.17 90) 70%, oklch(40% 0.1 85)); }

/* ink underline — imperfect */
.ink-underline {
  text-decoration: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='6'><path d='M0 3 Q 25 0, 50 3 T 100 3' stroke='%23332a20' stroke-width='1' fill='none' opacity='0.6'/></svg>");
  background-repeat: repeat-x;
  background-position: 0 100%;
  background-size: 100px 6px;
  padding-bottom: 4px;
}

/* taped corner */
.tape {
  position: absolute;
  width: 60px; height: 18px;
  background: oklch(85% 0.08 85 / 0.55);
  border-left: 1px dashed oklch(70% 0.06 80 / 0.6);
  border-right: 1px dashed oklch(70% 0.06 80 / 0.6);
  box-shadow: 0 1px 2px oklch(30% 0.03 60 / 0.1);
}

/* scroll styling */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: oklch(80% 0.03 70 / 0.5); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: oklch(60% 0.03 60 / 0.6); border: 2px solid transparent; background-clip: padding-box; }

/* input */
textarea.paper-input, input.paper-input {
  font-family: var(--font-prose);
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  background-image: repeating-linear-gradient(
    transparent 0,
    transparent 27px,
    oklch(75% 0.04 220 / 0.28) 27px,
    oklch(75% 0.04 220 / 0.28) 28px
  );
  line-height: 28px;
  padding: 4px 10px 4px 10px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  outline: none;
  width: 100%;
  resize: vertical;
}
textarea.paper-input:focus, input.paper-input:focus {
  border-bottom-color: var(--ink);
}
input.paper-input { background-image: none; line-height: 1.4; padding: 6px 10px; }

/* dashed divider */
.dashed {
  border: 0;
  border-top: 1px dashed var(--rule);
  margin: 1em 0;
}

/* bucket column */
.bucket {
  padding: 14px 14px 20px 14px;
  min-height: 300px;
}

/* card on cork */
.map-card {
  background: var(--paper);
  padding: 10px 12px;
  font-size: 0.92rem;
  line-height: 1.35;
  box-shadow: 0 2px 4px oklch(30% 0.05 60 / 0.15), 0 6px 14px -4px oklch(30% 0.05 60 / 0.12);
  position: relative;
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid oklch(86% 0.03 70);
}
.map-card:hover {
  transform: translateY(-2px) rotate(-0.3deg);
  box-shadow: 0 4px 8px oklch(30% 0.05 60 / 0.18), 0 10px 20px -4px oklch(30% 0.05 60 / 0.16);
}
.map-card.rot-1 { transform: rotate(-0.8deg); }
.map-card.rot-2 { transform: rotate(0.6deg); }
.map-card.rot-3 { transform: rotate(-0.4deg); }
.map-card.rot-4 { transform: rotate(1deg); }

/* thermometer */
.thermo {
  width: 22px;
  height: 140px;
  position: relative;
}

/* scribble check */
.check-scribble {
  display: inline-block;
  width: 14px; height: 14px;
  vertical-align: middle;
}

/* fade in */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.4s ease-out both; }

@keyframes ink-bleed {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}
.ink-in { animation: ink-bleed 0.5s ease-out both; }

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* phase nav */
.phase-pip {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-3);
  background: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.phase-pip:hover { border-color: var(--ink); color: var(--ink); }
.phase-pip.done { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.phase-pip.active { background: var(--paper); color: var(--ink); border-color: var(--ink); border-width: 2px; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--ink); }

/* chat */
.msg {
  padding: 10px 14px;
  border-left: 2px solid var(--ink-4);
  margin: 0;
}
.msg-a { border-left-color: oklch(55% 0.1 25); }
.msg-b { border-left-color: oklch(50% 0.1 240); }
.msg-mediator {
  border-left: 0;
  border: 1px solid var(--ink-3);
  background: var(--paper-2);
  padding: 12px 14px;
}

/* callout */
.callout {
  position: relative;
  padding: 16px 18px 16px 60px;
  background: var(--red-soft);
  border: 1px solid var(--red);
  color: var(--ink);
}
.callout-yellow {
  background: oklch(94% 0.06 85);
  border-color: oklch(70% 0.12 85);
}

.god-note {
  font-family: var(--font-hand);
  color: var(--blue);
  font-size: 1.05rem;
  line-height: 1.2;
  padding: 6px 10px;
  border-left: 2px solid var(--blue);
  background: var(--blue-soft);
  margin: 8px 0;
}

/* viewpoint toggle visual */
.seat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--ink-4);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--paper);
  color: var(--ink-3);
}
.seat-chip.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* inset truth card */
.truth-stack {
  background: var(--paper-2);
  padding: 14px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink);
}

/* parking lot strikethrough */
.parked { color: var(--ink-3); font-style: italic; }
.parked::before {
  content: "⎯ ";
  color: var(--ink-4);
}

/* god view panel */
.god-panel {
  background: oklch(94% 0.05 235);
  border: 1px dashed var(--blue);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--blue);
  line-height: 1.5;
}

/* handwriting margin */
.margin-note {
  font-family: var(--font-hand);
  font-size: 1.2rem;
  color: oklch(40% 0.1 240 / 0.8);
  line-height: 1.1;
  transform: rotate(-2deg);
}

/* agent badge */
.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid currentColor;
}
.agent-coach-a { color: oklch(48% 0.12 25); }
.agent-coach-b { color: oklch(42% 0.12 240); }
.agent-mediator { color: oklch(25% 0.03 60); }

/* thermometer (instrument) */
.thermometer {
  position: relative;
  width: 18px;
  height: 80px;
  border: 1.2px solid var(--ink);
  border-radius: 10px 10px 0 0;
  background: var(--paper);
  overflow: hidden;
}
.thermometer-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, oklch(60% 0.18 25), oklch(72% 0.15 55));
  transition: height 0.4s ease-out;
}
.thermometer-bulb {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: oklch(55% 0.18 25);
  border: 1.2px solid var(--ink);
  margin: -3px auto 0;
  position: relative;
}

/* tape/sticky notes */
.sticky {
  background: oklch(90% 0.1 90);
  padding: 10px 12px;
  font-family: var(--font-hand);
  font-size: 1.15rem;
  line-height: 1.15;
  box-shadow: 2px 3px 6px oklch(30% 0.05 60 / 0.15);
  transform: rotate(-1.5deg);
  color: oklch(30% 0.08 60);
}
.sticky-blue { background: oklch(88% 0.06 235); color: oklch(28% 0.08 240); }
.sticky-green { background: oklch(88% 0.08 145); color: oklch(28% 0.08 145); }

/* tabs */
.tab {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 14px;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* asymmetry indicator */
.scale-asym {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

/* progress bar for steel-man */
.rating-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  cursor: pointer;
  background: var(--paper);
  transition: all 0.12s;
}
.rating-dot:hover { background: var(--ink-4); }
.rating-dot.filled { background: var(--ink); }

/* tweaks drawer */
.tweaks {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 320px;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 16px;
  z-index: 100;
  box-shadow: 0 10px 30px oklch(30% 0.05 60 / 0.2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 72vh;
  overflow-y: auto;
}
.tweaks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

/* pill */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--ink-3);
  color: var(--ink-3);
  background: var(--paper);
}
.pill-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ———— thinking / streaming indicators ———— */
/* A wavy ink line that "draws itself" L→R on a slow loop. Paired with label text. */
@keyframes ink-wave-draw {
  0%   { background-position: -120% 100%, 0 0; }
  60%  { background-position: 120% 100%, 0 0; }
  100% { background-position: 120% 100%, 0 0; }
}
.thinking-ink {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.thinking-ink__label {
  font-style: italic;
  color: var(--ink-2);
  font-family: var(--font-prose);
  font-size: 0.88rem;
  letter-spacing: 0;
  text-transform: none;
}
.thinking-ink__nib {
  width: 14px;
  height: 2px;
  background: var(--ink-2);
  position: relative;
  flex-shrink: 0;
  animation: nib-drift 2.4s ease-in-out infinite;
}
.thinking-ink__nib::after {
  content: '';
  position: absolute;
  right: -3px; top: -1.5px;
  width: 5px; height: 5px;
  background: var(--ink);
  border-radius: 50%;
  opacity: 0.85;
}
@keyframes nib-drift {
  0%, 100% { transform: translateX(0); opacity: 0.55; }
  50%      { transform: translateX(4px); opacity: 1; }
}

/* Streaming skeleton lines: thin paper rules that pulse while empty. */
.skel-line {
  height: 10px;
  background: linear-gradient(90deg,
    oklch(90% 0.02 75) 0%,
    oklch(94% 0.02 75) 50%,
    oklch(90% 0.02 75) 100%);
  background-size: 200% 100%;
  animation: skel-pulse 1.8s ease-in-out infinite;
  border-radius: 1px;
}
@keyframes skel-pulse {
  0%, 100% { background-position: 200% 0; }
  50%      { background-position: 0 0; }
}

/* A soft "reveal" when streamed content fills a previously-skeleton area. */
@keyframes stream-reveal {
  from { opacity: 0.4; filter: blur(1.5px); }
  to   { opacity: 1; filter: blur(0); }
}
.stream-reveal { animation: stream-reveal 0.35s ease-out both; }

/* utility */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.grow { flex: 1; }
.flex { display: flex; }
.col { flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-6 { padding: 24px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.relative { position: relative; }
