/* Koppo Analytics — customizable tick explorer styling on the shared theme. */

/* ---------- Controls bar ---------- */
#controls { margin: 1.2rem 1.5rem 0; }
.ctl-row { display: flex; flex-wrap: wrap; gap: 1.6rem; align-items: flex-end; }
.ctl-group { display: flex; flex-direction: column; gap: 0.35rem; }
.ctl-label { font-size: 0.66rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  background: var(--panel-2); color: var(--muted); border: none;
  padding: 0.45rem 0.85rem; font-size: 0.82rem; cursor: pointer;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); }
.seg button.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-weight: 700; }
.seg-digits button { padding: 0.45rem 0.7rem; min-width: 34px; }

/* ---------- Market pulse ---------- */
.pulse-row { display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap; }
.pulse-main { min-width: 190px; }
.pulse-name { font-size: 0.85rem; color: var(--muted); display: block; }
.pulse-symbol { font-size: 0.72rem; color: var(--muted); }
.pulse-price { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: 0.2rem 0; }
.pulse-chart { flex: 1; min-width: 240px; height: 90px; }
.pulse-chart canvas { width: 100%; height: 100%; display: block; }
.pulse-kv { min-width: 240px; }
.pulse-kv div { display: flex; justify-content: space-between; padding: 0.3rem 0; border-bottom: 1px dashed rgba(139, 152, 169, 0.15); }
.pulse-kv dt { color: var(--muted); font-size: 0.75rem; }
.pulse-kv dd { margin: 0; font-size: 0.82rem; }

/* ---------- Shared tool bits (copied minimal set) ---------- */
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.an-grid .tool-card { min-width: 0; }
.an-grid .tool-card:nth-child(odd) { margin-right: 0.6rem; }
.an-grid .tool-card:nth-child(even) { margin-left: 0.6rem; }
.tool-card { margin: 1.2rem 1.5rem 0; }
.tool-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.9rem; }
.tool-title { margin: 0; font-size: 1rem; letter-spacing: 0.02em; }
.tool-sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.5; }
.btn-mini { font-size: 0.72rem; padding: 0.3rem 0.6rem; }

/* ---------- Digit stream ---------- */
.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 4px;
  max-height: 390px;
  overflow-y: auto;
  padding-right: 4px;
}
.stream-grid::-webkit-scrollbar { width: 8px; }
.stream-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
  border-radius: 5px;
  border: 1px solid transparent;
}
.cell.c-even { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.cell.c-odd { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.cell.c-over { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.cell.c-push { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.cell.c-under { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.cell.c-rise { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.cell.c-fall { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.cell.c-flat { background: rgba(139, 152, 169, 0.14); color: var(--muted); }
.cell.c-new { animation: cellPop 0.6s ease; }
@keyframes cellPop {
  0% { transform: scale(1.4); box-shadow: 0 0 14px rgba(56, 189, 248, 0.6); }
  100% { transform: scale(1); }
}

/* ---------- Distribution ---------- */
.dist-chart {
  display: flex; align-items: flex-end; gap: 6px; height: 170px;
  padding: 0 4px; position: relative;
}
.dist-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; height: 100%; gap: 4px;
}
.dist-pct { font-size: 0.66rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dist-bar { width: 100%; border-radius: 4px 4px 0 0; transition: height 0.35s ease; min-height: 2px; }
.dist-digit { font-size: 0.75rem; font-weight: 700; }
.dist-col.hot .dist-bar { background: var(--up); }
.dist-col.cold .dist-bar { background: var(--down); }
.dist-col:not(.hot):not(.cold) .dist-bar { background: #2a3a4d; }
.dist-line {
  position: absolute; left: 0; right: 0; border-top: 1px dashed rgba(139, 152, 169, 0.5);
  pointer-events: none;
}
.dist-line span {
  position: absolute; right: 0; top: -16px; font-size: 0.62rem; color: var(--muted);
}

/* ---------- Breakdown bars ---------- */
.brk { margin-bottom: 1.05rem; }
.brk:last-child { margin-bottom: 0; }
.brk-label { font-size: 0.74rem; color: var(--muted); display: block; margin-bottom: 0.4rem; }
.brk-bar {
  display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border);
}
.brk-bar i { display: block; height: 100%; transition: width 0.4s ease; }
.seg-a { background: var(--up); }
.seg-b { background: var(--down); }
.seg-c { background: rgba(139, 152, 169, 0.45); }
.brk-labels { display: flex; justify-content: space-between; font-size: 0.74rem; margin-top: 0.35rem; }
.brk-labels b { font-variant-numeric: tabular-nums; }

/* ---------- Pattern reader ---------- */
.pattern-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed rgba(139, 152, 169, 0.2);
}
.pat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  background: rgba(15, 21, 30, 0.6);
}
.pat.pat-hot { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pat-t {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}
.pat p { margin: 0; font-size: 0.76rem; line-height: 1.55; color: var(--muted); }
.pat p b { color: var(--text); }

/* ---------- Per-digit table ---------- */
.barrier-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.barrier-table th {
  text-align: left; color: var(--muted); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.07em; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border);
}
.barrier-table td { padding: 0.42rem 0.6rem; border-bottom: 1px dashed rgba(139, 152, 169, 0.12); }
.barrier-table tr:last-child td { border-bottom: none; }
#digit-table td,
#digit-table th {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}
#digit-table td:not(:first-child),
#digit-table th:not(:first-child) { text-align: right; }
#digit-table td:nth-child(5),
#digit-table th:nth-child(5) { text-align: center; } /* bias bar column */

.dt-digit { font-size: 0.95rem; font-weight: 800; }
#digit-table tr.row-hot td { background: color-mix(in srgb, var(--up) 6%, transparent); }
#digit-table tr.row-cold td { background: color-mix(in srgb, var(--down) 6%, transparent); }
.biasbar {
  position: relative;
  display: inline-block;
  width: 70px;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  vertical-align: middle;
}
.biasbar::before {
  content: "";
  position: absolute;
  left: 50%; top: -2px; bottom: -2px;
  width: 1px;
  background: rgba(139, 152, 169, 0.5);
}
.biasbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bb-pos { background: var(--up); }
.bb-neg { background: var(--down); }

@media (max-width: 900px) {
  .ctl-row { gap: 1rem; }
  .stream-grid { grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); }
}
