:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --ink: #171615;
  --muted: #66645f;
  --line: #d9d5ca;
  --paper: #ffffff;
  --accent: #19615a;
  --accent-soft: #d7ebe7;
  --warm: #d48b2a;
  --rose: #b64c62;
  --shadow: 0 18px 50px rgba(23, 22, 21, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Heebo", "Assistant", "Rubik", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar, .tabs, .filters, .candidate-section, .moments-section, .sounds-section {
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-top: 6px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }

h1 {
  font-size: clamp(2rem, 6.8vw, 4.9rem);
  line-height: 0.92;
}

.tagline {
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 750;
}

h2 { font-size: 1rem; }

.tabs {
  display: flex;
  gap: 8px;
}

.tab-button, .sound-filter, .tag-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

.tab-button.active, .sound-filter.active, .tag-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.view { display: none; }
.view.active { display: block; }

.sort-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.sort-control {
  display: grid;
  gap: 7px;
  min-width: 190px;
}

label, .filter-head p, #momentsMeta {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  padding-block: 10px;
  padding-inline-start: 12px;
  padding-inline-end: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: 16px 50%, 21px 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.filter-head, .moments-head, .sounds-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.mood-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.mood-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  min-height: 74px;
  padding: 12px;
  text-align: start;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.mood-button strong { display: block; font-size: 1rem; }
.mood-button span   { display: block; margin-top: 6px; color: var(--muted); font-size: 0.82rem; }

.mood-button:hover, .candidate-button:hover { border-color: var(--accent); }
.mood-button.active, .candidate-button.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}

.candidate-button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  min-height: 148px;
  padding: 0;
  text-align: start;
}

.candidate-photo, .candidate-initials {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: #e9e2d5;
}

.candidate-photo  { object-fit: cover; }
.candidate-initials { color: var(--accent); font-size: 1.55rem; font-weight: 850; }

.candidate-label {
  display: grid;
  gap: 2px;
  padding: 9px;
}

.candidate-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
.candidate-label span   { color: var(--muted); font-size: 0.75rem; }

.moments-head { align-items: end; }

.moments-grid, .sounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.moment-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.video-wrap { background: #111; }

video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #111;
}

.moment-body { display: grid; gap: 10px; padding: 14px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 7px; }

.pill {
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 5px 8px;
}

.pill.warm { background: #f5dfbf; color: #7a470d; }
.pill.score { background: #ead9f0; color: #6a2a76; }

.moment-title { font-size: 1rem; line-height: 1.28; }
.summary { color: var(--muted); font-size: 0.9rem; line-height: 1.42; }

.moment-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.84rem;
  font-weight: 750;
  padding: 0 12px;
  text-decoration: none;
}

.action-button.secondary { background: white; color: var(--accent); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: 18px;
}

.page-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 38px;
  min-width: 88px;
  padding: 0 14px;
}

.page-button:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.page-status {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.sound-filter-row, .tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.tag-button strong {
  color: inherit;
  font-size: 0.75rem;
  opacity: 0.75;
}

.sound-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 14px;
}

.sound-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.sound-category {
  color: var(--rose);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.sound-title {
  margin: 4px 0 2px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.sound-name-en {
  color: var(--muted);
  font-size: 0.82rem;
}

.sound-intensity {
  border-radius: 999px;
  background: #f5dfbf;
  color: #7a470d;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 850;
  padding: 6px 9px;
}

audio {
  display: block;
  width: 100%;
  min-height: 42px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.loading { color: var(--muted); padding: 12px; }

@media (max-width: 720px) {
  .shell { width: min(100% - 22px, 1180px); padding-top: 16px; }
  .topbar, .moments-head, .sounds-head { align-items: stretch; flex-direction: column; }
  .sort-controls { justify-content: stretch; }
  .sort-control { min-width: 0; }
  .candidate-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .moments-grid, .sounds-grid { grid-template-columns: 1fr; }
}
