/* Piamidiso — calm, trustworthy, low-shine. */

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #23201c;
  --ink-soft: #5d574d;
  --line: #e7e1d6;
  --accent: #3f5b73;
  --accent-soft: #eef2f6;
  --radius: 10px;
  --maxw: 860px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .wrap {
  padding-top: 26px;
  padding-bottom: 22px;
}
.brand {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.brand-mark { color: var(--accent); font-size: 26px; }
.tagline {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

/* Intro */
.intro {
  margin: 28px 0 8px;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink-soft);
}
.intro strong { color: var(--ink); }

/* Controls */
.controls { margin: 22px 0 8px; }
.search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.search-field { flex: 1 1 280px; }
#search {
  width: 100%;
  padding: 11px 14px;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
#search:focus, #sort:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
#sort {
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.tag-chip {
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
}
.tag-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.result-count {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

/* Catalog */
.catalog {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}
.card-main { flex: 1 1 320px; min-width: 0; }
.card-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  margin: 0;
}
.card-sub {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}
.card-tags {
  margin: 10px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card-tag {
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 9px;
}
.badge {
  font-size: 12px;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

.card-downloads {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex-basis: 100%;   /* always on its own row, below title/artist */
  margin-top: 6px;
}
.dl {
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 7px 13px;
  white-space: nowrap;
}
.dl:hover { background: var(--accent); color: #fff; }
.dl[aria-disabled="true"] {
  color: #b3ada2;
  border-color: var(--line);
  pointer-events: none;
}

/* Inline MIDI preview player */
.player-slot {
  flex-basis: 100%;
  width: 100%;
  margin-top: 4px;
}
.player-slot[hidden] { display: none; }
.preview-msg {
  margin: 4px 0 8px;
  font-size: 13px;
  color: var(--ink-soft);
}
.sp-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.sp-btn {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.sp-btn:hover { opacity: 0.92; }
.sp-seek {
  flex: 1 1 auto;
  min-width: 60px;
  accent-color: var(--accent);
  cursor: pointer;
}
.sp-time {
  flex: none;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 78px;
  text-align: right;
}
.sp-status {
  flex: none;
  font-size: 12px;
  color: var(--ink-soft);
}

.empty {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 0;
}

/* Footer */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-footer .wrap {
  padding-top: 20px;
  padding-bottom: 28px;
  font-size: 14px;
  color: var(--ink-soft);
}
.site-footer a { color: var(--accent); }
.site-footer .credit {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  opacity: 0.85;
}

.visually-hidden, .visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Submit page */
.prose { font-family: var(--serif); }
.prose h2 { font-size: 22px; margin-top: 30px; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
.prose pre {
  background: #2b2722;
  color: #f3efe7;
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 13px;
}
.prose pre code { background: none; color: inherit; padding: 0; }

/* Submission form */
.submit-form {
  font-family: var(--sans);
  margin-top: 24px;
  display: grid;
  gap: 16px;
  max-width: 560px;
}
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; color: var(--ink-soft); font-weight: 600; }
.field > span em { color: var(--accent); font-style: normal; }
.field input[type="text"],
.field input[type="file"],
.field select,
.field textarea {
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
}
.submit-btn {
  justify-self: start;
  font-size: 15px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
.submit-btn:hover { opacity: 0.92; }
.form-status { font-size: 14px; color: var(--ink-soft); min-height: 1.2em; }

/* Section headings shared by track page + popular strip */
.section-title {
  font-family: var(--serif);
  font-size: 20px;
  margin: 32px 0 12px;
}

/* Popular strip (homepage) */
.popular { margin-top: 20px; }
.popular[hidden] { display: none; }
.popular .section-title { margin-top: 20px; }
.popular-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (max-width: 560px) { .popular-list { grid-template-columns: 1fr; } }
.pop-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}
.pop-link:hover { border-color: var(--accent); }
.pop-rank {
  flex: none;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  width: 22px;
  text-align: center;
}
.pop-body { flex: 1 1 auto; min-width: 0; }
.pop-title {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pop-artist {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card → track-page links */
.card-link { color: inherit; text-decoration: none; }
.card-link:hover { color: var(--accent); text-decoration: underline; }
.card-versions { color: var(--accent); }
.dl-more { border-style: dashed; }

/* Track detail page */
.crumb { margin: 20px 0 0; font-size: 14px; }
.crumb a { color: var(--accent); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

.track-head { margin: 8px 0 4px; }
.track-title {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  margin: 6px 0 0;
}
.track-sub { margin: 4px 0 0; color: var(--ink-soft); font-size: 16px; }
.card-tags a.card-tag { text-decoration: none; }
.card-tags a.card-tag:hover { background: var(--accent); color: #fff; }

.ver-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 12px; }
.ver {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.ver-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 12px;
}
.ver-title { font-family: var(--serif); font-size: 18px; margin: 0; flex: 1 1 auto; }
.ver-meta { display: flex; align-items: center; gap: 8px; }
.ver-arr { font-size: 13px; color: var(--ink-soft); }
.ver-notes { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); }
.ver-downloads {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ver .player-slot { margin-top: 10px; }
.ver-single .ver-downloads { margin-top: 0; }
.ver-single .ver-notes:first-child { margin-top: 0; }

/* Related grids ("More from artist" / "More like this") */
.related { margin-top: 8px; }
.rel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 640px) { .rel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px) { .rel-grid { grid-template-columns: 1fr; } }
.rel-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}
.rel-card:hover { border-color: var(--accent); }
.rel-title { font-family: var(--serif); font-weight: 700; }
.rel-sub { margin: 0; font-size: 13px; color: var(--ink-soft); }
.rel-foot {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rel-versions { font-size: 12px; color: var(--accent); }
