
:root {
  --cream: #fff8f3; --paper: #ffffff; --ink: #171310; --ink-2: #4a403a; --ink-3: #8a7d75;
  --line: #f0e3d9; --line-strong: #e3cfc1;
  --brand: #d25f31; --brand-deep: #cb480c; --flame: #ff853f; --amber: #ffd236; --amber-soft: #fef3c6; --red: #bf000f;
  --display: "Bricolage Grotesque", "Inter", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px; --radius-lg: 20px; --topbar: 60px;
}
* { box-sizing: border-box; }
html { margin: 0; min-height: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
body { font-family: var(--sans); font-size: 15px; background: var(--cream); color: var(--ink); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, .score, .brand span, .playbar .title { font-family: var(--display); letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar { height: var(--topbar); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; border-radius: 8px; }
.brand span { font-weight: 600; font-size: 17px; }
.nav { display: flex; align-items: center; gap: 14px; }
.inline { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
.user { color: #cfc4bb; font-size: 14px; max-width: 32vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .link { color: #fff; }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; }
.foot { margin-top: auto; padding: 20px; text-align: center; color: var(--ink-3); font-size: 12px; }

.button { display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); text-decoration: none; font: inherit; font-weight: 500; cursor: pointer; }
.button:hover { border-color: var(--brand); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.button.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.button.play { padding: 6px 14px; font-size: 14px; }
.link { background: none; border: none; padding: 0; font: inherit; color: var(--brand-deep); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--red); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.card.center { max-width: 440px; margin: 56px auto; text-align: center; padding: 36px 28px; }
.card.center h1 { font-size: 28px; margin: 12px 0 8px; }
.card.center p { color: var(--ink-2); margin: 0 0 20px; }
.card.narrow { max-width: 720px; margin: 0 auto; }
.hero-mark { display: block; margin: 0 auto; }
.lead { color: var(--ink-2); margin-top: -4px; }
.error { color: var(--red); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 22px; }
.search { position: relative; flex: 1 1 320px; display: block; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; padding: 11px 16px 11px 42px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); font: inherit; font-size: 15px; color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--amber-soft); }
.sort { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line-strong); }
.sort a { padding: 7px 14px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.sort a.active { background: var(--ink); color: #fff; }
.empty { color: var(--ink-3); text-align: center; padding: 56px 0; margin: 0; }

.day { margin-bottom: 28px; }
.day[hidden] { display: none; }
.day-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 10px; margin-bottom: 12px; border-bottom: 1px solid var(--line-strong); }
.weekday { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.date { font-family: var(--display); font-size: 18px; font-weight: 700; line-height: 1.2; }
.count { margin-left: auto; font-size: 13px; color: var(--ink-2); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 8px 8px 7px; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; transition: border-color 120ms ease; }
.tile:hover { border-color: var(--line-strong); }
.tile[hidden] { display: none; }
.tile-icon { display: block; }
.tile-icon img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 12px; background: var(--cream); }
.tile-head { display: flex; align-items: center; gap: 6px; padding: 2px 2px 0; }
.tile-name { flex: 1; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-name a { text-decoration: none; }
.tile-name a:hover { color: var(--brand-deep); }
.tile-play { flex: none; width: 24px; height: 24px; border-radius: 999px; background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.tile-play:hover { background: var(--brand-deep); }
.tile-play svg { margin-left: 1px; }
.tile-by { margin: 0; padding: 0 2px; font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.tile-author { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version { font-family: var(--sans); flex: none; color: var(--ink-3); font-size: 11px; font-weight: 500; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; }

.votes { display: inline-flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); }
.vote { width: 34px; height: 34px; border-radius: 999px; border: none; background: transparent; color: var(--ink-2); font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.vote:hover { background: var(--paper); color: var(--ink); }
.vote.active { background: var(--brand); color: #fff; }
.score { font-size: 20px; font-weight: 700; min-width: 34px; padding: 2px 0; text-align: center; font-variant-numeric: tabular-nums; }
.votes.compact { flex-direction: row; padding: 2px; gap: 0; }
.votes.compact .vote { width: 26px; height: 24px; font-size: 12px; }
.votes.compact .score { font-size: 14px; min-width: 20px; padding: 0 3px; }
.tile-delete { width: 26px; height: 26px; border: none; border-radius: 999px; background: transparent; color: var(--ink-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tile-delete:hover { background: var(--cream); color: var(--red); }

#upload-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 16px 0 24px; }
#upload-form input[type="file"] { flex: 1 1 260px; }
#upload-progress { width: 100%; height: 8px; accent-color: var(--brand); }
.status { width: 100%; margin: 0; min-height: 1.5em; }
.status.ok { color: #1f7a3a; }
.status.error { color: var(--red); }
.card h2 { font-size: 18px; margin: 20px 0 8px; }
.hints { padding-left: 20px; margin: 0; font-size: 14px; color: var(--ink-2); }
.hints li { margin-bottom: 6px; }
code { background: var(--cream); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; color: var(--ink); }

.role-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 20px; }
.role-form input, .role-form select { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--paper); font: inherit; color: var(--ink); }
.role-form input { flex: 1 1 240px; }
.role-form input:focus, .role-form select:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--amber-soft); }
.table-wrap { overflow-x: auto; }
.roles { width: 100%; border-collapse: collapse; font-size: 14px; }
.roles th { text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.roles td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.roles td:first-child { overflow-wrap: anywhere; }
.role-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.role-badge.admin { background: var(--ink); color: #fff; }
.role-badge.developer { background: var(--amber-soft); color: var(--brand-deep); }
.muted { color: var(--ink-3); font-size: 12px; }

body.bare { overflow: hidden; }
.playview { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--ink); }
.playbar { height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--ink); color: #fff; }
.playbar .back { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 500; color: #cfc4bb; }
.playbar .back:hover { color: #fff; }
.playbar .back img { border-radius: 7px; }
.playbar .title { flex: 1; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playbar .votes { flex-direction: row; gap: 2px; background: #2a241f; border-color: #3a322c; }
.playbar .vote { width: 30px; height: 30px; font-size: 17px; color: #cfc4bb; }
.playbar .vote:hover { background: #3a322c; color: #fff; }
.playbar .vote.active { background: var(--brand); color: #fff; }
.playbar .score { color: #fff; font-size: 17px; min-width: 28px; }
.frame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .brand span { display: none; }
  .button, .topbar .link { white-space: nowrap; }
  .main { padding: 16px 14px 40px; }
  .toolbar { align-items: stretch; }
  .search { flex-basis: 100%; }
  .user { display: none; }
  .day { margin-bottom: 20px; }
  .date { font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
