*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #252525;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-muted: #888;
  --accent: #ff0000;
  --accent-hover: #cc0000;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; overflow-x: hidden; }
body { background: var(--bg); color: var(--text); font-family: var(--font); min-height: 100vh; overflow-x: hidden; width: 100%; }

.container { max-width: 1300px; margin: 0 auto; padding: 0 20px; }

/* ── Header ── */
.site-header {
  background: rgba(15,15,15,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding: 12px 0;
}
.site-header .container { display: flex; align-items: center; gap: 16px; }

.logo { display: flex; align-items: center; gap: 7px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.5px; white-space: nowrap; cursor: pointer; }
.logo svg { width: 26px; height: 26px; flex-shrink: 0; }
.logo span { color: var(--accent); }

.lang-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: .82rem;
  padding: 6px 8px;
  outline: none;
  flex-shrink: 0;
  transition: border-color .15s;
}
.lang-select:focus, .lang-select:hover { border-color: #555; }

.search-form { display: flex; align-items: center; flex: 1; gap: 8px; max-width: 720px; }
.site-header.minimal .search-form { display: none; }

.header-mode-tabs {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}
.header-mode-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 500;
  padding: 5px 11px 5px 9px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.header-mode-tab svg { width: 12px; height: 12px; flex-shrink: 0; }
.header-mode-tab:not(.active):hover { background: rgba(255,255,255,.05); color: var(--text); }
.header-mode-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(255,0,0,.3);
}
.search-form input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  padding: 8px 14px;
  outline: none;
  transition: border-color .15s;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button:not(.header-mode-tab) {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  padding: 8px 20px;
  transition: background .15s;
  white-space: nowrap;
}
.search-form button:not(.header-mode-tab):hover { background: var(--accent-hover); }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Welcome / Hero ── */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 57px);
  padding: 60px 20px;
  /* subtle radial glow from top-center */
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255,0,0,0.07) 0%, transparent 70%),
    var(--bg);
}

.hero {
  text-align: center;
  max-width: 700px;
  width: 100%;
  animation: fadeUp .5s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: 1px;
  padding: 5px 14px;
  margin-bottom: 28px;
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin-bottom: 20px;
  color: #f0f0f0;
}

.hero-accent { color: var(--accent); }

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.75;
  margin-bottom: 40px;
}

/* Hero search card with mode tabs */
.hero-search-form { width: 100%; margin-bottom: 32px; }

.hero-search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.hero-search-card:focus-within {
  border-color: rgba(255, 0, 0, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.07);
}

.hero-mode-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
}

.hero-mode-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: .87rem;
  font-weight: 500;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.hero-mode-tab svg { width: 14px; height: 14px; flex-shrink: 0; }
.hero-mode-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.hero-mode-tab:hover:not(.active) { color: var(--text); }

.hero-search-box {
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  padding: 6px 6px 6px 18px;
  gap: 10px;
}

.hero-search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.hero-search-box input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  padding: 10px 0;
  min-width: 0;
}
.hero-search-box input::placeholder { color: var(--text-muted); }

.hero-search-btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  padding: 10px 22px;
  transition: background .15s, transform .1s;
  white-space: nowrap;
  flex-shrink: 0;
}
.hero-search-btn:hover { background: var(--accent-hover); }
.hero-search-btn:active { transform: scale(.97); }

/* ── Hero bulk box ── */
.hero-bulk-box {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--border);
}
.hero-bulk-box textarea {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  line-height: 1.6;
  outline: none;
  padding: 16px 20px 8px;
  resize: none;
  min-height: 110px;
  width: 100%;
}
.hero-bulk-box textarea::placeholder { color: var(--text-muted); }
.hero-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 10px 20px;
}
.hero-bulk-count {
  color: var(--text-muted);
  font-size: .8rem;
}
.hero-bulk-count.over { color: var(--accent); }

/* ── Header bulk textarea ── */
.bulk-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .88rem;
  line-height: 1.5;
  outline: none;
  padding: 6px 12px;
  resize: none;
  transition: border-color .15s;
}
.bulk-input:focus { border-color: var(--accent); }
.bulk-input::placeholder { color: var(--text-muted); }

/* ── Bulk results ── */
.col-dur  { width: 70px; text-align: right; }
.col-tags { width: 55px; text-align: right; }
.bulk-failed { color: var(--text-muted); font-style: italic; font-size: .82rem; }

/* Feature pills row */
.hero-features {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: .82rem;
}
.feature-pill svg { width: 13px; height: 13px; opacity: .7; }

.feature-pill-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--border);
}

