/* === Theme: Light === */
body.light {
  --bg: #FFFFFF; --s1: #F5F5F7; --s2: #EBEBF0; --s3: #D1D1D6;
  --t1: #000000; --t2: #1C1C1E; --t3: #8E8E93; --t4: #AEAEB2; --pink: #FF375F;
}
body.light .hdr { background: rgba(255,255,255,.85); border-bottom-color: rgba(0,0,0,.08); }
body.light .bnav { background: rgba(255,255,255,.92); border-top-color: rgba(0,0,0,.08); }
body.light .pill { background: rgba(0,0,0,.06); color: var(--t2); }
body.light .pill:hover { background: rgba(0,0,0,.1); }
body.light .tchip { background: var(--s1); border-color: rgba(0,0,0,.06); }
body.light .card { background: var(--s1); }
body.light .hc { background: var(--s1); }
body.light .lc { border-bottom-color: rgba(0,0,0,.06); }
body.light .hero-ov { background: linear-gradient(transparent, rgba(0,0,0,.7)); }
body.light .hero-t { color: #fff; }
body.light .hero-src { color: rgba(255,255,255,.7); }
body.light .hero-m { color: rgba(255,255,255,.6); }
body.light .hero-pills .pill { background: rgba(255,255,255,.2); color: #fff; }
body.light .card-pills .pill { background: rgba(0,0,0,.05); color: var(--t2); }
body.light .theme-btn { background: var(--s2); }
body.light .tst { background: var(--s1); box-shadow: 0 4px 16px rgba(0,0,0,.1); }

/* === Theme: Dark (default) === */
:root {
  --bg: #000; --s1: #1C1C1E; --s2: #2C2C2E; --s3: #3A3A3C;
  --t1: #fff; --t2: #EBEBF5; --t3: #8E8E93; --t4: #636366;
  --pink: #FF375F; --r: 14px;
  --sb: env(safe-area-inset-bottom, 0px);
  --st: env(safe-area-inset-top, 0px);
}

/* === Reset === */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
  background: var(--bg); color: var(--t1); min-height: 100dvh;
  overflow-x: hidden; transition: background .3s, color .3s;
}
a { text-decoration: none; color: inherit; }
img { display: block; }

/* === Header === */
.hdr {
  position: sticky; top: 0; z-index: 100; background: rgba(0,0,0,.85);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: calc(12px + var(--st)) 16px 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.08); transition: background .3s;
}
.hdr-top { display: flex; justify-content: space-between; align-items: center; }
.hdr h1 { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.hdr-date { font-size: 13px; color: var(--t3); font-weight: 500; margin-top: 2px; }
.theme-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--s2); display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: background .2s;
}
.theme-btn:hover { background: var(--s3); }

/* === Tabs === */
.tabs {
  display: flex; gap: 0; padding: 12px 0 0; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; padding: 8px 16px 12px; font-size: 15px; font-weight: 600;
  cursor: pointer; color: var(--t3); border: none;
  border-bottom: 2.5px solid transparent; background: none;
  white-space: nowrap; transition: all .2s;
}
.tab:hover { color: var(--t2); }
.tab.active { color: var(--pink); border-bottom-color: var(--pink); }

/* === Content === */
.cnt { padding: 0 0 100px; max-width: 900px; margin: 0 auto; }
.sh {
  font-size: 22px; font-weight: 700; color: var(--pink);
  padding: 24px 16px 10px; letter-spacing: -.3px;
}
.ss {
  font-size: 13px; color: var(--t3); font-weight: 600;
  padding: 20px 16px 10px; text-transform: uppercase; letter-spacing: .5px;
}

/* === Hero === */
.hero {
  position: relative; margin: 10px 16px; border-radius: var(--r);
  overflow: hidden; cursor: pointer; box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.hero img { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--s1); }
