*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f4f0; --surface: #fff; --surface2: #f0efe9;
  --border: #e0dfd8; --text: #1a1a1a; --muted: #777; --radius: 12px;
  --purple: #7F77DD; --green: #2E7D32; --amber: #BA7517; --blue: #185FA5; --red: #D85A30;
}
* { font-family: system-ui, sans-serif; font-size: 14px; }
body { background: var(--bg); color: var(--text); }
input, select, button { border-radius: 8px; border: 0.5px solid var(--border); padding: 8px 12px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus { border-color: #999; }
button { cursor: pointer; } button:hover { background: var(--surface2); }
a { color: var(--blue); }

nav { background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; min-height: 52px; position: sticky; top: 0; z-index: 10; }
.nav-logo { font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.nav-tabs { display: flex; }
.nav-tab { padding: 16px 14px; border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.nav-tab.active { border-bottom-color: var(--text); color: var(--text); font-weight: 500; }
.nav-actions { display: flex; gap: 8px; }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

.page { display: none; }
.page.active { display: block; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--surface); border: 0.5px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat-val { font-size: 28px; font-weight: 500; }

.series-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 60px 40px; padding: 24px 8px 32px; }
.sc { position: relative; cursor: pointer; }
.sc-board { position: relative; width: 100%; aspect-ratio: 2/3; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10); }
.sc-cover { position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px; overflow: hidden; z-index: 1; transition: transform 0.35s cubic-bezier(0.23,1,0.32,1); }
.sc:hover .sc-cover { transform: translateY(-40px); }
.sc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-cover-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 36px; background: #2a2a2a; }
.sc-bag { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; backdrop-filter: blur(0.4px); -webkit-backdrop-filter: blur(0.4px); }
.sc-bag::before { content: ''; position: absolute; bottom: 0; left: 0; width: 80%; height: 45%; background: rgba(255,255,255,0.2); clip-path: polygon(0% 0%, 0% 100%, 100% 100%); }
.sc-bag-rim { position: absolute; inset: 0; border: 0.5px solid rgba(255,255,255,0.4); z-index: 3; pointer-events: none; }
.sc-info { padding: 10px 2px 0; }
.sc-title { font-size: 13px; font-weight: 600; line-height: 1.3; color: #1a1a1a; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-sub { font-size: 11px; color: #888; margin-bottom: 5px; }
.sc-bar { height: 3px; background: #eee; overflow: hidden; }
.sc-bar-fill { height: 100%; }

.coll-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 60px 40px; padding: 24px 8px 32px; }
.cc { position: relative; cursor: pointer; }
.cc-board { position: relative; width: 100%; aspect-ratio: 2/3; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10); }
.cc-cover { position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px; overflow: hidden; z-index: 1; transition: transform 0.35s cubic-bezier(0.23,1,0.32,1); }
.cc:hover .cc-cover { transform: translateY(-30px); }
.cc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-cover-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 28px; background: #2a2a2a; }
.cc-bag { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; backdrop-filter: blur(0.4px); }
.cc-bag::before { content: ''; position: absolute; bottom: 0; left: 0; width: 80%; height: 45%; background: rgba(255,255,255,0.2); clip-path: polygon(0% 0%, 0% 100%, 100% 100%); }
.cc-bag-rim { position: absolute; inset: 0; border: 0.5px solid rgba(255,255,255,0.4); z-index: 3; pointer-events: none; }
.cc-read-badge { position: absolute; top: 6px; right: 6px; z-index: 4; width: 36px; height: 36px; cursor: pointer; transition: transform 0.2s ease; }
.cc-read-badge:hover { transform: scale(1.15); }
.cc-wish-badge { position: absolute; top: 8px; left: 8px; z-index: 4; background: rgba(186,117,23,0.85); color: #fff; border-radius: 99px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.cc-info { padding: 8px 2px 0; }
.cc-title { font-size: 12px; font-weight: 600; line-height: 1.3; color: #1a1a1a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-sub { font-size: 11px; color: #888; }

.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.detail-back { font-size: 13px; color: var(--muted); background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 0; }
.detail-back:hover { color: var(--text); background: none; }
.detail-title { font-size: 22px; font-weight: 600; }
.detail-sub { font-size: 13px; color: var(--muted); }
.detail-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }

.iss-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 40px 24px; padding: 8px 4px; }
.ic { position: relative; cursor: default; }
.ic-board { position: relative; width: 100%; aspect-ratio: 2/3; background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10); }
.ic-cover { position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px; overflow: hidden; z-index: 1; }
.ic-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ic-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: var(--surface2); font-size: 20px; }
.ic-bag { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; backdrop-filter: blur(0.4px); }
.ic-bag::before { content: ''; position: absolute; bottom: 0; left: 0; width: 80%; height: 45%; background: rgba(255,255,255,0.2); clip-path: polygon(0% 0%, 0% 100%, 100% 100%); }
.ic-bag-rim { position: absolute; inset: 0; border: 0.5px solid rgba(255,255,255,0.4); z-index: 3; pointer-events: none; }
.ic.locked { opacity: 0.28; filter: grayscale(1); }
.ic.wishlisted { opacity: 0.55; filter: grayscale(0.5); }
.ic-num { padding: 5px 2px 2px; font-size: 11px; font-weight: 500; }
.ic-sub { font-size: 10px; color: var(--muted); padding-bottom: 2px; }
.ic-actions { display: flex; gap: 3px; padding-bottom: 3px; }
.ic-actions button { font-size: 9px; padding: 2px 5px; border-radius: 4px; flex: 1; }

