/* Spellsing. Midnight ink, a throat-to-vision light, and the chakra spectrum for the lanes. */

:root {
  --ink: #07060f;
  --ink-2: #0d0b1a;
  --ink-3: #151227;
  --line: rgba(190, 182, 255, 0.11);
  --line-2: rgba(190, 182, 255, 0.2);
  --text: #ece9ff;
  --soft: #a7a1c8;
  --dim: #6d678f;
  --throat: rgb(107, 184, 255);
  --vision: rgb(138, 129, 255);
  --crown: rgb(241, 167, 255);
  --gold: #f3cf7a;
  --rose: #ff7a93;
  --light: linear-gradient(100deg, var(--throat), var(--vision) 60%, var(--crown));
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --code-size: 14.5px;
  --code-line: 1.62;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); }
body {
  font: 400 15px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--throat); text-decoration: none; }
a:hover { color: var(--text); }
button { font: inherit; color: inherit; }
code { font: 500 0.92em var(--mono); color: var(--crown); }
[hidden] { display: none !important; }

/* The aura follows the music: app.js writes --aura-a (0..1) and --aura-hue each frame. */
.aura {
  position: fixed;
  inset: -20vh -20vw auto auto;
  width: 80vw;
  height: 80vh;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(closest-side, rgba(138, 129, 255, calc(0.08 + var(--aura-a, 0) * 0.16)), transparent 70%),
    radial-gradient(closest-side at 30% 70%, rgba(107, 184, 255, calc(0.05 + var(--aura-a, 0) * 0.1)), transparent 70%);
  filter: blur(20px);
  transition: background 0.2s linear;
}