.hero-ov {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 80px 16px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
}
.hero-src {
  font-size: 11px; color: rgba(255,255,255,.7); font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 6px;
}
.hero-t {
  font-size: 22px; font-weight: 700; line-height: 1.22; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hero-m { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 8px; font-weight: 500; }
.hero-pills { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* === Pills === */
.pill {
  padding: 6px 14px; border-radius: 20px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.15); color: rgba(255,255,255,.9); cursor: pointer;
  border: none; white-space: nowrap; transition: all .15s; backdrop-filter: blur(8px);
}
.pill:hover { background: rgba(255,255,255,.25); }
.pill:active { transform: scale(.96); }

/* === Grid / Cards === */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 0 16px; margin-bottom: 10px;
}
.card {
  position: relative; border-radius: var(--r); overflow: hidden; background: var(--s1);
  cursor: pointer; transition: transform .12s; box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.card:active { transform: scale(.97); }
.card .ci { width: 100%; aspect-ratio: 3/2; object-fit: cover; background: var(--s2); }
.card-b { padding: 10px 12px 14px; }
.card-src {
  font-size: 10px; color: var(--t3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px;
}
.card-t {
  font-size: 14px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-pills { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.card-pills .pill {
  font-size: 10px; padding: 4px 10px;
  background: rgba(255,255,255,.08); color: var(--t2); backdrop-filter: none;
}

/* === Trending row === */
.trow {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 0 16px 4px; -webkit-overflow-scrolling: touch;
}
.trow::-webkit-scrollbar { display: none; }
.tchip {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  background: var(--s1); border-radius: 12px; padding: 12px 16px;
  cursor: pointer; border: 1px solid rgba(255,255,255,.06); transition: background .15s;
}
.tchip:hover { background: var(--s2); }
.tnum { font-size: 18px; font-weight: 800; color: var(--pink); font-variant-numeric: tabular-nums; }
.tlbl { font-size: 13px; font-weight: 600; white-space: nowrap; }
.tcnt { font-size: 10px; color: var(--t4); white-space: nowrap; }

/* === Horizontal scroll cards === */
.hscr {
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none;
  padding: 0 16px 4px; -webkit-overflow-scrolling: touch;
}
.hscr::-webkit-scrollbar { display: none; }
.hc {
  position: relative;
  flex-shrink: 0; width: 220px; border-radius: var(--r); overflow: hidden;
  background: var(--s1); cursor: pointer; transition: transform .12s;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.hc:active { transform: scale(.97); }
.hc img { width: 100%; aspect-ratio: 16/10; object-fit: cover; background: var(--s2); }
.hc-b { padding: 10px 12px; }
.hc-l {
  font-size: 10px; color: var(--pink); font-weight: 700;
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px;
}
.hc-t {
  font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.hc-m { font-size: 10px; color: var(--t4); margin-top: 4px; }

/* === List cards === */
.lc {
  position: relative;
  display: flex; gap: 12px; padding: 14px 16px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,.04); transition: background .12s;
}
.lc:hover { background: rgba(255,255,255,.03); }
.lc-b { flex: 1; min-width: 0; }
.lc-src {
  font-size: 10px; color: var(--t3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px;
}
.lc-t {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lc-tm { font-size: 11px; color: var(--t4); margin-top: 6px; }
.lc img {
  width: 88px; height: 88px; border-radius: 10px; object-fit: cover;
  flex-shrink: 0; background: var(--s2);
}

/* === Bottom nav === */
.bnav {
  position: fixed; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.92);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex; justify-content: space-around;
  padding: 8px 0 calc(8px + var(--sb));
  border-top: 1px solid rgba(255,255,255,.08); z-index: 100; transition: background .3s;
}
.ni {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; padding: 4px 16px; transition: opacity .15s;
}
.ni svg { width: 24px; height: 24px; }
.ni span { font-size: 10px; font-weight: 600; color: var(--t4); }
.ni.active svg { color: var(--pink); }
.ni.active span { color: var(--pink); }

/* === Toast === */
.tst {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--s2); color: var(--t1); padding: 12px 24px; border-radius: 20px;
  font-size: 13px; font-weight: 600; z-index: 400; opacity: 0;
  transition: opacity .3s; pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.tst.show { opacity: 1; }

/* === Shimmer === */
.shim {
  background: linear-gradient(90deg, var(--s1) 25%, var(--s2) 50%, var(--s1) 75%);
  background-size: 200% 100%; animation: sh 1.5s infinite; border-radius: var(--r);
}
@keyframes sh { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.ftn { text-align: center; padding: 24px; font-size: 11px; color: var(--t4); }

/* === Explore pills === */
.ex-pill {
  background: rgba(255,255,255,.1); color: var(--t2); cursor: pointer;
  padding: 6px 14px; font-size: 12px; border-radius: 20px;
  border: 1px solid rgba(255,255,255,.15);
}
.ex-pill.active { background: var(--ac); color: #fff; border-color: var(--ac); }

/* === AI Panel === */
.ai-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 500; opacity: 0;
  pointer-events: none; transition: opacity .25s;
}
.ai-overlay.show { opacity: 1; pointer-events: auto; }
.ai-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 501;
  background: var(--s1); border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(20px + var(--sb));
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
  max-width: 500px; margin: 0 auto; box-shadow: 0 -8px 40px rgba(0,0,0,.4);
  display: flex; flex-direction: column; max-height: 70vh;
}
.ai-panel.show { transform: translateY(0); }
.ai-handle {
  width: 36px; height: 4px; background: var(--s3); border-radius: 2px;
  margin: 0 auto 12px; flex-shrink: 0;
}
.ai-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-shrink: 0; }
.ai-logo {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #F48120, #F6821F);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.ai-title { font-size: 16px; font-weight: 700; }
.ai-close {
  margin-left: auto; background: none; border: none; color: var(--t3);
  font-size: 22px; cursor: pointer; padding: 4px 8px;
}
.ai-msgs {
  flex: 1; overflow-y: auto; margin-bottom: 12px; display: flex;
  flex-direction: column; gap: 10px; min-height: 100px; max-height: 50vh;
}
.ai-msg {
  padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5;
  max-width: 85%; word-wrap: break-word;
}
.ai-msg.user {
  background: var(--pink); color: #fff; align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  background: var(--s2); color: var(--t1); align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.ai-msg.typing { color: var(--t3); font-style: italic; }
.ai-input-row { display: flex; gap: 8px; flex-shrink: 0; }
.ai-input {
  flex: 1; background: var(--s2); border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px; padding: 12px 16px; font-size: 14px; color: var(--t1);
  outline: none; font-family: inherit;
}
.ai-input:focus { border-color: var(--pink); }
.ai-input::placeholder { color: var(--t4); }
.ai-send {
  background: linear-gradient(135deg, #F48120, #F6821F); color: #fff;
  border: none; border-radius: 12px; padding: 12px 16px; font-size: 14px;
  font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.ai-send:hover { opacity: .9; }
.ai-send:active { transform: scale(.97); }
.ai-send:disabled { opacity: .4; cursor: not-allowed; }

/* === AI Panel light overrides === */
body.light .ai-panel { background: #fff; box-shadow: 0 -8px 40px rgba(0,0,0,.15); }
body.light .ai-input { background: var(--s1); border-color: rgba(0,0,0,.08); }
body.light .ai-overlay { background: rgba(0,0,0,.3); }
body.light .ai-msg.bot { background: var(--s1); }

/* === Pill shimmer === */
.pill-shimmer {
  display: inline-block; width: 80px; height: 24px; border-radius: 20px;
  background: linear-gradient(90deg, rgba(255,255,255,.06) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.06) 75%);
  background-size: 200% 100%; animation: sh 1.5s infinite;
  vertical-align: middle; margin: 2px 4px;
}
body.light .pill-shimmer {
  background: linear-gradient(90deg, rgba(0,0,0,.04) 25%, rgba(0,0,0,.08) 50%, rgba(0,0,0,.04) 75%);
  background-size: 200% 100%; animation: sh 1.5s infinite;
}
.pill-fade { animation: pfade .3s ease-in; }
@keyframes pfade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Discover Card (Trending Feed) === */
.dcard {
  position: relative; margin: 0 16px 16px; border-radius: var(--r);
  overflow: hidden; background: var(--s1); cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,.15); transition: transform .12s;
}
.dcard:active { transform: scale(.98); }
.dcard img {
  width: 100%; aspect-ratio: 16/9; object-fit: cover; background: var(--s2);
  display: block;
}
.dcard-b { padding: 14px 16px 16px; }
.dcard-src {
  font-size: 11px; color: var(--t3); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.dcard-t {
  font-size: 17px; font-weight: 700; line-height: 1.3; color: var(--t1);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.dcard-pills { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.dcard-pills .pill {
  font-size: 10px; padding: 4px 10px;
  background: rgba(255,255,255,.08); color: var(--t2); backdrop-filter: none;
}
body.light .dcard { background: var(--s1); box-shadow: 0 2px 12px rgba(0,0,0,.08); }
body.light .dcard-pills .pill { background: rgba(0,0,0,.05); color: var(--t2); }

/* === Responsive === */
@media (max-width: 600px) {
  .hero img { aspect-ratio: 4/3; }
  .hero-t { font-size: 18px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .card .ci { aspect-ratio: 4/3; }
}
@media (min-width: 601px) and (max-width: 1024px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 1025px) {
  .grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .cnt { padding-left: calc(50% - 450px); padding-right: calc(50% - 450px); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .hero img { aspect-ratio: 21/9; }
  .hero-t { font-size: 16px; }
  .bnav { padding: 4px 0 calc(4px + var(--sb)); }
}
@media (min-width: 601px) and (orientation: landscape) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (min-width: 900px) and (orientation: landscape) {
  .grid { grid-template-columns: 1fr 1fr 1fr 1fr; }
}

/* === Bookmark Icon === */
.bm-icon {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4); border-radius: 50%; cursor: pointer;
  color: rgba(255,255,255,.85); transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.bm-icon:hover { background: rgba(0,0,0,.6); }
.bm-icon:active { transform: scale(.9); }
.bm-icon svg { width: 16px; height: 16px; }
.bm-icon.bm-saved { color: var(--pink); background: rgba(0,0,0,.5); }
body.light .bm-icon { background: rgba(255,255,255,.7); color: rgba(0,0,0,.6); }
body.light .bm-icon:hover { background: rgba(255,255,255,.9); }
body.light .bm-icon.bm-saved { color: var(--pink); background: rgba(255,255,255,.8); }
