/* ==========================================================================
   MUSCA — interface
   ========================================================================== */

:root {
  --bg:        #04070d;
  --bg-2:      #070c15;
  --panel:     rgba(9, 16, 27, .82);
  --panel-2:   rgba(12, 21, 35, .92);
  --line:      #17293f;
  --line-2:    #21385a;
  --ink:       #cbdcf0;
  --ink-dim:   #6f8bab;
  --ink-faint: #46617f;
  --cyan:      #38e8ff;
  --magenta:   #ff4fd8;
  --amber:     #ffb347;
  --lime:      #7dff9b;
  --violet:    #a98bff;
  --red:       #ff5a6a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
}

* { box-sizing: border-box; }

/* the [hidden] attribute must beat any display: rule we set below */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {   /* subtle vignette so the 3D reads as "deep" */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse 90% 70% at 50% 45%, transparent 35%, rgba(0,0,0,.55) 100%);
}

#app { position: fixed; inset: 0; }

canvas#gl { position: fixed; inset: 0; display: block; z-index: 0; }

button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font-family: var(--mono); font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: #12203a; border: 1px solid var(--line-2); color: var(--ink-dim);
}

/* ---------------------------------------------------------------- boot ---- */
#boot {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 45%, #0a1626 0%, #04070d 70%);
}
.boot-inner { text-align: center; width: 320px; }
.boot-mark svg { animation: spin 9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot-inner h1 {
  font-family: var(--mono); font-size: 30px; letter-spacing: .42em;
  margin: 18px 0 4px; font-weight: 500; text-indent: .42em;
}
.boot-sub { color: var(--ink-faint); font-size: 11px; margin: 0 0 26px; letter-spacing: .04em; }
.boot-bar { height: 2px; background: #12203a; border-radius: 2px; overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); transition: width .3s; }
.boot-msg { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-top: 12px; letter-spacing: .08em; }

/* --------------------------------------------------------------- chrome --- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: linear-gradient(180deg, rgba(4,7,13,.96), rgba(4,7,13,.72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: baseline; gap: 9px; white-space: nowrap; }
.brand b { font-family: var(--mono); letter-spacing: .3em; font-weight: 500; font-size: 14px; }
.brand-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan); align-self: center;
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.brand-tag { color: var(--ink-faint); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }

.search-wrap { position: relative; flex: 1; max-width: 460px; }
#search {
  width: 100%; height: 32px; padding: 0 12px;
  background: #0b1524; border: 1px solid var(--line); border-radius: 8px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
#search::placeholder { color: var(--ink-faint); }
#search:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(56,232,255,.09); }
.search-results {
  position: absolute; top: 38px; left: 0; right: 0; max-height: 320px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px;
  backdrop-filter: blur(14px); box-shadow: 0 18px 44px rgba(0,0,0,.6); z-index: 40;
}
.sr-item { padding: 7px 12px; display: flex; justify-content: space-between; gap: 10px; cursor: pointer; border-bottom: 1px solid rgba(23,41,63,.5); }
.sr-item:last-child { border-bottom: 0; }
.sr-item:hover, .sr-item.is-sel { background: #16273f; }
.sr-item b { font-weight: 500; }
.sr-item span { color: var(--ink-faint); font-family: var(--mono); font-size: 10px; white-space: nowrap; }
.sr-none { padding: 12px; color: var(--ink-faint); text-align: center; }

.topnav { display: flex; gap: 8px; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 11px; color: var(--ink-dim); font-size: 12px; transition: .15s;
}
.ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.ghost.is-on { border-color: var(--cyan); color: var(--cyan); background: rgba(56,232,255,.08); }

/* --------------------------------------------------------------- panels --- */
#left, #right {
  position: fixed; top: 52px; bottom: 0; width: 252px; z-index: 15;
  padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
#left  { left: 0; }
#right { right: 0; width: 316px; }
#left::-webkit-scrollbar, #right::-webkit-scrollbar { width: 6px; }
#left::-webkit-scrollbar-thumb, #right::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px; backdrop-filter: blur(12px);
}
.panel h2 {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 10px; font-weight: 500;
}

.modes { display: flex; flex-direction: column; gap: 5px; }
.mode {
  text-align: left; background: #0a1322; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; transition: .15s; display: block; width: 100%;
}
.mode b { display: block; font-weight: 500; font-size: 13px; }
.mode span { display: block; color: var(--ink-faint); font-size: 10.5px; margin-top: 2px; line-height: 1.35; }
.mode:hover { border-color: var(--line-2); background: #0e1a2c; }
.mode.is-on { border-color: var(--cyan); background: rgba(56,232,255,.09); }
.mode.is-on b { color: var(--cyan); }
.mode.is-on span { color: #8fb6cf; }

.chk { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; user-select: none; }
.chk input { appearance: none; width: 15px; height: 15px; border: 1px solid var(--line-2); border-radius: 4px; background: #0b1524; position: relative; flex: none; }
.chk input:checked { background: var(--cyan); border-color: var(--cyan); }
.chk input:checked::after { content: "✓"; position: absolute; inset: 0; color: #04070d; font-size: 11px; line-height: 14px; text-align: center; font-weight: 700; }
.chk em { color: var(--ink-faint); font-style: normal; font-family: var(--mono); font-size: 10px; margin-left: 4px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.seg button {
  background: #0a1322; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 4px; font-size: 11px; color: var(--ink-dim); transition: .15s;
}
.seg button:hover { border-color: var(--line-2); }
.seg button.is-on { border-color: var(--magenta); color: var(--magenta); background: rgba(255,79,216,.08); }

.legend { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; }
.lg-row { display: flex; align-items: center; gap: 7px; font-size: 11px; cursor: pointer; padding: 2px 3px; border-radius: 4px; }
.lg-row:hover { background: #12203a; }
.lg-row.is-off { opacity: .3; }
.lg-sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.lg-row span { flex: 1; color: var(--ink-dim); }
.lg-row em { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); font-style: normal; }

/* ------------------------------------------------------------ inspector --- */
.insp-empty p { color: var(--ink-faint); margin: 0 0 8px; line-height: 1.5; }
.dim { color: var(--ink-faint) !important; }

.insp-head { margin-bottom: 10px; }
.insp-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
.insp-sub { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); margin-top: 3px; }
.insp-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.tag {
  font-family: var(--mono); font-size: 9.5px; padding: 2px 7px; border-radius: 20px;
  border: 1px solid var(--line-2); color: var(--ink-dim); letter-spacing: .03em;
}
.tag.c { border-color: rgba(56,232,255,.4); color: var(--cyan); }
.tag.m { border-color: rgba(255,79,216,.4); color: var(--magenta); }
.tag.a { border-color: rgba(255,179,71,.4); color: var(--amber); }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin: 10px 0 0; font-size: 11.5px; }
.kv dt { color: var(--ink-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 11px; text-align: right; }

.bar { height: 3px; background: #12203a; border-radius: 2px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--cyan); }

.partners { margin-top: 12px; }
.partners h3 { font-family: var(--mono); font-size: 9.5px; letter-spacing: .18em; color: var(--ink-faint); text-transform: uppercase; margin: 0 0 6px; font-weight: 500; }
.pt { display: grid; grid-template-columns: 1fr 42px; gap: 6px; align-items: center; padding: 3px 0; font-size: 11px; cursor: pointer; border-radius: 4px; }
.pt:hover { background: #12203a; }
.pt b { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pt em { font-family: var(--mono); font-size: 10px; color: var(--ink-faint); font-style: normal; text-align: right; }

/* --------------------------------------------------------------- action --- */
.act { display: flex; flex-direction: column; gap: 8px; }
.act p { margin: 0; color: var(--ink-faint); font-size: 11.5px; line-height: 1.5; }
.big {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--cyan);
  background: rgba(56,232,255,.1); color: var(--cyan); font-size: 13px; font-weight: 500;
  transition: .15s; letter-spacing: .02em;
}
.big:hover:not(:disabled) { background: rgba(56,232,255,.2); }
.big:disabled { opacity: .35; cursor: not-allowed; }
.big.mag { border-color: var(--magenta); background: rgba(255,79,216,.1); color: var(--magenta); }
.big.mag:hover:not(:disabled) { background: rgba(255,79,216,.2); }
.big.red { border-color: var(--red); background: rgba(255,90,106,.1); color: var(--red); }
.big.red:hover:not(:disabled) { background: rgba(255,90,106,.2); }

.slider { display: grid; grid-template-columns: 62px 1fr 40px; gap: 8px; align-items: center; font-size: 11px; color: var(--ink-faint); }
.slider input { width: 100%; accent-color: var(--cyan); }
.slider em { font-family: var(--mono); font-style: normal; text-align: right; font-size: 10px; }

.behaviours { display: flex; flex-direction: column; gap: 5px; }
.bh {
  text-align: left; background: #0a1322; border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 9px; transition: .15s;
}
.bh b { display: block; font-weight: 500; font-size: 12px; }
.bh span { display: block; color: var(--ink-faint); font-size: 10px; margin-top: 1px; }
.bh:hover { border-color: var(--line-2); }
.bh.is-on { border-color: var(--magenta); background: rgba(255,79,216,.08); }
.bh.is-on b { color: var(--magenta); }

.path { margin-top: 10px; display: flex; flex-direction: column; gap: 0; }
.step { display: grid; grid-template-columns: 16px 1fr; gap: 8px; position: relative; padding-bottom: 9px; }
.step::before {
  content: ""; position: absolute; left: 7px; top: 14px; bottom: 0; width: 1px; background: var(--line-2);
}
.step:last-child::before { display: none; }
.step i {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--line-2);
  background: #0b1524; font-style: normal; font-family: var(--mono); font-size: 8px;
  display: grid; place-items: center; color: var(--ink-faint); z-index: 1;
}
.step b { font-size: 12px; font-weight: 500; display: block; }
.step span { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); }
.step.hot i { border-color: var(--magenta); color: var(--magenta); box-shadow: 0 0 10px rgba(255,79,216,.35); }
.step.hot b { color: var(--magenta); }

/* ------------------------------------------------------------------ hud --- */
#hud {
  position: fixed; left: 252px; right: 316px; bottom: 0; z-index: 14;
  padding: 8px 16px 10px;
  background: linear-gradient(0deg, rgba(4,7,13,.95), rgba(4,7,13,0));
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 4px; }
.stat { display: flex; flex-direction: column; }
.stat b { font-family: var(--mono); font-size: 15px; font-weight: 500; line-height: 1.15; }
.stat span { font-family: var(--mono); font-size: 8.5px; letter-spacing: .14em; color: var(--ink-faint); text-transform: uppercase; }
.stat.hi b { color: var(--cyan); }
.stat.mg b { color: var(--magenta); }
#timeline { width: 100%; height: 46px; display: block; }
.hud-hint { font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); letter-spacing: .06em; margin-top: 2px; }

/* -------------------------------------------------------------- tooltip --- */
#tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 7px;
  padding: 6px 9px; font-size: 11.5px; backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0,0,0,.6); max-width: 240px;
}
#tooltip b { font-weight: 500; }
#tooltip span { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--ink-faint); margin-top: 2px; }

/* ---------------------------------------------------------------- modal --- */
.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(2,4,8,.8); backdrop-filter: blur(6px); padding: 24px;
}
.modal-card {
  position: relative; max-width: 660px; max-height: 84vh; overflow-y: auto;
  background: #08111d; border: 1px solid var(--line-2); border-radius: 14px;
  padding: 28px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.modal-card h2 { font-family: var(--mono); font-size: 15px; letter-spacing: .16em; text-transform: uppercase; margin: 0 0 18px; font-weight: 500; color: var(--cyan); }
.modal-card h3 { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin: 22px 0 8px; font-weight: 500; font-family: var(--mono); }
.modal-card p, .modal-card li { line-height: 1.65; color: var(--ink-dim); }
.modal-card b { color: var(--ink); font-weight: 600; }
.modal-card ul { padding-left: 18px; margin: 8px 0; }
.modal-card code { font-family: var(--mono); font-size: 11px; background: #12203a; padding: 1px 5px; border-radius: 4px; color: var(--cyan); }
.modal-x { position: absolute; top: 14px; right: 16px; background: none; border: 0; font-size: 24px; color: var(--ink-faint); line-height: 1; }
.modal-x:hover { color: var(--ink); }
.cite { font-size: 11.5px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 20px; }
#errMsg { white-space: pre-wrap; font-family: var(--mono); font-size: 11px; color: var(--red); }

/* --------------------------------------------------------------- toasts --- */
#toast {
  position: fixed; left: 50%; top: 68px; transform: translateX(-50%); z-index: 70;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 16px; font-size: 12px; backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
#toast.on { opacity: 1; }

/* ------------------------------------------------------------ responsive -- */
@media (max-width: 1180px) {
  #right { width: 270px; }
  #hud { right: 270px; }
}
@media (max-width: 900px) {
  #left, #right {
    position: fixed; top: auto; bottom: 0; width: 100%; max-height: 44vh;
    flex-direction: row; overflow-x: auto; padding: 8px; gap: 8px;
    background: linear-gradient(0deg, rgba(4,7,13,.98), rgba(4,7,13,.9));
    border-top: 1px solid var(--line);
  }
  #right { bottom: 0; display: none; }
  #right.is-open { display: flex; }
  .panel { min-width: 240px; }
  #hud { left: 0; right: 0; bottom: 46vh; }
  .brand-tag { display: none; }
  #timeline { display: none; }
}
