:root {
  --bg: #0b0b0f;
  --panel: #131319;
  --card: #18181f;
  --line: #262630;
  --text: #ecebf0;
  --muted: #8d8b99;
  --ember: #ff6a2b;
  --gold: #ffc35a;
  --melt: linear-gradient(135deg, #ffd36b 0%, #ff8a3d 45%, #ff4d1f 100%);
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Elements styled with a display of their own still hide. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100dvh; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

/* Header */

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121218, #0d0d12);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.wordmark:hover { text-decoration: none; }
.wordmark b {
  background: var(--melt);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.crucible { width: 28px; height: 28px; filter: drop-shadow(0 0 8px rgba(255, 106, 43, 0.45)); }

.tagline { margin: 0; flex: 1; color: var(--text); font-size: 14px; }

.links { display: flex; gap: 6px; }
.links a {
  color: var(--text);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}
.links a:hover { border-color: var(--ember); text-decoration: none; }

/* Layout */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 85%, #2a1710 0%, #0e0d12 55%, #08080b 100%);
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#canvas:active { cursor: grabbing; }

/* Drop zone */

.drop {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  transition: background 0.15s;
}
.drop.loaded { pointer-events: none; opacity: 0; }
.drop.dragging, .stage.dragging .drop {
  opacity: 1;
  background: rgba(255, 106, 43, 0.08);
}
.stage.dragging .drop-card { border-color: var(--ember); box-shadow: 0 0 0 4px rgba(255, 106, 43, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5); }

.drop-card {
  max-width: 440px;
  text-align: center;
  padding: 32px 28px 24px;
  border: 1.5px dashed #3a3a46;
  border-radius: 20px;
  background: rgba(16, 16, 22, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
.drop-icon { width: 44px; height: 44px; color: var(--ember); }
.drop-card h1 { margin: 10px 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.drop-card p { margin: 0 0 16px; color: var(--muted); }
.drop-card .private { margin: 14px 0 0; font-size: 12.5px; }
.pick { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1f1f28;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover { border-color: #4a4a58; background: #262630; }
.button.primary {
  border-color: transparent;
  background: var(--melt);
  color: #1a0d05;
  box-shadow: 0 4px 18px rgba(255, 106, 43, 0.25);
}
.button.primary:hover { filter: brightness(1.08); }
.button:disabled { opacity: 0.5; cursor: default; }

.icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(20, 20, 27, 0.85);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.icon svg { width: 18px; height: 18px; }
.icon:hover { border-color: #4a4a58; }
.icon.toggle.on { color: var(--gold); border-color: rgba(255, 195, 90, 0.4); }

/* Overlays on the stage */

.toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.busy {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 12px;
  background: rgba(16, 16, 22, 0.9);
  border: 1px solid var(--line);
  font-weight: 600;
}
.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 106, 43, 0.25);
  border-top-color: var(--ember);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: #2a1414;
  border: 1px solid #6b2a22;
  color: #ffd9d2;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  white-space: pre-wrap;
}

.hint {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(16, 16, 22, 0.75);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.6s;
}
.hint.fade { opacity: 0; }

.player {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border-radius: 14px;
  background: rgba(16, 16, 22, 0.88);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.player select {
  max-width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1f1f28;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.player input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--ember); }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 56px; text-align: right; }

/* Side panel */

.panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.card h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.sample-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sample {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1d1d25;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sample:hover { border-color: var(--ember); background: #23202a; }
.sample b { font-size: 13.5px; }
.sample span { font-size: 11.5px; color: var(--muted); }
.sample .ext { font-family: ui-monospace, "SF Mono", Consolas, monospace; color: var(--gold); }

.info-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.info-head h2 {
  margin: 0;
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  word-break: break-all;
}
.format { margin: 2px 0 0; color: var(--gold); font-size: 13px; }

dl { margin: 10px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13.5px; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
.stats { padding-top: 10px; border-top: 1px solid var(--line); }

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}
.tag.declared { background: rgba(110, 200, 140, 0.15); color: #8fe0a8; }
.tag.assumed { background: rgba(255, 195, 90, 0.13); color: var(--gold); }
.legend { margin: 12px 0 0; font-size: 12px; color: var(--muted); }
.legend .tag { margin: 0 2px 0 0; }

.formats summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.formats p { font-size: 12.5px; margin: 10px 0 0; line-height: 1.7; }
#format-list code {
  display: inline-block;
  margin: 0 3px 3px 0;
  padding: 0 6px;
  border-radius: 6px;
  background: #22222b;
  font: 12px ui-monospace, "SF Mono", Consolas, monospace;
  color: #d8d6e0;
}
#format-list code.no { color: var(--muted); text-decoration: line-through; }

.footer { margin: 0; padding: 0 4px 6px; font-size: 12px; color: var(--muted); }

/* Phones: the view on top, the panel below it. */

@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px; }
  .tagline { order: 3; flex-basis: 100%; font-size: 13px; }
  .tagline .muted { display: none; }
  .links a { padding: 4px 10px; font-size: 12px; }
  .layout { display: flex; flex-direction: column; }
  .stage { flex: none; height: 62dvh; min-height: 340px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .drop-card { padding: 22px 18px 18px; }
  .drop-card h1 { font-size: 19px; }
  .player { gap: 6px; padding: 6px 8px 6px 6px; bottom: 10px; }
  .player select#speed { display: none; }
  .player select { max-width: 110px; }
  .hint { display: none; }
}