/* ------------------------------------------------------------ header */
.top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(16px, 3vw, 36px) 14px;
  border-bottom: 1px solid var(--line);
}
.mark { display: flex; align-items: center; gap: 12px; color: var(--text); }
.sigil { width: 30px; height: 30px; }
.word { font: 500 27px/1 var(--serif); letter-spacing: 0.01em; }
.word i { font-style: italic; background: var(--light); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 2px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a {
  color: var(--soft);
  padding: 7px 12px;
  border-radius: 999px;
  font: 500 13px/1 var(--sans);
  letter-spacing: 0.02em;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }

main { position: relative; z-index: 1; flex: 1; }

/* ------------------------------------------------------------ play view */
.transport {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px clamp(16px, 3vw, 36px);
}
.go {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: var(--light);
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 0 rgba(138, 129, 255, 0.5), 0 10px 40px -10px rgba(107, 184, 255, 0.6);
  transition: transform 0.15s ease, box-shadow 0.3s ease;
}
.go svg { width: 26px; height: 26px; fill: var(--ink); }
.go .i-stop { display: none; }
.playing .go .i-stop { display: block; }
.playing .go .i-play { display: none; }
.go:hover { transform: scale(1.04); }
.go:active { transform: scale(0.97); }
.playing .go { animation: breathe calc(60s / var(--tempo, 100)) ease-in-out infinite; }
@keyframes breathe {
  0% { box-shadow: 0 0 0 0 rgba(138, 129, 255, 0.55), 0 10px 40px -10px rgba(107, 184, 255, 0.6); }
  100% { box-shadow: 0 0 0 14px rgba(138, 129, 255, 0), 0 10px 40px -10px rgba(107, 184, 255, 0.6); }
}
.spell-id { min-width: 0; flex: 1; }
.spell-name {
  font: italic 500 30px/1.1 var(--serif);
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  width: 100%;
  outline: none;
}
.spell-name:focus { text-decoration: underline 1px var(--line-2); text-underline-offset: 6px; }
.readout { font: 400 12.5px/1.4 var(--mono); color: var(--soft); margin-top: 4px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; }
.ghost {
  background: none;
  border: 1px solid var(--line-2);
  color: var(--soft);
  padding: 8px 14px;
  border-radius: 999px;
  font: 500 12.5px/1 var(--sans);
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--vision); }
.ghost.done { color: var(--ink); background: var(--throat); border-color: var(--throat); }

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 0;
  border-top: 1px solid var(--line);
  min-height: calc(100vh - 200px);
}
.left { border-right: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.right { min-width: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------ editor */
.editor { position: relative; flex: 1; min-height: 420px; }
.editor pre, .editor textarea {
  margin: 0;
  padding: 22px clamp(16px, 2.5vw, 30px) 60px;
  font: 400 var(--code-size) / var(--code-line) var(--mono);
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  letter-spacing: 0;
  font-variant-ligatures: none;
}
.editor pre { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--soft); }
.editor textarea {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  overflow: auto;
}
.editor textarea::selection { background: rgba(138, 129, 255, 0.32); color: transparent; }

/* syntax */
.hl .c { color: var(--dim); font-style: italic; }
.hl .k { color: var(--crown); }
.hl .f { color: var(--throat); }
.hl .m { color: var(--throat); font-style: italic; }
.hl .kw { color: #c9c3ef; }
.hl .n { color: var(--gold); }
.hl .o { color: var(--dim); }
.hl .q { color: var(--dim); }
.hl .s { color: #d9d4f7; }
.hl .lane { color: var(--lane, var(--text)); font-weight: 500; }
.hl .lane.muted { opacity: 0.45; text-decoration: line-through 1px; }
.hl .st { color: var(--lane, #e9e4ff); border-radius: 3px; transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease; }
.hl .st.r { color: rgba(167, 161, 200, 0.42); }
.hl .st.bar { color: var(--dim); }
.hl .st.lit {
  color: var(--ink);
  background: var(--lane, var(--throat));
  box-shadow: 0 0 14px 1px var(--lane, var(--throat));
  transition: none;
}
.hl .st.lit.mute { background: transparent; color: var(--lane); box-shadow: inset 0 -2px 0 var(--lane); }
.hl .bad { text-decoration: underline wavy rgba(255, 122, 147, 0.85) 1px; text-underline-offset: 4px; }
.hl .soft { text-decoration: underline dotted rgba(243, 207, 122, 0.7) 1.5px; text-underline-offset: 4px; }
.hl .stale { opacity: 0.55; }

.whisper {
  min-height: 46px;
  padding: 10px clamp(16px, 2.5vw, 30px) 14px;
  border-top: 1px solid var(--line);
  font: 400 12.5px/1.6 var(--mono);
  color: var(--soft);
}
.whisper .w { display: block; }
.whisper .w b { color: var(--gold); font-weight: 500; }
.whisper .w.bad b { color: var(--rose); }
.whisper .ok { color: var(--dim); }

/* ------------------------------------------------------------ circle */
.circle-wrap { position: relative; border-bottom: 1px solid var(--line); }
#circle { display: block; width: 100%; aspect-ratio: 1 / 1; max-height: 460px; cursor: crosshair; touch-action: manipulation; }
.circle-hint { padding: 2px 16px 14px; text-align: center; font: 400 11px/1 var(--sans); color: var(--dim); letter-spacing: 0.03em; pointer-events: none; }

/* ------------------------------------------------------------ console */
.console { padding: 6px 0 24px; }
.strip {
  display: grid;
  grid-template-columns: 112px auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(14px, 2vw, 22px);
  border-bottom: 1px solid var(--line);
  transition: background-color 0.3s ease;
}
.strip.hot { background: rgba(255, 255, 255, 0.025); }
.strip.off { opacity: 0.42; }
.strip.part-idle { opacity: 0.6; }
.strip .who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.strip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--lane); box-shadow: 0 0 0 0 var(--lane); flex: none; transition: box-shadow 0.25s ease; }
.strip .dot.pulse { box-shadow: 0 0 12px 3px var(--lane); transition: none; }
.strip .name { font: 500 13px/1.2 var(--mono); color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip .snd { display: block; font: 400 11px/1.2 var(--sans); color: var(--dim); }
.ms { display: flex; gap: 4px; }
.ms button {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-2); background: none;
  font: 600 11px/1 var(--mono); color: var(--soft); cursor: pointer; padding: 0;
}
.ms button[aria-pressed="true"].m { background: var(--rose); border-color: var(--rose); color: var(--ink); }
.ms button[aria-pressed="true"].s { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.knobs { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.knob { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 40px; cursor: ns-resize; user-select: none; touch-action: none; }
.knob svg { width: 32px; height: 32px; overflow: visible; }
.knob .trk { fill: none; stroke: var(--line-2); stroke-width: 2.5; stroke-linecap: round; }
.knob .val { fill: none; stroke: var(--lane); stroke-width: 2.5; stroke-linecap: round; }
.knob .cap { fill: var(--ink-3); }
.knob .ptr { stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; }
.knob label { font: 400 9.5px/1 var(--sans); color: var(--dim); letter-spacing: 0.04em; cursor: inherit; }
.knob.moving label { color: var(--text); }
.knob.mod .val { stroke-dasharray: 2 3; }
.knob:focus-visible { outline: 1px solid var(--vision); outline-offset: 2px; border-radius: 6px; }

.steps { grid-column: 1 / -1; display: flex; gap: 3px; flex-wrap: wrap; }
.steps button {
  flex: 1 1 0; min-width: 9px; max-width: 26px; height: 14px; border-radius: 3px; border: 0; padding: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
}
.steps button.on { background: var(--lane); opacity: 0.75; }
.steps button.note { background: var(--lane); opacity: 0.45; }
.steps button.bar { flex: 0 0 1px; min-width: 1px; background: var(--line-2); pointer-events: none; }
.steps button.lit { opacity: 1; box-shadow: 0 0 8px var(--lane); }

/* ------------------------------------------------------------ pages */
.page { max-width: 1060px; margin: 0 auto; padding: 40px clamp(16px, 4vw, 40px) 80px; }
.page h1 { font: 500 clamp(40px, 6vw, 64px)/1.02 var(--serif); margin: 0 0 14px; letter-spacing: -0.01em; }
.page h2 { font: 500 30px/1.15 var(--serif); margin: 48px 0 10px; }
.lede { font: 400 italic clamp(19px, 2.2vw, 23px)/1.5 var(--serif); color: var(--soft); max-width: 46em; margin: 0 0 36px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1px; padding: 1px; }
.grid > * { box-shadow: 0 0 0 1px var(--line); }
.card {
  background: var(--ink);
  padding: 22px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
  min-height: 210px;
  transition: background-color 0.2s ease;
}
.card:hover { background: var(--ink-2); color: var(--text); }
.card h3 { font: 500 26px/1.1 var(--serif); margin: 0; }
.card p { margin: 0; color: var(--soft); font-size: 14px; }
.card .glyph { width: 100%; height: 54px; }
.card .addr { margin-top: auto; font: 400 12px/1 var(--mono); color: var(--dim); }

.lessons { list-style: none; padding: 0; margin: 0; counter-reset: l; }
.lessons li { counter-increment: l; display: grid; grid-template-columns: 56px 1fr; gap: 0 18px; padding: 26px 0; border-top: 1px solid var(--line); }
.lessons li::before { content: counter(l, decimal-leading-zero); font: 400 italic 34px/1 var(--serif); color: var(--vision); }
.lessons h3 { font: 500 26px/1.1 var(--serif); margin: 0 0 6px; }
.lessons h3 a { color: var(--text); }
.lessons p { margin: 0 0 12px; color: var(--soft); max-width: 44em; }
.lessons pre { margin: 0 0 12px; padding: 14px 16px; background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px; font: 400 13px/1.6 var(--mono); color: #d9d4f7; overflow-x: auto; }
.open { font: 500 13px/1 var(--sans); }

.sounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.sound {
  background: var(--ink); border: 0; padding: 18px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-height: 120px;
}
.sound:hover, .sound.here { background: var(--ink-2); }
.sound b { font: 500 22px/1 var(--serif); color: var(--text); }
.sound span { font-size: 13px; color: var(--soft); }
.sound code { margin-top: auto; font-size: 11.5px; color: var(--dim); }
.sound.ping b { color: var(--throat); }
.group-label { grid-column: 1 / -1; background: var(--ink); padding: 18px 18px 6px; font: 500 11px/1 var(--sans); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }

.prose p, .prose li { max-width: 44em; color: #d7d2f2; }
.prose .readings { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1px; padding: 1px; margin: 20px 0 8px; }
.prose .readings div { background: var(--ink); padding: 14px 16px; box-shadow: 0 0 0 1px var(--line); }
.prose .readings b { display: block; font: 500 21px/1.1 var(--serif); }
.prose .readings span { font: 400 12px/1.3 var(--mono); color: var(--dim); }
.prose table { border-collapse: collapse; width: 100%; max-width: 640px; font: 400 13.5px/1.4 var(--mono); margin: 16px 0; }
.prose td, .prose th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { color: var(--dim); font-weight: 500; }
.prose td.score { color: var(--throat); text-align: right; }
.prose tr.pick td { color: var(--text); background: rgba(107, 184, 255, 0.07); }
.prose tr.ctl td { color: var(--dim); }
.prose blockquote { margin: 24px 0; padding: 0 0 0 20px; border-left: 2px solid var(--vision); font: italic 400 22px/1.45 var(--serif); color: var(--text); max-width: 34em; }

/* ------------------------------------------------------------ footer */
.foot {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; align-items: center;
  padding: 18px clamp(16px, 3vw, 36px) 26px;
  border-top: 1px solid var(--line);
  font: 400 12px/1.5 var(--sans);
  color: var(--dim);
}
.foot a { color: var(--soft); }
.build-stamp { color: var(--dim) !important; font: 400 11px/1 var(--mono) !important; }
.build-stamp-row { padding: 0 !important; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 999px; font: 500 13px/1 var(--sans);
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 10; pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ phone */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .left { border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .right { order: 1; }
  #circle { max-height: 360px; }
  .editor, .editor textarea { min-height: 360px; }
  :root { --code-size: 13.5px; }
}
@media (max-width: 560px) {
  .top { flex-direction: column; align-items: flex-start; gap: 10px; }
  .tabs a { padding: 6px 9px; }
  .transport { flex-wrap: wrap; gap: 12px; }
  .actions { width: 100%; }
  .spell-name { font-size: 25px; }
  .strip { grid-template-columns: 1fr auto; }
  .knobs { grid-column: 1 / -1; justify-content: space-between; }
  .lessons li { grid-template-columns: 1fr; }
  .lessons li::before { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .playing .go { animation: none; }
  .hl .st { transition: none; }
}

/* ------------------------------------------------------------ lessons inside the player */
.lesson-box { padding: 16px clamp(16px, 2.5vw, 30px) 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(107, 184, 255, 0.05), transparent); }
.lesson-box p { margin: 0 0 10px; font: 400 italic 19px/1.45 var(--serif); color: var(--text); max-width: 40em; }
.lesson-box nav { display: flex; justify-content: space-between; gap: 12px; font: 500 12.5px/1 var(--sans); }

.circle-hint .touch { display: none; }
@media (hover: none) { .circle-hint .mouse { display: none; } .circle-hint .touch { display: inline; } }
