/* SoundClips - hand-rolled, no external deps */

:root {
  --bg:        #0f1115;
  --bg-soft:   #161a21;
  --bg-card:   #1a1f28;
  --border:    #262d39;
  --border-hi: #384354;
  --text:      #e6e9ef;
  --text-dim:  #9aa4b5;
  --text-mute: #6b7688;
  --accent:    #5b9dff;
  --accent-hi: #7db0ff;
  --accent-dim:#1e3a63;
  --good:      #4ade80;
  --bad:       #f87171;
  --warn:      #fbbf24;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.22);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f7f8fa;
    --bg-soft:   #ffffff;
    --bg-card:   #ffffff;
    --border:    #e2e6ec;
    --border-hi: #cbd3de;
    --text:      #161a21;
    --text-dim:  #576073;
    --text-mute: #838d9e;
    --accent:    #2563eb;
    --accent-hi: #1d4ed8;
    --accent-dim:#dbe7ff;
    --shadow:    0 1px 2px rgba(16,24,40,.05), 0 6px 16px rgba(16,24,40,.06);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.grow { flex: 1; }
.dot  { color: var(--text-mute); }

/* ---------- header ---------- */

.site-head {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.head-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 16.5px;
  letter-spacing: -.01em;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark { display: flex; color: var(--accent); }

.head-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14px;
}
.head-nav a { color: var(--text-dim); }
.head-nav a:hover { color: var(--text); text-decoration: none; }
.head-nav a.btn { color: #fff; }

/* ---------- buttons / forms ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  transition: background .13s ease;
}
.btn:hover { background: var(--accent-hi); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 13px; font-size: 13.5px; }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-hi);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text); }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #ef4444; }

label { display: block; font-size: 13.5px; font-weight: 550; margin-bottom: 6px; color: var(--text-dim); }
.field { margin-bottom: 18px; }
.hint  { font-size: 12.5px; color: var(--text-mute); margin-top: 6px; }

input[type=text], input[type=password], input[type=search], input[type=file], textarea, select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
textarea { min-height: 90px; resize: vertical; }
input[type=file] { padding: 22px 12px; border-style: dashed; cursor: pointer; }

/* ---------- flashes ---------- */

.flash {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 11px 14px;
  margin: 20px 0 0;
  font-size: 14px;
  background: var(--bg-card);
}
.flash-ok    { border-left-color: var(--good); }
.flash-error { border-left-color: var(--bad); }
.flash-warn  { border-left-color: var(--warn); }

/* ---------- page furniture ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin: 22px 0 14px;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.02em;
}
.page-head .sub { color: var(--text-mute); font-size: 13.5px; margin: 3px 0 0; }

.toolbar {
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar form { display: flex; gap: 10px; flex: 1; min-width: 260px; }
.toolbar select { width: auto; }

/* ---------- clip list ---------- */

.clip-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  transition: background .12s ease;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-soft); }

.row-main { flex: 1; min-width: 0; }