/* ── Loading ── */
.loading { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 80px 0; color: var(--text-muted); }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-box {
  background: #2a0a0a;
  border: 1px solid #5a1a1a;
  border-radius: var(--radius);
  color: #ff8080;
  margin: 32px 0;
  padding: 16px 20px;
}

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}
@media (max-width: 800px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { color: var(--text-muted); font-size: .8rem; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 1.4rem; font-weight: 700; }
.stat-sub { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }

/* ── Suggestions ── */
.suggestions-section { margin: 0 0 20px; }
.section-label { color: var(--text-muted); font-size: .8rem; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .5px; }
.suggestions-list { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-size: .85rem;
  padding: 4px 12px;
  transition: border-color .15s, background .15s;
}
.suggestion-chip:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

/* ── Sort ── */
.sort-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sort-label { color: var(--text-muted); font-size: .85rem; }
.sort-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.sort-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  padding: 5px 12px;
  transition: all .15s;
}
.sort-btn:hover { border-color: #555; color: var(--text); }
.sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ── Table ── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 40px; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
thead { background: var(--surface); }
th {
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

.col-rank { width: 48px; text-align: center; }
.col-views, .col-likes, .col-comments, .col-subs, .col-vcount, .col-date { white-space: nowrap; }
td.col-rank { text-align: center; color: var(--text-muted); font-weight: 700; }

/* ── Video cell ── */
.video-cell { display: flex; align-items: center; gap: 12px; }
.video-thumb {
  width: 80px; height: 45px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}
.video-info { min-width: 0; }
.video-title {
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .9rem;
  line-height: 1.35;
  margin-bottom: 3px;
}
.video-title a, a.video-title { color: inherit; text-decoration: none; }
.video-title a:hover, a.video-title:hover { color: var(--accent); }
.video-channel { color: var(--text-muted); font-size: .8rem; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }

/* ── Video Analysis ── */
.va-header {
  display: flex;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 24px 0 12px;
  align-items: flex-start;
}
.va-thumb-wrap {
  position: relative;
  flex-shrink: 0;
  width: 260px;
  border-radius: 6px;
  overflow: hidden;
  display: block;
  background: var(--surface2);
  aspect-ratio: 16/9;
}
.va-thumb-main {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.va-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .15s;
}
.va-thumb-wrap:hover .va-play-icon { opacity: 1; }

.va-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.va-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
  margin: 0;
}
.va-channel-row { display: flex; align-items: center; gap: 8px; }
.va-channel-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.va-channel-name:hover { text-decoration: underline; }
.va-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: .85rem;
}
.va-meta-sep { display: flex; align-items: center; gap: 8px; }
.va-meta-item { color: var(--text-muted); }
.va-open-yt {
  display: inline-block;
  margin-top: 4px;
  padding: 7px 16px;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
  align-self: flex-start;
}
.va-open-yt:hover { background: var(--accent-hover); }

/* Stats row */
.va-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.va-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.va-stat-label {
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.va-stat-value { font-size: 1.45rem; font-weight: 700; }
.va-stat-sub { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }

/* Sections */
.va-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}
.va-section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Tags */
.va-tags-list { display: flex; flex-wrap: wrap; gap: 8px; }
.va-tag {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-size: .83rem;
  padding: 4px 13px;
  transition: border-color .15s, color .15s, background .15s;
}
.va-tag { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font); }
.va-tag:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,0,0,.05); }
.va-tag-source {
  font-size: .62rem;
  font-weight: 600;
  color: var(--text-muted);
  opacity: .7;
  letter-spacing: .02em;
  pointer-events: none;
}
.va-no-tags { color: var(--text-muted); font-size: .9rem; }

/* Description */
.va-desc {
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 110px;
  overflow: hidden;
  transition: max-height .3s ease;
}
.va-desc.expanded { max-height: 9999px; }
.va-desc-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: .83rem;
  margin-top: 8px;
  padding: 0;
}
.va-desc-toggle:hover { text-decoration: underline; }

