/* ── Reset & base ─────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #f4f2ee;
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100vh;
  color: #2a2622;
  overflow: hidden;
}

/* ── App split layout ─────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
}
.app.dragging { user-select: none; cursor: col-resize; }

/* ── Main area (schematic) ────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #eae7e2;
}

.header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding-left: 4px;
  flex-shrink: 0;
  align-self: flex-start;
}
.header h1 {
  font-size: 11px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #8a6a10;
}
.header span {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: #8a8480;
  text-transform: uppercase;
}

#controller {
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}
.main.single-deck #controller { max-width: 82%; }
#controller svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.deck-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 500;
  color: #7a7470;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.deck-toggle input { display: none; }
.deck-toggle__check {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: #d0ccc4;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.deck-toggle__check::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.deck-toggle input:checked + .deck-toggle__check {
  background: #b08818;
}
.deck-toggle input:checked + .deck-toggle__check::after {
  transform: translateX(14px);
}

/* ── Interactive control highlights ───────────────────────── */
[data-control] { cursor: pointer; }
[data-control]:hover {
  filter: brightness(1.08) drop-shadow(0 0 5px rgba(160,120,30,0.4));
}
[data-control].active {
  filter: brightness(1.12) drop-shadow(0 0 8px rgba(200,160,48,0.9)) drop-shadow(0 0 18px rgba(200,160,48,0.5));
  animation: controlPulse 1.5s ease-in-out infinite;
}
@keyframes controlPulse {
  0%, 100% { filter: brightness(1.12) drop-shadow(0 0 8px rgba(200,160,48,0.9)) drop-shadow(0 0 18px rgba(200,160,48,0.5)); }
  50%      { filter: brightness(1.2) drop-shadow(0 0 14px rgba(200,160,48,1.0)) drop-shadow(0 0 28px rgba(200,160,48,0.65)); }
}

/* ── Tooltip ──────────────────────────────────────────────── */
.ddj-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: #fff;
  border: 1px solid #d8d4cc;
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 260px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.ddj-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
.ddj-tooltip__name {
  font-size: 11px;
  font-weight: 700;
  color: #6a5010;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}
.ddj-tooltip__cat {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ddj-tooltip__cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.ddj-tooltip__desc {
  font-size: 10px;
  font-weight: 400;
  color: #6a6460;
  line-height: 1.5;
}

/* ── Legend ────────────────────────────────────────────────── */
.ddj-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 2px 4px;
  flex-shrink: 0;
  align-self: flex-start;
}
.ddj-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.ddj-legend__item.dimmed { opacity: 0.25; }
.ddj-legend__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ddj-legend__label {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #6a6460;
}
.ddj-legend__item:hover .ddj-legend__label { color: #2a2622; }

/* ══════════════════════════════════════════════════════════ */
/* PANEL                                                      */
/* ══════════════════════════════════════════════════════════ */
/* ── Draggable divider ─────────────────────────────────────── */
.divider {
  width: 6px;
  cursor: col-resize;
  background: #e0dcd6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}
.divider:hover,
.divider.active {
  background: #c8a030;
}
.divider__line {
  width: 2px;
  height: 40px;
  border-radius: 1px;
  background: #c0bab2;
  transition: background 0.15s, height 0.15s;
}
.divider:hover .divider__line,
.divider.active .divider__line {
  background: #fff;
  height: 60px;
}

/* ══════════════════════════════════════════════════════════ */
/* PANEL                                                      */
/* ══════════════════════════════════════════════════════════ */
.panel {
  width: 40vw;
  min-width: 180px;
  max-width: none;
  background: #fff;
  border-left: none;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.panel__scroll {
  overflow-y: auto;
  flex: 1;
  padding: 28px 28px 40px;
}

/* ── Welcome / Home ───────────────────────────────────────── */
.panel__home { }
.panel__detail { display: none; }
.panel__home.hidden { display: none; }
.panel__detail.visible { display: block; }

/* ── Home tabs ────────────────────────────────────────────── */
.panel__tabs {
  display: flex;
  border-bottom: 2px solid #e8e4de;
  margin: 0 -20px 0;
  padding: 0 20px;
  gap: 0;
  flex-shrink: 0;
}
.panel__tab {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 12px 16px 10px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  color: #9a9490;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.panel__tab:hover {
  color: #4a4440;
}
.panel__tab--active {
  color: #2a2622;
  border-bottom-color: #2a2622;
}
.panel__tab-panel--hidden {
  display: none;
}

.panel__hero {
  padding: 20px 0 24px;
  border-bottom: 1px solid #e8e4de;
  margin-bottom: 24px;
}
.panel__hero-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
  background: #8a6a10;
  padding: 4px 12px;
  border-radius: 3px;
  margin-bottom: 12px;
}
.panel__hero-title {
  font-size: 24px;
  font-weight: 700;
  color: #1a1714;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}
.panel__hero-sub {
  font-size: 14px;
  font-weight: 400;
  color: #7a7470;
  line-height: 1.65;
}

/* ── Section titles ───────────────────────────────────────── */
.panel__section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a8a29a;
  margin-bottom: 10px;
}
.panel__hint {
  font-size: 13px;
  color: #9a9490;
  line-height: 1.55;
  margin-bottom: 14px;
}

/* ── Signal flow ──────────────────────────────────────────── */
.panel__signal-flow {
  margin-bottom: 28px;
}
.panel__flow-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.panel__flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 32px 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}
.panel__flow-step:hover {
  background: #f5f0e6;
}
.panel__flow-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 19px;
  bottom: -4px;
  width: 1px;
  height: 8px;
  background: #dcd8d0;
}
.panel__flow-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f4f2ee;
  border: 1.5px solid #d8d4cc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #8a8480;
  flex-shrink: 0;
}
.panel__flow-step:hover .panel__flow-num {
  border-color: #8a6a10;
  color: #8a6a10;
  background: #faf6ec;
}
.panel__flow-label {
  font-size: 13px;
  font-weight: 600;
  color: #3a3630;
  letter-spacing: 0.03em;
}
.panel__flow-sub {
  font-size: 11px;
  font-weight: 400;
  color: #a8a29a;
  margin-left: auto;
  letter-spacing: 0.02em;
}