.row-title {
  margin: 0 0 1px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.row-title a:first-child {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-title a:first-child:hover { color: var(--accent); text-decoration: none; }

.row-embedded {
  font-size: 12px;
  color: var(--accent);
  line-height: 1.3;
  margin: 1px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: .85;
}
.row-identified {
  font-size: 12.5px;
  color: var(--good);
  font-weight: 550;
  line-height: 1.3;
  margin: 1px 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-identified .maybe { color: var(--text-mute); font-weight: 400; }
.identified-title {
  font-size: 16px;
  color: var(--good);
  font-weight: 600;
  margin: 8px 0 0;
}
.identified-title .conf { color: var(--text-mute); font-size: 12.5px; font-weight: 400; }
.embedded-title {
  font-size: 15px;
  color: var(--accent);
  margin: 6px 0 0;
  font-style: italic;
}

.row-meta {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-mute);
  overflow: hidden;
  white-space: nowrap;
}
.row-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}
.tag-sm { font-size: 11px; padding: 0 6px; line-height: 1.5; }

.row audio.player {
  width: 230px;
  flex-shrink: 0;
  height: 30px;
  margin: 0;
}

/* The native player is the tallest thing in a row; trimming it is what
   actually sets the row height. */
.row audio.player::-webkit-media-controls-panel { padding: 0 4px; }

/* ---------- WASM-backed player (MIDI, modules, chiptunes) ---------- */

.wplayer {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  width: 230px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.wplayer.player-detail { width: 100%; height: 40px; margin: 18px 0; }

.wp-play {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 0;
}
.wp-play:hover { background: var(--accent-hi); }
.wp-play svg { margin-left: 1px; }
/* Icon swap is driven by the .is-playing class, NOT the [hidden] attribute:
   these are SVG elements, and el.hidden (an HTMLElement-only property) is a
   no-op on them, so the attribute never toggles. Class selectors used
   throughout so specificity beats the `.wp-play svg` rule above. */
.wp-play .wp-icon-play  { display: block; }
.wp-play .wp-icon-pause { display: none; }
.wplayer.is-playing .wp-play .wp-icon-play  { display: none; }
.wplayer.is-playing .wp-play .wp-icon-pause { display: block; margin-left: 0; }

.wp-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border-hi);
  overflow: hidden;
}
.wp-fill { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.wp-time {
  flex-shrink: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
  min-width: 34px;
  text-align: right;
}
.wplayer.player-detail .wp-time { font-size: 13px; min-width: 90px; }

.wplayer.is-loading .wp-play { opacity: .55; cursor: progress; }
.wplayer.is-loading .wp-fill {
  width: 100% !important;
  background: repeating-linear-gradient(90deg, var(--accent-dim) 0 8px, transparent 8px 16px);
}
.wplayer.is-error { border-color: var(--bad); }
.wplayer.is-error .wp-time { color: var(--bad); }

.pill {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* type filter chips */

.type-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color .13s ease, color .13s ease;
}
.type-chip:hover { border-color: var(--border-hi); color: var(--text); text-decoration: none; }
.type-chip .n {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
}
.type-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.type-chip.is-on .n { color: rgba(255,255,255,.75); }
.type-chip.is-on:hover { color: #fff; }

a.pill:hover { text-decoration: none; filter: brightness(1.15); }

audio.player {
  width: 100%;
  height: 36px;
  margin: 10px 0 12px;
  display: block;
}

.dl {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 550;
}
.dl:hover { text-decoration: none; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- star ratings ---------- */

.stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.star {
  background: none;
  border: none;
  padding: 1px;
  cursor: pointer;
  color: var(--border-hi);
  display: flex;
  line-height: 0;
  transition: color .1s ease, transform .1s ease;
}
.star.on { color: #f5a623; }
.star.preview { color: #f7c260; transform: scale(1.15); }
.stars.is-busy { opacity: .5; pointer-events: none; }
.star-count {
  font-size: 11px;
  color: var(--text-mute);
  margin-left: 5px;
  font-variant-numeric: tabular-nums;
  min-width: 30px;
}
.stars-lg { gap: 2px; }
.stars-lg .star-count { font-size: 13px; margin-left: 9px; }

.pill-coll {
  background: var(--bg-soft);
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- collections ---------- */

.coll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.coll-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  transition: border-color .13s ease;
}
.coll-card:hover { border-color: var(--accent); text-decoration: none; color: var(--text); }
.coll-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.coll-desc { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.coll-meta { margin: 0; font-size: 12.5px; color: var(--text-mute); }

/* ---------- single clip ---------- */

.clip-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.detail-head { display: flex; align-items: flex-start; gap: 12px; }
.detail-head h1 { flex: 1; min-width: 0; word-break: break-word; }
.clip-detail h1 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.02em; }
.clip-detail audio { height: 44px; margin: 20px 0; }
.clip-detail .desc { color: var(--text-dim); white-space: pre-wrap; margin: 0 0 4px; }

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 20px;
}
.spec { background: var(--bg-card); padding: 12px 14px; }
.spec dt { font-size: 11.5px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; margin: 0 0 3px; }
.spec dd { margin: 0; font-size: 14px; font-weight: 550; font-variant-numeric: tabular-nums; }

/* ---------- table (admin) ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); font-weight: 600; background: var(--bg-soft); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-soft); }
td.wrap-cell { white-space: normal; max-width: 320px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions button {
  font-size: 13px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  font-family: inherit;
}
.row-actions .danger { color: var(--bad); }

/* admin dashboard inline player */
.admin-player { margin-top: 8px; }
.admin-player audio.player { width: 260px; height: 32px; margin: 0; display: block; }
.admin-player .wplayer { margin: 0; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-mute); }
.stat .v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- misc ---------- */

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
  border: 1px dashed var(--border-hi);
  border-radius: var(--radius);
}
.empty h3 { color: var(--text-dim); margin: 0 0 6px; font-weight: 600; }

.pager {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin: 16px 0 28px;
}
.pager a, .pager > span:not(.pager-note):not(.gap) {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  background: var(--bg-card);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .gap { color: var(--text-mute); padding: 0 2px; }
.pager-note {
  flex-basis: 100%;
  text-align: center;
  color: var(--text-mute);
  font-size: 12px;
  margin-top: 6px;
}

.auth-box {
  max-width: 380px;
  margin: 70px auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
}
.auth-box h1 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.02em; }
.auth-box .sub { color: var(--text-mute); font-size: 14px; margin: 0 0 22px; }

.site-foot {
  margin-top: 60px;
  padding: 22px 0;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 13px;
}
.site-foot .wrap { display: flex; gap: 8px; }

.upload-list { margin-top: 16px; font-size: 13.5px; }
.upload-list li { margin-bottom: 4px; color: var(--text-dim); }

@media (max-width: 760px) {
  /* Stack the row: title block, then player full width, download inline. */
  .row {
    flex-wrap: wrap;
    gap: 9px;
    padding: 13px 14px;
  }
  .row-main { flex: 1 1 100%; }
  .row audio.player { width: 100%; flex: 1 1 auto; }
  .row-desc { max-width: 100%; }
  .dl-text { display: none; }
}

@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .head-nav { gap: 14px; font-size: 13.5px; }
  .brand span:last-child { display: none; }
}
