:root {
  --bg: #121212;
  --bg2: #1c1c1c;
  --card: #232323;
  --fg: #e8e8e8;
  --muted: #9a9a9a;
  --accent: #6cc6ff;
  --gold: #ffd166;
  --line: #2e2e2e;
  --topbar-h: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Noto Sans KR", "Noto Sans", system-ui, sans-serif; }
body { overscroll-behavior-y: none; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px; padding-top: env(safe-area-inset-top);
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
#topbar h1 { font-size: 17px; font-weight: 700; margin: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: none; border: none; color: var(--fg); font-size: 24px;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
}
.icon-btn:active { background: var(--card); }
#backBtn { font-size: 30px; line-height: 1; }

#app { min-height: calc(100vh - var(--topbar-h)); }
.loading, .empty { color: var(--muted); text-align: center; padding: 48px 16px; }

/* ----- library / series grids ----- */
.grid {
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.card {
  background: var(--card); border-radius: 12px; overflow: hidden;
  cursor: pointer; display: flex; flex-direction: column;
  border: 1px solid var(--line);
}
.card:active { transform: scale(0.98); }
.card .cover {
  width: 100%; aspect-ratio: 3/4; background: #2a2a2a; object-fit: cover;
  display: block;
}
.card .meta { padding: 8px 10px; }
.card .name { font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.card .sub .read { color: var(--accent); }
.badge { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: #333; color: var(--gold); margin-left: 4px; }

/* ----- chapter list ----- */
.list { padding: 6px 0 24px; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:active { background: var(--bg2); }
.row .num { font-weight: 700; min-width: 56px; }
.row .info { flex: 1; font-size: 13px; color: var(--muted); }
.row .state { font-size: 12px; }
.row.read .num { color: var(--muted); }
.row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.row .chk { color: var(--accent); font-weight: 700; }
.continue-bar {
  margin: 12px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(90deg, #1f3a4d, #233); border: 1px solid #2c5066;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.continue-bar b { color: var(--accent); }

/* ----- reader ----- */
#reader { position: fixed; inset: 0; background: #000; z-index: 30;
  display: none; flex-direction: column; }
#reader.show { display: flex; }
/* Continuous (webtoon-style) scroll — no page snapping, native momentum. */
#pages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#pages img { width: 100%; display: block; background: #111; }
#readerBar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,0.75); display: flex; align-items: center; gap: 12px;
  transform: translateY(110%); transition: transform .2s; backdrop-filter: blur(4px);
}
#readerBar.show { transform: none; }
#readerTop {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5;
  padding: 10px 8px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(0,0,0,0.75); display: flex; align-items: center; gap: 8px;
  transform: translateY(-110%); transition: transform .2s; backdrop-filter: blur(4px);
}
#readerTop.show { transform: none; }
#readerTop .t { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
#pageInfo { color: var(--fg); font-size: 13px; min-width: 64px; text-align: center; }
#readerBar input[type=range] { flex: 1; }
.spinner { color: var(--muted); text-align: center; padding: 40px; }

/* ----- dialog ----- */
dialog {
  border: 1px solid var(--line); background: var(--bg2); color: var(--fg);
  border-radius: 16px; padding: 20px; width: min(92vw, 440px);
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
dialog .hint { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
dialog label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
dialog input {
  width: 100%; padding: 11px 12px; border-radius: 10px; font-size: 15px;
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
}
.seg { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; }
.seg-btn { flex: 1; padding: 9px; border: none; border-radius: 8px; cursor: pointer;
  background: none; color: var(--muted); font-size: 14px; }
.seg-btn.active { background: var(--accent); color: #062b3e; font-weight: 700; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn { padding: 10px 16px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--accent); color: #062b3e; font-weight: 700; font-size: 14px; }
.btn.ghost { background: none; color: var(--muted); border: 1px solid var(--line); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #000d; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 50; border: 1px solid var(--line);
}

/* ----- float menu (⋯ button) ----- */
.float-menu {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 6px);
  right: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  z-index: 100; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,0.55);
  min-width: 190px;
}
.float-menu-item {
  display: block; width: 100%; padding: 15px 16px;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--fg); font-size: 15px; text-align: left; cursor: pointer;
}
.float-menu-item:last-child { border-bottom: none; }
.float-menu-item:active { background: var(--bg2); }

/* ----- PC 원격제어 패널 ----- */
.pc-panel { padding: 16px; max-width: 520px; margin: 0 auto; }

.pc-status-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 12px;
  padding: 16px; margin-bottom: 16px; border: 1px solid var(--line);
}
.pc-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted);
}
.pc-dot.online  { background: #4caf50; box-shadow: 0 0 8px #4caf5066; }
.pc-dot.offline { background: #f44336; }
.pc-dot.busy    { background: var(--gold); animation: pc-blink 1s ease-in-out infinite; }
@keyframes pc-blink { 0%,100% { opacity:1 } 50% { opacity:0.25 } }

.pc-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.pc-btn {
  width: 100%; padding: 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--fg); font-size: 16px; font-weight: 700;
  cursor: pointer; text-align: left; line-height: 1.3;
}
.pc-btn span { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.pc-btn:active { background: var(--bg2); transform: scale(0.99); }

.pc-settings {
  background: var(--card); border-radius: 12px;
  padding: 16px; border: 1px solid var(--line);
}
.pc-settings h3 { margin: 0 0 12px; font-size: 15px; }
.pc-settings label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.pc-settings input {
  width: 100%; padding: 11px 12px; border-radius: 10px; font-size: 14px;
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
}