/* ── Essentials ───────────────────────────────────────────── */
.panel__essentials {
  margin-bottom: 28px;
}
.panel__essentials-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel__essential-btn {
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  width: 100%;
}
.panel__essential-btn:hover {
  background: #f5f0e6;
}
.panel__essential-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.panel__essential-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.panel__essential-name {
  font-size: 13px;
  font-weight: 600;
  color: #2a2622;
  letter-spacing: 0.03em;
}
.panel__essential-sub {
  font-size: 11px;
  font-weight: 400;
  color: #9a9490;
}

/* ── Category grid ────────────────────────────────────────── */
.panel__categories {
  margin-bottom: 20px;
}
.panel__cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.panel__cat-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: #f9f7f4;
  border: 1px solid #e8e4de;
  border-radius: 6px;
  padding: 10px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6a6460;
  transition: background 0.12s, border-color 0.15s, color 0.15s;
}
.panel__cat-btn:hover {
  background: #f2ede4;
  border-color: #d0ccc4;
  color: #2a2622;
}
.panel__cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.panel__cat-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 400;
  color: #c0bab2;
}

/* ══════════════════════════════════════════════════════════ */
/* DETAIL STATE                                               */
/* ══════════════════════════════════════════════════════════ */
.panel__back {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #8a8480;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 18px;
  transition: color 0.12s;
}
.panel__back:hover { color: #8a6a10; }

.panel__detail-cat {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.panel__detail-cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.panel__detail-cat-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.panel__detail-name {
  font-size: 22px;
  font-weight: 700;
  color: #1a1714;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  line-height: 1.3;
}
.panel__detail-short {
  font-size: 14px;
  color: #7a7470;
  line-height: 1.55;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e8e4de;
}

.panel__detail-section {
  margin-bottom: 24px;
}
.panel__detail-desc {
  font-size: 14px;
  line-height: 1.75;
  color: #3a3630;
}
.panel__tips {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel__tips li {
  font-size: 13px;
  line-height: 1.65;
  color: #4a4640;
  padding: 8px 0 8px 18px;
  position: relative;
  border-left: 2px solid #e8e4de;
}
.panel__tips li::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b08818;
}
.panel__related {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.panel__related-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: #f9f7f4;
  border: 1px solid #e0dcd6;
  border-radius: 5px;
  color: #6a6460;
  padding: 6px 13px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.panel__related-btn:hover {
  color: #8a6a10;
  border-color: #c8a030;
  background: #faf6ec;
}

/* ── Panel content transitions ────────────────────────────── */
.panel__detail,
.panel__home {
  animation: panelFadeIn 0.2s ease-out;
}
@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar styling ────────────────────────────────────── */
.panel__scroll::-webkit-scrollbar,
.main::-webkit-scrollbar {
  width: 6px;
}
.panel__scroll::-webkit-scrollbar-track,
.main::-webkit-scrollbar-track {
  background: transparent;
}
.panel__scroll::-webkit-scrollbar-thumb {
  background: #d8d4cc;
  border-radius: 3px;
}
.main::-webkit-scrollbar-thumb {
  background: #ccc8c0;
  border-radius: 3px;
}

/* ── Collapsible panel sections ──────────────────────────── */
.panel__collapsible {
  border: 1px solid #e8e4de;
  border-radius: 6px;
  overflow: hidden;
}
.panel__collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f9f7f4;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  transition: background 0.12s;
}
.panel__collapsible-header:hover { background: #f2ede4; }
.panel__collapsible-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a5450;
}
.panel__collapsible-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid #8a8480;
  border-bottom: 2px solid #8a8480;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.panel__collapsible-chevron.rotated {
  transform: rotate(-135deg);
}
.panel__collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.panel__collapsible-body--open {
  max-height: 800px;
}

/* SHIFT pills */
.panel__shift-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
}
.panel__shift-pill {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
  background: #f4f2ee;
  border: 1px solid #e0dcd6;
  border-radius: 4px;
  padding: 5px 9px;
  color: #3a3630;
}

