/* ═══════════════════════════════════════════════
   Feed · nijikit — iOS-style mobile-first
   ═══════════════════════════════════════════════ */

:root {
  --bg: #000000;
  --bg-card: #1c1c1e;
  --bg-card-2: #2c2c2e;
  --bg-elev: #1c1c1e;
  --separator: #38383a;
  --separator-opaque: #2c2c2e;
  --text: #ffffff;
  --text-2: rgba(235,235,245,0.85);
  --text-3: rgba(235,235,245,0.5);
  --text-4: rgba(235,235,245,0.3);
  --accent: #0a84ff;
  --yt: #ff3b30;
  --x: #5ac8fa;
  --daily: #bf5af2;
  --green: #30d158;
  --orange: #ff9500;
  --fill: rgba(120,120,128,0.12);
  --fill-hover: rgba(120,120,128,0.24);
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, 'Inter', 'Noto Sans SC', 'Noto Sans JP', system-ui, sans-serif;
  --mono: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --transition: 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
*::-webkit-scrollbar { width: 0; height: 0; }

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }

/* ── App Container ─────────────────────────── */

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ── Top Bar ───────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 8px) 16px 6px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid transparent;
  transition: border-color var(--transition);
}

.topbar.scrolled {
  border-bottom-color: var(--separator-opaque);
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  -webkit-touch-callout: none;
}

.icon-btn:active {
  background: var(--fill);
  color: var(--text-3);
}

/* ── Search Bar ────────────────────────────── */

.search-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 8px;
  background: rgba(0,0,0,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator-opaque);
}

.search-bar.show { display: flex; }

.search-bar input {
  flex: 1;
  padding: 7px 12px;
  background: var(--fill);
  border: none;
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: var(--font);
}

.search-bar input::placeholder { color: var(--text-3); }

.search-cancel {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  font-weight: 400;
  padding: 4px 4px 4px 8px;
  flex-shrink: 0;
}

/* ── Segmented Control ─────────────────────── */

.segmented {
  display: flex;
  margin: 12px 16px 0;
  background: var(--fill);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.seg-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 4px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.seg-item:active {
  background: var(--fill-hover);
}

.seg-item.active {
  background: var(--bg-card-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.seg-item svg { flex-shrink: 0; }

.seg-item[data-tab="youtube"].active svg { color: var(--yt); }
.seg-item[data-tab="twitter"].active svg { color: var(--x); }
.seg-item[data-tab="daily"].active svg { color: var(--daily); }

/* ── Date Strip ────────────────────────────── */

.date-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 16px 2px;
}

.date-arrow {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.date-arrow:active { background: var(--fill); color: var(--text); }
.date-arrow:disabled { opacity: 0.25; pointer-events: none; }

.date-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-family: var(--mono);
  min-width: 70px;
  text-align: center;
}

/* ── Content ──────────────────────────────── */

.content {
  padding: 8px 16px 24px;
}

/* ── YouTube Cards ────────────────────────── */

.yt-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
  transition: transform 0.15s ease;
}

.yt-card:active { transform: scale(0.985); }

.yt-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-card-2);
  overflow: hidden;
}

.yt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.yt-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  letter-spacing: 0.2px;
}

.yt-badge-live { background: rgba(255,59,48,0.92); color: #fff; }
.yt-badge-upcoming { background: rgba(255,149,0,0.92); color: #fff; }
.yt-badge-video { background: rgba(0,0,0,0.72); color: #fff; }

.yt-body { padding: 12px 14px 14px; }

.yt-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-channel {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 8px;
}

.yt-channel-name { color: var(--yt); font-weight: 500; }

.yt-ai {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--fill);
  border-radius: 8px;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-4);
  font-family: var(--mono);
}

.yt-meta-item {
  display: flex;
  align-items: center;
  gap: 3px;
}

.yt-go {
  margin-left: auto;
  color: var(--accent);
  font-weight: 500;
  font-size: 13px;
}

/* ── X / Twitter Cards ─────────────────────── */

.x-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.x-card:active { transform: scale(0.985); }

.x-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 8px;
}

.x-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.x-info { flex: 1; min-width: 0; }

.x-title {
  font-size: 14px;
  font-weight: 600;
}

.x-subtitle {
  font-size: 12px;
  color: var(--text-3);
  font-family: var(--mono);
}

.x-window {
  flex-shrink: 0;
  padding: 2px 8px;
  background: rgba(90,200,250,0.15);
  border-radius: 6px;
  font-size: 11px;
  color: var(--x);
  font-weight: 600;
  font-family: var(--mono);
}

.x-summary {
  padding: 0 14px 8px;
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.4;
}

.x-entries {
  padding: 0 14px;
  border-top: 0.5px solid var(--separator);
}

.x-entry {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--separator-opaque);
}

.x-entry:last-child { border-bottom: none; }

.x-entry-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(90,200,250,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--x);
  font-family: var(--mono);
  margin-top: 1px;
}

.x-entry-body { flex: 1; min-width: 0; }

.x-entry-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 1px;
}

.x-entry-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.45;
  word-break: break-word;
}

.x-entry-link {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--accent);
  opacity: 0.75;
  font-family: var(--mono);
}

.x-entry-link:active { opacity: 1; }

.x-footer {
  display: flex;
  gap: 12px;
  padding: 8px 14px 12px;
  border-top: 0.5px solid var(--separator);
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--mono);
}

/* ── Daily Cards ──────────────────────────── */

.daily-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 12px;
}

.daily-card:active { transform: scale(0.985); }

.daily-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 14px 12px;
  background: linear-gradient(135deg, rgba(191,90,242,0.08), transparent 60%);
}

.daily-date-big {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1;
}

.daily-month {
  font-size: 12px;
  color: var(--daily);
  font-weight: 600;
  margin-top: 2px;
}

.daily-stats-row {
  margin-left: auto;
  display: flex;
  gap: 14px;
}

.daily-stat { text-align: right; }
.daily-stat-n { font-size: 18px; font-weight: 700; font-family: var(--mono); color: var(--daily); }
.daily-stat-l { font-size: 10px; color: var(--text-4); }

.daily-items { padding: 0 14px; }

.daily-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--separator-opaque);
}

.daily-item:last-child { border-bottom: none; }

.daily-src {
  font-size: 12px;
  font-weight: 600;
  color: var(--daily);
  flex-shrink: 0;
  width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daily-item-title {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.4;
  flex: 1;
}

.daily-item-arrow {
  flex-shrink: 0;
  color: var(--text-4);
  margin-top: 1px;
}

.daily-foot {
  padding: 8px 14px 12px;
  border-top: 0.5px solid var(--separator);
  font-size: 11px;
  color: var(--text-4);
  font-family: var(--mono);
  display: flex;
  gap: 12px;
}

/* ── Empty ────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--text-4);
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: 3px;
}

.empty-sub {
  font-size: 13px;
  color: var(--text-4);
}

/* ── Loading ──────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--fill);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Safe Area ────────────────────────────── */

.safe-area-bottom { height: calc(var(--safe-bottom) + 20px); }

/* ── Desktop ──────────────────────────────── */

@media (min-width: 481px) {
  #app {
    max-width: 480px;
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
    min-height: 100vh;
  }
  body {
    background: #0a0a0c;
    display: flex;
    justify-content: center;
  }
}
