:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212b;
  --line: #272c38;
  --ink: #e8eaf0;
  --muted: #8b91a3;
  --muted-2: #5a6072;
  --brand: #6d5efc;
  --brand-2: #8b7bff;
  --danger: #ff5d6c;
  --ok: #34d399;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 80% -10%, #1a1740 0%, transparent 55%),
              radial-gradient(900px 600px at -10% 10%, #161a3a 0%, transparent 50%),
              var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── top bar ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: rgba(15,17,21,.72); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
.brand img { width: 28px; height: 28px; border-radius: 8px; display: block; }
.brand span b { color: #fff; }
.brand span small { color: var(--muted); font-weight: 500; }
.topbar .spacer { flex: 1; }
.topbar nav a { color: var(--muted); margin-left: 18px; font-weight: 500; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; text-decoration: none; }

/* ── layout ──────────────────────────────────────────── */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* ── cards / grid ────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; transition: transform .12s ease, border-color .12s ease;
}
.card.link:hover { transform: translateY(-2px); border-color: #3a3f57; }
.card .title { font-weight: 650; font-size: 16px; margin: 0 0 6px; color: #fff; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .helix-thumb { height: 86px; border-radius: 10px; margin-bottom: 12px;
  background: linear-gradient(135deg,#8b7bff,#3a1fb0); display: grid; place-items: center; overflow: hidden; }
.card .helix-thumb img { width: 56px; height: 56px; opacity: .96; }

/* ── forms ───────────────────────────────────────────── */
.input, textarea.input, select.input {
  width: 100%; background: #11141b; border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; color: var(--ink); outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,94,252,.18); }
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: #3a3f57; filter: none; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.danger { color: var(--danger); }
.notice { padding: 10px 13px; border-radius: 10px; background: rgba(255,93,108,.12);
  border: 1px solid rgba(255,93,108,.3); color: #ffb3ba; margin-bottom: 14px; font-size: 14px; }
.notice.ok { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.3); color: #a7f3d0; }

/* ── auth ────────────────────────────────────────────── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth .box { width: min(420px, 92vw); background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.auth .box .input { width: 100%; }
.auth .logo { display: grid; place-items: center; margin-bottom: 14px; }
.auth .logo img { width: 64px; height: 64px; border-radius: 16px; }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; }
.tabs { display: flex; gap: 6px; background: #11141b; border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; background: transparent; border: 0; padding: 8px; border-radius: 7px;
  color: var(--muted); cursor: pointer; font-weight: 600; }
.tabs button.active { background: var(--brand); color: #fff; }

/* ── viewer ──────────────────────────────────────────── */
.viewer { display: grid; grid-template-columns: 260px 1fr; height: calc(100vh - 57px); }
.side { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 16px; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); margin: 18px 0 8px; }
.taglist { list-style: none; margin: 0; padding: 0; }
.taglist li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.taglist li:hover { background: var(--panel-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.canvas-host { position: relative; overflow: auto; background:
  repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(255,255,255,.025) 27px, rgba(255,255,255,.025) 28px); }
#paper { display: block; background: #fbfbfd; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
.minimap { position: absolute; top: 0; right: 0; width: 12px; height: 100%; background: rgba(0,0,0,.25); }
.minimap .m { position: absolute; right: 2px; width: 8px; height: 4px; border-radius: 2px; }
.floating { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 40; }
.fab { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--brand); color: #fff;
  font-size: 20px; cursor: pointer; box-shadow: var(--shadow); display: grid; place-items: center; }
.fab.ghost { background: var(--panel-2); border: 1px solid var(--line); }
.pill { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 45;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 8px 8px 16px;
  display: none; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.pill .nav { display: flex; gap: 6px; }
.pill .nav button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: #fff; cursor: pointer; }

/* ── modal ───────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; place-items: center; z-index: 100; }
.modal-bg.open { display: grid; }
.modal { width: 440px; max-width: calc(100vw - 32px); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty img { width: 72px; opacity: .5; margin-bottom: 12px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 720px) { .viewer { grid-template-columns: 1fr; } .side { display: none; } }