/* Technical Specs table */
.panel__spec-table {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  row-gap: 6px;
  padding: 12px 14px;
  margin: 0;
}
.panel__spec-key {
  font-size: 11px;
  font-weight: 600;
  color: #8a8480;
  white-space: nowrap;
}
.panel__spec-val {
  font-size: 11px;
  font-weight: 400;
  color: #3a3630;
  margin: 0;
  word-break: break-word;
}

/* Common Issues list */
.panel__issues-list {
  list-style: none;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel__issues-list li {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.panel__issue-problem {
  font-size: 12px;
  font-weight: 600;
  color: #b84000;
}
.panel__issue-fix {
  font-size: 12px;
  font-weight: 400;
  color: #4a4640;
  padding-left: 12px;
  border-left: 2px solid #e8e4de;
  line-height: 1.65;
}

/* ── How to Use It — numbered steps ─────────────────────── */
.panel__howto-steps {
  list-style: none;
  padding: 0;
  counter-reset: howto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel__howto-step {
  counter-increment: howto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 32px;
  position: relative;
}
.panel__howto-step::before {
  content: counter(howto);
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  background: #2a2622;
  color: #f4f2ee;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel__howto-action {
  font-size: 13px;
  font-weight: 600;
  color: #1a1714;
  line-height: 1.5;
}
.panel__howto-detail {
  font-size: 12px;
  font-weight: 400;
  color: #6a6460;
  line-height: 1.65;
  padding-left: 2px;
}

/* ── Concepts home section ──────────────────────────────── */
.panel__concepts-home {
  margin-bottom: 24px;
}
.panel__concept-cat-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel__concept-cat-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: #f9f7f4;
  border: 1px solid #e8e4de;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: background 0.12s, border-color 0.15s;
}
.panel__concept-cat-btn:hover {
  background: #f2ede4;
  border-color: #d0ccc4;
}
.panel__concept-cat-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.panel__concept-cat-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.panel__concept-cat-label {
  font-size: 12px;
  font-weight: 600;
  color: #2a2622;
}
.panel__concept-cat-count {
  font-size: 10px;
  font-weight: 400;
  color: #8a8480;
}

/* ── Concept panel state ────────────────────────────────── */
.panel__concept { display: none; }
.panel__concept.visible { display: block; animation: panelFadeIn 0.2s ease-out; }

/* ── Concept browse view ────────────────────────────────── */
.concept-browse__category {
  margin-bottom: 22px;
}
.concept-browse__cat-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.concept-browse__cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.concept-browse__cat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.concept-browse__item {
  font-family: 'IBM Plex Mono', monospace;
  width: 100%;
  background: #f9f7f4;
  border: 1px solid #e8e4de;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 5px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.12s, border-color 0.15s;
}
.concept-browse__item:hover {
  background: #f2ede4;
  border-color: #d0ccc4;
}
.concept-browse__item-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1714;
}
.concept-browse__item-tagline {
  font-size: 11px;
  font-weight: 400;
  color: #8a8480;
  line-height: 1.5;
}
.concept-browse__item-tagline em {
  font-style: normal;
  color: #b0a89e;
}

/* ── Concept article view ───────────────────────────────── */
.concept-article__badge {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.concept-article__badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.concept-article__title {
  font-size: 22px;
  font-weight: 700;
  color: #1a1714;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  line-height: 1.3;
}
.concept-article__tagline {
  font-size: 14px;
  color: #7a7470;
  line-height: 1.55;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e8e4de;
}
.concept-article__intro {
  font-size: 14px;
  line-height: 1.8;
  color: #2a2622;
  margin-bottom: 20px;
  font-weight: 500;
}
.concept-article__section-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5a5450;
  margin-bottom: 6px;
  margin-top: 18px;
}
.concept-article__section-heading:first-of-type { margin-top: 0; }
.concept-article__section-body {
  font-size: 13px;
  line-height: 1.8;
  color: #3a3630;
  margin-bottom: 0;
}
.concept-article__keypoints {
  background: #f4f2ee;
  border: 1px solid #e0dcd6;
  border-radius: 6px;
  padding: 14px 16px;
  margin-top: 22px;
  margin-bottom: 6px;
}
.concept-article__keypoints-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a5450;
  margin-bottom: 10px;
}
.concept-article__keypoints-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.concept-article__keypoints-list li {
  font-size: 12px;
  line-height: 1.6;
  color: #2a2622;
  padding-left: 18px;
  position: relative;
}
.concept-article__keypoints-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #5a8f6a;
  font-weight: 700;
  font-size: 11px;
}
.concept-article__stub {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f9f7f4;
  border: 1px solid #e0dcd6;
  border-radius: 6px;
  padding: 16px;
  margin: 20px 0;
  font-size: 13px;
  color: #8a8480;
  line-height: 1.6;
}
.concept-article__stub-icon {
  font-size: 18px;
  flex-shrink: 0;
  color: #b0a89e;
}
.concept-article__related {
  margin-top: 22px;
}
.concept-article__related-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8a8480;
  margin-bottom: 8px;
}
.concept-article__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.concept-article__chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.concept-article__chip--control {
  background: #f4f2ee;
  border: 1px solid #e0dcd6;
  color: #3a3630;
}
.concept-article__chip--control:hover {
  background: #eae7e2;
  border-color: #c8c2b8;
}
.concept-article__chip--concept {
  background: #eef3f0;
  border: 1px solid #c8dcd0;
  color: #3a6a4a;
}
.concept-article__chip--concept:hover {
  background: #e0ede6;
  border-color: #a8c8b8;
}
.concept-article__missing {
  font-size: 13px;
  color: #8a8480;
  padding: 20px 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .app {
    flex-direction: column;
  }
  .divider {
    width: auto;
    height: 6px;
    cursor: row-resize;
  }
  .divider__line {
    width: 40px;
    height: 2px;
  }
  .panel {
    width: auto !important;
    min-width: 0;
    max-width: none;
    height: auto;
    max-height: 50vh;
    flex-shrink: 1;
    border-top: 1px solid #e0dcd6;
  }
  .main { overflow-y: auto; flex: 1; }
}

