:root {
  --ink:    #231f20;
  --green:  #9ccb47;
  --cream:  #f2f1ee;
  --border: #e0e0e0;
  --ink-soft: #4a4647;
  --ink-mute: #6c6869;
  --green-soft: #d3e6a9;
  --green-deep: #7daa30;
  --shadow-sm: 0 1px 2px rgba(35, 31, 32, 0.04), 0 1px 3px rgba(35, 31, 32, 0.06);
  --shadow-md: 0 4px 14px rgba(35, 31, 32, 0.06), 0 1px 3px rgba(35, 31, 32, 0.04);
  --shadow-lg: 0 24px 48px -16px rgba(35, 31, 32, 0.18);
  --radius:    18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'kern';
}

.font-arabic { font-family: 'Cairo', 'Nunito', sans-serif; }
.text-rtl   { direction: rtl; text-align: right; }
.text-mute  { color: var(--ink-mute); }
.text-soft  { color: var(--ink-soft); }
.text-green { color: var(--green-deep); }

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--green-deep); }

/* ── Layout ─────────────────────────────────────────────── */

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(242, 241, 238, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark .logo-tile {
  width: 36px;
  height: 36px;
  background: var(--ink);
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 4px;
}
.brand-mark .logo-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-mark .wordmark {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 18px;
}
.brand-mark .tagline {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: -2px;
}
.topbar .meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.topbar .meta .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(156, 203, 71, 0.18);
}

main {
  flex: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 56px 28px 96px;
  width: 100%;
}

/* ── Hero / page heading ────────────────────────────────── */

.hero {
  margin-bottom: 40px;
}
.hero .kicker {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green-deep);
  font-weight: 700;
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hero .kicker::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.hero h1 {
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--ink);
}
.hero p {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  max-width: 600px;
}

/* ── Surface / cards ────────────────────────────────────── */

.surface {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.surface-padded { padding: 32px; }

.surface-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 28px;
}
.surface-head h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
}
.surface-head .step-pill {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
}

/* ── Form controls ──────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}
.field label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.input, .textarea, select.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.input:focus, .textarea:focus, select.input:focus {
  outline: none;
  border-color: var(--green);
  background: white;
  box-shadow: 0 0 0 4px rgba(156, 203, 71, 0.18);
}
.textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.55;
}

/* segmented control (tones) */
.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px;
}
.segment input { display: none; }
.segment label {
  text-align: center;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  border-radius: 9px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.segment input:checked + label {
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow-sm);
}
.segment label:hover { color: var(--ink); }
.segment input:checked + label:hover { color: white; }
.segment input:disabled + label {
  color: var(--ink-mute);
  opacity: 0.55;
  cursor: not-allowed;
}
.segment input:disabled + label:hover { color: var(--ink-mute); }
.seg-hint {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0.65;
  text-transform: lowercase;
}
.segment input:checked + label .seg-hint { opacity: 0.7; }

/* primary CTA button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
.btn-primary {
  background: var(--ink);
  color: var(--cream);
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary .accent {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: white; border-color: var(--ink-mute); }

.btn-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* ── Result panel ───────────────────────────────────────── */

