/* ---------------------------------------
   FlowForge Studio � Master Stylesheet
   --------------------------------------- */

/* --- Design Tokens --- */
:root {
  --bg-main: #eaf2f9;
  --bg-accent: #d5eaf4;
  --surface-1: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(255, 255, 255, 0.88);
  --surface-3: #f7fbff;
  --surface-border: rgba(30, 68, 96, 0.2);
  --text-main: #0f2436;
  --text-dim: #4f697f;
  --text-soft: #6a849a;
  --brand-500: #1e7f98;
  --brand-600: #15596d;
  --brand-100: rgba(30, 127, 152, 0.15);
  --danger-500: #9b3c44;
  --node-bg: #ffffff;
  --node-border: rgba(30, 68, 96, 0.18);
  --grid: rgba(30, 68, 96, 0.07);
  --glow: 0 20px 50px rgba(16, 48, 72, 0.12);
  --card-shadow: 0 8px 20px rgba(16, 48, 72, 0.12);
  --sidebar-w: 340px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --panel-pad: 18px;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --bg-main: #091a22;
  --bg-accent: #0e2430;
  --surface-1: rgba(14, 32, 46, 0.85);
  --surface-2: rgba(18, 40, 56, 0.92);
  --surface-3: #132d3e;
  --surface-border: rgba(71, 172, 197, 0.18);
  --text-main: #d8eaf4;
  --text-dim: #7da8be;
  --text-soft: #4f7a90;
  --brand-500: #3ab5cf;
  --brand-600: #1e7f98;
  --brand-100: rgba(58, 181, 207, 0.18);
  --node-bg: #112233;
  --node-border: rgba(71, 172, 197, 0.22);
  --grid: rgba(71, 172, 197, 0.07);
  --glow: 0 20px 50px rgba(0, 30, 48, 0.6);
  --card-shadow: 0 8px 20px rgba(0, 20, 36, 0.5);
}

[data-theme="dark"] body {
  background:
    radial-gradient(1200px 620px at -8% -14%, rgba(0, 60, 80, 0.7) 0%, transparent 62%),
    radial-gradient(900px 520px at 118% 118%, rgba(0, 48, 64, 0.6) 0%, transparent 56%),
    linear-gradient(165deg, #091a22, #0e2430);
}

[data-theme="dark"] .canvas-viewport {
  background:
    radial-gradient(circle at 0 0, rgba(71, 172, 197, 0.06) 0, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(21, 89, 109, 0.15) 0, transparent 36%),
    linear-gradient(0deg, var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    #091a22;
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

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

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-main);
  font-family: "Sora", "Segoe UI", sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

body {
  background:
    radial-gradient(1200px 620px at -8% -14%, rgba(71, 172, 197, 0.18) 0%, transparent 62%),
    radial-gradient(900px 520px at 118% 118%, rgba(38, 146, 121, 0.14) 0%, transparent 56%),
    linear-gradient(165deg, var(--bg-main), var(--bg-accent));
}

/* --- App Shell --- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: var(--gap);
  width: 100%;
  height: 100%;
  padding: var(--gap);
}

/* --- Sidebar --- */
.sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-2));
  backdrop-filter: blur(16px);
  box-shadow: var(--glow);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 4px; }

