:root {
  --bg: #0e0e0c;
  --surface: #171714;
  --elevated: #1f1f1a;
  --fg: #f2efe6;
  --muted: #9c9788;
  --subtle: #6f6b60;
  --accent: #d4a017;
  --accent-fg: #1a1406;
  --olive: #8fa083;
  --border: #2a2a24;
  --danger: #c45c4a;
  --gold: #d4a017;
  --silver: #c5c9ce;
  --bronze: #b87333;
  --sans: "Figtree", "Segoe UI", system-ui, sans-serif;
  --display: "Fraunces", "Iowan Old Style", Palatino, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -0.03em;
  line-height: 1.15;
  font-weight: 500;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0; }

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid color-mix(in oklab, var(--border) 80%, transparent);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
}

.header-inner, .footer-inner, .page {
  width: min(1152px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  padding: 8px 0 6px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.header-user {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
  text-align: right;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.2;
}

.brand-text {
  display: block;
  white-space: nowrap;
}

.mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  background: #000;
}

.nav {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
}

.nav-record {
  width: 100%;
}

.nav-record .btn {
  width: 100%;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal.hidden {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(90dvh, 900px);
  overflow: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

body.modal-open {
  overflow: hidden;
}

.page { flex: 1; padding: 12px 0 80px; }
.page.has-dock { padding-bottom: 108px; }
.page.home-page > .section:first-child { margin-top: 0; }

.footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.footer-inner {
  padding: 28px 0;
  color: var(--subtle);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 500 0.925rem/1 var(--sans);
  background: transparent;
  color: var(--fg);
  white-space: nowrap;
}

.btn-sm { height: 40px; padding: 0 14px; font-size: 0.875rem; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 1rem; }
.btn-ghost:hover { background: color-mix(in oklab, var(--elevated) 80%, transparent); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--elevated); border-color: var(--border); }
.btn-outline { border-color: var(--border); background: var(--elevated); }
.btn-danger { background: color-mix(in oklab, var(--danger) 18%, var(--elevated)); color: #f2c4bc; border-color: color-mix(in oklab, var(--danger) 40%, var(--border)); }

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  min-height: 280px;
}

.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg) 0%, color-mix(in oklab, var(--bg) 70%, transparent) 55%, transparent 100%);
}

.hero-grid {
  position: relative;
  display: grid;
  gap: 24px;
  padding: 32px 28px;
}

@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1.1fr 0.9fr; align-items: center; padding: 40px; }
}

.hero h1 { font-size: clamp(2.4rem, 6vw, 3.75rem); max-width: 12ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-side {
  justify-self: center;
  max-height: 240px;
  border-radius: 16px;
  border: 1px solid var(--border);
  display: none;
}
@media (min-width: 900px) { .hero-side { display: block; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.card-body { padding: 22px; }
@media (min-width: 640px) { .card-body { padding: 28px; } }

.stack { display: grid; gap: 16px; }
.section { margin-top: 56px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.banner {
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--border);
  margin-bottom: 22px;
}
.banner img { width: 100%; height: 160px; object-fit: cover; }
@media (min-width: 640px) { .banner img { height: 200px; } }

.input, .textarea, select.input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--fg);
  border-radius: 14px;
  padding: 12px 14px;
  font: 400 1rem/1.4 var(--sans);
}

.textarea { min-height: 90px; resize: vertical; }
.input:focus, .textarea:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 50%, transparent);
  outline-offset: 1px;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.row { display: grid; gap: 12px; }
.fart-row {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
@media (min-width: 720px) {
  .fart-row { grid-template-columns: auto 1fr auto; align-items: center; }
}

.rank-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 1.15rem;
  background: var(--elevated);
  border: 1px solid var(--border);
}
.rank-badge.gold { background: var(--gold); color: #1a1406; border-color: #f0c14b; }
.rank-badge.silver { background: var(--silver); color: #222; border-color: #e8ecf0; }
.rank-badge.bronze { background: var(--bronze); color: #1a0e06; border-color: #d99955; }

.meta { color: var(--muted); font-size: 0.9rem; }
.subtle { color: var(--subtle); font-size: 0.8rem; }
.title { font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--elevated);
  color: var(--muted);
  font: 500 0.875rem/1 var(--sans);
}
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

.rate-block { display: grid; gap: 10px; width: 100%; }
.rate-slider { display: grid; gap: 4px; }
.rate-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.rate-val {
  font-weight: 600;
  color: var(--fg);
  min-width: 1.5rem;
  text-align: right;
}
.rate-slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 28px;
  margin: 0;
  cursor: pointer;
}

.fart-row-rate {
  align-items: start;
}
.fart-main {
  display: grid;
  gap: 12px;
  min-width: 0;
  width: 100%;
}
.fart-head {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.recorder {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--elevated);
  overflow: hidden;
}
.recorder-top { padding: 16px; }
.wave {
  height: 64px;
  display: flex;
  align-items: end;
  gap: 3px;
}
.wave i {
  display: block;
  width: 4px;
  background: var(--olive);
  border-radius: 2px;
  min-height: 4px;
}
.recorder-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.pager { display: flex; gap: 8px; align-items: center; margin-top: 22px; flex-wrap: wrap; }
.auth-card { max-width: 420px; margin: 0 auto; }
.list { display: grid; gap: 12px; }

.recent-dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  max-width: 720px;
  margin: 0 auto;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px color-mix(in oklab, #000 45%, transparent);
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.recent-dock-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  min-height: 48px;
}
.recent-dock-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  cursor: pointer;
}
.recent-dock-main .title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-dock-main .meta {
  margin: 0;
  font-size: 0.72rem;
}
.recent-dock-vote {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.recent-dock-panel {
  display: none;
  border-top: 1px solid var(--border);
  max-height: 62vh;
  overflow: auto;
  padding: 8px;
}
.recent-dock.open .recent-dock-panel { display: block; }
body.has-dock .toast { bottom: 78px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--fg);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 50;
  font-size: 0.9rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

.clip-preview {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}
.clip-preview audio {
  width: 100%;
  height: 40px;
}

.battle-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.battle-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--elevated);
}
.battle-vs {
  font-family: var(--display);
  font-weight: 600;
  opacity: 0.7;
}
@media (max-width: 640px) {
  .battle-grid {
    grid-template-columns: 1fr;
  }
  .battle-vs {
    text-align: center;
  }
}

.goat-vid {
  width: min(360px, 100%);
  max-height: 420px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #000;
  object-fit: cover;
}

.medal-icon {
  width: 40px;
  height: 50px;
  object-fit: contain;
  flex-shrink: 0;
}
.medal-row {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}
.medals-banner {
  position: relative;
  margin-bottom: 18px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border, #333);
}
.medals-banner > img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.medals-row {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
}
.medals-row .medal-icon {
  width: 56px;
  height: 70px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.45));
}
.medals-row .medal-icon:nth-child(2) {
  width: 72px;
  height: 90px;
  transform: translateY(-6px);
}
.medals-title {
  position: absolute;
  left: 12px;
  bottom: 8px;
  margin: 0;
  font-size: 12px;
  color: rgba(255,255,255,.75);
  letter-spacing: .04em;
  text-transform: uppercase;
}
