:root {
  --bg: #0d0d0f;
  --panel: #17171b;
  --panel2: #1f1f25;
  --line: #2c2c34;
  --text: #ece7df;
  --muted: #8d8a84;
  --gold: #c9a24b;
  --gold2: #e3c074;
  --danger: #c7584f;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; margin: .4rem 0 0; }
.screen { min-height: 100vh; }
h1, h2, h3 { font-weight: 600; letter-spacing: .3px; }

button {
  background: var(--gold);
  color: #1a1407;
  border: 0;
  border-radius: 8px;
  padding: .55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
button:hover { background: var(--gold2); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.ghost:hover { border-color: var(--gold); color: var(--gold2); }
button.danger { color: var(--danger); border-color: #4a2a28; }
input {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: .6rem .8rem;
  font-size: 1rem;
  width: 100%;
}
input:focus { outline: none; border-color: var(--gold); }

/* login */
#login { display: flex; align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.6rem; }
.login-card { width: min(340px, 92vw); text-align: center; }
.login-card h1 { font-size: 2rem; line-height: 1.05; margin: 0 0 .2rem; }
.login-card h1 span { color: var(--gold); }
.login-card input { margin: 1rem 0 .8rem; text-align: center; letter-spacing: 4px; }
.login-card button { width: 100%; }

/* topbar */
.topbar { display: flex; align-items: center; gap: .75rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(13,13,15,.92); backdrop-filter: blur(6px); z-index: 5; }
.brand { font-size: 1.05rem; cursor: pointer; }
.brand b { color: var(--gold); }
.spacer { flex: 1; }
.badge { font-size: .72rem; padding: .2rem .5rem; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: #7fc29b; border-color: #2d4a3b; }
.badge.off { color: var(--danger); border-color: #4a2a28; }

.view { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1.1rem 4rem; }
.row { display: flex; align-items: center; gap: 1rem; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { margin-bottom: .8rem; }

/* grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; margin-top: 1rem; }
.grid.pages { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .1s; }
.tile:hover { border-color: var(--gold); }
.tile .cover { aspect-ratio: 3/4; background: var(--panel2) center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; }
.tile .info { padding: .55rem .6rem; }
.tile .info b { display: block; font-size: .9rem; margin-bottom: .15rem; }
.tile .info small { color: var(--muted); }
.pill { display: inline-block; font-size: .68rem; padding: .12rem .45rem; border-radius: 20px; border: 1px solid var(--line); color: var(--muted); margin-top: .35rem; }
.pill.done { color: #7fc29b; border-color: #2d4a3b; }
.pill.part { color: var(--gold2); border-color: #4a3d1e; }

/* page tile */
.ptile { position: relative; }
.ptile .cover { aspect-ratio: 3/4; }
.ptile .st { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 2px rgba(0,0,0,.4); }
.ptile .st.done { background: #7fc29b; }
.ptile .st.error { background: var(--danger); }
.ptile .pnum { position: absolute; bottom: 6px; left: 6px; font-size: .7rem; background: rgba(0,0,0,.6); padding: .1rem .4rem; border-radius: 6px; }

/* uploader */
.uploader { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.2rem 0 .4rem; }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 1.3rem; text-align: center; cursor: pointer; display: flex; flex-direction: column; gap: .2rem; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--gold); background: var(--panel); }
.drop b { color: var(--gold2); }

/* catalog */
.catalog { margin: 1.4rem 0; display: grid; gap: 1rem; }
.catbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; }
.catbox h4 { margin: 0 0 .6rem; color: var(--gold); font-size: .85rem; text-transform: uppercase; letter-spacing: 1px; }
.catbox ul { margin: 0; padding-left: 1.1rem; }
.catbox li { margin: .2rem 0; }
.catbox .tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: .22rem .6rem; margin: .18rem .25rem .18rem 0; font-size: .82rem; }
.catbox .role { color: var(--muted); font-size: .76rem; }

.pages-h { margin-top: 1.6rem; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 520px) {
  .uploader { grid-template-columns: 1fr; }
}