/* --- Brand Card --- */
.brand-card {
  padding: 20px 18px 18px;
  margin: 6px;
  border-radius: 14px;
  background:
    linear-gradient(130deg, #eef7fb, #e4f4f9 65%, #f0fafe),
    repeating-linear-gradient(135deg, #ffffff4d 0 10px, #ffffff26 10px 20px);
  border: 1px solid rgba(30, 127, 152, 0.2);
}

[data-theme="dark"] .brand-card {
  background:
    linear-gradient(130deg, #0d2535, #0a1e2c 65%, #091a22),
    repeating-linear-gradient(135deg, rgba(71,172,197,0.08) 0 10px, rgba(71,172,197,0.04) 10px 20px);
  border-color: rgba(71, 172, 197, 0.2);
}

.brand-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.brand-kicker {
  margin: 0 0 3px;
  font-size: 0.68rem;
  color: #1a6f83;
  letter-spacing: 1.4px;
  font-weight: 700;
  text-transform: uppercase;
}

[data-theme="dark"] .brand-kicker { color: #3ab5cf; }

.sidebar h1 {
  margin: 0;
  font-size: 1.36rem;
  line-height: 1.24;
  letter-spacing: -0.3px;
}

.diagram-title-input {
  width: 100%;
  border: 1px solid var(--surface-border) !important;
  border-radius: 10px !important;
  padding: 8px 12px !important;
  background: var(--surface-3) !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  color: var(--text-main) !important;
}

/* --- Panels --- */
.panel {
  margin: 6px;
  padding: var(--panel-pad);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--surface-border);
  box-shadow: var(--card-shadow);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 0.72rem;
  color: var(--text-soft);
  letter-spacing: 1.4px;
  font-weight: 700;
  text-transform: uppercase;
}

/* First field-label in panel doesn't need extra top margin */
.panel h2 + .field-label,
.inspector-section > .field-label:first-child,
.inspector-header + .inspector-section > .field-label:first-child {
  margin-top: 0;
}

/* --- Form Elements --- */
.field-label {
  display: block;
  margin: 14px 0 6px;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

input, select, button { font: inherit; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-main);
  background: var(--surface-3);
  transition: border-color 120ms, box-shadow 120ms;
}

input[type="text"]::placeholder { color: var(--text-soft); }

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(30, 127, 152, 0.18);
}

/* --- Color Swatches --- */
.color-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.color-field {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.color-swatch {
  width: 100% !important;
  height: 36px;
  border: 1.5px solid var(--surface-border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 2px 3px !important;
  cursor: pointer;
  background: var(--surface-3) !important;
}

/* --- Range Slider --- */
.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-row input[type="range"] {
  flex: 1;
  height: 4px;
  border: none !important;
  border-radius: 99px;
  padding: 0 !important;
  background: linear-gradient(to right, var(--brand-500) 0%, var(--surface-border) 0%);
  cursor: pointer;
  accent-color: var(--brand-500);
}

.range-val {
  min-width: 36px;
  text-align: right;
  font-size: 0.78rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--text-soft);
}

/* --- Buttons --- */
.row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.row > .btn:only-child { flex: 1 0 100%; }

.btn {
  flex: 1;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  padding: 10px 12px;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  cursor: pointer;
  font-weight: 500;
  font-size: 0.84rem;
  transition: transform 100ms ease, box-shadow 100ms ease, border-color 100ms ease, background 100ms;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--brand-500);
  box-shadow: 0 6px 16px #1f355d1f;
}

.btn:active { transform: translateY(0); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  color: #fff;
  border-color: var(--brand-600);
  background: linear-gradient(120deg, var(--brand-500), var(--brand-600));
}

.btn-primary:hover { box-shadow: 0 6px 18px rgba(30, 127, 152, 0.35); }

.btn-danger {
  color: #8c1d1d;
  border-color: #f2b7b7;
  background: linear-gradient(180deg, #fff6f6, #ffebeb);
}

[data-theme="dark"] .btn-danger {
  color: #fca5a5;
  border-color: #7f1d1d;
  background: linear-gradient(180deg, #2d1515, #3d1818);
}

.panel > .btn { width: 100%; margin-top: 14px; }

.btn.active {
  border-color: var(--brand-500);
  background: linear-gradient(180deg, var(--brand-100), #c7d8ff);
  color: #1e3a8a;
}

/* --- Icon Button --- */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-3);
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 120ms, background 120ms, color 120ms;
}

.icon-btn:hover {
  border-color: var(--brand-500);
  color: var(--brand-500);
}

/* --- Toggle Switches --- */
.toggle-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle-check { display: none; }

.toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--surface-border);
  border-radius: 99px;
  flex-shrink: 0;
  transition: background 180ms;
}

.toggle-check:checked + .toggle-track { background: var(--brand-500); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: left 180ms;
  box-shadow: 0 1px 4px #0004;
}

.toggle-check:checked + .toggle-track .toggle-thumb { left: 19px; }

/* --- Status Text --- */
.status-text {
  margin: 12px 2px 0;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-family: "JetBrains Mono", monospace;
}

.status-text[data-tone="ok"] { color: var(--brand-500); }

/* --- Shortcut Grid (Tips Panel) --- */
.panel-tip .shortcut-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--surface-border);
  background: var(--surface-3);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.panel-tip .shortcut-grid span {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.panel-ad-box {
  min-height: 120px;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  background: var(--surface-3);
  padding: 8px;
}

/* --- Workspace --- */
.workspace {
  min-width: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  background: var(--surface-1);
  backdrop-filter: blur(12px);
  box-shadow: var(--glow);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* --- Topbar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--surface-border);
  background: linear-gradient(180deg, var(--surface-2), var(--surface-2));
}

.topbar-title h2 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.2px;
}

.hint {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#zoomDisplay {
  min-width: 54px;
  text-align: center;
  color: var(--text-main);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
  font-weight: 500;
}

.zoom-btn {
  min-width: 34px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-3);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.zoom-btn:hover { border-color: var(--brand-500); }
.zoom-btn.wide { min-width: 46px; }

