:root {
  color-scheme: dark;
  --bg: #141210;
  --surface: #1c1916;
  --surface-2: #221e1a;
  --line: #3a332c;
  --text: #f5efe6;
  --text-2: #d9cfc2;
  --muted: #b3a89a;
  --accent: #ffc93c;
  --on-accent: #1a1400;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Hind Madurai', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
body.clip-open { overflow: hidden; }

button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header + search */

.top {
  position: sticky; top: 0; z-index: 2;
  max-width: 960px; margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 22px; font-weight: 600; line-height: 1;
}
.brand h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: 24px; letter-spacing: -0.02em;
}
.tagline { margin: 4px 0 14px; color: var(--muted); font-size: 15px; }

.search {
  height: 52px; padding: 0 6px 0 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0; height: 100%;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-size: 17px; /* 16px+ stops iOS zooming in */
}
.search input::placeholder { color: #9a8f82; }
.search input::-webkit-search-cancel-button { display: none; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 10px;
  display: grid; place-items: center; background: transparent; color: var(--muted);
}

/* Clip grid */

.list { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }
.count {
  margin: 4px 0 12px; color: var(--muted);
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 18px 12px;
}
.grid.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px 10px; }

.card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden; background: var(--surface-2);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.04); }
.play {
  position: absolute; inset: 0; margin: auto; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0, 0, 0, .5); color: var(--text);
}
.dur {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, .72); font-size: 12px; font-weight: 600;
}
.dialogue {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.grid.small .dialogue { font-size: 14px; font-weight: 500; -webkit-line-clamp: 2; }

.empty { padding: 32px 8px; text-align: center; color: var(--muted); }
.empty-title { margin: 0 0 6px; font-family: var(--display); font-size: 20px; font-weight: 600; color: var(--text); }

/* Clip page */

.clip {
  position: fixed; inset: 0; z-index: 10;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg);
}
.clip-inner { max-width: 640px; margin: 0 auto; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
.clip-nav { min-height: 56px; padding: env(safe-area-inset-top) 8px 0; display: flex; align-items: center; }
.back {
  height: 44px; padding: 0 12px 0 6px; border: 0; border-radius: 12px;
  display: flex; align-items: center; gap: 4px; background: transparent; font-size: 16px; font-weight: 500;
}
#player { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.clip-body { padding: 20px 16px 0; }
#clip-title {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: 30px; line-height: 1.15; letter-spacing: -0.015em;
}
#clip-title.long { font-size: 21px; line-height: 1.3; letter-spacing: 0; }
.meta { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

.actions { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.primary {
  height: 56px; border: 0; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: var(--on-accent); font-size: 18px; font-weight: 600;
}
.primary:active { filter: brightness(.92); }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
.secondary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-top: 4px; }
.btn {
  height: 52px; border: 1px solid var(--line); border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface); font-size: 16px; font-weight: 500; text-decoration: none;
}
.more-title { margin: 32px 0 12px; font-family: var(--display); font-size: 19px; font-weight: 600; }