.section-label { font-size: 13px; font-weight: 600; color: var(--muted); margin: 24px 0 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.empty { text-align: center; padding: 3rem; color: var(--muted); }
.empty .icon { font-size: 48px; margin-bottom: 12px; }
.empty p { margin-bottom: 16px; }
.status-msg { font-size: 13px; color: var(--muted); margin-bottom: 8px; min-height: 18px; }
.err { color: #c0392b; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); border: 0.5px solid var(--border); width: 100%; max-width: 1000px; padding: 1.5rem; margin-top: 1rem; }
.modal-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-hdr h3 { font-size: 18px; font-weight: 500; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--muted); padding: 0 4px; }
.rg { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; max-height: 55vh; overflow-y: auto; margin-bottom: 12px; }
.ri { cursor: pointer; border: 0.5px solid var(--border); border-radius: 8px; overflow: hidden; }
.ri:hover { border-color: #999; }
.ri img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.ri-ph { aspect-ratio: 2/3; display: flex; align-items: center; justify-content: center; background: var(--surface2); font-size: 24px; }
.ri-label { padding: 5px 6px 2px; font-size: 12px; font-weight: 500; line-height: 1.3; }
.ri-sub { padding: 0 6px 5px; font-size: 11px; color: var(--muted); }
.sel-box { border: 0.5px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.sel-row { display: flex; gap: 12px; margin-bottom: 12px; align-items: flex-start; }
.sel-row img { width: 60px; border-radius: 4px; object-fit: cover; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.form-lbl { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.form-lbl + select { width: 100%; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; cursor: pointer; }
.btn-primary { width: 100%; padding: 10px; border-radius: 8px; background: var(--text); color: #fff; border: none; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary:hover { opacity: 0.88; background: var(--text); }
.btn-secondary { width: 100%; padding: 10px; border-radius: 8px; background: none; color: var(--amber); border: 0.5px solid var(--amber); font-size: 14px; font-weight: 500; cursor: pointer; margin-top: 8px; }
.btn-secondary:hover { background: #fffbf0; }
.btn-danger { width: 100%; padding: 8px; border-radius: 8px; background: none; color: var(--red); border: 0.5px solid var(--red); font-size: 13px; cursor: pointer; margin-top: 8px; }
.btn-danger:hover { background: #fef0f0; }

#keyscreen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.keybox { max-width: 440px; width: 100%; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; }
.keybox h2 { font-size: 22px; font-weight: 500; margin: 12px 0 8px; }
.keybox p { font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.6; }
.keybox input { width: 100%; margin-bottom: 12px; }
#app { display: none; }