:root {
  --bg: #05060d;
  --bg2: #0b0d1c;
  --panel: rgba(16, 18, 36, 0.78);
  --panel-solid: #11132a;
  --border: rgba(130, 150, 255, 0.16);
  --border-strong: rgba(130, 150, 255, 0.32);
  --text: #e8eaff;
  --muted: #8b90b8;
  --rh: #22d3ee;
  --rh-deep: #0e7490;
  --lh: #f472b6;
  --lh-deep: #9d174d;
  --violet: #a78bfa;
  --unsure: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Orbitron", "Inter", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--rh); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 24px;
  background: rgba(5, 6, 13, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo {
  font: 700 18px var(--display);
  letter-spacing: 0.14em;
  background: linear-gradient(90deg, var(--rh), var(--violet) 55%, var(--lh));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted);
  font-size: 14px; letter-spacing: 0.02em;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav a.active { color: var(--text); background: rgba(130, 150, 255, 0.10); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }
.who b { color: var(--text); font-weight: 500; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer; white-space: nowrap; font-size: 14px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.btn:hover { border-color: rgba(167, 139, 250, 0.6); background: rgba(167, 139, 250, 0.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  border: none; color: #050510; font-weight: 600;
  background: linear-gradient(90deg, var(--rh), var(--violet));
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.25);
}
.btn.primary:hover { box-shadow: 0 0 32px rgba(167, 139, 250, 0.45); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(248, 113, 113, .08); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.rh { border-color: rgba(34, 211, 238, .5); color: var(--rh); }
.btn.lh { border-color: rgba(244, 114, 182, .5); color: var(--lh); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.input {
  height: 42px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: rgba(5, 6, 13, 0.6); outline: none;
}
.input:focus { border-color: var(--rh); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- welcome ---------- */
.hero {
  position: relative; min-height: calc(100vh - 56px); overflow: hidden;
  display: grid; place-items: center; padding: 48px 24px 160px;
}
.hero-bg { position: fixed; inset: 56px 0 0 0; z-index: 0; pointer-events: none; }
.hero-bg .glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 50% at 20% 25%, rgba(34, 211, 238, 0.14), transparent 70%),
    radial-gradient(55% 45% at 85% 30%, rgba(244, 114, 182, 0.13), transparent 70%),
    radial-gradient(70% 60% at 50% 110%, rgba(167, 139, 250, 0.20), transparent 70%);
}
.hero-bg .photo {
  position: absolute; inset: 0; background-size: cover; background-position: center 30%;
  opacity: 0; transition: opacity 1s;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,.25) 60%, transparent);
}
.hero-bg .photo.loaded { opacity: 1; }
.hero-bg .rain { position: absolute; left: 0; top: 0; width: 100%; height: calc(100% - 112px); display: block; }
.hero-bg .keys {
  position: absolute; left: 0; right: 0; bottom: 0; height: 112px;
  transform-origin: 50% 100%; /* tilt is set by hero.js so the notes can line up with it */
  box-shadow: 0 -1px 0 rgba(167, 139, 250, 0.55), 0 -12px 40px rgba(167, 139, 250, 0.18);
}
.hero-bg .keys i { position: absolute; top: 0; display: block; }
.hero-bg .keys .w {
  bottom: 0;
  background: linear-gradient(#c9cdea, #f3f4ff 70%, #dcdff3);
  border-right: 1px solid rgba(25, 27, 48, 0.55);
  border-radius: 0 0 4px 4px;
  box-shadow: inset 0 -5px 0 rgba(120, 125, 170, 0.25);
}
.hero-bg .keys .b {
  height: 62%; z-index: 1;
  background: linear-gradient(#2c2f4c, #0b0c18 92%);
  border-radius: 0 0 3px 3px;
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.07), 0 3px 5px rgba(0, 0, 0, 0.55);
}
.hero-bg .keys i::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: linear-gradient(var(--c), color-mix(in srgb, var(--c) 55%, #05060d));
  box-shadow: 0 0 16px var(--c);
  transition: opacity .12s ease-out;
}
.hero-bg .keys i.on::after { opacity: .9; transition-duration: .03s; }

.hero-inner { position: relative; z-index: 1; width: min(640px, 100%); text-align: center; }
.hero h1 {
  margin: 0 0 6px; font: 700 clamp(34px, 6vw, 60px)/1.05 var(--display); letter-spacing: 0.08em;
  background: linear-gradient(90deg, var(--rh), var(--violet) 50%, var(--lh));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 24px rgba(167, 139, 250, 0.35));
}
.hero p.tag { margin: 0 0 32px; color: var(--muted); font-size: 17px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  padding: 28px; text-align: left;
}
.tabs { display: flex; gap: 6px; padding: 4px; margin-bottom: 18px;
  border: 1px solid var(--border); border-radius: 11px; background: rgba(5, 6, 13, .5); }
.tabs button {
  flex: 1; height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs button.on { background: rgba(130, 150, 255, .14); color: var(--text); }
.drop {
  display: grid; place-items: center; gap: 6px; height: 120px; padding: 12px;
  border: 1.5px dashed var(--border-strong); border-radius: 12px; cursor: pointer; text-align: center;
  color: var(--muted); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--rh); background: rgba(34, 211, 238, .05); color: var(--text); }
.drop b { color: var(--text); font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.filename { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.filename code { color: var(--text); background: rgba(255,255,255,.05); padding: 2px 6px; border-radius: 6px; }

/* ---------- progress ---------- */
.progress-wrap { width: min(640px, 100%); margin: 64px auto; padding: 0 24px; }
.steps { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.steps li .dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; }
.steps li.done { color: var(--text); }
.steps li.done .dot { background: var(--rh); border-color: var(--rh); box-shadow: 0 0 10px var(--rh); }
.steps li.now { color: var(--text); }
.steps li.now .dot { border-color: var(--violet); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(167, 139, 250, .18); } }
.log { margin-top: 18px; max-height: 160px; overflow: auto; font: 12px/1.6 ui-monospace, Consolas, monospace;
  color: var(--muted); background: rgba(5, 6, 13, .6); border-radius: 10px; padding: 10px 12px; }

/* ---------- library ---------- */
.page { width: min(1100px, 100%); margin: 0 auto; padding: 32px 24px 64px; }
.page h2 { font: 600 22px var(--display); letter-spacing: .06em; margin: 0; }
.lib-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.lib-head .tabs { margin: 0; }
.lib-head .input { height: 36px; width: 240px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.song {
  position: relative; padding: 16px 16px 14px; border-radius: var(--radius); cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.song:hover { border-color: rgba(167, 139, 250, .5); transform: translateY(-2px); }
.song::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--rh), var(--lh));
}
.song .t { font-weight: 600; font-size: 16px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song .a { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.song .meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.song .meta .u { color: var(--unsure); }
.song .actions { display: flex; gap: 6px; margin-top: 12px; }
.empty { color: var(--muted); padding: 48px 0; text-align: center; }

/* ---------- login ---------- */
.login { position: relative; z-index: 1; width: min(380px, 100%); margin: 6vh auto 0; padding: 0 24px 160px; }
.login-logo {
  text-align: center; margin-bottom: 22px; font: 700 34px var(--display); letter-spacing: .1em;
  background: linear-gradient(90deg, var(--rh), var(--violet) 50%, var(--lh));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.35));
}
.login .card { backdrop-filter: blur(16px); }
.login .card { display: grid; gap: 16px; }
.login form { display: grid; gap: 16px; }
.login [hidden] { display: none !important; }
.login form { gap: 14px; }
.login .tabs { margin-bottom: 0; }
.login .closed { color: var(--unsure); }
.login h2 { font: 600 20px var(--display); letter-spacing: .08em; margin: 0 0 4px; }

/* ---------- editor ---------- */
.editor { position: fixed; inset: 56px 0 0 0; display: flex; flex-direction: column; background: var(--bg); }
.toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto;
  padding: 7px 10px; border-bottom: 1px solid var(--border); background: var(--bg2);
}
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 2px; }
.toolbar .title-edit { display: flex; gap: 6px; }
.toolbar .title-edit input {
  height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 7px; background: transparent;
  font-size: 14px; width: 108px; outline: none;
}
.toolbar .title-edit input:hover { border-color: var(--border); }
.toolbar .title-edit input:focus { border-color: var(--rh); background: rgba(5,6,13,.6); }
.toolbar .title-edit input.t { font-weight: 600; }
.toolbar select { height: 30px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--panel-solid); padding: 0 6px; font-size: 13px; }
.time { font: 13px ui-monospace, Consolas, monospace; color: var(--muted); min-width: 52px; text-align: center; }
.unsure-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--unsure); }
.unsure-chip .d { width: 8px; height: 8px; border-radius: 50%; background: var(--unsure); box-shadow: 0 0 8px var(--unsure); }
.dirty { color: var(--unsure); font-size: 12px; text-shadow: 0 0 8px var(--unsure); }
.canvas-wrap { position: relative; flex: 1; min-height: 0; }
.canvas-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.statusbar {
  display: flex; gap: 18px; align-items: center; padding: 6px 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--bg2);
}
.statusbar .legend { display: flex; gap: 14px; }
.statusbar .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.help {
  position: absolute; right: 16px; top: 16px; z-index: 5; width: 320px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; backdrop-filter: blur(14px);
  padding: 16px 18px; font-size: 13px; display: none;
}
.help.open { display: block; }
.help h4 { margin: 0 0 8px; font: 600 13px var(--display); letter-spacing: .08em; }
.help table { width: 100%; border-collapse: collapse; }
.help td { padding: 3px 0; vertical-align: top; }
.help td:first-child { color: var(--muted); width: 46%; }
.kbd { font: 11px ui-monospace, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 4px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50;
  padding: 10px 16px; border-radius: 10px; background: var(--panel-solid); border: 1px solid var(--border-strong);
  box-shadow: 0 10px 40px rgba(0,0,0,.5); font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 700px) {
  .row2 { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 12px; }
  .who { display: none; }
}

