:root {
  --bg: #101114;
  --rail: #17191e;
  --card: #1c1f26;
  --card-2: #232833;
  --line: #313743;
  --text: #f3efe6;
  --muted: #a7a194;
  --amber: #e4a33a;
  --amber-ink: #1b1408;
  --sand: #f3ecdf;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 70% -10%, rgba(228, 163, 58, 0.1), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 "Avenir Next", "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
a { color: var(--amber); }

.app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 22px 6px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { height: 72px; width: auto; display: block; }
.wordmark { display: flex; flex-direction: column; line-height: 1; min-width: 0; }
.wordmark b {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.wordmark span {
  margin-top: 6px;
  color: var(--muted);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 12px;
}
.top { position: relative; }
.head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.head-actions button { padding: 8px 14px; }
.head-actions .avatar { padding: 0; }
.avatar {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border-color: transparent;
  background: transparent;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}
.avatar img, .avatar canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.figure-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.figure-choices button {
  width: 64px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
}
.figure-choices button.on { border-color: var(--amber); }
.figure-choices canvas { width: 44px; height: 44px; border-radius: 50%; }
.figure-choices small { color: var(--muted); font-size: 10px; line-height: 1.2; }
.account-panel {
  position: absolute;
  top: 86px;
  right: 22px;
  z-index: 5;
  width: min(300px, calc(100vw - 24px));
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.account-panel[hidden] { display: none; }
.account-panel h2 { font-size: 16px; }
.account-panel input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
}
.account-panel form, #account-in { display: flex; flex-direction: column; gap: 8px; }
#people { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow: auto; }
#people li { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 5px 0; border-top: 1px solid var(--line); }
#people small { color: var(--muted); }
#people-wrap[hidden] { display: none; }
#join-ask { text-align: center; margin: 0 0 8px; }
#join-ask[hidden] { display: none; }
.account-panel form[hidden], #account-in[hidden] { display: none; }
#cosmos {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: none;
}
body.future #cosmos { display: block; }
.app { position: relative; z-index: 1; }
.text-link { text-decoration: none; }
.fine { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 18px;
  padding: 8px 22px 28px;
}
.songs, .metals, .stage-wrap {
  background: var(--rail);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}
.stage-wrap { display: flex; flex-direction: column; align-items: center; }
h1, h2 { font-size: 18px; margin: 0 0 12px; font-weight: 650; }
.side-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.side-toggle button { padding: 8px 6px; }
.side-toggle button.on { border-color: var(--amber); color: var(--text); }
#song-pane[hidden],
#freq-pane[hidden] { display: none; }
#upload-form { margin-top: 18px; }
#spectrum-range-row[hidden] { display: none; }
.freq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  margin-top: 12px;
}
.freq {
  text-align: left;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
}
.freq small { color: var(--muted); font-size: 12px; }
.freq.in-range { box-shadow: inset 3px 0 0 var(--amber); }
.freq.on { border-color: var(--line-choice, #7c3aed); }

button, .shape {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}
button.primary {
  background: var(--amber);
  color: var(--amber-ink);
  border-color: transparent;
  font-weight: 700;
  width: 100%;
}
.shape-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; justify-content: center; }
.shape-row button { padding: 8px 10px; }
.shape.on, .song.on, .material.on { border-color: var(--amber); }
#future.on {
  border-color: var(--line-choice, #7c3aed);
  color: #f4ecff;
  box-shadow: 0 0 16px color-mix(in srgb, var(--line-choice, #7c3aed) 45%, transparent);
}
#particles.on {
  border-color: #8eb6ff;
  color: #eef3ff;
  box-shadow: 0 0 16px rgba(120, 170, 255, 0.45);
}
.future-bar[hidden] {
  display: none;
}
.future-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(100%, 560px);
  margin-bottom: 8px;
}
.color-choice, .hz-choice { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.hz-choice { width: min(100%, 560px); margin-bottom: 4px; flex: 0 0 auto; }
.hz-choice input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.hz-choice input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: #3c424c;
}
.hz-choice input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
}
.hz-choice input[type="range"]::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: #3c424c;
}
.hz-choice input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--amber);
}
body.future .hz-choice input[type="range"]::-webkit-slider-thumb,
body.future .hz-choice input[type="range"]::-moz-range-thumb {
  background: var(--line-choice, #7c3aed);
}
.hz-choice b { min-width: 64px; color: var(--text); font-variant-numeric: tabular-nums; }
input[type="color"] {
  width: 44px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
body.future { background: #07060f; }
body.future .songs,
body.future .metals,
body.future .stage-wrap {
  background: rgba(10, 8, 20, 0.62);
  border-color: color-mix(in srgb, var(--line-choice, #7c3aed) 45%, #313743);
}
body.future #plate { width: min(100%, 440px); touch-action: none; background: transparent; }
#plate {
  width: min(100%, 560px);
  height: auto;
  background: #000;
  border-radius: 0;
  touch-action: none;
}
.play-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 560px);
  margin-top: 12px;
}
.play-row .primary { width: auto; }
.readout {
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
  margin: 16px 0 0;
}
.readout div { margin: 0; }
.readout .span { grid-column: 1 / -1; }
dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
dd { margin: 3px 0 0; font-variant-numeric: tabular-nums; }
#figure { font-size: 20px; font-weight: 650; letter-spacing: 0.01em; }
.song-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
  max-height: calc(100vh - 250px);
  overflow: auto;
}
.song-block {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-2);
  overflow: hidden;
}
.song-block.on { border-color: var(--amber); }
.song-row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}
.song {
  text-align: left;
  background: transparent;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  width: auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
}
.song-more {
  flex: 0 0 36px;
  width: 36px;
  align-self: stretch;
  height: auto;
  min-height: 36px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
}
.song-menu {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(200px, calc(100vw - 16px));
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.song-menu[hidden] { display: none; }
.song-menu button { text-align: left; background: transparent; }
.song-hz {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.song-hz[hidden], .song-rename[hidden] { display: none; }
.song-rename {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.song-rename input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.song-hz input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
}
.song strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}
.song span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}
.material-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 340px);
  overflow: auto;
}
.material {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: transparent;
  padding: 8px;
}
.swatch {
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.material b { display: block; }
.material small { color: var(--muted); }
details { margin-top: 14px; }
summary { cursor: pointer; color: var(--muted); }
#sources { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
#sources li { margin: 6px 0; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .songs, .metals, .stage-wrap { min-width: 0; max-width: 100%; }
  .stage-wrap { order: 1; }
  .metals { order: 2; }
  .songs { order: 3; }
  .song-list, .freq-list { max-height: 280px; }
  .material-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    max-width: 100%;
    max-height: none;
    padding-bottom: 4px;
  }
  .material { flex: 0 0 200px; min-width: 200px; }
}
@media (max-width: 640px) {
  .top { flex-wrap: wrap; row-gap: 8px; }
  .head-actions { margin-left: auto; }
  .head-actions .avatar { padding: 0; }
  .top, .layout { padding-left: 12px; padding-right: 12px; }
  .logo { height: 52px; }
  .wordmark b { font-size: 18px; letter-spacing: 0.1em; }
  .wordmark span { letter-spacing: 0.16em; font-size: 11px; }
  .head-actions button { padding: 6px 8px; font-size: 12px; }
  .avatar { width: 36px; height: 36px; }
  .account-panel { right: 12px; top: 72px; }
  #plate { width: min(100%, 280px); }
  .readout { grid-template-columns: 1fr 1fr; }
  .play-row { flex-direction: column; align-items: stretch; }
  .play-row .primary { width: 100%; }
  .future-bar { flex-direction: column; align-items: stretch; }
}
