:root {
  --bg: #1b1712;
  --panel: #262019;
  --text: #eee4d3;
  --muted: #a8998a;
  --accent: #c9a227;
  --danger: #a33b2b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }

h1 { font-size: 1.3rem; margin: 0; }
h2 { margin: 0 0 .5rem; font-size: 1.1rem; }

button, .button-like {
  font: inherit;
  background: #3a3027;
  color: var(--text);
  border: 1px solid #4d4034;
  border-radius: 8px;
  padding: .45rem .8rem;
  cursor: pointer;
  user-select: none;
}
button:hover, .button-like:hover { border-color: var(--accent); }
button.danger { background: var(--danger); border-color: #c4503e; }
button.ghost { background: transparent; }
button.active { background: var(--accent); color: #1b1712; }

input, select {
  font: inherit;
  background: #14110d;
  color: var(--text);
  border: 1px solid #4d4034;
  border-radius: 6px;
  padding: .4rem .5rem;
  width: 100%;
}
input[type=checkbox] { width: auto; }
input[type=range] { padding: 0; accent-color: var(--accent); }
input[type=color] { height: 2.2rem; padding: .1rem; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: var(--radius);
  width: min(360px, 100%);
  display: grid;
  gap: .75rem;
}
.error { color: #ff8a75; min-height: 1.2em; margin: 0; }

.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .75rem 16px;
  background: rgba(27, 23, 18, .95);
  border-bottom: 1px solid #3a3027;
}
.toolbar h1 { margin-right: auto; }
.master { display: flex; align-items: center; gap: .3rem; }
.master input { width: 110px; }

.status, .hint { margin: .75rem 16px 0; color: var(--muted); }
.status { color: var(--accent); }

.panels {
  display: grid;
  gap: 1rem;
  padding: 1rem 16px 3rem;
}
@media (min-width: 900px) {
  .panels { grid-template-columns: 1fr 1fr; align-items: start; }
}
.panel {
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: .9rem;
  min-width: 0;
}
.panel.drop-target { border-color: var(--accent); border-style: dashed; }
.panel-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0 auto 0 0; font-size: 1.1rem; }
.panel .empty { margin: .75rem 0 0; }
#fade-music.active, #random-mode.active { background: var(--accent); color: #1b1712; }

.random-bar {
  margin-top: .75rem;
  padding: .6rem .75rem;
  background: #1f1a14;
  border-radius: 8px;
}
.random-bar .hint { margin: 0 0 .5rem; }
.random-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.random-controls label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.random-controls input { width: 4.2rem; }
#random-status { color: var(--accent); font-variant-numeric: tabular-nums; }
.sound.random { outline: 2px dotted var(--accent); outline-offset: -6px; }
body.random-pick #sfx-board .sound { cursor: copy; }

.group h3 {
  margin: 1rem 0 .5rem;
  color: var(--muted);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .6rem;
}

.sound {
  --p: 0;
  position: relative;
  overflow: hidden;
  min-height: 84px;
  padding: .6rem;
  text-align: left;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--c, #5b4636);
  border: 2px solid transparent;
  border-radius: var(--radius);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
  transition: transform .05s, border-color .15s;
}
.sound:active { transform: scale(.97); }
.sound .name { font-weight: 600; word-break: break-word; }
.sound .meta { display: flex; justify-content: space-between; font-size: .8rem; opacity: .85; }
.sound .key {
  background: rgba(0, 0, 0, .35);
  border-radius: 4px;
  padding: 0 .35rem;
  font-family: ui-monospace, monospace;
}
/* progress bar along the bottom */
.sound::after {
  content: "";
  position: absolute; left: 0; bottom: 0;
  height: 4px;
  width: calc(var(--p) * 100%);
  background: rgba(255, 255, 255, .8);
}
.sound.playing { border-color: #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .35); }
.sound.loading { opacity: .6; }
body.editing .sound { outline: 2px dashed rgba(255, 255, 255, .4); outline-offset: -6px; }


dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #4d4034;
  border-radius: var(--radius);
  width: min(420px, calc(100vw - 32px));
  padding: 1.25rem;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
#edit-form { display: grid; gap: .6rem; }
#edit-form label { display: grid; gap: .2rem; color: var(--muted); font-size: .9rem; }
#edit-form label.row { display: flex; align-items: center; gap: .5rem; }
.dialog-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.spacer { flex: 1; }

.panel-body { margin-top: .75rem; }
.panel-body .group:first-child h3 { margin-top: 0; }