/* ── Iteration 3: Search, signal-flow concepts, detail concept links ── */

/* Concept search in browse view */
.concept-browse__search-wrap {
  padding: 0 0 14px;
}
.concept-browse__search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d8d4ce;
  border-radius: 6px;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  color: #2a2622;
  outline: none;
}
.concept-browse__search:focus {
  border-color: #9b8ea0;
  box-shadow: 0 0 0 2px rgba(155,142,160,0.15);
}
.concept-browse__empty {
  font-size: 12px;
  color: #9a9490;
  padding: 8px 0;
  font-style: italic;
}

/* Signal flow concept button */
.panel__flow-concept {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #c8c4be;
  background: #fff;
  color: #8a8480;
  font-size: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.panel__flow-concept:hover {
  background: #f0eae8;
  border-color: #9b8ea0;
  color: #5a3060;
}

/* "Learn More" concept chips in detail panel */
.panel__concept-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}
.panel__concept-chip {
  display: inline-block;
  padding: 5px 10px;
  background: #f0eaf6;
  border: 1px solid #c8b8d8;
  border-radius: 4px;
  color: #5a3060;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.panel__concept-chip:hover {
  background: #e4d8f0;
  border-color: #9b6ec0;
}

/* ── Chat Widget ────────────────────────────────────────────── */

