:root {
  --bg: #0e0e10;
  --surface: #18181c;
  --surface-2: #232329;
  --border: #2e2e36;
  --text: #ececf1;
  --muted: #9a9aa6;
  --accent: #fa5c00; /* Devious Machines brand orange */
  --accent-text: #ffffff;
  --danger: #ff4d6a;
  --wave-played: var(--accent);
  --wave-rest: #4a4a55;
  --radius: 10px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Elements given a display value in this file would otherwise ignore the
   hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--text); text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { color: var(--accent); }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

main {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
  flex: 1;
}

.narrow { max-width: 640px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.danger { color: var(--danger); }
.grow { flex: 1; min-width: 0; }
.inline { display: inline; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > h2, .stack > h3, .stack > p { margin: 0; }
.stack > .button, .stack > button { align-self: flex-start; }

/* Header and footer */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px var(--gutter);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; height: 22px; width: auto; }
.brand span {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.site-header nav { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.site-header nav a { text-decoration: none; color: var(--muted); }
.site-header nav a:hover { color: var(--text); }
.site-header nav button.link { text-decoration: none; }
.site-header nav button.link:hover { color: var(--text); }
.site-footer { padding: 24px var(--gutter); text-align: center; color: var(--muted); font-size: 0.875rem; }
.site-footer a { color: var(--muted); }

/* Buttons and forms */
.button, button {
  font: inherit;
  cursor: pointer;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.button:hover { border-color: var(--muted); color: var(--text); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.primary:hover { filter: brightness(1.1); }
.button.danger { color: var(--danger); }
.button.small { padding: 5px 10px; font-size: 0.875rem; }
.button.wide { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
.button:disabled { opacity: 0.5; cursor: default; }
button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.link:hover { color: var(--accent); }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
label .muted { font-weight: 400; }
fieldset { border: none; padding: 0; margin: 0; }
legend { font-weight: 600; margin-bottom: 8px; }

input[type="text"], input[type="email"], textarea, select {
  font: inherit;
  font-weight: 400;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="file"] { font: inherit; font-weight: 400; color: var(--muted); }

.notice {
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
}
.error { color: var(--danger); font-weight: 600; }
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
}
.badge.muted { background: var(--surface-2); color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

/* Home */
.hero { max-width: 680px; margin: 32px auto; }
.hero h1 { font-size: 2.4rem; letter-spacing: -0.02em; }
.lede { font-size: 1.15rem; color: var(--muted); }
.features { padding-left: 1.2em; color: var(--muted); }
.features strong { color: var(--text); }

/* Track lists with players */
.track-rows { list-style: none; padding: 0; margin: 0; }
.track-row { display: flex; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); }
.track-row-art img { display: block; width: 120px; height: 120px; border-radius: 8px; object-fit: cover; }
.track-row-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.track-row-title { display: flex; flex-direction: column; min-width: 0; }
.track-row-title a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.track-row-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.track-row-stats { margin-left: auto; }
@media (max-width: 560px) {
  .track-row-art img { width: 64px; height: 64px; }
  .track-row { gap: 12px; }
}

.tag {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.icon-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0;
}
.icon-button:hover { border-color: var(--muted); color: var(--text); }
.icon-button svg, .button svg { width: 16px; height: 16px; flex-shrink: 0; }
.copy-feedback {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.button { position: relative; }

/* Track page share panel */
.track-facts { display: flex; gap: 10px; align-items: center; margin: 8px 0 0; }
.track-actions { display: flex; gap: 8px; margin: 4px 0 12px; align-items: stretch; }
.track-actions .icon-button { width: auto; height: auto; aspect-ratio: 1; }
.share-panel { display: flex; flex-direction: column; gap: 14px; }
.share-panel label { font-weight: 600; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; }
.native-share { align-self: flex-start; }

/* Track page */
.track-head { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.track-head .artwork { width: 200px; height: 200px; border-radius: var(--radius); object-fit: cover; }
.track-head h1 { font-size: 2.2rem; margin-bottom: 4px; overflow-wrap: anywhere; }
.byline { font-size: 1.1rem; margin: 0; }
.owner-bar { color: var(--muted); margin-top: 10px; }
.description { white-space: pre-wrap; color: var(--muted); margin: 20px 0; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .track-head .artwork { width: 100%; height: auto; aspect-ratio: 1; }
  .track-head h1 { font-size: 1.7rem; }
}

/* Player */
.player {
  display: grid;
  /* minmax(0, ...) lets the column shrink below the canvas's pixel width. */
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "play wave";
  column-gap: 14px;
  align-items: center;
  margin: 16px 0;
}
.player .play {
  grid-area: play;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
}
.player .play svg { width: 24px; height: 24px; fill: currentColor; }
.player .icon-pause, .player.playing .icon-play { display: none; }
.player.playing .icon-pause { display: block; }
.wave-wrap { grid-area: wave; position: relative; min-width: 0; }
.wave { display: block; width: 100%; height: 72px; cursor: pointer; touch-action: none; }
/* Timed comment avatars sit in a strip under the waveform. */
.markers { position: relative; height: 24px; margin-top: 4px; }
.marker {
  position: absolute;
  top: 2px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  font-size: 0.55rem;
  border: 2px solid var(--bg);
  padding: 0;
  cursor: pointer;
  transition: transform 0.1s;
}
.marker:hover, .marker:focus-visible { transform: scale(1.25); z-index: 2; }
.marker-tip {
  position: absolute;
  bottom: 30px;
  max-width: min(320px, 100%);
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.4);
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  pointer-events: none;
  z-index: 3;
}
.marker-tip strong { margin-right: 4px; }
/* Position and length sit on the waveform's left and right ends. */
.wave-time {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 1px 5px;
  border-radius: 4px;
  background: rgb(14 14 16 / 0.85);
  color: var(--text);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.wave-time.position { left: 0; color: var(--accent); }
.wave-time.total { right: 0; color: var(--muted); }
.markers:empty { display: none; }

/* Compact players in track lists */
.player.compact { margin: 8px 0 0; column-gap: 10px; }
.player.compact .play { width: 40px; height: 40px; }
.player.compact .play svg { width: 18px; height: 18px; }
.player.compact .wave { height: 48px; }

/* Avatars: initials on a colour picked from the name (getAvatarClass). */
.avatar {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}
.hue-0 { background: #c2410c; }
.hue-1 { background: #a16207; }
.hue-2 { background: #4d7c0f; }
.hue-3 { background: #047857; }
.hue-4 { background: #0e7490; }
.hue-5 { background: #1d4ed8; }
.hue-6 { background: #7e22ce; }
.hue-7 { background: #be185d; }

/* A time in the track, e.g. "1:32". */
.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: none;
  background: rgb(250 92 0 / 0.16);
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.time-chip:hover { background: rgb(250 92 0 / 0.28); }

/* Comment composer under the player. */
.composer { margin: 8px 0 24px; }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.composer-input:focus-within { border-color: var(--accent); }
.composer-input input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  padding: 10px 0;
  outline: none;
}
.composer-input input:focus { outline: none; }
.composer-row .button { border-radius: 999px; }
.composer-details { margin: 10px 0 0 42px; display: flex; flex-direction: column; gap: 8px; }
.composer-details p { margin: 0; }
.composer-fields { display: flex; gap: 8px; flex-wrap: wrap; }
.composer-fields input { flex: 1 1 180px; width: auto; }
.composer-status { margin: 8px 0 0 42px; color: var(--muted); }
.composer-status:empty { display: none; }
.composer-status.error { color: var(--danger); }
@media (max-width: 480px) {
  .composer-avatar { display: none; }
  .composer-details, .composer-status { margin-left: 0; }
}

/* Comment list */
.comments { margin-top: 36px; }
.comments h2 .muted { font-weight: 400; }
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.comment {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.comment-list p, .inbox p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-link { margin-left: auto; opacity: 0; transition: opacity 0.15s; }
.comment:hover .report-link, .report-link:focus { opacity: 1; }
@media (hover: none) {
  .report-link { opacity: 1; }
}

/* Inbox */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  text-transform: capitalize;
  color: var(--muted);
}
.tabs a.active { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.inbox { list-style: none; padding: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Edit page */
.versions { width: 100%; border-collapse: collapse; }
.versions td { padding: 10px 8px 10px 0; border-top: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.versions td:first-child { font-weight: 700; color: var(--muted); width: 3em; }
.version-status { text-align: right; white-space: nowrap; }

.links { display: flex; gap: 14px; flex-wrap: wrap; overflow-wrap: anywhere; }
.account-pick { margin-bottom: 10px; }

/* Embed player: fills a 166px-high iframe. */
body.embed { min-height: 0; background: var(--surface); }
.embed-card { display: flex; gap: 14px; padding: 12px; height: 166px; overflow: hidden; }
.embed-card .artwork { width: 142px; height: 142px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.embed-title { display: flex; flex-direction: column; line-height: 1.3; }
.embed-title a { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embed .player { margin: 8px 0 0; }
.embed .player .play { width: 44px; height: 44px; }
.embed .wave { height: 44px; }
.embed .player .time { margin-top: 2px; }
.embed-footer a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.embed-footer img { height: 11px; width: auto; opacity: 0.8; }
@media (max-width: 420px) {
  .embed-card .artwork { display: none; }
}

/* Profile management */
.profile-list { list-style: none; padding: 0; margin: 16px 0 0; }
.profile-list li { display: flex; align-items: center; gap: 10px; }
.profile-list a { text-decoration: none; }

/* Playlists */
.kicker { margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.section-heading { margin-top: 28px; }
.playlist-grid {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
}
.playlist-grid a { text-decoration: none; display: flex; flex-direction: column; gap: 8px; }
.playlist-grid img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); }
ol.track-rows { counter-reset: none; }
.playlist-order { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.order-number { width: 1.5em; text-align: right; font-variant-numeric: tabular-nums; }
.playlist-order li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.playlist-order .actions { margin: 0; }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.thumb { border-radius: 6px; flex-shrink: 0; object-fit: cover; }
