/* Thomod Learn — Direction artistique thomod-da (Calcaire / Craie / Sapin / Laiton) */

:root,
[data-theme="light"] {
  --bg: #F2F2EE;
  --card: #FAFAF7;
  --fg: #14231D;
  --primary: #1F3D33;
  --primary-hover: #162E26;
  --primary-fg: #FAFAF7;
  --accent: #A8874A;
  --accent-text: #7A6230;
  --muted-fg: #5F6A64;
  --border: #D8DBD3;
  --muted: #E7E9E3;
  --danger: #9E3B2F;
  --danger-soft: #F5EAE8;
  --success-soft: #E8EFEA;
  --shadow-float: 0 8px 24px -12px rgb(20 35 29 / 0.18);
  --font-serif: "Newsreader", Georgia, serif;
  --font-sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #0F1F1A;
  --card: #162A23;
  --fg: #E9E7DF;
  --primary: #C9D8CF;
  --primary-hover: #DCE7E0;
  --primary-fg: #0F1F1A;
  --accent: #C2A266;
  --accent-text: #C2A266;
  --muted-fg: #9BA69F;
  --border: #273B33;
  --muted: #1B3029;
  --danger: #D16B5D;
  --danger-soft: #2E1E1C;
  --success-soft: #1B332A;
  --shadow-float: 0 8px 24px -12px rgb(0 0 0 / 0.45);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

button {
  font-family: var(--font-sans);
  cursor: pointer;
}

.brass-rule {
  width: 4rem;
  height: 1px;
  background: var(--accent);
  margin: 1.25rem 0;
}

/* ── Buttons & Inputs (arrondi 3px strict) ───────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 3px;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

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

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-fg);
  border-color: transparent;
  padding: 0.4rem 0.65rem;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--fg);
  background: var(--muted);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  border-radius: 3px;
  font-size: 0.85rem;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.85rem;
}

.btn-full {
  width: 100%;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 3px;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background-color 150ms ease;
}

.icon-btn:hover {
  background: var(--muted);
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0.35rem;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 150ms ease;
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.textarea-input {
  resize: vertical;
  min-height: 4.5rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0.4rem 0 0;
}

/* ── Login Screen ────────────────────────────────────────────────── */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-box {
  width: 100%;
  max-width: 26rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2.25rem;
}

.login-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 2.25rem;
  line-height: 1.1;
  margin: 0;
}

.login-subtitle {
  color: var(--muted-fg);
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* ── App Shell Layout ────────────────────────────────────────────── */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.sidebar-actions {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section-head {
  padding: 0.75rem 1rem 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted-fg);
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: 3px;
  border-left: 2px solid transparent;
  transition: background-color 150ms ease;
}

.session-row:hover {
  background: var(--muted);
}

.session-row.active {
  background: var(--muted);
  border-left-color: var(--accent);
}

.session-row-btn {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  color: var(--fg);
  min-width: 0;
}

.session-row-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-row-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted-fg);
}

.session-del-btn {
  background: none;
  border: none;
  color: var(--muted-fg);
  font-size: 1rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 150ms ease, color 150ms ease;
}

.session-row:hover .session-del-btn,
.session-del-btn:focus {
  opacity: 1;
}

.session-del-btn:hover {
  color: var(--danger);
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: var(--fg);
  padding: 0.5rem 0.65rem;
  border-radius: 3px;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  transition: background-color 150ms ease;
}

.sidebar-link:hover {
  background: var(--muted);
}

.muted-count {
  color: var(--muted-fg);
  font-size: 0.82rem;
}

/* ── Main Area & Topbar ──────────────────────────────────────────── */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.topbar {
  height: 54px;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.topbar-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.25rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted-fg);
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.phase-step.active {
  color: var(--fg);
  font-weight: 600;
  border-bottom: 1.5px solid var(--accent);
}

.phase-step.done {
  color: var(--primary);
}

.phase-sep {
  color: var(--border);
}

.mode-tag {
  font-size: 0.82rem;
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* ── Split Workspace ─────────────────────────────────────────────── */

.workspace-split {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.lesson-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.timeline-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 2.25rem 3rem;
}

/* ── Welcome View (thomod-da editorial hero) ─────────────────────── */

.welcome-view {
  max-width: 44rem;
  padding: 3.5rem 0 2rem;
}

.hero-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: clamp(2.25rem, 4.5vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0;
  animation: hero-enter 550ms ease-out both;
}

@keyframes hero-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-title {
    animation: none;
  }
}

