/* neta · story arcade — Instagram-style dark skin
   Layout metrics (grid columns, breakpoints, gaps, sticky offsets,
   aspect ratios, sheet sizing) are unchanged — visual layer only. */

:root {
  --bg: #000000;
  --bg-2: #0a0a0a;
  --panel: #121212;
  --panel-2: #181818;
  --line: #262626;                 /* hairline */
  --line-2: #3a3a3a;
  --text: #f5f5f5;
  --text-dim: #a8a8a8;
  --text-faint: #737373;
  /* Instagram brand gradient family */
  --ig-orange: #f58529;
  --ig-pink: #dd2a7b;
  --ig-purple: #8134af;
  --ig-blue: #515bd4;
  --grad: linear-gradient(92deg, #f58529 0%, #dd2a7b 38%, #8134af 74%, #515bd4 100%);
  --nav-h: 58px;
}

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

html, body {
  min-height: 100%;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, 'PingFang SC', sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ============ top nav ============ */
.topnav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  min-height: var(--nav-h);
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.brand-logo {
  height: 24px;
  width: auto;
  opacity: 0.95;
}

.topnav-search {
  flex: 0 1 340px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px; padding: 0 14px 0 10px;
  height: 36px;
  margin-left: 8px;
  min-width: 0;
}
.topnav-search:focus-within { border-color: var(--line-2); }
.search-toggle, .search-close {
  appearance: none; background: none; border: 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); cursor: pointer; flex: 0 0 auto;
}
.search-toggle { width: 22px; height: 22px; cursor: default; }
.search-close { display: none; width: 22px; height: 22px; font-size: 13px; }
.search-close:hover { color: var(--text); }
.topnav-search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 13.5px;
}
.topnav-search input::placeholder { color: var(--text-faint); }
.topnav-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.nav-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.nav-discord {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  color: #f5f5f5;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  flex: 0 0 auto;
  transition: color 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}
.nav-discord svg { width: 22px; height: 22px; display: block; fill: currentColor; }
.nav-discord:hover,
.nav-discord:focus-visible {
  color: #ffffff;
  background: var(--panel);
  border-color: var(--line);
  outline: none;
}
/* Discord entry hidden for now — restore by deleting this rule */
.nav-discord { display: none; }

/* mobile: search collapses to an icon, expands over the nav on tap */
@media (max-width: 640px) {
  .topnav { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); gap: 8px; }
  .topnav-search {
    flex: 0 0 auto; margin-left: auto;
    width: 34px; padding: 0;
    justify-content: center;
    background: transparent; border-color: transparent;
  }
  .topnav-search input { display: none; }
  .search-toggle { width: 32px; height: 34px; color: var(--text); cursor: pointer; border-radius: 8px; }
  .search-toggle:active { background: var(--panel); }
  .nav-actions { margin-left: 0; gap: 6px; }
  .nav-actions .btn { padding: 7px 11px; font-size: 12.5px; }

  .topnav.search-open .brand,
  .topnav.search-open .nav-actions { display: none; }
  .topnav.search-open .topnav-search {
    flex: 1 1 auto; width: auto; margin-left: 0;
    justify-content: flex-start; padding: 0 10px;
    background: var(--panel); border-color: var(--line-2);
  }
  .topnav.search-open .search-toggle { width: 22px; height: 22px; color: var(--text-faint); pointer-events: none; }
  .topnav.search-open .topnav-search input { display: block; }
  .topnav.search-open .search-close { display: flex; }
}

/* ≤480px: compact single-row header — with the Discord icon hidden this fits
   down to ~345px with real slack (measured, not guessed). */
@media (max-width: 480px) {
  .topnav { padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); gap: 6px; }
  .brand-logo { height: 18px; }
  .topnav-search { width: 30px; }
  .search-toggle { width: 28px; height: 32px; }
  .nav-actions .btn { padding: 7px 9px; font-size: 12px; }
}

/* ≤359px: one row cannot hold brand + search + both buttons — wrap the two
   buttons onto their own full-width row so nothing is ever clipped.
   --nav-h is kept in sync with the real header height by the script in index.html. */