#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
}

/* Toggle button — fake input bar */
.chat__toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  width: 240px;
  background: #fff;
  color: #a8a29a;
  border: 1.5px solid #d0ccc6;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: text;
  box-shadow: 0 2px 10px rgba(0,0,0,0.09);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}
.chat__toggle:hover {
  border-color: #b85000;
  box-shadow: 0 2px 14px rgba(0,0,0,0.12), 0 0 0 3px rgba(184,80,0,0.08);
}
.chat__toggle--hidden {
  opacity: 0;
  transform: scale(0.9) translateY(6px);
  pointer-events: none;
}
.chat__toggle-icon {
  color: #d4820a;
  font-size: 13px;
  flex-shrink: 0;
}
.chat__toggle-text {
  flex: 1;
  color: #a8a29a;
}
.chat__toggle-cursor {
  width: 1.5px;
  height: 14px;
  background: #b85000;
  border-radius: 1px;
  animation: chat-blink 1.1s step-end infinite;
  flex-shrink: 0;
}
@keyframes chat-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* One-shot pulse animation */
@keyframes chat-pulse {
  0%   { box-shadow: 0 4px 16px rgba(0,0,0,0.22), 0 0 0 0 rgba(184,80,0,0.5); }
  60%  { box-shadow: 0 4px 16px rgba(0,0,0,0.22), 0 0 0 12px rgba(184,80,0,0); }
  100% { box-shadow: 0 4px 16px rgba(0,0,0,0.22), 0 0 0 0 rgba(184,80,0,0); }
}
.chat__toggle--pulse {
  animation: chat-pulse 1.2s ease-out 0.6s 1 forwards;
}

/* Chat panel */
.chat__panel {
  width: 480px;
  height: 580px;
  min-width: 320px;
  min-height: 340px;
  max-width: 720px;
  max-height: 80vh;
  background: #f4f2ee;
  border: 1px solid #d8d4ce;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: auto;
  position: relative;
  transform-origin: bottom right;
  transform: scale(0.88) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s cubic-bezier(0.4, 0, 1, 1), opacity 0.15s ease;
}
.chat__panel--open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

/* Top-left resize handle */
.chat__resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 10;
}
.chat__resize-handle::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-top: 2px solid rgba(255,255,255,0.25);
  border-left: 2px solid rgba(255,255,255,0.25);
  border-radius: 2px 0 0 0;
}

/* Header */
.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #2a2622;
  color: #f4f2ee;
  flex-shrink: 0;
}
.chat__header-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat__header-icon {
  color: #d4820a;
}
.chat__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat__clear {
  background: none;
  border: none;
  color: #8a8480;
  font-size: 10px;
  font-family: inherit;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}
.chat__clear:hover {
  color: #f4f2ee;
  background: rgba(255,255,255,0.08);
}
.chat__close {
  background: none;
  border: none;
  color: #c8c4be;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  font-family: inherit;
  transition: color 0.15s;
}
.chat__close:hover {
  color: #f4f2ee;
}

