/* Fenwick tree page — reuses variables from maxflow.css */

.fenwick-page {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 38px);
}

.fenwick-stage {
  background:
    radial-gradient(circle at 1px 1px, oklch(0.85 0.01 80) 1px, transparent 1px) 0 0/24px 24px,
    var(--bg);
  overflow: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.fenwick-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.fenwick-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.row-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

/* Cells */
.cells {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.cell {
  width: var(--cell-size, 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cell .idx {
  font-family: var(--label-font, 'system-ui', monospace);
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 2px;
}
.cell .bin {
  font-family: var(--label-font, 'system-ui', monospace);
  font-size: 9.5px;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.04em;
}
.cell .box {
  width: 100%;
  aspect-ratio: 1;
  border: 1.5px solid var(--cell-border, var(--line-strong));
  border-radius: 8px;
  background: var(--cell-fill, var(--surface));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--label-font, 'system-ui', monospace);
  font-size: var(--cell-font-size, 18px);
  font-weight: 600;
  color: var(--cell-text-color, var(--ink));
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.cell.target .box {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.cell.active .box {
  background: var(--cell-active-fill, var(--cool));
  border-color: var(--cell-active-fill, var(--cool));
  color: var(--cell-active-text, white);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px -6px oklch(0.4 0.1 245 / 0.4);
}
.cell.touched .box {
  background: var(--cool-soft);
  border-color: var(--cool);
}
.cell.used .box {
  background: var(--good-soft);
  border-color: var(--good);
}
.cell .delta {
  font-family: 'system-ui', monospace;
  font-size: 11px;
  color: var(--accent-deep);
  margin-top: 4px;
  height: 14px;
}

/* Range bars over the tree row */
.range-bars {
  display: grid;
  /* columns set dynamically via inline style */
  grid-auto-rows: 14px;
  gap: 3px;
  margin-bottom: 8px;
}
.range-bar {
  height: 12px;
  border-radius: 3px;
  background: oklch(0.9 0.02 240);
  border: 1px solid oklch(0.78 0.04 240);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-family: 'system-ui', monospace;
  font-size: 9px;
  color: oklch(0.4 0.06 240);
  transition: background 0.18s, border-color 0.18s;
}
.range-bar.active {
  background: var(--cool);
  border-color: var(--cool);
  color: white;
}
.range-bar.touched {
  background: var(--cool-soft);
  border-color: var(--cool);
  color: oklch(0.35 0.1 245);
}
.range-bar.used {
  background: var(--good-soft);
  border-color: var(--good);
  color: oklch(0.32 0.1 145);
}

/* Sum readout */
.sum-readout {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'system-ui', monospace;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
}
.sum-readout .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-family: 'system-ui', sans-serif;
  font-weight: 600;
}
.sum-readout .val { font-size: 22px; font-weight: 600; }

.op-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.op-bar .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.op-bar .field label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.op-bar input { width: 70px; }

.nav-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 1px;
}
.nav-link:hover { color: var(--ink); border-color: var(--ink-soft); }

.array-edit input {
  width: 56px;
  text-align: center;
  font-size: 14px;
  padding: 6px 4px;
}

/* Paste-array textarea (uses .graph-text base from maxflow.css) */
.fenwick-stage .graph-text {
  font-size: 13px;
  background: var(--surface);
}
