:root{
  --bg:#0e1116;
  --panel:#131722;
  --card:#151a25;
  --line:#2a2e39;
  --text:#d1d4dc;
  --muted:#8f96a3;
  --blue:#2962ff;
  --green:#26a69a;
  --red:#ef5350;
  --shadow:0 10px 30px rgba(0,0,0,.45);
  --r:18px;
}

/* ===== THEMES ===== */
html[data-theme="darktv"]{
  --bg:#0e1116; --panel:#131722; --card:#151a25; --line:#2a2e39;
  --text:#d1d4dc; --muted:#8f96a3;
  --blue:#2962ff; --green:#26a69a; --red:#ef5350;
  --shadow:0 10px 30px rgba(0,0,0,.45);
}
html[data-theme="midnight"]{
  --bg:#0a0f1d; --panel:#0f172a; --card:#111c33; --line:#26334f;
  --text:#e5e7eb; --muted:#a3adc2;
  --blue:#5b8cff; --green:#2dd4bf; --red:#fb7185;
  --shadow:0 10px 30px rgba(0,0,0,.50);
}
html[data-theme="ocean"]{
  --bg:#061018; --panel:#071a24; --card:#0a2230; --line:#1b3a4a;
  --text:#e6f0f7; --muted:#9fb3c3;
  --blue:#38bdf8; --green:#34d399; --red:#fb7185;
  --shadow:0 10px 30px rgba(0,0,0,.50);
}
html[data-theme="semidark"]{
  --bg:#0b1020; --panel:#111827; --card:#131c2e; --line:#334155;
  --text:#e5e7eb; --muted:#a8b0bd;
  --blue:#2962ff; --green:#26a69a; --red:#ef5350;
  --shadow:0 10px 30px rgba(0,0,0,.45);
}
html[data-theme="semilight"]{
  --bg:#eef2ff; --panel:#f6f7fb; --card:#ffffff; --line:#d6dbe7;
  --text:#111827; --muted:#4b5563;
  --blue:#2962ff; --green:#1f9d8a; --red:#ef5350;
  --shadow:0 10px 30px rgba(0,0,0,.12);
}
html[data-theme="paper"]{
  --bg:#fbf7ef; --panel:#fffaf0; --card:#ffffff; --line:#e7dcc8;
  --text:#1f2937; --muted:#5b6472;
  --blue:#2457ff; --green:#0f9d87; --red:#d94b4b;
  --shadow:0 10px 30px rgba(0,0,0,.10);
}
html[data-theme="light"]{
  --bg:#f5f7fb; --panel:#ffffff; --card:#ffffff; --line:#e5e7eb;
  --text:#111827; --muted:#4b5563;
  --blue:#2962ff; --green:#1f9d8a; --red:#ef5350;
  --shadow:0 10px 30px rgba(0,0,0,.12);
}

/* ===== Base ===== */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:var(--bg);
  color:var(--text);
}
a{color:inherit}
.wrap{max-width:1100px;margin:0 auto;padding:0 18px}
.muted{color:var(--muted)}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace}

/* Header */
.top{
  position:sticky;top:0;z-index:20;
  background:var(--panel);
  border-bottom:1px solid var(--line);
}
.top .wrap{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 18px;
  gap:12px;
}
.brand{display:flex;gap:12px;align-items:center}
.logo{
  width:42px;height:42px;border-radius:14px;
  display:grid;place-items:center;
  background: linear-gradient(135deg, rgba(41,98,255,.22), rgba(38,166,154,.14));
  border:1px solid var(--line);
  box-shadow: var(--shadow);
  font-weight:800;
}
.title{font-weight:800;letter-spacing:.2px}
.subtitle{font-size:12px;color:var(--muted);margin-top:2px}

.nav{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.nav a{
  padding:8px 10px;border-radius:12px;
  text-decoration:none;
  opacity:.9;
}
.nav a:hover{background:rgba(255,255,255,.06);opacity:1}

.themeSelect{
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  cursor:pointer;
  font-size:13px;
}

/* Buttons / inputs */
.btn{
  border:1px solid var(--line);
  background:rgba(41,98,255,.12);
  color:var(--text);
  padding:12px 14px;
  border-radius:14px;
  cursor:pointer;
}
.btn.secondary{background:rgba(255,255,255,.04)}
.btn:hover{filter:brightness(1.10)}
.smallBtn{
  padding:8px 10px;border-radius:12px;cursor:pointer;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--text);
  font-size:13px;
}
.smallBtn:hover{filter:brightness(1.08)}
input[type="search"], input[type="text"], select{
  background:var(--card);
  border:1px solid var(--line);
  color:var(--text);
  padding:12px 12px;
  border-radius:14px;
  outline:none;
}

/* Layout */
.hero{
  display:grid;
  grid-template-columns: 1.35fr .85fr;
  gap:16px;
  padding:24px 0 8px;
}
.hero h1{margin:0 0 8px;font-size:40px;line-height:1.05}
.hero p{margin:0;color:var(--muted);max-width:62ch}

.searchRow{
  margin-top:16px;
  display:flex;gap:10px;flex-wrap:wrap;
}
.chips{margin-top:10px;display:flex;gap:8px;flex-wrap:wrap}
.chip{
  font-size:12px;
  padding:7px 10px;border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--muted);
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  padding:16px;
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  gap:10px;
}
.cardHead{display:flex;align-items:center;justify-content:space-between}
.cardTitle{font-weight:700}
.badge{
  font-size:12px;padding:6px 10px;border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--muted);
}