/* --- Canvas Viewport --- */
.canvas-viewport {
  position: relative;
  contain: paint;
  cursor: default;
  background:
    radial-gradient(circle at 0 0, rgba(255,255,255,0.7) 0, transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(30, 127, 152, 0.1) 0, transparent 36%),
    linear-gradient(0deg, var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    #f0f8fc;
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

.canvas-viewport.reconnect-mode { cursor: crosshair; }

.canvas-viewport.reconnect-mode .handle {
  box-shadow: 0 0 0 3px #bfdbfe, 0 0 0 1px #0f172a3d;
}

/* Disable inspector pointer-events while dragging an edge so handles remain clickable */
.canvas-viewport.connecting .canvas-inspector { pointer-events: none; }

.canvas-viewport.snap-active .node { transition: left 60ms, top 60ms; }

/* --- World --- */
.world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  width: 100%;
  height: 100%;
}

.edges-svg,
.nodes-layer {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none; /* Let edge clicks pass through empty space */
}

/* Re-enable pointer events on nodes so they remain interactive */
.node {
  pointer-events: auto;
}

/* --- Minimap --- */
.minimap-canvas {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 160px;
  height: 100px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-2);
  box-shadow: 0 4px 12px #0002;
  pointer-events: none;
  opacity: 0.9;
}

.minimap-canvas.hidden { display: none; }

/* --- Canvas Inspector --- */
.canvas-inspector {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 300px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  z-index: 6;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--surface-border);
  background: var(--surface-2);
  box-shadow: 0 16px 32px #1e293b28;
  backdrop-filter: blur(10px);
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
  /* Allow handles behind the inspector to still receive mouse events */
  pointer-events: none;
}

/* Re-enable pointer events on all interactive elements inside the inspector */
.canvas-inspector input,
.canvas-inspector select,
.canvas-inspector button,
.canvas-inspector [contenteditable],
.canvas-inspector .inspector-header,
.canvas-inspector label {
  pointer-events: auto;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--surface-border);
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.canvas-inspector h3 {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-soft);
}

.inspector-close {
  width: 28px;
  height: 28px;
  font-size: 0.78rem;
}

.inspector-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--surface-border);
}

.inspector-section:last-of-type { border-bottom: none; }

.inspector-section > .btn { margin-top: 12px; width: 100%; }

.inspector-size-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.inspector-note {
  margin: 10px 0 0;
  font-size: 0.74rem;
  color: var(--brand-500);
  font-family: "JetBrains Mono", monospace;
  line-height: 1.5;
}

.canvas-inspector > .btn {
  display: block;
  width: calc(100% - 32px);
  margin: 14px 16px;
}

/* --- Nodes --- */
@keyframes fade-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

.node {
  position: absolute;
  min-width: 140px;
  min-height: 62px;
  background: var(--node-bg);
  border: 1.5px solid var(--node-border);
  box-shadow: 0 8px 20px #0f172a14, 0 2px 4px #0f172a0a;
  cursor: grab;
  user-select: none;
  animation: fade-in 160ms ease;
  transition: box-shadow 120ms;
}