@media (max-width: 359px) {
  .topnav { flex-wrap: wrap; row-gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .brand { order: 1; }
  .topnav-search { order: 2; margin-left: auto; }
  .nav-actions { order: 3; flex: 1 1 100%; margin-left: 0; gap: 6px; }
  .nav-actions .btn { flex: 1 1 0; justify-content: center; }
}

.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 8px 16px; border-radius: 8px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; text-align: center;
  transition: transform 0.1s ease, filter 0.12s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--grad); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line-2); }
.btn-ghost:hover { background: var(--panel); }

/* ============ tabs row ============ */
.tabsrow {
  position: sticky; top: var(--nav-h); z-index: 49;
  display: flex; align-items: center; gap: 4px;
  padding: 10px 24px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-faint);
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: #000; background: #fff; font-weight: 700; }

/* ============ page + grid ============ */
.page { max-width: 1440px; margin: 0 auto; padding: 18px 24px 40px; }

.grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
@media (max-width: 1280px) { .grid { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 1024px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 780px)  { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px)  { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* hero banner on For You */
.banner {
  grid-column: 1 / -1;
  position: relative; border-radius: 8px; overflow: hidden;
  aspect-ratio: 6 / 1; min-height: 140px; max-height: 300px;
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.banner img, .banner-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-video { background: #000; }
.banner::after {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.18) 55%, rgba(0,0,0,0.05) 100%);
}
.carousel { position: absolute; inset: 0; }
.carousel-slide {
  position: absolute; inset: 0;
  opacity: 0; visibility: hidden;
  transition: opacity 0.6s ease;
}
.carousel-slide.active { opacity: 1; visibility: visible; }
.carousel-slide video { position: absolute; inset: 0; }
.banner-copy { position: absolute; left: 34px; top: 50%; transform: translateY(-50%); z-index: 2; max-width: 560px; }
.banner-badge {
  position: absolute; right: 16px; top: 14px; z-index: 2;
  font-size: 10px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase;
  color: #fff; background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.35);
  padding: 4px 10px; border-radius: 999px;
  pointer-events: none;
}
.banner-dots {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 3;
  display: flex; gap: 6px;
}
.banner-dots .dot {
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.4); cursor: pointer;
  transition: all 0.2s ease;
}
.banner-dots .dot.active { background: #fff; width: 18px; border-radius: 999px; }
.banner-kicker {
  font-size: 11px; letter-spacing: 1.8px; text-transform: uppercase; font-weight: 700;
  color: var(--text-dim);
}
.banner-title { font-size: clamp(20px, 2.6vw, 34px); font-weight: 800; letter-spacing: -0.6px; line-height: 1.1; margin: 8px 0 8px; }
.banner-sub { font-size: clamp(12px, 1.2vw, 14.5px); color: var(--text-dim); line-height: 1.5; font-weight: 400; }
@media (max-width: 560px) {
  .banner { aspect-ratio: 16 / 9; }
  .banner-copy { left: 18px; right: 18px; }
}

/* ============ card ============ */
.card {
  position: relative; border-radius: 8px; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.16s ease;
}
.card:hover { border-color: var(--line-2); }
.card:active { transform: scale(0.99); }
.card-img {
  width: 100%; aspect-ratio: 5 / 7; object-fit: cover; display: block;
  background: var(--panel-2);
}
.card-shade {
  position: absolute; left: 0; right: 0; bottom: 0; height: 62%;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.82) 78%);
  pointer-events: none;
}
.card-inner { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 11px 10px; }
.badges { display: flex; gap: 6px; margin-bottom: 6px; }
.badge {
  font-size: 9.5px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 2.5px 8px; border-radius: 999px;
}
.badge-soon { color: #fff; background: rgba(0, 0, 0, 0.45); }
.card-title {
  font-size: 15px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.card-desc {
  font-size: 11.8px; color: #c7c7c7; line-height: 1.42; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-author { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; min-width: 0; }
.card-handle { font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-count { margin-left: auto; font-size: 10.5px; color: var(--text-faint); white-space: nowrap; display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
@media (max-width: 560px) {
  .card-title { font-size: 13px; }
  .card-desc { font-size: 10.8px; }
  .card-inner { padding: 8px 9px 9px; }
}

/* ============ detail modal ============ */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: min(430px, calc(100vw - 32px));
  max-height: min(86dvh, 780px); overflow-y: auto; scrollbar-width: none;
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid var(--line-2);
  transform: translateY(16px) scale(0.98);
  transition: transform 0.22s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.8);
}
.sheet::-webkit-scrollbar { display: none; }
.overlay.open .sheet { transform: translateY(0) scale(1); }
.sheet-hero { position: relative; aspect-ratio: 4 / 3; overflow: hidden; border-radius: 20px 20px 0 0; }
.sheet-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--panel) 100%); }
.sheet-close {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.6); border: 1px solid var(--line-2);
  color: #fff; font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
}
.sheet-body { position: relative; margin-top: -52px; z-index: 2; padding: 0 22px 26px; }
.sheet-kicker { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sheet-kicker .card-count { color: var(--text-faint); }
.sheet-title { font-size: 25px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.15; }
.sheet-li { color: var(--text-dim); font-weight: 600; font-size: 14px; margin-top: 4px; }
.sheet-premise { color: var(--text-dim); font-size: 14px; line-height: 1.6; margin-top: 12px; }
.sheet-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tag {
  font-size: 11px; color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px;
}
.sheet-endings {
  margin-top: 16px; padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
}
.sheet-endings h4 { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-faint); font-weight: 600; margin-bottom: 6px; }
.sheet-endings p { font-size: 13px; color: var(--text-dim); line-height: 1.55; }
.sheet-note {
  margin-top: 16px; font-size: 12.5px; color: var(--text-faint); line-height: 1.55;
  padding: 10px 14px; border-left: 2px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
}
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; justify-content: center; padding: 13px; font-size: 14.5px; border-radius: 10px; }

