/* Modern light theme — sans-serif bersih, aksen indigo tunggal, shadow lembut, segmented tabs. */
:root {
  --bg: #f7f7fb;
  --panel: #ffffff;
  --panel-2: #f1f1f8;
  --text: #16161f;
  --muted: #6b7085;
  --border: #e7e7f1;
  --accent: #f97316;      /* oranye — aksen utama, link, tombol, badge */
  --accent-2: #c2410c;    /* oranye gelap — hover/active */
  --info: #0ea5e9;        /* biru — status netral (terkirim, dsb) */
  --success: #16a34a;     /* hijau — state aktif/on */
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --panel: #131a2e;
    --panel-2: #1a2338;
    --text: #e9ecf5;
    --muted: #8a92ab;
    --border: #232c46;
    --accent: #fb923c;
    --accent-2: #fdba74;
    --info: #38bdf8;
    --success: #34d399;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 3rem;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: .85rem 1rem;
  padding-top: max(.85rem, env(safe-area-inset-top));
}
.header-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.02rem; min-width: 0; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0; box-shadow: var(--shadow); }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.link-btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: .55rem .9rem; border-radius: 999px; font-size: .8rem; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  min-height: 40px; white-space: nowrap;
}
.link-btn:hover { border-color: var(--accent); color: var(--accent); }

#subscribeBtn {
  border: none; border-radius: 999px; padding: .6rem 1.05rem; font-size: .82rem; font-weight: 700;
  cursor: pointer; background: var(--accent); color: #fff; transition: transform .15s ease, opacity .15s ease;
  min-height: 40px; flex-shrink: 0; white-space: nowrap; box-shadow: var(--shadow);
}
#subscribeBtn:active { transform: scale(.96); }
#subscribeBtn[data-state="on"] { background: var(--success); }
#subscribeBtn:disabled { opacity: .5; cursor: default; }

main { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem; }
.eyebrow {
  font-size: .74rem; font-weight: 700; color: var(--accent); text-transform: uppercase;
  letter-spacing: .05em; margin: 0 0 .6rem;
}
.status-line {
  color: var(--muted); font-size: .78rem; margin: .25rem 0 1.1rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  min-height: 1.1em; /* reservasi tinggi supaya teks status tidak geser konten di bawahnya */
}

/* Segmented control ala aplikasi modern — track abu lembut, pill aktif putih + shadow. */
.tabs {
  display: inline-flex; gap: 2px; margin-bottom: 1.1rem; flex-wrap: wrap;
  background: var(--panel-2); padding: 4px; border-radius: 999px; border: 1px solid var(--border);
}
.tabs button {
  border: none; background: transparent; color: var(--muted);
  padding: .5rem .95rem; border-radius: 999px; font-size: .8rem; font-weight: 600; cursor: pointer;
  min-height: 36px;
}
.tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.tabs[aria-busy="true"] { opacity: .6; pointer-events: none; }

#list { min-height: 60vh; } /* reservasi tinggi area list supaya footer/scroll tidak "lompat" saat data pertama kali masuk */

.story {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.1rem; margin-bottom: 1rem; display: flex; gap: 1rem;
}
.story-thumb {
  width: 80px; height: 80px; object-fit: cover; border-radius: 14px; flex-shrink: 0;
  background: var(--panel-2);
}
.story-body { flex: 1; min-width: 0; }
.story-title {
  font-weight: 800; font-size: 1.02rem; margin: 0 0 .4rem; line-height: 1.35;
  word-break: break-word; letter-spacing: -.01em;
}
.story-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; font-size: .76rem; color: var(--muted); margin-bottom: .65rem; }
.traffic-badge {
  background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-2);
  padding: .2rem .6rem; border-radius: 999px; font-weight: 700; font-size: .72rem; white-space: nowrap;
}
.sent-badge {
  background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info);
  padding: .2rem .6rem; border-radius: 999px; font-weight: 700; font-size: .7rem; white-space: nowrap;
}
.status-badge.fail {
  background: var(--panel-2); color: var(--muted);
  padding: .2rem .6rem; border-radius: 999px; font-weight: 600; font-size: .7rem; white-space: nowrap;
}
.related { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .7rem; }
.related span {
  font-size: .7rem; color: var(--muted); background: var(--panel-2); padding: .2rem .6rem; border-radius: 999px;
  word-break: break-word;
}

.section-label {
  margin: 0 0 .55rem; font-size: .7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.articles-list { display: flex; flex-direction: column; gap: .6rem; border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .1rem; }
.article-item {
  display: flex; gap: .65rem; text-decoration: none; color: inherit; align-items: flex-start;
  padding: .4rem; margin: -.4rem; border-radius: 12px; transition: background .15s ease;
}
.article-item:hover { background: var(--panel-2); }
.article-thumb {
  width: 46px; height: 46px; object-fit: cover; border-radius: 10px; flex-shrink: 0; background: var(--panel-2);
}
.article-text { min-width: 0; flex: 1; }
.article-title {
  display: block; font-size: .82rem; font-weight: 600; color: var(--text); line-height: 1.4;
  word-break: break-word;
}
.article-item:hover .article-title { color: var(--accent-2); }
.article-source { display: block; font-size: .71rem; color: var(--muted); margin-top: .2rem; }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; font-size: .9rem; }

.skeleton {
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 1.1rem; margin-bottom: 1rem; display: flex; gap: 1rem; height: 112px;
}
.skeleton .sk-thumb { width: 80px; height: 80px; border-radius: 14px; flex-shrink: 0; }
.skeleton .sk-lines { flex: 1; display: flex; flex-direction: column; gap: .55rem; padding-top: .25rem; }
.sk-block, .sk-thumb {
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--border) 50%, var(--panel-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 6px;
}
.sk-block.w1 { width: 70%; height: 15px; }
.sk-block.w2 { width: 45%; height: 11px; }
.sk-block.w3 { width: 90%; height: 11px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .sk-block, .sk-thumb { animation: none; }
}

.news-section { border-top: 1px solid var(--border); padding-top: .75rem; margin-top: .75rem; }
.news-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  flex-wrap: wrap; margin-bottom: .55rem;
}
.news-heading { margin: 0; }
.news-when-tabs {
  display: inline-flex; gap: 2px; background: var(--panel-2); padding: 3px; border-radius: 999px;
}
.news-when-tabs button {
  border: none; background: transparent; color: var(--muted);
  padding: .22rem .6rem; border-radius: 999px; font-size: .68rem; font-weight: 600; cursor: pointer;
}
.news-when-tabs button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.news-results { display: flex; flex-direction: column; gap: .6rem; }
.news-loading, .news-empty { font-size: .76rem; color: var(--muted); padding: .1rem 0; }

.toast {
  position: fixed; left: 50%; bottom: max(1.25rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); border: 1px solid var(--text); color: var(--bg);
  padding: .7rem 1.1rem; border-radius: 12px; font-size: .82rem; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease; max-width: 90vw; z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 380px) {
  .story-thumb { width: 64px; height: 64px; }
  .article-thumb { width: 40px; height: 40px; }
  .story-title { font-size: .96rem; }
}