.result-wrap { margin-top: 40px; animation: slideUp 320ms ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
  margin-bottom: 24px;
}
.result-meta .sep { color: var(--border); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.chip.chip-green {
  background: var(--green-soft);
  border-color: transparent;
  color: var(--ink);
}

.hook-card {
  background: var(--ink);
  color: var(--cream);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.hook-card::before {
  content: "";
  position: absolute;
  top: 0; right: 0;
  width: 160px; height: 160px;
  background: radial-gradient(closest-side, rgba(156, 203, 71, 0.22), transparent);
  pointer-events: none;
}
.hook-card .label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 800;
  margin-bottom: 14px;
}
.hook-card .hook-text {
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 30px;
  line-height: 1.35;
  font-weight: 700;
  direction: rtl;
  text-align: right;
}
.hook-card .hook-rationale {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(242, 241, 238, 0.7);
  font-family: 'Cairo', 'Nunito', sans-serif;
  direction: rtl;
  text-align: right;
  line-height: 1.55;
}

.section-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 800;
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.scene {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
  margin-bottom: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.scene:hover { border-color: var(--ink-mute); box-shadow: var(--shadow-sm); }

.scene-with-image {
  display: grid;
  grid-template-columns: 168px 1fr;
  gap: 22px;
  align-items: start;
}
.scene-image {
  display: block;
  width: 168px;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  position: relative;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.scene-image:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.scene-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scene-with-image .scene-body { min-width: 0; }

.notice {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.55;
}
.notice code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  background: rgba(0,0,0,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}
.notice-info {
  background: var(--cream);
  border-left: 3px solid var(--green);
  color: var(--ink-soft);
}
.notice-warn {
  background: #fdf0d6;
  border-left: 3px solid #d4a017;
  color: #6a4505;
}

@media (max-width: 640px) {
  .scene-with-image {
    grid-template-columns: 1fr;
  }
  .scene-image {
    width: 100%;
    max-width: 240px;
  }
}
.scene-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.scene-num {
  width: 30px; height: 30px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}
.scene-time {
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink-mute);
}
.scene-grid {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 6px 18px;
  align-items: baseline;
  font-size: 14px;
}
.scene-grid dt {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
  padding-top: 4px;
}
.scene-grid dd {
  margin: 0;
  font-family: 'Cairo', 'Nunito', sans-serif;
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  color: var(--ink);
}
.scene-grid dd.ltr {
  font-family: 'Nunito', sans-serif;
  direction: ltr;
  text-align: left;
}

.cta-card {
  background: var(--green-soft);
  border-radius: var(--radius-sm);
  padding: 22px;
  margin-top: 18px;
}
.cta-card .label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green-deep);
  font-weight: 800;
  margin-bottom: 10px;
}
.cta-card .cta-text {
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 17px;
  line-height: 1.55;
  font-weight: 600;
  direction: rtl;
  text-align: right;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.pill {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--ink);
  font-family: 'Cairo', 'Nunito', sans-serif;
}

.alt-hook {
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 16px;
  direction: rtl;
  text-align: right;
  line-height: 1.55;
  margin-bottom: 8px;
  color: var(--ink-soft);
}

.trend-row {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 28px;
  margin-top: 8px;
}
.trend-row .cell .lbl {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 800;
  margin-bottom: 4px;
}
.trend-row .cell .val { font-size: 14px; line-height: 1.5; }

.notes-card {
  margin-top: 22px;
  padding: 18px 22px;
  background: white;
  border-left: 3px solid var(--green);
  border-radius: 4px var(--radius-sm) var(--radius-sm) 4px;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.notes-card .lbl {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
  margin-bottom: 6px;
}

/* ── Critique card ──────────────────────────────────────── */

.critique-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  margin-bottom: 28px;
  position: relative;
}
.critique-approve { border-left: 3px solid var(--green); }
.critique-revise  { border-left: 3px solid #d4a017; }

.critique-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.critique-title { display: flex; align-items: baseline; gap: 14px; }
.critique-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
}
.attempts {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.05em;
}

.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.verdict-approve {
  background: var(--green-soft);
  color: #4a6b1a;
}
.verdict-revise {
  background: #fdf0d6;
  color: #8a5a05;
}
.verdict-pending {
  background: var(--cream);
  color: var(--ink-mute);
}

