:root {
  --bg: #0e1015;
  --bg2: #151821;
  --panel: #1b1f2a;
  --panel2: #232836;
  --line: #2c3243;
  --text: #eceef4;
  --muted: #9aa3b8;
  --accent: #e5a00d;
  --accent-ink: #1a1305;
  --good: #3ccf7c;
  --bad: #ff6b5b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1d2233 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* Buttons and fields */
.btn, button {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); color: var(--text); padding: 9px 16px; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover, button:hover { border-color: #3d4560; background: #2a3042; }
.btn:active, button:active { transform: translateY(1px); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover, button.primary:hover { background: #f2b52d; }
button.danger { color: var(--bad); }
button.ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: 0.5; cursor: default; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(229, 160, 13, 0.18); }
.error { color: var(--bad); min-height: 1.5em; margin: 10px 0 0; }

/* Centered card pages (sign-in, invite, errors) */
body.center { display: grid; place-items: center; padding: 24px 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.narrow { width: min(400px, 100%); }
.brandmark { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #f4b73a, #d9860b); color: var(--accent-ink); font-weight: 900;
}
.logo svg { width: 18px; height: 18px; }
.brandmark h1 { font-size: 1.35rem; margin: 0; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.form-actions .primary { flex: 1; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(14, 16, 21, 0.82); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.top .brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.top .spacer { flex: 1; }
.top a.link { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.top a.link:hover { color: var(--text); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; padding: 0; border: 2px solid rgba(255, 255, 255, 0.15);
  background: var(--c, var(--accent)); color: #111; font-weight: 800; font-size: 0.95rem; text-transform: uppercase;
}

/* Library */
main.library { padding: 28px clamp(16px, 4vw, 40px) 60px; max-width: 1400px; margin: 0 auto; }
.hello h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 20px 0 24px; }
.toolbar input { max-width: 280px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.8rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.card {
  display: flex; flex-direction: column; text-decoration: none; color: var(--text); background: var(--panel); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.card:hover, .card:focus-visible { transform: translateY(-4px); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); border-color: #454e68; outline: none; }
.cover {
  position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--c) 70%, #fff 30%), var(--c) 55%, color-mix(in srgb, var(--c) 45%, #000 55%));
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .emoji { font-size: 3.4rem; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35)); }
.cover .play {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.18s;
}
.cover .play span { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.card:hover .play, .card:focus-visible .play { opacity: 1; }
.badge {
  position: absolute; top: 10px; left: 10px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #fff; display: flex; align-items: center; gap: 5px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 6px var(--good); }
.meta { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.meta h3 { font-size: 1.02rem; margin: 0; }
.meta p { margin: 0; color: var(--muted); font-size: 0.86rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 6px; }
.meta .tags span { font-size: 0.72rem; color: var(--muted); background: var(--bg2); padding: 2px 8px; border-radius: 6px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-title { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.card-wrap { position: relative; display: flex; }
.card-wrap .card { flex: 1; }
.card-action {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); border-color: rgba(255, 255, 255, 0.2); color: #fff; opacity: 0; transition: opacity 0.18s;
}
.card-wrap:hover .card-action, .card-action:focus-visible { opacity: 1; }
@media (hover: none) { .card-action { opacity: 1; } }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: min(260px, 100%); margin: 14px auto; }
.qr svg { display: block; width: 100%; height: auto; }
.code { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; user-select: all; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); margin: 18px auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.guest .cover { border-radius: 10px; }

/* Dialogs */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text);
  padding: 24px; width: min(440px, calc(100% - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog::backdrop { background: rgba(5, 6, 10, 0.7); backdrop-filter: blur(3px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; padding: 0; background: var(--c); border: 2px solid transparent; }
.swatches button.on { border-color: #fff; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .meta p { display: none; }
  .toolbar input { max-width: none; }
}
