:root {
  --bg: #0a0a0f;
  --bg2: #121218;
  --card: #17171f;
  --text: #f0f0f5;
  --muted: #9a9aad;
  --accent: #7c5cff;
  --accent-d: #5b3df0;
  --border: #23232e;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding-bottom: 70px; min-height: 100vh;
}
body.reading { padding-bottom: 0; }
body.reading .topbar, body.reading .bottomnav { display: none; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }

/* ===== TOPBAR ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10,10,15,.95); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); padding: 10px 14px;
}
.logo { font-size: 1.35rem; font-weight: 900; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.logo span { color: var(--accent); }
.logo-img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--accent); }
.top-actions { position: absolute; right: 12px; top: 8px; display: flex; gap: 6px; }
.icon-btn {
  background: none; border: none; font-size: 1.25rem; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; color: var(--text);
}
.icon-btn:active { background: var(--bg2); }
.searchbar { display: flex; gap: 8px; margin-top: 10px; }
.searchbar input {
  flex: 1; padding: 10px 14px; border-radius: 8px;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  font-size: .95rem; outline: none;
}
.searchbar input:focus { border-color: var(--accent); }
.searchbar button {
  padding: 10px 18px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 700; cursor: pointer;
}

/* ===== MAIN ===== */
#app { max-width: 900px; margin: 0 auto; }
.loading { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.sec { padding: 14px 14px 4px; }
.sec-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.viewtoggle { display: inline-flex; background: var(--bg2); border-radius: 8px; overflow: hidden; }
.viewtoggle button {
  border: none; background: none; color: var(--muted);
  font-size: 1rem; padding: 6px 12px; cursor: pointer;
}
.viewtoggle button.on { background: var(--accent); color: #fff; }

/* update grid ala shinigami */
.updgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 0 14px 20px; }
.ugcard .ugth { aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; background: var(--card); }
.ugcard .ugth img { width: 100%; height: 100%; object-fit: cover; }
.ugcard h4 { font-size: .85rem; margin: 8px 0; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ugcard .up {
  display: inline-block; background: #e5484d; color: #fff;
  font-size: .62rem; font-weight: 800; padding: 2px 6px; border-radius: 5px; margin-right: 4px;
}
.ugch {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border-radius: 8px; padding: 9px 12px;
  font-size: .8rem; font-weight: 600; margin-bottom: 6px;
}
.ugch:active { background: var(--bg2); }
.ugch .t { color: var(--muted); font-size: .72rem; font-weight: 400; }

/* type tabs */
.typetabs { display: flex; gap: 10px; padding: 14px 14px 4px; }
.typetabs button {
  flex: 1; padding: 10px; border: none; border-radius: 8px;
  background: var(--bg2); color: var(--muted); font-weight: 700; font-size: .9rem; cursor: pointer;
}
.typetabs button.on { background: var(--accent); color: #fff; }

/* horizontal scroll cards */
.hscroll { display: flex; gap: 12px; overflow-x: auto; padding: 4px 14px 14px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.mcard { flex: 0 0 128px; }
.mcard .th { position: relative; width: 128px; height: 170px; border-radius: var(--radius); overflow: hidden; background: var(--card); }
.mcard .th img { width: 100%; height: 100%; object-fit: cover; }
.mcard .th .flag {
  position: absolute; top: 6px; right: 6px; font-size: .68rem;
  background: rgba(0,0,0,.7); padding: 2px 6px; border-radius: 6px; font-weight: 700;
}
.mcard .th .ago {
  position: absolute; top: 6px; left: 6px; font-size: .68rem;
  background: rgba(0,0,0,.7); padding: 2px 6px; border-radius: 6px; color: #ffd75e;
}
.mcard h4 { font-size: .8rem; margin-top: 6px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mcard .ch { font-size: .72rem; color: var(--muted); }

/* update list */
.upd { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.upd-item { display: flex; gap: 12px; background: var(--card); border-radius: var(--radius); padding: 10px; align-items: center; }
.upd-item img { width: 52px; height: 68px; object-fit: cover; border-radius: 8px; background: var(--bg2); }
.upd-item .b { flex: 1; min-width: 0; }
.upd-item .b h4 { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upd-item .b .c { font-size: .78rem; color: var(--accent); font-weight: 600; }
.upd-item .b .t { font-size: .72rem; color: var(--muted); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 14px 20px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(5, 1fr); } }
.gcard .th { position: relative; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; background: var(--card); }
.gcard .th img { width: 100%; height: 100%; object-fit: cover; }
.gcard h4 { font-size: .78rem; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* segmented */
.seg { display: flex; gap: 10px; padding: 0 14px 12px; }
.seg button {
  padding: 8px 20px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--bg2); color: var(--muted); font-weight: 700; font-size: .85rem;
}
.seg button.on { background: var(--accent); color: #fff; }

/* ===== BOTTOM NAV ===== */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: rgba(10,10,15,.97);
  border-top: 1px solid var(--border); padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: .68rem; font-weight: 600; padding: 4px;
}
.bottomnav a .ni { font-size: 1.3rem; }
.bottomnav a.on { color: var(--accent); }

/* ===== DETAIL ===== */
.dhead { position: relative; }
.dcover-bg {
  height: 190px; background-size: cover; background-position: center;
  filter: blur(2px) brightness(.4); 
}
.dmain { padding: 0 14px; margin-top: -70px; position: relative; display: flex; gap: 14px; }
.dmain img.cover { width: 110px; height: 150px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.dmain .inf h1 { font-size: 1.15rem; margin-bottom: 6px; line-height: 1.3; }
.dmain .inf .m { font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.pill { display: inline-block; background: var(--bg2); border: 1px solid var(--border); font-size: .72rem; padding: 3px 10px; border-radius: 12px; margin: 0 6px 6px 0; }
.pill b { color: var(--accent); }
.genres { padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.genres a { background: rgba(124,92,255,.14); color: #b7a6ff; font-size: .78rem; font-weight: 600; padding: 6px 12px; border-radius: 14px; }
.syn { padding: 0 14px 6px; color: #c9c9d6; font-size: .88rem; line-height: 1.6; }
.chlist { padding: 8px 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.chrow {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); padding: 12px 14px; border-radius: 10px; font-size: .88rem;
}
.chrow:active { background: var(--bg2); }
.chrow .d { color: var(--muted); font-size: .75rem; }
.bmbtn {
  margin: 0 14px 14px; width: calc(100% - 28px); padding: 12px;
  border: 1px solid var(--accent); background: rgba(124,92,255,.12); color: #b7a6ff;
  border-radius: 10px; font-weight: 700; cursor: pointer; font-size: .9rem;
}
.bmbtn.saved { background: var(--accent); color: #fff; }

/* ===== READER (fullscreen) ===== */
.reader { background: #000; min-height: 100vh; }
.rbar {
  position: fixed; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.85); backdrop-filter: blur(6px);
  padding: 10px 14px; transition: transform .25s;
}
.rtop { top: 0; }
.rbottom { bottom: 0; justify-content: space-between; }
body.ui-hidden .rbar { transform: translateY(-110%); }
body.ui-hidden .rbottom { transform: translateY(110%); }
.rbar .t { flex: 1; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rbtn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-weight: 700; font-size: .82rem; cursor: pointer;
}
.rbtn.ghost { background: rgba(255,255,255,.12); }
.rbtn:disabled { opacity: .35; }
.rpages img { width: 100%; display: block; }
.rtapzone { min-height: 60vh; }

/* ===== LOGIN MODAL ===== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 22px; width: 100%; max-width: 340px; position: relative;
}
.modal-x { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.modal-box h2 { margin-bottom: 6px; }
.modal-box input {
  width: 100%; padding: 11px 13px; margin-top: 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: .92rem; outline: none;
}
.modal-box input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; margin-top: 14px; padding: 12px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: .95rem; cursor: pointer;
}
.login-note { margin-top: 10px; font-size: .82rem; color: var(--muted); text-align: center; }
.login-note a { color: var(--accent); }
.userchip { font-size: .8rem; color: var(--accent); font-weight: 700; }

/* ===== PROFILE ===== */
.phead { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.avatar-wrap { position: relative; cursor: pointer; flex-shrink: 0; }
.avatar-wrap img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  background: var(--bg); border: 2px solid var(--accent);
}
.avatar-edit {
  position: absolute; bottom: -2px; right: -2px;
  background: var(--accent); border-radius: 50%; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center; font-size: .8rem;
}
.pname { font-weight: 800; font-size: 1.05rem; }
.flabel { display: block; font-size: .8rem; color: var(--muted); margin: 4px 0 2px; }
.btn-danger {
  width: 100%; margin-top: 12px; padding: 12px; border-radius: 10px;
  background: rgba(229,72,77,.12); color: #ff7b80; border: 1px solid rgba(229,72,77,.4);
  font-weight: 700; font-size: .9rem; cursor: pointer;
}
.btn-danger:active { background: rgba(229,72,77,.25); }

/* library tabs */
.libtab { display: flex; gap: 10px; padding: 0 14px 12px; }
.libtab button {
  padding: 8px 20px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--bg2); color: var(--muted); font-weight: 700; font-size: .85rem;
}
.libtab button.on { background: var(--accent); color: #fff; }