.section{padding:22px 0}
.sectionHead{display:flex;align-items:end;justify-content:space-between;gap:12px;flex-wrap:wrap}
.sectionHead h2{margin:0}
.sectionHead p{margin:0}

.grid{
  margin-top:14px;
  display:grid;
  grid-template-columns: repeat(4,1fr);
  gap:12px;
}
.tile{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  padding:14px;
}
.step{
  width:34px;height:34px;border-radius:12px;
  display:grid;place-items:center;
  background: rgba(41,98,255,.12);
  border:1px solid var(--line);
  font-weight:800;
}
.tile h3{margin:10px 0 8px}
.tile ul{margin:0;padding-left:18px;color:var(--muted)}
.tile li{margin:6px 0}

.list{
  margin-top:14px;
  display:grid;
  grid-template-columns: repeat(2,1fr);
  gap:12px;
}
.item{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  padding:14px;
  box-shadow: var(--shadow);
}
.itemTop{display:flex;align-items:start;justify-content:space-between;gap:10px}
.item h4{margin:0;font-size:16px}
.tag{
  font-size:12px;
  padding:6px 10px;border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--muted);
  white-space:nowrap;
}
.item p{margin:10px 0 0;color:var(--muted);line-height:1.6}
.example{margin-top:10px;padding:10px;border-radius:14px;border:1px dashed rgba(255,255,255,.18);color:rgba(233,238,252,.82);font-size:13px}
.actions{margin-top:12px;display:flex;gap:10px;flex-wrap:wrap}
.star.on{
  background: rgba(38,166,154,.14);
  border-color: rgba(38,166,154,.45);
}

/* Watched */
.watchedBadge{
  font-size:12px;
  padding:6px 10px;border-radius:999px;
  border:1px solid rgba(38,166,154,.45);
  background: rgba(38,166,154,.12);
  color: var(--text);
  white-space:nowrap;
}
.watchedRow{
  margin-top:10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.08);
}
.watchToggle{
  display:flex; align-items:center; gap:8px;
  font-size:13px;
  color: var(--muted);
}
.watchToggle input{ width:18px; height:18px; }

/* News */
.newsList{
  margin-top:14px;
  display:grid;
  grid-template-columns: repeat(2,1fr);
  gap:12px;
}
.newsItem{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  padding:14px;
  box-shadow: var(--shadow);
}
.newsTitle{
  margin:0;
  font-size:15px;
  line-height:1.35;
  color: var(--text);
  text-decoration: underline;  /* requested */
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.newsTitle:hover{ color: rgba(41,98,255,.95); }
.newsMeta{margin-top:10px;display:flex;gap:8px;flex-wrap:wrap}
.pill{
  font-size:12px;padding:6px 10px;border-radius:999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
  color:var(--muted);
}

/* Library (book style) */
.libGrid{
  margin-top:14px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:12px;
}
.book{
  background: var(--card);
  border:1px solid var(--line);
  border-radius: var(--r);
  overflow:hidden;
  box-shadow: var(--shadow);
}
.bookTop{
  padding:14px 14px 12px;
  border-bottom:1px solid rgba(255,255,255,.08);
  background: rgba(41,98,255,.08);
}
.bookTitle{margin:0;font-size:16px;font-weight:800}
.bookMeta{margin-top:6px;display:flex;gap:8px;flex-wrap:wrap}
.bookBody{padding:14px}
.bookText{
  margin:0;color:var(--muted);line-height:1.65;
  display:-webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow:hidden;
}
.bookActions{margin-top:12px;display:flex;gap:10px;flex-wrap:wrap}

/* Modal + markdown */
.modalOverlay{
  position:fixed;inset:0;z-index:50;
  background: rgba(0,0,0,.62);
  display:none;align-items:center;justify-content:center;
  padding:18px;
}
.modal{
  width:min(960px, 100%);
  max-height: min(85vh, 900px);
  overflow:auto;
  background: var(--panel);
  border:1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.modalHead{
  position:sticky;top:0;
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:14px 16px;
  border-bottom:1px solid rgba(255,255,255,.10);
  background: var(--panel);
}
.modalTitle{margin:0;font-size:16px;font-weight:800}
.modalBody{padding:16px}
.md code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  padding:2px 6px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.04);
}
.md a{ color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.md a:hover{ filter:brightness(1.15); }
.mdH1{ margin:0 0 12px; font-size:22px; }
.mdH2{ margin:16px 0 10px; font-size:18px; }
.mdH3{ margin:14px 0 8px; font-size:16px; }
.mdP{ margin:0 0 12px; color: var(--text); opacity:.92; line-height:1.85; }
.mdUl{ margin:0 0 14px 18px; color: var(--text); opacity:.92; line-height:1.85; }
.mdSpace{ height:6px; }

/* Empty / footer */
.empty{
  margin-top:14px;
  padding:16px;
  border:1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255,255,255,.03);
  color:var(--muted);
}
.hidden{display:none}
.footer{padding:24px 0 36px;font-size:13px;text-align:center;color:var(--muted)}

/* Scroll to top */
#toTop{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:60;
  display:none;
  padding:10px 12px;
  border-radius:14px;
  border:1px solid var(--line);
  background: rgba(41,98,255,.14);
  color: var(--text);
  cursor:pointer;
  box-shadow: var(--shadow);
}
#toTop:hover{filter:brightness(1.12)}

/* Responsive */
@media (max-width: 980px){
  .hero{grid-template-columns:1fr}
  .grid{grid-template-columns:repeat(2,1fr)}
  .list{grid-template-columns:1fr}
  .newsList{grid-template-columns:1fr}
  .libGrid{grid-template-columns:1fr}
  .hero h1{font-size:34px}
}