.node:hover { box-shadow: 0 12px 28px #0f172a22; }

.node.selected {
  border-color: var(--brand-500) !important;
  box-shadow: 0 0 0 3px rgba(30, 127, 152, 0.22), 0 12px 28px rgba(21, 89, 109, 0.25);
}

.node[data-type="start-end"] { border-radius: 999px; }
.node[data-type="process"] { border-radius: 12px; }
.node[data-type="decision"] { border-radius: 8px; transform: rotate(45deg); }
.node[data-type="decision"] .node-body { transform: rotate(-45deg); }
.node[data-type="input-output"] { border-radius: 10px; transform: skewX(-12deg); }
.node[data-type="input-output"] .node-body { transform: skewX(12deg); }

.node-body {
  min-height: 100%;
  padding: 10px 16px;
  display: grid;
  align-content: center;
  gap: 3px;
}

.node-type {
  color: var(--text-soft);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  font-weight: 700;
}

.node-label {
  min-height: 22px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: pre-wrap;
  cursor: text;
  user-select: text;
  line-height: 1.4;
}

/* --- Handles --- */
.handle {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  position: absolute;
  background: #1e7f98;
  border: 2px solid var(--node-bg);
  box-shadow: 0 0 0 1.5px rgba(30, 68, 96, 0.3);
  z-index: 2;
  cursor: crosshair;
  transition: transform 120ms, box-shadow 120ms;
}

.handle:hover { transform: scale(1.3) !important; box-shadow: 0 0 0 2px #1e7f98; }

.handle.snap-target { transform: scale(1.5) !important; box-shadow: 0 0 0 3px #1e7f98, 0 0 12px rgba(30, 127, 152, 0.3); }

.handle-top    { top: -8px;    left: 50%; transform: translateX(-50%); }
.handle-right  { right: -8px;  top: 50%;  transform: translateY(-50%); }
.handle-bottom { bottom: -8px; left: 50%; transform: translateX(-50%); }
.handle-left   { left: -8px;   top: 50%;  transform: translateY(-50%); }

/* Decision (diamond) nodes: parent is rotated 45°, so place handles at the
   corners of the unrotated div — those corners land on the diamond tips. */
.node[data-type="decision"] .handle-top    { top: 0;    left: 0;   right: auto;  bottom: auto; transform: translate(-50%, -50%) rotate(-45deg); }
.node[data-type="decision"] .handle-right  { top: 0;    right: 0;  left: auto;   bottom: auto; transform: translate( 50%, -50%) rotate(-45deg); }
.node[data-type="decision"] .handle-bottom { bottom: 0; right: 0;  left: auto;   top: auto;    transform: translate( 50%,  50%) rotate(-45deg); }
.node[data-type="decision"] .handle-left   { bottom: 0; left: 0;   right: auto;  top: auto;    transform: translate(-50%,  50%) rotate(-45deg); }

/* --- Edges --- */
.edge-hit {
  stroke: transparent;
  stroke-width: 16;
  fill: none;
  cursor: pointer;
  pointer-events: stroke;
}

.edge-path {
  stroke: #1e5a6e;
  stroke-width: 2.4;
  fill: none;
  marker-end: url(#arrow);
}

.edge-group.selected .edge-path {
  stroke: var(--brand-500);
  stroke-width: 3;
  marker-end: url(#arrow-selected);
}

.edge-label {
  font-size: 11px;
  fill: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
  pointer-events: none;
}

.edge-endpoint {
  fill: #fff;
  stroke: var(--brand-500);
  stroke-width: 2;
  cursor: grab;
  transition: transform 100ms ease;
}

.edge-endpoint:hover { fill: var(--brand-100); transform: scale(1.2); }

.ghost-edge {
  display: none;
  fill: none;
  stroke: #64748b;
  stroke-width: 1.8;
  stroke-dasharray: 6 5;
  opacity: 0.8;
}

#arrow path { fill: #1e5a6e; }
#arrow-selected path { fill: var(--brand-500); }

/* --- Responsive --- */
@media (max-width: 1100px) {
  :root { --sidebar-w: 300px; }
  .app-shell { padding: 10px; gap: 10px; }
}

@media (max-width: 880px) {
  html, body { overflow: auto; }
  .app-shell {
    height: auto;
    min-height: 100%;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(58vh, 1fr);
  }
  .sidebar { max-height: 46vh; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .controls { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .canvas-inspector { width: min(94%, 320px); right: 3%; top: 10px; }
}

@media (max-width: 480px) {
  .app-shell { padding: 8px; gap: 8px; }
  .sidebar { max-height: 42vh; }
  .workspace { min-height: 44vh; }
  .brand-card { padding: 14px 12px; }
  .panel { padding: 12px; }
  .color-row,
  .row {
    flex-wrap: wrap;
  }
  .row > .btn {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
    white-space: normal;
  }
  .row > .btn:only-child {
    flex-basis: 100%;
  }
  .topbar {
    padding: 12px 14px;
  }
  .controls {
    gap: 6px;
  }
  #zoomDisplay {
    min-width: 46px;
  }
  .canvas-inspector { width: min(88vw, 260px); font-size: 0.82rem; }
  .minimap-canvas { width: 110px; height: 68px; }
  .hint { display: none; }
}

/* ── Decision Tree Branch Panel ─────────────────── */
.decision-branch-panel {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.branch-panel-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  font-weight: 700;
  color: var(--text-muted);
}
.branch-btn-row {
  display: flex;
  gap: 6px;
}
.branch-btn-row .btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 6px 8px;
  white-space: nowrap;
}
.branch-yes { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.branch-yes:hover { background: #a7f3d0; }
.branch-no  { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.branch-no:hover  { background: #fecaca; }
[data-theme="dark"] .branch-yes { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .branch-yes:hover { background: #065f46; }
[data-theme="dark"] .branch-no  { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .branch-no:hover  { background: #7f1d1d; }

/* ── Snapshot Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: min(480px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close-btn:hover { background: var(--surface-2); }
.modal-hint { margin: 0; font-size: 0.82rem; color: var(--text-muted); }
.snapshot-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.snapshot-list li button {
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: background 0.15s;
}
.snapshot-list li button:hover { background: var(--brand-100); border-color: var(--brand-400); }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; }