/* ============ footer ============ */
.foot {
  max-width: 1440px; margin: 0 auto;
  padding: 22px 24px 34px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--text-faint);
}
.foot a { color: var(--text-faint); text-decoration: none; }
.foot a:hover { color: var(--text); }
.foot-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-faint);
}
.foot-logo {
  height: 16px;
  width: auto;
  opacity: 0.7;
}
.foot-right { margin-left: auto; }

.empty { grid-column: 1 / -1; text-align: center; color: var(--text-faint); padding: 70px 0; font-size: 14px; }

/* chips row (tag filter) */
.chipsrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chipsrow::-webkit-scrollbar { display: none; }
.chip {
  appearance: none; cursor: pointer;
  min-height: 32px;
  font: inherit; font-size: 12px; font-weight: 500;
  line-height: 1.2;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; white-space: nowrap;
  transition: all 0.15s ease;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.active {
  background: #fff; border-color: #fff; color: #000; font-weight: 700;
}

/* ============ 认证相关样式 ============ */

/* 认证状态指示器 */
.auth-indicator {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.auth-status {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.auth-status.auth-ok {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.auth-status.auth-ok:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
}

.auth-status.auth-none {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* 认证弹窗 */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 32px;
  animation: slideUp 0.3s ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

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

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo {
  height: 32px;
  width: auto;
  margin-bottom: 16px;
  opacity: 0.95;
}

.auth-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.auth-body {
  margin-bottom: 24px;
}

.auth-body p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.auth-body p:last-child {
  margin-bottom: 0;
}

.auth-note {
  font-size: 13px;
  color: var(--text-faint);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
}

/* 移动端适配 */
@media (max-width: 640px) {
  .auth-indicator {
    display: none;
  }
  
  .auth-dialog {
    padding: 24px;
    max-width: 90%;
  }
  
  .auth-header h2 {
    font-size: 18px;
  }
  
  .auth-body p {
    font-size: 13px;
  }
}

/* 认证加载状态 */
.auth-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.auth-loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 2px solid var(--line);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
