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

:root {
  --bg:      #080c12;
  --card:    #0f1520;
  --border:  #14203a;
  --accent:  #00c9a7;
  --text:    #edf2f7;
  --muted:   #3a5a70;
  --secondary: #5a7a8a;
  --bar-h:   52px;
  --cat-h:   40px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overscroll-behavior: none;
}

/* ── Status strip ─────────────────────────────────────────── */
#status-strip {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary);
  font-family: ui-monospace, monospace;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}
.strip-dot { color: var(--border); }
.strip-info {
  margin-left: 10px;
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
}
.strip-info:hover { opacity: 0.75; }

/* ── Language switcher ────────────────────────────────────── */
#lang-wrap {
  position: relative;
  margin-left: auto;
}
#lang-btn {
  background: none;
  border: 0.5px solid var(--muted);
  border-radius: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.06em;
  padding: 3px 7px;
  cursor: pointer;
}
#lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #111a28;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 50;
  min-width: 140px;
}
#lang-dropdown.hidden { display: none; }
.lang-opt {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
}
.lang-opt:hover { background: var(--card); }
.lang-opt.active { color: var(--accent); }

/* ── Feed ─────────────────────────────────────────────────── */
#feed {
  padding-top: 38px;
  padding-bottom: calc(var(--bar-h) + var(--cat-h) + 16px);
  min-height: 100vh;
}

#sentinel { height: 1px; }

#search-not-found {
  padding: 48px 24px;
  text-align: center;
  color: var(--secondary);
  font-size: 15px;
  font-family: ui-monospace, monospace;
}
#search-not-found.hidden { display: none; }

/* ── Loading / Skeleton (#12) ─────────────────────────────── */
#loading { padding: 8px 0; }
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.skeleton-card {
  margin: 10px 14px;
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}
.sk-meta  { height: 10px; width: 60%; margin-bottom: 12px; }
.sk-img   { height: 120px; width: 100%; margin-bottom: 12px; }
.sk-line  { height: 12px; margin-bottom: 8px; }
.sk-line.long { width: 90%; }
.sk-line.med  { width: 65%; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.card:active { background: var(--card); }
.card.top-card .headline {
  font-size: 16px;
  color: #1a8cff;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}
.source-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-family: ui-monospace, 'SF Mono', monospace;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}
.cross {
  font-size: 10px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  flex-shrink: 0;
}
.age {
  font-size: 10px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  margin-left: auto;
  white-space: nowrap;
}
.headline {
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.card-img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  margin-bottom: 9px;
  display: block;
}

.score-bar {
  margin-top: 9px;
  height: 2px;
  background: #101825;
  border-radius: 1px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0.45;
}

/* ── Search history (#11) ────────────────────────────────── */
#search-history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
#search-history.hidden { display: none; }
.hist-chip {
  background: var(--border);
  border: none;
  border-radius: 12px;
  color: var(--text);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hist-clear {
  background: none;
  border: 0.5px solid var(--muted);
  border-radius: 12px;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}

/* ── Theme toggle (#14) ───────────────────────────────────── */
.strip-theme {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Light theme (#14) ────────────────────────────────────── */
:root[data-theme="light"] {
  --bg:        #f0f4f8;
  --card:      #ffffff;
  --border:    #ccd8e4;
  --accent:    #00a887;
  --text:      #0d1b2a;
  --muted:     #6a8fa8;
  --secondary: #4a6a7a;
}

/* ── Search bar ───────────────────────────────────────────── */
#search-bar {
  position: fixed;
  bottom: var(--cat-h);
  left: 0; right: 0;
  background: var(--card);
  border-top: 0.5px solid var(--border);
  padding: 8px 14px;
  z-index: 20;
}
#search-bar.hidden { display: none; }
#search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  font-family: -apple-system, sans-serif;
  outline: none;
}
#search-input::placeholder { color: var(--muted); }

/* ── Category bar ─────────────────────────────────────────── */
#cat-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--cat-h);
  background: #0a1220;
  border-top: 0.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  z-index: 30;
  -webkit-overflow-scrolling: touch;
}
#cat-bar::-webkit-scrollbar { display: none; }
.cat-tab {
  flex-shrink: 0;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: 14px;
  color: var(--secondary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.cat-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #080c12;
}
.cat-feedback { color: #00c9a7; border-color: #00c9a7; }
.cat-foryou { color: #f5c518; border-color: #f5c518; }
.cat-foryou.active { background: #f5c518; border-color: #f5c518; color: #080c12; }

/* ── Feedback modal ───────────────────────────────────────── */
#feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#feedback-overlay.hidden { display: none; }
#feedback-modal {
  background: #111a28;
  border: 0.5px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#feedback-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
#feedback-email,
#feedback-message {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  font-family: -apple-system, sans-serif;
  outline: none;
  resize: none;
}
#feedback-email:focus,
#feedback-message:focus { border-color: var(--accent); }
#feedback-email::placeholder,
#feedback-message::placeholder { color: var(--muted); }
#feedback-submit {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #080c12;
  font-size: 14px;
  font-weight: 700;
  padding: 11px;
  cursor: pointer;
}
#feedback-submit:disabled { opacity: 0.6; }
#feedback-cancel {
  background: none;
  border: 0.5px solid var(--muted);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
}
.feedback-ok    { color: var(--accent); font-size: 13px; text-align: center; }
.feedback-error { color: #ff6b6b;       font-size: 13px; text-align: center; }
#feedback-status.hidden { display: none; }
.cat-country { font-size: 16px; padding: 2px 10px; }

/* ── Country picker sheet (#15) ───────────────────────────── */
#country-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
#country-overlay.hidden { display: none; }
#country-sheet {
  background: #111a28;
  border-top: 0.5px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  padding: 20px 16px 32px;
}
#country-sheet-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 16px;
  font-family: ui-monospace, monospace;
}
#country-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.country-btn {
  background: var(--card);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.country-btn:active { background: var(--border); }
#country-close {
  display: block;
  width: 100%;
  background: none;
  border: 0.5px solid var(--muted);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#foryou-empty { display: none; }

/* ── Trending bar (#8) ────────────────────────────────────── */
#trending-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg);
}
#trending-bar::-webkit-scrollbar { display: none; }
#trending-bar.hidden { display: none; }
.trend-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  flex-shrink: 0;
  font-family: ui-monospace, monospace;
}
.trend-chip {
  flex-shrink: 0;
  background: none;
  border: 0.5px solid var(--muted);
  border-radius: 12px;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  text-transform: capitalize;
}
.trend-chip:active { background: var(--border); }