/* Channel card */
.va-channel-card { display: flex; flex-direction: column; gap: 6px; }
.va-channel-card-name { font-size: 1rem; font-weight: 600; }
.va-channel-card-name a { color: var(--text); text-decoration: none; }
.va-channel-card-name a:hover { color: var(--accent); }
.va-channel-stats { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 4px; }
.va-channel-stat { display: flex; flex-direction: column; gap: 2px; }
.va-channel-stat-label { font-size: .73rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.va-channel-stat-value { font-size: 1.05rem; font-weight: 700; }


/* ── Section header with actions ── */
.va-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.va-section-header .va-section-title { margin-bottom: 0; }
.va-section-actions { display: flex; align-items: center; gap: 8px; }
.va-section-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: .72rem;
  padding: 2px 10px;
  white-space: nowrap;
}
.va-copy-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: .75rem;
  padding: 3px 10px;
  transition: border-color .15s, color .15s;
  white-space: nowrap;
}
.va-copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Keyword rank list ── */
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }
.va-rank-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.va-rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  gap: 12px;
}
.va-rank-keyword {
  font-size: .9rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text);
  background: none;
  border: none;
  font-family: var(--font);
  text-align: left;
  padding: 0;
}
.va-rank-keyword:hover { color: var(--accent); }
.va-rank-left { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex: 1; min-width: 0; }
.va-rank-source {
  font-size: .65rem;
  color: var(--text-muted);
  opacity: .75;
}
.source-search { color: #7ba0e0; }
.source-inferred { color: var(--text-muted); }
.va-rank-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.va-rank-badge {
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 700;
  padding: 2px 9px;
  min-width: 44px;
  text-align: center;
}
.rank-high { background: rgba(0,200,100,.15); color: #00c864; border: 1px solid rgba(0,200,100,.3); }
.rank-mid  { background: rgba(255,180,0,.12); color: #ffb400; border: 1px solid rgba(255,180,0,.3); }
.rank-low  { background: rgba(255,100,50,.12); color: #ff6432; border: 1px solid rgba(255,100,50,.3); }
.va-rank-none { color: var(--text-muted); font-size: .78rem; min-width: 44px; text-align: center; }
.va-rank-loading { color: var(--text-muted); font-size: .78rem; animation: pulse 1.2s ease-in-out infinite; }

/* ── Topic signals ── */
.va-topics-list { display: flex; flex-wrap: wrap; gap: 8px; }
.va-topic-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .83rem;
  padding: 5px 14px;
  color: var(--text-muted);
}
.va-topic-chip svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Related searches ── */
.va-related-list { display: flex; flex-wrap: wrap; gap: 8px; }
.va-related-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  font-size: .83rem;
  padding: 5px 14px;
  transition: border-color .15s, color .15s, background .15s;
}
.va-related-chip:hover { border-color: var(--accent); color: var(--accent); background: rgba(255,0,0,.04); }

/* ── Description hashtag ── */
.va-hashtag {
  background: rgba(255,0,0,.08);
  border: none;
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
  font-size: inherit;
  padding: 0 2px;
}
.va-hashtag:hover { background: rgba(255,0,0,.16); }

/* ── Competing videos ── */
.va-competing-list { display: flex; flex-direction: column; gap: 10px; }
.va-competing-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color .15s;
}
.va-competing-item:hover { border-color: rgba(255,0,0,.4); }
.va-competing-thumb {
  width: 100px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}
.va-competing-info { flex: 1; min-width: 0; }
.va-competing-title {
  color: var(--text);
  display: -webkit-box;
  font-size: .88rem;
  font-weight: 500;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
}
.va-competing-title:hover { color: var(--accent); }
.va-competing-meta { color: var(--text-muted); font-size: .78rem; margin-top: 4px; }
.va-competing-channel { color: var(--text-muted); text-decoration: none; }
.va-competing-channel:hover { color: var(--accent); }
.va-competing-views { color: var(--text); font-size: .9rem; font-weight: 600; flex-shrink: 0; }

@media (max-width: 800px) {
  .va-header { flex-direction: column; }
  .va-thumb-wrap { width: 100%; max-width: 400px; }
  .va-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .va-competing-thumb { width: 72px; height: 40px; }
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Prevent iOS Safari auto-zoom on input focus (triggers when font-size < 16px) */
  input, textarea, select { font-size: 16px !important; }

  .container { padding: 0 12px; }

  /* Header: allow wrapping so the search row doesn't overflow */
  .site-header .container {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
  }

  /* Logo shrinks a bit */
  .logo { font-size: 1.15rem; }

  /* Mode-tab labels hidden on very small screens — icons only */
  .header-mode-tab span { display: none; }
  .header-mode-tab { padding: 5px 9px; }
  .header-mode-tab svg { width: 14px; height: 14px; }

  /* Search form takes full width on second row */
  .search-form {
    order: 10;
    width: 100%;
    max-width: none;
    flex: none;
  }

  /* Lang select stays on first row, pushed to right */
  .lang-select { margin-left: auto; }

  /* Sort bar stacks vertically */
  .sort-bar { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Table: tighter padding and smaller thumbnail so all columns fit in the scroll area */
  .col-rank { width: 32px; }
  th, td { padding: 8px 8px; }
  .video-thumb { width: 60px; height: 34px; }
  .video-cell { gap: 8px; }

  /* Stats grid: 2 columns on mobile */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* VA stats: single column */
  .va-stats-grid { grid-template-columns: 1fr 1fr; }
}