.scores {
  display: grid;
  gap: 10px;
}
.score-row {
  display: grid;
  grid-template-columns: 150px 1fr 56px;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.score-label {
  color: var(--ink-soft);
  font-weight: 600;
}
.score-bar {
  display: block;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.score-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green-deep), var(--green));
  border-radius: 999px;
  transition: width 320ms ease;
}
.score-val {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-align: right;
  color: var(--ink);
}
.score-weak { color: #b07212; }

.critique-feedback {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.critique-feedback-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.critique-feedback-text {
  font-family: 'Cairo', 'Nunito', sans-serif;
  direction: rtl;
  text-align: right;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* ── Run details (collapsible) ─────────────────────────── */

.run-details {
  margin-top: 32px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.run-details summary {
  padding: 14px 22px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 140ms ease;
}
.run-details summary::-webkit-details-marker { display: none; }
.run-details summary:hover { background: var(--cream); }
.run-details-chevron {
  display: inline-block;
  transition: transform 160ms ease;
  color: var(--ink-mute);
}
.run-details[open] .run-details-chevron { transform: rotate(90deg); }
.run-details-errors { color: #b07212; }

.run-details-body {
  padding: 4px 22px 20px;
  border-top: 1px solid var(--border);
}

.run-plan {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0;
  font-size: 12px;
}
.run-plan-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
  margin-right: 4px;
}
.run-plan-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.run-plan-node {
  background: var(--cream);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.run-plan-arrow { color: var(--ink-mute); }

.event-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}
.event-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
.event-row td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--cream);
}
.event-row:last-child td { border-bottom: none; }
.event-node {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.event-time {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  width: 88px;
}
.event-note {
  color: var(--ink-soft);
  font-size: 12px;
}
.event-skipped .event-node { color: var(--ink-mute); }
.event-skipped .event-note { font-style: italic; opacity: 0.7; }
.event-failed td { background: #fdf0ee; }
.event-failed .event-node { color: #b07212; }

.error-list { margin-top: 14px; }
.error-line {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: #8a261e;
  background: #fdf0ee;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 6px;
}

/* ── Loading state ──────────────────────────────────────── */

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request .btn-text { display: none; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(242, 241, 238, 0.3);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.htmx-request.btn-primary { opacity: 0.85; cursor: progress; }

/* ── Error ──────────────────────────────────────────────── */

.error-card {
  margin-top: 32px;
  background: white;
  border: 1px solid #f0c8c0;
  border-left: 3px solid #c4332b;
  border-radius: var(--radius-sm);
  padding: 22px;
}
.error-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 800;
  color: #8a261e;
}
.error-card pre {
  margin: 0;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--ink-soft);
}

/* ── Architecture page ─────────────────────────────────── */

.mermaid-wrap {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  margin-bottom: 18px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}
.mermaid-wrap .mermaid {
  font-family: 'Nunito', sans-serif !important;
  font-size: 14px;
  background: transparent;
}
.mermaid svg { max-width: 100%; height: auto; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 14px 6px 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--ink);
}
.legend-swatch.live { background: var(--green); }
.legend-swatch.stub { background: var(--border); border-color: var(--ink-mute); border-style: dashed; }
.legend-swatch.io   { background: var(--ink); border-color: var(--ink); }

.node-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.node-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 800;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
}
.node-row td {
  padding: 14px;
  border-bottom: 1px solid var(--cream);
  vertical-align: top;
}
.node-row:last-child td { border-bottom: none; }
.node-row:hover { background: var(--cream); }
.node-name code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.node-purpose { font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
.node-file code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--ink-mute);
  background: transparent;
  padding: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.status-live { background: var(--green-soft); color: #4a6b1a; }
.status-stub { background: var(--border); color: var(--ink-mute); }

.node-stub .node-name code,
.node-stub .node-purpose { opacity: 0.7; }

/* ── Teach-the-agent action panel ──────────────────────── */

.actions-card {
  margin-top: 36px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
}
.actions-head { margin-bottom: 16px; }
.actions-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--green-deep);
  margin-bottom: 4px;
}
.actions-sub { font-size: 13px; color: var(--ink-soft); line-height: 1.55; }

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.action-form { margin: 0; }
.action-approve { min-width: 160px; }

.action-panel {
  margin-top: 16px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-panel[hidden] { display: none; }
.action-panel-label {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.action-json {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  min-height: 280px;
  direction: ltr;
}
.action-reason { min-height: 90px; }

.action-done {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-top: 36px;
  border: 1px solid var(--border);
  animation: slideUp 240ms ease;
}
.action-done-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.action-done-body { padding-top: 4px; }
.action-done-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.action-done-message { font-size: 13px; color: var(--ink-soft); line-height: 1.55; }

.action-approved { border-left: 3px solid var(--green); }
.action-approved .action-done-icon { background: var(--green-soft); color: var(--green-deep); }
.action-rejected { border-left: 3px solid #d4a017; }
.action-rejected .action-done-icon { background: #fdf0d6; color: #8a5a05; }
.action-edited { border-left: 3px solid var(--ink); }
.action-edited .action-done-icon { background: var(--cream); color: var(--ink); }
.action-error { border-left: 3px solid #c4332b; }
.action-error .action-done-icon { background: #fdf0ee; color: #8a261e; }

/* ── Top nav ───────────────────────────────────────────── */

.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  margin-right: 16px;
}
.topnav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  transition: background 140ms ease, color 140ms ease;
}
.topnav-link:hover { background: var(--cream); color: var(--ink); }
.topnav-link.active { background: var(--ink); color: var(--cream); }

/* ── User menu (top-right dropdown) ───────────────────── */

.user-menu { position: relative; }
.user-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 6px 6px;
  border-radius: 9px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  transition: background 140ms ease, border-color 140ms ease;
}
.user-button:hover { background: var(--cream); border-color: var(--border); }
.user-avatar {
  width: 28px; height: 28px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}
.user-email {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chevron { color: var(--ink-mute); font-size: 10px; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 60;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown-org {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.user-dropdown-org-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 800;
  display: block;
  margin-bottom: 2px;
}
.user-dropdown-org-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.user-dropdown-link,
.user-dropdown-logout {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 140ms ease;
}
.user-dropdown-link:hover { background: var(--cream); }
.user-dropdown-form { margin: 0; padding-top: 6px; border-top: 1px solid var(--cream); margin-top: 6px; }
.user-dropdown-logout:hover { background: #fdf0ee; color: #8a261e; }

/* ── Auth pages ────────────────────────────────────────── */

.auth-shell {
  min-height: calc(100vh - 200px);
  display: grid;
  place-items: center;
  padding: 60px 28px 80px;
}
.auth-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 44px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.auth-card-wide { max-width: 520px; }

.auth-head { text-align: center; margin-bottom: 32px; }
.auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  text-align: left;
}
.auth-logo .logo-tile {
  width: 40px; height: 40px;
  background: var(--ink);
  border-radius: 11px;
  display: grid;
  place-items: center;
  padding: 5px;
}
.auth-logo .logo-tile img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo .wordmark { font-weight: 800; letter-spacing: -0.02em; font-size: 20px; }
.auth-logo .tagline {
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: -2px;
}
.auth-head h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.auth-sub {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.auth-form { display: flex; flex-direction: column; gap: 0; }
.auth-form .field { margin-bottom: 18px; }
.field-hint {
  font-size: 12px;
  color: var(--ink-mute);
  line-height: 1.4;
  margin-top: 2px;
}

.signup-promise {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin: 6px 0 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.promise-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}
.promise-icon {
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  background: var(--green);
  color: var(--ink);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-submit { width: 100%; padding: 14px; }

.auth-foot {
  text-align: center;
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-soft);
}
.auth-link {
  color: var(--green-deep);
  font-weight: 700;
  margin-left: 4px;
}
.auth-link:hover { color: var(--ink); }

@media (max-width: 520px) {
  .auth-card { padding: 28px 22px 24px; }
  .auth-head h1 { font-size: 22px; }
  .user-email { display: none; }
}

/* ── Generic page utilities ─────────────────────────────── */

.page-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-clients { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.card-link { color: inherit; text-decoration: none; display: block; }
.card-link:hover { color: inherit; }

.segment-2 { grid-template-columns: 1fr 1fr; }

.btn-small { padding: 8px 14px; font-size: 12px; }
.btn-danger { color: #8a261e; border-color: #f0c8c0; }
.btn-danger:hover { background: #fdf0ee; color: #8a261e; border-color: #c4332b; }

.btn-text-link {
  color: var(--ink-mute);
  font-size: 13px;
  padding: 8px 6px;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 140ms ease;
}
.btn-text-link:hover { text-decoration-color: var(--ink); color: var(--ink); }

.welcome-banner {
  border-left: 3px solid var(--green) !important;
  animation: slideUp 320ms ease;
}

/* ── Empty states ───────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 64px 28px;
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; line-height: 1; }
.empty-state h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
}
.empty-state p {
  color: var(--ink-soft);
  max-width: 460px;
  margin: 0 auto 24px;
  line-height: 1.55;
}

/* ── Clients list / cards ───────────────────────────────── */

.client-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
  display: grid;
  grid-template-columns: 48px 1fr 18px;
  gap: 16px;
  align-items: center;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.client-card:hover {
  transform: translateY(-2px);
  border-color: var(--ink-mute);
  box-shadow: var(--shadow-md);
}
.client-avatar {
  width: 48px; height: 48px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
}
.client-body { min-width: 0; }
.client-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-industry {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.client-stats {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.stat-pill {
  font-size: 11px;
  color: var(--ink-soft);
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}
.stat-pill .stat-num { font-weight: 800; color: var(--ink); }
.client-chev { color: var(--ink-mute); font-size: 18px; }

/* ── Client detail / stat cards ─────────────────────────── */

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.card-link:hover .stat-card { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card-label {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 800;
}
.stat-card-num {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 8px 0 0;
  line-height: 1;
}
.stat-card-sub {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 4px;
}

.quickactions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }

.profile-block { margin-bottom: 18px; }
.profile-block-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.profile-list { margin: 0; padding-left: 20px; line-height: 1.7; color: var(--ink); font-size: 14px; }

/* ── Voice memory list ──────────────────────────────────── */

.voice-list { display: flex; flex-direction: column; gap: 12px; }
.voice-entry {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 22px;
}
.voice-entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.voice-entry-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  flex: 1 1 240px;
  min-width: 240px;
}
.anchor-star {
  color: var(--green-deep);
  font-size: 16px;
  margin-right: 4px;
}
.voice-entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;
}
.voice-entry-meta .chip { flex: 0 0 auto; align-self: center; }
.voice-entry-body summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-mute);
  padding: 6px 0;
}
.voice-content {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  line-height: 1.55;
  background: var(--cream);
  border-radius: var(--radius-xs);
  padding: 14px;
  overflow-x: auto;
  margin-top: 8px;
  direction: ltr;
  text-align: left;
}
.voice-entry-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--cream);
}

/* ── Rules ──────────────────────────────────────────────── */

.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 20px;
  align-items: start;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.rule-inactive { opacity: 0.55; }
.rule-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  grid-column: 1;
}
.rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1;
  margin-top: 6px;
}
.rule-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
}

/* ── History list ───────────────────────────────────────── */

.filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.filter-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-input { min-width: 160px; padding: 9px 12px; font-size: 13px; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.card-link:hover .history-row {
  transform: translateY(-1px);
  border-color: var(--ink-mute);
  box-shadow: var(--shadow-sm);
}
.history-row-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.history-row-when {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--ink-mute);
}
.history-row-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.history-row-hook {
  font-family: 'Cairo', 'Nunito', sans-serif;
  direction: rtl;
  text-align: right;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  margin: 12px 0 8px;
  color: var(--ink);
}
.history-row-foot {
  font-size: 12px;
  color: var(--ink-mute);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.run-id-mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; }

.pagination {
  margin-top: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

/* ── Ingest / curate ────────────────────────────────────── */

.big-spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--cream);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  margin: 0 auto;
}

.curate-intro {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.curate-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin-bottom: 12px;
}
.curate-row-bad { opacity: 0.6; }
.curate-row-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.curate-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.curate-num {
  display: inline-grid;
  place-items: center;
  width: 24px; height: 24px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}
.curate-url {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--ink-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.curate-fields { display: flex; flex-direction: column; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }

/* ── Approval history ───────────────────────────────────── */

.approval-list { display: flex; flex-direction: column; gap: 12px; }
.approval-row {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border-left: 3px solid var(--border);
}
.approval-approve { border-left-color: var(--green); }
.approval-reject  { border-left-color: #d4a017; }
.approval-edit    { border-left-color: var(--ink); }
.approval-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.approval-status {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink);
}
.approval-text {
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ── Profile YAML editor (clients/edit) ─────────────────── */

.profile-yaml {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  min-height: 360px;
  direction: ltr;
}

/* ── Voice memory inspector (on result page) ───────────── */

.voice-inspector {
  margin-top: 28px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.voice-inspector summary {
  padding: 14px 22px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 140ms ease;
}
.voice-inspector summary::-webkit-details-marker { display: none; }
.voice-inspector summary:hover { background: var(--cream); }
.voice-inspector[open] .run-details-chevron { transform: rotate(90deg); }
.voice-inspector-body {
  padding: 6px 22px 22px;
  border-top: 1px solid var(--border);
}
.inspector-block { margin-top: 18px; }

/* ── Toast notifications ───────────────────────────────── */

.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 16px;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}
.toast-msg {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  flex: 1;
}
.toast-close {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--ink-mute);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 140ms ease;
}
.toast-close:hover { color: var(--ink); }

.toast-approved      { border-left-color: var(--green); }
.toast-approved .toast-icon { background: var(--green-soft); color: var(--green-deep); }
.toast-edited        { border-left-color: var(--ink); }
.toast-edited .toast-icon   { background: var(--cream); color: var(--ink); }
.toast-rejected      { border-left-color: #d4a017; }
.toast-rejected .toast-icon { background: #fdf0d6; color: #8a5a05; }
.toast-error         { border-left-color: #c4332b; }
.toast-error .toast-icon    { background: #fdf0ee; color: #8a261e; }

/* Auto-dismiss toasts after 5s via tiny JS at end of base */

/* ── Mobile sweep ───────────────────────────────────────── */

@media (max-width: 720px) {
  .topbar-inner { padding: 12px 18px; gap: 12px; flex-wrap: wrap; }
  .topnav { display: none; }
  main { padding: 28px 16px 64px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 14px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-clients { grid-template-columns: 1fr; }
  .actions-row { flex-direction: column; align-items: stretch; }
  .actions-row .btn { width: 100%; }
  .surface-padded { padding: 22px 18px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
}

/* ── Topnav badge ───────────────────────────────────────── */

.topnav-badge {
  display: inline-block;
  background: var(--green);
  color: var(--ink);
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.topnav-link.active .topnav-badge { background: var(--green); color: var(--ink); }

/* ── Posts list / status colors ─────────────────────────── */

.post-list { display: flex; flex-direction: column; gap: 10px; }

.post-row {
  background: white;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.card-link:hover .post-row {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.post-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.post-row-kind {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--ink-mute);
}
.post-row-preview {
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 8px;
}
.post-row-foot { color: var(--ink-mute); }

.post-status-badge {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
}
.status-awaiting_review { background: var(--green-soft); color: var(--green-deep); }
.status-approved        { background: #d6e8f5;        color: #1e4a73; }
.status-posted          { background: var(--ink);     color: var(--cream); }
.status-rejected        { background: #fdf0d6;        color: #8a5a05; }
.status-skipped         { background: var(--cream);   color: var(--ink-mute); border: 1px solid var(--border); }
.status-failed          { background: #fdf0ee;        color: #8a261e; }

.post-status-awaiting_review { border-left-color: var(--green); }
.post-status-approved        { border-left-color: #4a7eaf; }
.post-status-posted          { border-left-color: var(--ink); }
.post-status-rejected        { border-left-color: #d4a017; }
.post-status-failed          { border-left-color: #c4332b; }

/* ── Tweet card (detail page) ───────────────────────────── */

.tweet-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin-bottom: 10px;
  position: relative;
}
.tweet-card.tweet-over { border-color: #f0c8c0; border-left: 3px solid #c4332b; }
.tweet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.tweet-num {
  width: 28px; height: 28px;
  background: var(--ink);
  color: var(--cream);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
}
.tweet-chars {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.tweet-chars-bad { color: #c4332b; font-weight: 700; }
.tweet-text {
  font-family: 'Cairo', 'Nunito', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  direction: rtl;
  text-align: right;
  color: var(--ink);
}

/* ── Footer ─────────────────────────────────────────────── */

.footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--ink-mute);
  letter-spacing: 0.06em;
}
.footer .dot {
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--green);
  margin: 0 8px;
  vertical-align: middle;
}

/* ── Small screens ──────────────────────────────────────── */

@media (max-width: 640px) {
  main { padding: 36px 18px 80px; }
  .hero h1 { font-size: 30px; }
  .surface-padded { padding: 22px; }
  .scene-grid { grid-template-columns: 1fr; }
  .scene-grid dt { padding-top: 0; }
  .trend-row { grid-template-columns: 1fr; }
}

/* ── Ingest pane tabs (URL vs paste-text) ───────────────────────── */
.ingest-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  padding: 0 6px;
}
.ingest-tab {
  appearance: none;
  background: transparent;
  border: none;
  font: 600 14px/1 var(--font-sans);
  color: var(--ink-mute);
  padding: 14px 18px 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease;
}
.ingest-tab:hover { color: var(--ink); }
.ingest-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--green);
}
.ingest-pane { display: none; border-top-left-radius: 0; border-top-right-radius: 0; }
.ingest-pane.is-active { display: block; }

/* ── Instructions Inspector page ────────────────────────────────── */
.inspector-section { margin-top: 24px; }
.inspector-section .surface-head { align-items: flex-start; gap: 18px; }
.inspector-section-tag {
  display: inline-block;
  font: 600 11px/1 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--green-soft);
  color: var(--green-deep);
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.inspector-section-tag.tag-org    { background: #ece7f5; color: #4d3a99; }
.inspector-section-tag.tag-client { background: var(--green-soft); color: var(--green-deep); }
.inspector-section-tag.tag-pool   { background: #fff3d6; color: #8a5a00; }
.inspector-section-tag.tag-derived { background: #fbe7ea; color: #8a261e; }
.inspector-section h2 { margin: 0; }
.inspector-section-sub {
  color: var(--ink-mute);
  font-size: 13.5px;
  margin: 6px 0 14px;
  line-height: 1.55;
}
.inspector-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fff;
  margin-bottom: 8px;
}
.inspector-item-title {
  font: 700 14.5px/1.45 var(--font-sans);
  margin-bottom: 4px;
}
.inspector-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.inspector-item-body {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.55;
}
.inspector-item-body pre {
  background: #faf8f4;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
}
.inspector-empty {
  color: var(--ink-mute);
  font-style: italic;
  font-size: 13.5px;
  padding: 10px 0;
}
.inspector-stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.inspector-stat-row .stat-card {
  text-align: left;
}
@media (max-width: 720px) {
  .inspector-stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── Learned-rules review (pending candidates from feedback) ────── */
.learned-rule {
  background: white;
  border: 1px solid #f0d8a8;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.learned-rule-rule {
  font-size: 14.5px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.learned-rule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.learned-rule-source {
  background: #faf6ee;
  border: 1px solid #f0e8d0;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.learned-rule-source summary {
  cursor: pointer;
  color: var(--ink-mute);
  font-size: 12px;
}
.learned-rule-source blockquote {
  margin: 8px 0 0;
  padding: 0 0 0 12px;
  border-left: 3px solid var(--green);
  color: var(--ink-soft);
  font-style: italic;
  line-height: 1.5;
}
.learned-rule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.learned-rule-edit-form {
  flex-basis: 100%;
}

/* ── Rich voice-entry rendering (source link + structured body) ── */
.voice-entry-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f6f4ef;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  max-width: 100%;
  transition: background 160ms ease, border-color 160ms ease;
}
.voice-entry-source:hover {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--ink);
}
.voice-entry-source-icon { font-size: 14px; }
.voice-entry-source-url {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.voice-entry-source-arrow { font-size: 13px; opacity: 0.6; }

.voice-entry-section {
  margin: 12px 0;
  padding: 10px 14px;
  background: #faf8f4;
  border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0;
}
.voice-entry-section-label {
  font: 700 11px/1 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.voice-entry-section-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ── Transcript rendered as timestamped rows ─────────────────── */
.transcript-rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 4px;
}
.transcript-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: start;
  padding: 9px 14px;
  background: white;
  font-size: 14px;
  line-height: 1.65;
}
.transcript-row-nostamp {
  grid-template-columns: 1fr;
}
.transcript-row + .transcript-row { /* no extra border, gap+bg already paints */ }
.transcript-time {
  font: 700 11.5px/1 ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  color: var(--green-deep);
  background: var(--green-soft);
  padding: 5px 7px;
  border-radius: 6px;
  text-align: center;
  align-self: start;
  margin-top: 2px;
}
.transcript-text {
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.voice-entry-hook {
  font-weight: 700;
  font-size: 15px;
}
.voice-entry-scenes {
  margin: 0;
  padding-left: 24px;
  font-size: 13.5px;
  line-height: 1.55;
}
.voice-entry-scenes li {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.voice-entry-scenes li:last-child { border-bottom: none; margin-bottom: 0; }
.voice-entry-scene-vo {
  color: var(--ink);
  margin-bottom: 2px;
}
.voice-entry-scene-text {
  color: var(--ink-soft);
  font-size: 12.5px;
}
.voice-entry-hashtags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.voice-entry-hashtag {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--green-deep);
  font-weight: 600;
}
.voice-entry-raw {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.voice-entry-raw summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--ink-mute);
  padding: 4px 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Copy button — flashes green when copied ──────────────────── */
.btn-copy-success,
button.btn-copy-success {
  background: var(--green) !important;
  color: white !important;
  border-color: var(--green) !important;
  transition: all 180ms ease;
}
.copy-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 12px/1 var(--font-sans);
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn-copy:hover {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--ink);
}
.copy-hidden {
  position: absolute;
  left: -10000px;
  top: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
