/* Crazy Sounds - Mobile-first UI */
:root {
  --bg: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: #141414;
  --text: #ffffff;
  --text-muted: #b3b3b3;
  --primary: #e50914;
  --primary-hover: #f40612;
  --border: #222;
  --radius: 8px;
  --shadow: 0 8px 24px rgba(0,0,0,0.5);
  --transition: all 0.25s ease;
  --header-h: auto;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-card: #fff;
  --text: #111;
  --text-muted: #555;
  --border: #e0e0e0;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 70px;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select { font-family: inherit; }

/* Shared logo (all pages) */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.logo img {
  height: 38px !important;
  width: 38px !important;
  max-width: 38px !important;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}
.logo span {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Secondary pages: classic one-row header */
.header-inner.simple,
.header > .header-inner:not(:has(.header-top)) {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}



/* ========== HEADER (mobile-first) ========== */
.header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .header {
  background: rgba(255,255,255,0.98);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Top bar: menu | logo | actions */
.header-top {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.header-top .menu-btn {
  order: 0;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.05rem;
}

.header-top .brand {
  order: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.header-top .brand img {
  height: 36px;
  width: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.header-top .brand-text {
  min-width: 0;
  overflow: hidden;
}

.header-top .brand-text .site-name {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.header-top .brand-text .site-tag {
  display: block;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-top .header-right {
  order: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.header-top .icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.header-top .account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff !important;
  font-weight: 600;
  font-size: 0.8rem;
  border: none;
  flex-shrink: 0;
}
.header-top .account-btn .btn-label { display: none; }

/* Search row */
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
}
.search-wrap:focus-within { border-color: var(--primary); }
.search-wrap i { color: var(--text-muted); font-size: 0.85rem; flex-shrink: 0; }
.search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  min-width: 0;
  width: 100%;
}
.search-wrap input::placeholder { color: var(--text-muted); }

.lang-select {
  height: 40px;
  max-width: 100px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 8px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Tablet+ */
@media (min-width: 640px) {
  .header-inner { padding: 12px 4%; }
  .header-top .brand img { height: 40px; width: 40px; }
  .header-top .brand-text .site-name { font-size: 1.15rem; }
  .header-top .brand-text .site-tag { font-size: 0.68rem; }
  .header-top .account-btn .btn-label { display: inline; }
  .header-top .account-btn { padding: 0 14px; }
  .lang-select { max-width: 130px; font-size: 0.82rem; }
}

@media (min-width: 900px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
  .header-top { flex: 0 1 auto; width: auto; }
  .header-search { flex: 1; max-width: 480px; margin-left: auto; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 0.9rem; font-weight: 600;
  border: none; cursor: pointer; transition: var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 12px 22px; font-size: 0.95rem; }

/* Hero */
.hero {
  position: relative;
  height: 56vh;
  min-height: 320px;
  max-height: 520px;
  display: flex;
  align-items: flex-end;
  padding: 0 12px 48px;
  overflow: hidden;
}
@media (min-width: 640px) {
  .hero { height: 70vh; min-height: 400px; padding: 0 4% 60px; }
}
.hero-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center top;
  z-index: 0;
}
.hero-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, var(--bg) 0%, transparent 50%),
              linear-gradient(to right, rgba(0,0,0,0.75) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 2; max-width: 520px; }
.hero-title {
  font-size: 1.6rem; font-weight: 800; line-height: 1.15; margin-bottom: 10px;
}
@media (min-width: 640px) { .hero-title { font-size: 2.5rem; } }
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;
  font-size: 0.9rem; color: var(--text-muted); align-items: center;
}
.hero-meta .rating { color: #f5c518; font-weight: 700; }
.hero-desc {
  font-size: 0.92rem; color: var(--text-muted); margin-bottom: 16px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Filters */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 14px 12px 8px;
}
@media (min-width: 640px) { .filters { padding: 16px 4% 8px; } }
.filter-btn {
  padding: 7px 14px; border-radius: 50px; border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); font-size: 0.8rem;
  font-weight: 500; cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.filter-btn:hover, .filter-btn.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

/* Rows */
.row-section { padding: 8px 0 24px; }
.row-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; margin-bottom: 10px;
}
@media (min-width: 640px) { .row-header { padding: 0 4%; } }
.row-title { font-size: 1.1rem; font-weight: 700; }
@media (min-width: 640px) { .row-title { font-size: 1.25rem; } }
.row-scroll {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 4px 12px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .row-scroll { padding: 4px 4% 12px; } }
.row-scroll::-webkit-scrollbar { height: 4px; }
.row-scroll::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

.card {
  flex: 0 0 130px; scroll-snap-align: start;
  border-radius: 8px; overflow: hidden; background: var(--bg-card);
  cursor: pointer; transition: transform 0.25s ease, box-shadow 0.25s;
  position: relative;
}
@media (min-width: 640px) { .card { flex: 0 0 150px; } }
.card:hover { transform: scale(1.05); z-index: 5; box-shadow: var(--shadow); }
.card-poster {
  width: 100%; aspect-ratio: 2/3; object-fit: cover; background: #1a1a1a;
}
.card-info { padding: 8px; }
.card-title {
  font-size: 0.8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.card-rating {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.75); color: #f5c518;
  font-size: 0.7rem; font-weight: 700; padding: 3px 6px; border-radius: 4px;
}
.card-like {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.6); border: none; color: #fff;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}
.card-like.liked i { color: #e50914; }
.card-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: #333;
}
.card-progress span { display: block; height: 100%; background: var(--primary); }

/* Description expand */
.desc-box { position: relative; }
.desc-text {
  color: var(--text-muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.desc-text.expanded { -webkit-line-clamp: unset; }
.desc-toggle {
  background: none; border: none; color: var(--primary); font-size: 0.9rem;
  cursor: pointer; margin-top: 6px; font-weight: 600;
}

/* APK popup */
.apk-popup {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px;
}
.apk-popup.hidden { display: none; }
.apk-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 24px; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow);
}
.apk-card h3 { font-size: 1.2rem; margin-bottom: 10px; }
.apk-card p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.95rem; }
.apk-actions { display: flex; flex-direction: column; gap: 10px; }

.footer {
  border-top: 1px solid var(--border); padding: 32px 12px;
  text-align: center; color: var(--text-muted); font-size: 0.85rem;
}
.section { padding: 20px 12px; max-width: 1400px; margin: 0 auto; }
@media (min-width: 640px) {
  .section { padding: 20px 4%; }
  .footer { padding: 40px 4%; }
}

#searchResults {
  display: none;
  padding: 12px;
  max-width: 1400px;
  margin: 0 auto;
}
#searchResults.show { display: block; }
#searchResults h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}