.hero-subtitle {
  color: var(--muted-fg);
  font-size: 1.05rem;
  max-width: 58ch;
  margin: 0 0 2.25rem;
}

.welcome-start {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
}

.welcome-row {
  margin-bottom: 1rem;
}

.welcome-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

/* ── Editorial Lesson Stream (max-w-65ch left-aligned) ───────────── */

.timeline {
  max-width: 68ch;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.msg-user {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  padding: 0.85rem 1.1rem;
  font-size: 1rem;
}

.msg-user-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 0.25rem;
}

.msg-user-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.att-chip {
  font-size: 0.8rem;
  color: var(--muted-fg);
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.12rem 0.5rem;
}

.msg-assistant {
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--fg);
}

.thought-disclosure {
  margin-bottom: 0.75rem;
  border-left: 2px solid var(--border);
  padding-left: 0.85rem;
  font-size: 0.875rem;
  color: var(--muted-fg);
}

.thought-disclosure summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--muted-fg);
  user-select: none;
}

.thought-body {
  margin-top: 0.4rem;
  white-space: pre-wrap;
  line-height: 1.5;
}

/* Markdown prose rules (thomod-da §2 & §8) */
.prose h1,
.prose h2 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.18;
  margin: 1.5rem 0 0.65rem;
}

.prose h1 { font-size: 1.9rem; }
.prose h2 { font-size: 1.5rem; }

.prose h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 1.25rem 0 0.45rem;
}

.prose p {
  margin: 0 0 0.9rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose ul,
.prose ol {
  margin: 0 0 0.9rem;
  padding-left: 1.4rem;
}

.prose li {
  margin-bottom: 0.3rem;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--fg);
  background: transparent;
}

.prose blockquote.callout-important {
  border-left-width: 3px;
  padding: 0.55rem 0.95rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 3px 3px 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--muted);
  padding: 0.12rem 0.35rem;
  border-radius: 3px;
}

.prose pre {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 0.9rem 0;
}

.prose pre code {
  background: transparent;
  padding: 0;
  font-size: 0.86rem;
  line-height: 1.55;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.94rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.prose th {
  font-weight: 600;
  background: var(--muted);
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* ── Phase Divider & Inline Plan Block ───────────────────────────── */

.phase-divider {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.75rem 0;
  color: var(--accent-text);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
}

.phase-divider::before,
.phase-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.inline-plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
}

.card-kicker {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-text);
  margin-bottom: 0.4rem;
}

.plan-layer-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.plan-layer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.plan-node-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.875rem;
  color: var(--fg);
}

.plan-node-pill.status-current {
  border-color: var(--accent);
  border-left-width: 3px;
  background: var(--card);
  font-weight: 600;
}

.plan-node-pill.status-visited {
  border-color: var(--primary);
  background: var(--success-soft);
}

/* ── Question, Predict, Check & Practice Problem Cards ───────────── */

.interact-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.35rem;
}

.interact-card.card-predict {
  border-left: 3px solid var(--accent);
}

.interact-card.card-check {
  border-left: 3px solid var(--primary);
}

.interact-card.card-problem {
  border-left: 3px solid var(--accent);
}

.interact-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.interact-tag {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-text);
}

.interact-meta {
  font-size: 0.8rem;
  color: var(--muted-fg);
}

.interact-question {
  font-size: 1.04rem;
  font-weight: 500;
  margin-bottom: 0.85rem;
  line-height: 1.55;
}

.reveal-gate {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
}

.option-btn.selected {
  border-color: var(--primary);
  background: var(--muted);
}

.option-btn.is-correct {
  border-color: var(--primary);
  background: var(--success-soft);
}

.option-btn.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option-letter {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-fg);
  background: var(--card);
  margin-top: 0.08rem;
}

.option-btn.selected .option-letter {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

.option-desc {
  display: block;
  font-size: 0.84rem;
  color: var(--muted-fg);
  margin-top: 0.15rem;
}

/* Confidence Calibration Bar (0 / 30 / 50 / 70 / 90 / 100) */
.confidence-block {
  margin: 0.85rem 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.confidence-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}

.confidence-stops {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.3rem;
}

.conf-stop {
  padding: 0.32rem 0.2rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-fg);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.conf-stop.active {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

.interact-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.interact-actions .spacer {
  flex: 1;
}

.result-banner {
  margin-top: 0.9rem;
  padding: 0.75rem 0.95rem;
  border-radius: 3px;
  border-left: 3px solid var(--primary);
  background: var(--bg);
  font-size: 0.93rem;
}

.result-banner.wrong {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.result-banner.gap {
  border-left-color: var(--accent);
}

.result-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.thinking-echo {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--muted-fg);
}

/* ── Demos & Visuals (rounded-none on media) ─────────────────────── */

.artifact-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.artifact-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.artifact-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 400;
}

.demo-frame {
  width: 100%;
  height: 360px;
  border: none;
  display: block;
  background: #FAFAF7;
}

.visual-stage {
  padding: 1rem;
  background: #FAFAF7;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.visual-stage svg {
  max-width: 100%;
  height: auto;
  border-radius: 0;
}

.artifact-caption {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted-fg);
}