#e-play { min-width: 78px; }
.toolbar > * { flex-shrink: 0; }

.pop {
  position: absolute; top: 10px; z-index: 6; width: 350px; display: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; backdrop-filter: blur(14px);
  padding: 14px 16px; font-size: 13px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.pop.open { display: block; }
.pop h4 { margin: 0 0 10px; font: 600 13px var(--display); letter-spacing: .08em; }
.pop-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pop-row .input { width: 76px; height: 32px; padding: 0 8px; }
.pop-row input[type=range] { flex: 1; accent-color: var(--violet); }
.pop-check { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; margin-bottom: 8px; }
.pop-check .hint { grid-column: 2; }

/* ---------- library details view ---------- */
.page.wide { width: min(1280px, 100%); }
.view-toggle button { flex: none; }
.who-tag { color: var(--violet); }
.selbar { display: none; align-items: center; gap: 12px; margin: -6px 0 14px; padding: 8px 12px;
  border: 1px solid rgba(167, 139, 250, .35); border-radius: 10px; background: rgba(167, 139, 250, .08); font-size: 14px; }
.selbar.on { display: flex; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table.files { width: 100%; border-collapse: collapse; font-size: 14px; }
table.files th, table.files td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.files th { position: sticky; top: 0; background: var(--panel-solid); color: var(--muted); font-weight: 500; font-size: 12px;
  letter-spacing: .04em; text-transform: uppercase; user-select: none; }
table.files th.sortable { cursor: pointer; }
table.files th.sortable:hover, table.files th.sorted { color: var(--text); }
table.files .num { text-align: right; font-variant-numeric: tabular-nums; }
table.files td.title { font-weight: 500; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.files tbody tr { cursor: pointer; transition: background .1s; }
table.files tbody tr:hover { background: rgba(255, 255, 255, .03); }
table.files tbody tr.sel { background: rgba(34, 211, 238, .08); }
table.files tbody tr:last-child td { border-bottom: 0; }
table.files .cb { width: 36px; padding-right: 0; }
table.files .act { text-align: right; width: 1%; }
table.files .act .btn { height: 26px; padding: 0 8px; }
table.files input[type=checkbox], .song .pick input { accent-color: var(--rh); width: 15px; height: 15px; cursor: pointer; }
.u { color: var(--unsure); }
.song .pick { position: absolute; top: 12px; right: 12px; }
.song.sel { border-color: rgba(34, 211, 238, .6); background: rgba(34, 211, 238, .06); }
.viewonly { font-size: 12px; color: var(--violet); padding: 3px 8px; border: 1px solid rgba(167, 139, 250, .4); border-radius: 999px; }