/* Context chip */
.chat__context-chip {
  padding: 6px 14px;
  background: #edeae4;
  border-bottom: 1px solid #e0dcd6;
  font-size: 10px;
  color: #7a7470;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Messages */
.chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* Bubbles */
.chat__bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat__bubble--user {
  align-self: flex-end;
  background: #2a2622;
  color: #f4f2ee;
  border-bottom-right-radius: 3px;
}
.chat__bubble--assistant {
  align-self: flex-start;
  background: #edeae4;
  color: #2a2622;
  border-bottom-left-radius: 3px;
}
.chat__bubble--error {
  background: #fdf0ed;
  border-left: 3px solid #c0392b;
  color: #7a1a10;
}

/* Markdown inside assistant bubbles */
.chat__bubble--assistant p { margin: 0 0 5px; }
.chat__bubble--assistant p:last-child { margin-bottom: 0; }
.chat__bubble--assistant p:first-child { margin-top: 0; }
.chat__bubble--assistant strong { font-weight: 600; color: #1a1714; }
.chat__bubble--assistant em { font-style: italic; }
.chat__bubble--assistant ul, .chat__bubble--assistant ol { margin: 2px 0 5px 16px; padding: 0; }
.chat__bubble--assistant li { margin-bottom: 2px; }
.chat__bubble--assistant li:last-child { margin-bottom: 0; }
.chat__bubble--assistant code { background: #e0dcd6; padding: 1px 5px; border-radius: 3px; font-size: 11px; }
.chat__bubble--assistant h1, .chat__bubble--assistant h2, .chat__bubble--assistant h3 { font-size: 13px; font-weight: 600; margin: 6px 0 3px; }

/* Loading dots */
.chat__bubble--loading {
  padding: 12px 14px;
}
.chat__dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.chat__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9a9490;
  animation: chat-dot-bounce 1.2s ease-in-out infinite;
}
.chat__dots span:nth-child(2) { animation-delay: 0.18s; }
.chat__dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes chat-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-5px); }
}

/* Input area */
.chat__input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e0dcd6;
  background: #f4f2ee;
  flex-shrink: 0;
}
.chat__input {
  flex: 1;
  resize: none;
  border: 1px solid #d0ccc6;
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  color: #2a2622;
  background: #fff;
  line-height: 1.4;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.15s;
}
.chat__input:focus {
  border-color: #b85000;
  box-shadow: 0 0 0 2px rgba(184,80,0,0.1);
}
.chat__send {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: none;
  background: #b85000;
  color: #fff;
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat__send:hover { background: #963f00; }
.chat__send:disabled { background: #c8c4be; cursor: default; }

/* Setup notice */
.chat__setup-notice {
  flex: 1;
  padding: 6px 2px;
}
.chat__setup-title {
  font-size: 12px;
  font-weight: 600;
  color: #2a2622;
  margin: 0 0 4px;
}
.chat__setup-body {
  font-size: 11px;
  color: #7a7470;
  margin: 0;
  line-height: 1.5;
}
.chat__setup-body code {
  background: #e8e4de;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 10px;
}
.chat__setup-body a {
  color: #b85000;
  text-decoration: none;
}
.chat__setup-body a:hover { text-decoration: underline; }

/* ── Diagrams ────────────────────────────────────────────────── */

.concept-article__diagram {
  margin: 18px 0 24px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.concept-article__diagram svg {
  max-width: 100%;
  height: auto;
}

/* ── Reference tab ───────────────────────────────────────────── */

#reference-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 0 24px;
}

.ref-card {
  background: #fff;
  border: 1px solid #e0dcd6;
  border-radius: 10px;
  overflow: hidden;
}

.ref-card__header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid #edeae4;
  background: #faf8f5;
}

.ref-card__title {
  font-size: 14px;
  font-weight: 600;
  color: #2a2622;
  margin: 0 0 4px;
}

.ref-card__subtitle {
  font-size: 12px;
  color: #7a7470;
  margin: 0;
  line-height: 1.45;
}

.ref-card__diagram {
  padding: 16px;
  display: flex;
  justify-content: center;
  overflow-x: auto;
}

.ref-card__diagram svg {
  max-width: 100%;
  height: auto;
}

/* ── Reference table (shift functions) ───────────────────────── */

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-family: 'IBM Plex Mono', monospace;
}

.ref-table thead tr {
  background: #edeae4;
}

.ref-table th {
  padding: 7px 12px;
  text-align: left;
  font-weight: 600;
  color: #4a4440;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid #d8d4cc;
}

.ref-table td {
  padding: 6px 12px;
  color: #3a3630;
  border-bottom: 1px solid #f0ede8;
  vertical-align: top;
  line-height: 1.4;
}

.ref-table tbody tr:last-child td {
  border-bottom: none;
}

.ref-table tbody tr:hover td {
  background: #faf8f5;
}

.ref-table__control {
  font-weight: 600;
  color: #2a2622;
  white-space: nowrap;
}

.ref-table__shifted {
  color: #b85000;
}

/* Three-tab layout — make tabs slightly smaller to fit three */
.panel__tabs {
  gap: 2px;
}

.panel__tab {
  flex: 1;
  font-size: 11px;
  padding: 8px 4px;
}