/* ── Activity Indicator ──────────────────────────────────────────── */

.activity-bar {
  max-width: 68ch;
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  color: var(--muted-fg);
  padding: 0.45rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

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

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

.composer-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 0.85rem 2.25rem 1rem;
}

.practice-pause-bar {
  max-width: 68ch;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  padding: 0.65rem 0.9rem;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 3px;
  font-size: 0.88rem;
}

.attachment-strip {
  max-width: 68ch;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
}

.attachment-pill button {
  background: none;
  border: none;
  color: var(--muted-fg);
  padding: 0;
  font-size: 0.9rem;
}

.composer-form {
  max-width: 68ch;
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-fg);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.attach-btn:hover {
  color: var(--fg);
  border-color: var(--primary);
}

.composer-input {
  flex: 1;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.55rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.96rem;
  line-height: 1.5;
  resize: none;
  max-height: 10rem;
}

.composer-lock-note {
  max-width: 68ch;
  margin: 0.45rem 0 0;
  font-size: 0.82rem;
  color: var(--muted-fg);
}

/* ── Right Inspector (Plan / Graphe / Aide) ──────────────────────── */

.inspector {
  width: 390px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--card);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.inspector.collapsed {
  display: none;
}

.inspector-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 0.75rem;
  gap: 0.25rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.75rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted-fg);
  transition: color 150ms ease, border-color 150ms ease;
}

.tab-btn:hover {
  color: var(--fg);
}

.tab-btn.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

.panel-empty {
  color: var(--muted-fg);
  font-size: 0.9rem;
  line-height: 1.55;
  padding: 1.25rem 0.5rem;
}

.plan-node-card {
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-node-card.status-current {
  border-color: var(--accent);
  border-left-width: 3px;
  background: var(--card);
  font-weight: 600;
}

.plan-node-card.status-visited {
  border-color: var(--primary);
  background: var(--success-soft);
}

.status-label {
  font-size: 0.76rem;
  color: var(--muted-fg);
  white-space: nowrap;
}

.assessment-box {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
}

.assessment-box h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.assessment-strand {
  margin-bottom: 0.6rem;
  padding-left: 0.7rem;
  border-left: 2px solid var(--border);
}

/* ── Knowledge Graph Interactive SVG ─────────────────────────────── */

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.graph-stats {
  font-size: 0.82rem;
  color: var(--muted-fg);
}

.graph-toolbar-actions {
  display: flex;
  gap: 0.35rem;
}

.graph-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.graph-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.graph-svg:active {
  cursor: grabbing;
}

#graph-empty-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  pointer-events: none;
}

.graph-detail {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.87rem;
}

.graph-detail-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 400;
  margin: 0 0 0.35rem;
}

.graph-detail-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

/* ── Side Chat ───────────────────────────────────────────────────── */

.sidechat-panel {
  gap: 0.75rem;
}

.sidechat-notice {
  font-size: 0.82rem;
  color: var(--muted-fg);
  margin: 0;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.sidechat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sc-msg {
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0.6rem 0.75rem;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.sc-msg.user {
  background: var(--bg);
  border-left: 2px solid var(--primary);
}

.sc-msg.assistant {
  background: var(--card);
  border-left: 2px solid var(--accent);
}

.sidechat-form {
  display: flex;
  gap: 0.45rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(20 35 29 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 32rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-float);
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}

.modal-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.45rem;
  margin: 0;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.status-line {
  font-size: 0.84rem;
  color: var(--muted-fg);
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.5rem;
}

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

.mobile-only {
  display: none;
}

@media (max-width: 1080px) {
  .inspector {
    position: fixed;
    top: 54px;
    right: 0;
    bottom: 0;
    z-index: 40;
    box-shadow: var(--shadow-float);
    width: min(390px, 92vw);
  }
}

@media (max-width: 780px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-float);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .timeline-scroll,
  .composer-bar {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .phase-strip {
    display: none;
  }
}
