:root {
  --bg: #170e24;
  --bg-2: #1e1330;
  --purple: #35214a;
  --slate: #44637f;
  --turq: #66d9d3;
  --mint: #d9fff3;
  --text: #e7f6f2;
  --muted: #9fb5bf;
  --line: rgba(102, 217, 211, .18);
  --panel: rgba(53, 33, 74, .45);
  --radius: 14px;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--sans); line-height: 1.55; -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(900px 500px at 85% -5%, rgba(102, 217, 211, .13), transparent 60%),
    radial-gradient(700px 500px at -10% 30%, rgba(68, 99, 127, .28), transparent 60%);
  background-attachment: fixed;
}
a { color: var(--turq); text-decoration: none; }
a:hover { color: var(--mint); }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.01em; }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--turq); outline-offset: 2px; }

/* NAV */
.nav {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 48px); background: rgba(23, 14, 36, .8);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--mint); font-weight: 700; font-size: 1.15rem; }
.brand svg { color: var(--turq); }
.nav nav { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 28px); }
.nav nav a { color: var(--text); font-size: .95rem; opacity: .85; }
.nav nav a:hover { opacity: 1; color: var(--turq); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  font: 600 .95rem var(--sans); padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  background: var(--turq); color: #102129; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(102, 217, 211, .3); color: #102129; background: var(--mint); }
.btn-ghost { background: transparent; color: var(--turq); border-color: var(--line); }
.btn-ghost:hover { background: rgba(102, 217, 211, .1); color: var(--mint); box-shadow: none; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }

/* HERO */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: 24px;
  max-width: 1320px; margin: 0 auto; padding: clamp(28px, 5vw, 56px) clamp(16px, 4vw, 48px) 40px; min-height: min(760px, calc(100vh - 60px));
}
.eyebrow { font: 500 .78rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--turq); margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.3rem, 5vw, 4rem); font-weight: 700; color: var(--mint); }
.lead { margin-top: 20px; font-size: 1.12rem; color: var(--muted); max-width: 52ch; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.stats { display: flex; gap: clamp(20px, 4vw, 44px); margin: 40px 0 0; padding-top: 24px; border-top: 1px solid var(--line); }
.stats dt { font: 600 1.9rem var(--sans); color: var(--turq); }
.stats dd { margin: 0; font: .78rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hero-stage { position: relative; height: clamp(440px, 72vh, 680px); border-radius: 24px;
  background: radial-gradient(closest-side, rgba(102, 217, 211, .12), transparent 75%); }
.hero-stage canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.hero-stage canvas:active { cursor: grabbing; }
.hero-tag {
  position: absolute; left: 12px; bottom: 12px; font: .78rem var(--mono); color: var(--muted);
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(23, 14, 36, .7);
}
.hero-tag b { color: var(--mint); font-weight: 500; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--turq); margin-right: 4px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* SECTIONS */
.section { max-width: 1320px; margin: 0 auto; padding: clamp(40px, 7vw, 88px) clamp(16px, 4vw, 48px) 0; }
.section-head { margin-bottom: 28px; max-width: 70ch; }
.section-head.row { max-width: none; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.section-head h2, .about h2 { font-size: clamp(1.7rem, 3.2vw, 2.5rem); color: var(--mint); }
.section-head .muted { margin-top: 12px; }

/* EXPLORER */
.explorer { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; align-items: start; }
.picker {
  position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; padding: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-height: calc(100vh - 96px);
}
.search input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(23, 14, 36, .7); color: var(--text); font: .95rem var(--sans);
}
.search input::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 .74rem var(--mono); padding: 5px 10px; border-radius: 999px; cursor: pointer; color: var(--muted);
  background: transparent; border: 1px solid var(--line); transition: all .15s;
}
.chip:hover { color: var(--mint); border-color: var(--turq); }
.chip[aria-pressed="true"] { background: var(--turq); color: #102129; border-color: var(--turq); }
.list { overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: var(--slate) transparent; }
.group-h { font: 500 .7rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.group-h::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.item {
  display: block; width: 100%; text-align: left; cursor: pointer; padding: 9px 12px; margin-bottom: 3px;
  border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--text); font: .95rem var(--sans);
}
.item:hover { background: rgba(102, 217, 211, .08); }
.item[aria-selected="true"] { background: rgba(102, 217, 211, .14); border-color: var(--turq); color: var(--mint); }
.empty { color: var(--muted); font-size: .9rem; padding: 12px 4px; }

.workspace { min-width: 0; }
.subject { padding: 4px 4px 16px; }
.badge {
  display: inline-block; font: 500 .72rem var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px;
  border-radius: 999px; color: var(--c, var(--turq)); border: 1px solid var(--c, var(--turq)); background: rgba(255, 255, 255, .03);
}
.subject h3 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin: 10px 0 6px; color: var(--mint); }
.subject p { max-width: 70ch; }

.viewers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.viewer { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: linear-gradient(180deg, rgba(53, 33, 74, .55), rgba(23, 14, 36, .75)); }
.viewer figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px;
  font: 500 .8rem var(--mono); color: var(--turq); text-transform: uppercase; letter-spacing: .1em; border-bottom: 1px solid var(--line);
}
.tools { display: flex; gap: 6px; }
.tools button {
  font: .7rem var(--mono); text-transform: none; letter-spacing: 0; padding: 3px 9px; border-radius: 999px; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px solid var(--line);
}
.tools button:hover { color: var(--mint); border-color: var(--turq); }
.tools button[aria-pressed="true"] { color: var(--turq); }
.canvas-wrap { position: relative; height: clamp(360px, 52vh, 520px); }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.canvas-wrap canvas:active { cursor: grabbing; }
.nogl { margin-top: 12px; color: #ff9a9a; }

.hl-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.hl-label {
  position: absolute; left: 0; top: 0; white-space: nowrap; font: 500 .7rem var(--mono); color: var(--mint);
  padding: 3px 8px 3px 10px; margin: -11px 0 0 10px; border-radius: 6px; background: rgba(23, 14, 36, .82);
  border-left: 2px solid var(--c); transition: opacity .2s; will-change: transform;
}
.hl-label::before { content: ''; position: absolute; left: -14px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }

.detail { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.panel h4 { font: 500 .75rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--turq); margin: 18px 0 8px; }
.panel h4:first-child { margin-top: 0; }
.panel p { color: var(--text); font-size: .96rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font: .78rem var(--mono); padding: 4px 10px; border-radius: 6px; background: rgba(68, 99, 127, .4); color: var(--mint); }
.bullets { margin: 0; padding-left: 18px; font-size: .94rem; }
.bullets li { margin-bottom: 4px; }
.bullets li::marker { color: var(--turq); }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { padding: 7px 8px; margin: 0 -8px 2px; border-radius: 8px; cursor: default; transition: background .15s; }
.bars li:hover { background: rgba(102, 217, 211, .1); }
.bars .top { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.bars .lvl { font: .7rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.bars .track { height: 5px; margin-top: 5px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.bars .fill { height: 100%; border-radius: 3px; background: var(--c); box-shadow: 0 0 10px var(--c); transition: width .5s; }
.bars .role { font-size: .76rem; color: var(--muted); }
.none { color: var(--muted); font-size: .92rem; }
.fineprint { margin-top: 14px; font-size: .8rem; color: var(--muted); }

/* RESEARCH */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-top: 18px; }
.card { display: flex; flex-direction: column; gap: 10px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-2px); border-color: var(--turq); }
.card .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font: .72rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.card .type { color: var(--turq); }
.card .sample { padding: 1px 7px; border: 1px dashed var(--slate); border-radius: 999px; }
.card h3 { font-size: 1.15rem; color: var(--mint); }
.card .by { font-size: .85rem; color: var(--muted); }
.card p.sum { font-size: .93rem; color: var(--text); flex: 1; }
.card .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.card .tag { cursor: pointer; font: .75rem var(--mono); padding: 4px 10px; border-radius: 999px; color: var(--c); border: 1px solid var(--c); background: transparent; }
.card .tag:hover { background: rgba(255, 255, 255, .06); }
.card .admin { display: flex; gap: 10px; }
.card .rm { cursor: pointer; font: .72rem var(--mono); color: var(--muted); background: none; border: 0; padding: 0; }
.card .rm:hover { color: #ff8a8a; }
.card .ed:hover { color: var(--turq); }
#editNote { margin: 14px 0 0; font-size: .9rem; color: var(--mint); background: rgba(102, 217, 211, .1); padding: 10px 14px; border-radius: 10px; }
.noresults { color: var(--muted); padding: 24px 0; }

/* ABOUT */
.about { padding-bottom: 88px; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 24px; }

/* FOOTER */
.footer { border-top: 1px solid var(--line); padding: 28px clamp(16px, 4vw, 48px); display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.footer p { max-width: 70ch; }

/* DIALOG */
dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--turq); border-radius: 18px; background: var(--bg-2); color: var(--text); }
dialog::backdrop { background: rgba(10, 5, 18, .75); backdrop-filter: blur(4px); }
dialog form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
dialog header { display: flex; justify-content: space-between; align-items: center; }
dialog h3 { color: var(--mint); font-size: 1.3rem; }
dialog .x { font-size: 1.6rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--muted); }
dialog input, dialog select, dialog textarea {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(23, 14, 36, .8);
  color: var(--text); font: .95rem var(--sans); resize: vertical;
}
dialog .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
dialog .hint { font-size: .78rem; color: var(--muted); }
dialog .err { color: #ff9a9a; font-size: .85rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; }

/* AUTH */
[hidden] { display: none !important; }
.userchip { font: .8rem var(--mono); color: var(--mint); padding: 5px 12px; border-radius: 999px; background: rgba(102, 217, 211, .12); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#authDialog { width: min(420px, calc(100vw - 32px)); }
#authDialog .note { font-size: .88rem; color: var(--mint); background: rgba(102, 217, 211, .1); padding: 10px 12px; border-radius: 10px; }
#authDialog .or { display: flex; align-items: center; gap: 10px; font: .72rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
#authDialog .or::before, #authDialog .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
#authDialog .links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; font: .82rem var(--sans); color: var(--turq); }
.linkbtn:hover { color: var(--mint); text-decoration: underline; }
#authDialog .actions .btn { width: 100%; }
#authSubmit:disabled { opacity: .6; cursor: progress; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .explorer { grid-template-columns: 1fr; }
  .picker { position: static; max-height: 380px; }
  .detail { grid-template-columns: 1fr 1fr; }
  .detail .panel:first-child { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-stage { height: 460px; order: -1; }
  .viewers { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .nav nav a { display: none; }
  .detail { grid-template-columns: 1fr; }
  dialog .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dot { animation: none; }
}