/* ── Modal summary & related (#7 #9) ─────────────────────── */
.modal-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  font-family: ui-monospace, monospace;
  margin-bottom: 6px;
}
#modal-summary-wrap {
  margin-bottom: 14px;
}
#modal-related {
  margin-bottom: 14px;
  border-top: 0.5px solid var(--border);
  padding-top: 12px;
}
.related-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.related-item:last-child { border-bottom: none; }
.related-item:active { opacity: 0.7; }
.related-source {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.related-title {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

/* ── Star / Favourites ────────────────────────────────────── */
.star-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #f5c518;
  cursor: pointer;
  padding: 0 0 0 8px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
  opacity: 0.35;
  font-weight: 900;
}
.star-btn:active { transform: scale(1.3); }
.star-btn.starred { opacity: 1; }

#fav-section { border-bottom: 1px solid var(--accent); }
.fav-header {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-family: ui-monospace, monospace;
}

/* ── Search trigger in cat-bar ────────────────────────────── */
.cat-search-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  -webkit-tap-highlight-color: transparent;
}
.cat-search-btn.active { color: var(--text); }

/* ── Install banner ───────────────────────────────────────── */
#install-banner {
  position: fixed;
  bottom: var(--cat-h);
  left: 0; right: 0;
  background: var(--card);
  border-top: 0.5px solid var(--accent);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 25;
  font-size: 13px;
  color: var(--text);
}
#install-banner.hidden { display: none; }
#install-btn {
  flex-shrink: 0;
  background: var(--accent);
  color: #080c12;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
#install-btn:active { opacity: 0.8; }

/* ── Action bar ───────────────────────────────────────────── */
#btn-search { display: none; }
#action-bar { display: none; }

#action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bar-h);
  background: #0a1220;
  border-top: 0.5px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 30;
}
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--muted);
  transition: color 0.15s;
  padding: 6px 24px;
}
.action-btn:active { opacity: 0.7; }
.action-btn.active { color: var(--accent); }
.action-btn svg {
  width: 22px; height: 22px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.action-btn span { font-size: 10px; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 600; }

/* ── Modal overlay ────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
#modal-overlay.hidden { display: none; }

#modal {
  background: #111a28;
  border-top: 0.5px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 36px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slide-up 0.25s ease-out;
}
@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

#modal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#modal-source {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  text-transform: uppercase;
}
#modal-age {
  font-size: 11px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
#modal-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  margin-bottom: 12px;
}
#modal-img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 14px;
  display: block;
}

#modal-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--secondary);
  margin-bottom: 20px;
  min-height: 0;
}
#modal-link {
  display: block;
  background: var(--accent);
  color: #080c12;
  text-align: center;
  padding: 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  margin-bottom: 10px;
}
#modal-link:active { opacity: 0.85; }
#modal-share {
  display: block;
  width: 100%;
  background: none;
  border: 0.5px solid var(--accent);
  color: var(--accent);
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
#modal-share:active { opacity: 0.7; }

#modal-close {
  display: block;
  width: 100%;
  background: none;
  border: 0.5px solid var(--border);
  color: var(--secondary);
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}
#modal-close:active { opacity: 0.7; }

#share-toast {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  letter-spacing: 0.04em;
}
#share-toast.hidden { display: none; }

/* ── Disclaimer ───────────────────────────────────────────── */
#disclaimer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#disclaimer-overlay.hidden { display: none; }
#disclaimer {
  background: #111a28;
  border: 0.5px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 22px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
#disclaimer-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
#disclaimer-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--secondary);
  margin-bottom: 22px;
}
#disclaimer-ok {
  width: 100%;
  background: var(--accent);
  color: #080c12;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
}
#disclaimer-ok:active { opacity: 0.85; }
#disclaimer-more {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  color: var(--secondary);
  text-decoration: none;
  letter-spacing: 0.03em;
}
#disclaimer-more:hover { color: var(--accent); }

/* ── Desktop ──────────────────────────────────────────────── */
@media (min-width: 640px) {
  body { max-width: 640px; margin: 0 auto; border-left: 0.5px solid var(--border); border-right: 0.5px solid var(--border); }
  .headline { font-size: 15px; }
  #modal { border-radius: 20px; margin: auto; max-width: 560px; }
  #modal-overlay { align-items: center; }
}
