/* ============================================================================
 * style.css — Ig Locus Explorer
 * A calm dark "lab notebook" palette. Everything is one self-contained sheet.
 * ==========================================================================*/
:root {
  --bg: #0d1017; --bg2: #131722; --panel: #171c28; --panel2: #1d2331;
  --line: #262d3d; --line2: #333c50;
  --ink: #e7ecf5; --ink2: #a9b4c6; --muted: #6f7c93;
  --accent: #6db4ff; --accent2: #7ee0c0;
  --ok: #57c98a; --bad: #ff6b6b; --warn: #ffb86b;
  --radius: 12px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink);
  background: radial-gradient(1200px 600px at 70% -10%, #17203200, #0d1017), var(--bg);
  font-size: 14px; line-height: 1.45;
}
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
button { font-family: inherit; cursor: pointer; }

/* ------------------------------- top bar -------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.1rem; background: linear-gradient(180deg, #131826, #10141d);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.logo {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; color: #08111d;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 4px 18px -6px var(--accent);
}
.topbar h1 { font-size: 1.02rem; margin: 0; letter-spacing: .1px; }
.subtitle { font-size: .76rem; color: var(--muted); }
.top-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.seg-toggle { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg-toggle button {
  border: 0; background: transparent; color: var(--ink2); padding: .38rem .7rem;
  border-radius: 6px; font-size: .8rem; font-weight: 600; transition: .15s;
}
.seg-toggle button.on { background: linear-gradient(180deg, #2b3550, #222a3f); color: #fff; box-shadow: inset 0 0 0 1px var(--line2); }
.seg-toggle button:hover:not(.on) { color: var(--ink); }
.help-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line2);
  background: var(--panel); color: var(--ink2); font-weight: 700; font-size: 1rem;
}
.help-btn:hover { color: #fff; border-color: var(--accent); }

/* ------------------------------- layout --------------------------------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, .95fr);
  gap: 14px; padding: 14px; align-items: start;
}
@media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } }

/* ------------------------------ browser --------------------------------- */
.browser { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.browser-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .55rem .7rem; border-bottom: 1px solid var(--line); background: var(--bg2);
}
.coord { font-family: var(--mono); font-size: .72rem; color: var(--ink2); white-space: nowrap; }
.crumbs { display: flex; gap: 5px; }
.crumb {
  font-size: .72rem; font-weight: 700; letter-spacing: .3px; padding: .2rem .5rem;
  border-radius: 6px; background: var(--panel2); color: var(--ink2); border: 1px solid var(--line);
  cursor: pointer; transition: .15s;
}
.crumb:hover { color: #fff; border-color: var(--line2); }
.crumb.active { background: var(--accent); color: #08111d; border-color: var(--accent); }
.crumb.near { color: var(--accent); border-color: var(--line2); }
.crumb.hidden { display: none; }
.zoom-tools { display: flex; gap: 5px; }
.zoom-tools button {
  min-width: 30px; height: 28px; padding: 0 .5rem; border: 1px solid var(--line2);
  background: var(--panel2); color: var(--ink); border-radius: 7px; font-size: .9rem; font-weight: 700;
}
.zoom-tools button:hover { border-color: var(--accent); color: #fff; }

.minimap { width: 100%; height: 30px; display: block; background: var(--bg); cursor: pointer; border-bottom: 1px solid var(--line); }
.canvas-wrap { position: relative; }
.view { width: 100%; height: 300px; display: block; background: linear-gradient(180deg, #10141e, #0e121b); cursor: grab; }
.hint-chip {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(20,26,38,.85); border: 1px solid var(--line2); color: var(--ink2);
  font-size: .72rem; padding: .3rem .7rem; border-radius: 20px; pointer-events: none; transition: opacity .3s;
}

.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem;
  padding: .6rem .8rem; border-top: 1px solid var(--line); background: var(--bg2); font-size: .74rem;
}
.lg-title { color: var(--muted); font-weight: 600; }
.lg-item { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink2); cursor: default; }
.lg-item[data-fam] { cursor: pointer; padding: 1px 4px; border-radius: 5px; }
.lg-item[data-fam]:hover { background: var(--panel2); color: #fff; }
.lg-item i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.lg-item em { color: var(--muted); font-style: normal; font-size: .68rem; }
.lg-item.pseudo { opacity: .8; }
.lg-sep { width: 1px; height: 14px; background: var(--line2); }

/* ------------------------------- side ----------------------------------- */
.side { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .85rem; }
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .82rem; font-weight: 700; letter-spacing: .2px; color: var(--ink);
  margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line);
}
.chain-tag { font-size: .68rem; font-weight: 600; color: var(--accent2); background: #17281f; border: 1px solid #24402f; padding: .15rem .45rem; border-radius: 6px; text-transform: none; }

/* inspector */
.inspector.flash { animation: flash .5s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--accent); } 100% { box-shadow: none; } }
.insp-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.insp-name { font-family: var(--mono); font-weight: 700; font-size: .95rem; }
.pill { font-size: .64rem; font-weight: 700; padding: .1rem .4rem; border-radius: 5px; text-transform: uppercase; letter-spacing: .4px; }
.pill.ok { background: #16301f; color: var(--ok); } .pill.warn { background: #3a2a13; color: var(--warn); }
.insp-rows { display: grid; gap: 3px; margin-bottom: .5rem; }
.ir { display: flex; justify-content: space-between; gap: 1rem; font-size: .76rem; padding: .12rem 0; border-bottom: 1px dashed var(--line); }
.ir-k { color: var(--muted); } .ir-v { color: var(--ink2); text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-left: 4px; }
.insp-seq { margin: .5rem 0; }
.insp-seq-h { font-size: .7rem; color: var(--muted); margin-bottom: .25rem; }
.insp-seq-body { font-size: .68rem; line-height: 1.5; word-break: break-all; max-height: 84px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: .4rem .5rem; letter-spacing: .5px; }
.insp-actions { display: flex; gap: .4rem; margin-top: .4rem; }

.mini-btn { font-size: .72rem; font-weight: 600; color: var(--ink2); background: var(--panel2); border: 1px solid var(--line2); border-radius: 7px; padding: .3rem .55rem; }
.mini-btn:hover { color: #fff; border-color: var(--accent); }
.mini-btn.primary { background: linear-gradient(180deg, #234, #1b3a5a); color: #dff0ff; border-color: #2a5680; }

/* --------------------------- recombinator ------------------------------- */
.guide-bar { display: flex; align-items: center; gap: .5rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: .45rem .55rem; margin-bottom: .6rem; }
.guide-text { flex: 1; font-size: .74rem; color: var(--ink2); }
.switch { position: relative; display: inline-block; width: 34px; height: 19px; flex: none; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: var(--line2); border-radius: 20px; transition: .2s; }
.slider:before { content: ''; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #cbd5e6; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(15px); background: #08111d; }

.slots { display: flex; align-items: stretch; gap: 4px; margin-bottom: .7rem; }
.slot { position: relative; flex: 1; min-width: 0; background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--c); border-radius: 8px; padding: .4rem .5rem; }
.slot.active { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 60%, transparent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); } }
.slot-type { font-size: .64rem; font-weight: 800; color: var(--c); letter-spacing: .5px; }
.slot-name { font-family: var(--mono); font-size: .74rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.filled { cursor: pointer; }
.slot-x { position: absolute; top: 3px; right: 4px; border: 0; background: transparent; color: var(--muted); font-size: .9rem; line-height: 1; }
.slot-x:hover { color: var(--bad); }
.slot-join { display: grid; place-items: center; color: var(--muted); font-weight: 700; flex: none; width: 14px; }

.assembly-wrap { margin-bottom: .5rem; }
.assembly-title { font-size: .72rem; color: var(--muted); margin-bottom: .3rem; }
.empty-hint { font-size: .74rem; color: var(--muted); background: var(--bg2); border: 1px dashed var(--line2); border-radius: 8px; padding: .55rem .6rem; text-align: center; }
.strip-scroll { overflow-x: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .5rem .4rem; }
.nt-row { display: flex; font-family: var(--mono); font-size: .72rem; }
.nt-chunk { display: inline-flex; border-bottom: 2px solid var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); }
.nt { width: 11px; text-align: center; color: var(--ink); }
.aa-row { display: flex; margin-top: 3px; font-family: var(--mono); font-size: .72rem; }
.aa { width: 33px; text-align: center; color: var(--ink2); border-radius: 3px; }
.aa.cdr3 { background: rgba(126,224,192,.16); color: #bff3e2; font-weight: 700; }
.aa.stop { color: var(--bad); font-weight: 800; }
.strip-legend { display: flex; flex-wrap: wrap; gap: .3rem .7rem; margin-top: .4rem; font-size: .68rem; color: var(--ink2); }
.strip-legend .lg { display: inline-flex; align-items: center; gap: .3rem; }
.strip-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* junction machinery */
.junc { margin-top: .5rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: .2rem .55rem .5rem; }
.junc summary { font-size: .76rem; font-weight: 700; cursor: pointer; padding: .4rem 0; color: var(--ink); }
.junc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
@media (max-width: 460px) { .junc-grid { grid-template-columns: 1fr; } }
.junc-h { font-size: .68rem; font-weight: 700; color: var(--accent); margin: .3rem 0 .25rem; }
.junc-col { min-width: 0; }
.ctl { margin-bottom: .3rem; }
.ctl label { display: block; font-size: .68rem; color: var(--ink2); margin-bottom: 1px; }
.ctl-row { display: flex; align-items: center; gap: .4rem; }
.ctl input[type=range] { flex: 1; accent-color: var(--accent); height: 3px; }
.ctl-val { font-family: var(--mono); font-size: .7rem; color: var(--ink); min-width: 14px; text-align: right; }
.n-col { margin-top: .3rem; }
.n-input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line2); border-radius: 6px; color: var(--accent2); font-family: var(--mono); font-size: .74rem; padding: .3rem .4rem; letter-spacing: 1px; text-transform: uppercase; }
.n-input:focus { outline: none; border-color: var(--accent); }

/* result */
.result { margin-top: .6rem; }
.prod { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: .82rem; padding: .45rem .6rem; border-radius: 8px; }
.prod.ok { background: #14301f; color: var(--ok); border: 1px solid #1f5236; }
.prod.bad { background: #341a1a; color: var(--bad); border: 1px solid #5a2a2a; }
.prod-why { font-weight: 500; font-size: .7rem; color: var(--ink2); margin-left: auto; }
.cdr3-box { margin-top: .5rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; }
.cdr3-label { font-size: .7rem; color: var(--muted); margin-bottom: .25rem; }
.cdr3-aa { font-family: var(--mono); font-size: 1rem; letter-spacing: 3px; color: #bff3e2; font-weight: 700; }
.cdr3-aa .stop { color: var(--bad); }
.cdr3-nt { font-size: .68rem; color: var(--ink2); word-break: break-all; margin-top: .2rem; letter-spacing: .5px; }
.jstats { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .5rem; font-size: .72rem; color: var(--ink2); }
.jstats b { color: var(--ink); }
.seqout { margin-top: .5rem; }
.seqout summary { font-size: .72rem; color: var(--muted); cursor: pointer; }
.seqfull { font-size: .66rem; color: var(--ink2); word-break: break-all; margin-top: .3rem; background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: .4rem .5rem; letter-spacing: .5px; }

/* reference */
.ref-list { margin: 0; padding-left: 1.05rem; display: flex; flex-direction: column; gap: .4rem; font-size: .74rem; color: var(--ink2); }
.ref-list b { color: var(--ink); }
.data-note { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid var(--line); font-size: .68rem; color: var(--muted); font-family: var(--mono); }

/* ------------------------------- tooltip -------------------------------- */
.tooltip {
  position: fixed; z-index: 40; pointer-events: none; background: #0c1119ee; border: 1px solid var(--line2);
  border-radius: 8px; padding: .35rem .55rem; font-size: .74rem; box-shadow: 0 8px 24px -8px #000;
  display: flex; flex-direction: column; max-width: 240px;
}
.tooltip b { color: #fff; font-family: var(--mono); }
.tooltip span { color: var(--ink2); font-size: .68rem; }
.tooltip .tw { color: var(--warn); }

/* -------------------------------- modal --------------------------------- */
.modal-back { position: fixed; inset: 0; background: #060810cc; backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 1rem; }
.modal-back[hidden] { display: none; }
.modal { position: relative; max-width: 820px; width: 100%; max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 1.4rem 1.5rem; }
.modal h2 { margin: 0 0 1rem; }
.modal-x { position: absolute; top: .8rem; right: 1rem; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line2); background: var(--panel2); color: var(--ink2); font-size: 1.1rem; }
.modal-x:hover { color: #fff; border-color: var(--accent); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.2rem; }
.help-grid h3 { font-size: .85rem; margin: 0 0 .5rem; color: var(--accent); }
.help-grid ul { margin: 0; padding-left: 1.05rem; display: flex; flex-direction: column; gap: .35rem; font-size: .78rem; color: var(--ink2); }
.help-grid b { color: var(--ink); }
.disclaimer { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); }

/* scrollbars */
::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
