* { box-sizing: border-box; }

:root {
    --bg: #f7f6f3;
    --surface: #ffffff;
    --fg: #23201b;
    --muted: #7a756c;
    --border: #e2ded6;
    --border-strong: #cfc9be;
    --panel: #efece6;
    --link: #3a4a7a;
    --link-visited: #6a4a86;
    --accent: #3d5a80;
    --accent-fg: #ffffff;
    --accent-soft: #e7ecf3;
    --danger: #a23b3b;
    --star: #c8892a;
    --input-bg: #ffffff;
    --shadow: 0 1px 2px rgba(35,32,27,.06), 0 2px 8px rgba(35,32,27,.05);
    --radius: 7px;
}

body.dark {
    --bg: #14161a;
    --surface: #1c1f25;
    --fg: #e7e5e1;
    --muted: #9a958c;
    --border: #2c3037;
    --border-strong: #3a3f47;
    --panel: #22262d;
    --link: #8fb0e0;
    --link-visited: #b79bd6;
    --accent: #5c7ba8;
    --accent-fg: #ffffff;
    --accent-soft: #263143;
    --danger: #cf7676;
    --star: #d6a353;
    --input-bg: #191c21;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.25);
}

html { height: 100%; }
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1 0 auto; }
.site-footer { flex-shrink: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent); }

/* ---------- header ---------- */
header.site {
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}
.bar {
    max-width: 1160px;
    margin: 0 auto;
    padding: 11px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.bar-collapse {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 1;
    min-width: 0;
}
.bar .logo {
    font-weight: 800;
    font-size: 20px;
    letter-spacing: .06em;
    color: var(--fg);
}
.bar .logo:hover { color: var(--accent); }
.bar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.bar nav a {
    color: var(--fg);
    padding: 5px 11px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14.5px;
}
.bar nav a:hover { background: var(--accent-soft); color: var(--accent); }
.bar .spacer { flex: 1; }
.bar form.inline { display: inline-flex; margin: 0; }
.bar .util { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.bar .util a {
    color: var(--muted);
    font-size: 13.5px;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 6px;
}
.bar .util a:hover { color: var(--accent); background: var(--accent-soft); }

/* ---------- selects & buttons in bar ---------- */
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--input-bg);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%23555' d='M0 1h10L5 7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px 7px;
    padding-right: 28px;
    cursor: pointer;
}
/* hide any native arrow on Safari/older engines so only our caret shows */
select::-ms-expand { display: none; }
body.dark select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath fill='%23aaa' d='M0 1h10L5 7z'/%3E%3C/svg%3E");
}
.bar select, .bar button.link {
    color: var(--fg);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.3;
}
.bar select { padding-right: 26px; }
.bar button.link {
    font-weight: 600;
    background-image: none;
    background-color: var(--input-bg);
}
.bar button.link:hover, .bar select:hover { border-color: var(--accent); }

main {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 22px 20px 60px;
}

h1 { font-size: 24px; margin: 4px 0 18px; letter-spacing: -.01em; }
h2 {
    font-size: 17px;
    margin: 28px 0 12px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
    line-height: 1.2;
}

/* ---------- card grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
    gap: 18px 16px;
}
.card {
    background: transparent;
    border: none;
    display: block;
    transition: transform .12s ease;
}
.card:hover { transform: translateY(-3px); }
.card .cover {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card:hover .cover { border-color: var(--border-strong); }
.card .meta { padding: 9px 2px 2px; }
.card .title {
    font-weight: 700;
    font-size: 14px;
    color: var(--fg);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card:hover .title { color: var(--accent); }
.card .sub {
    color: var(--star);
    font-size: 12.5px;
    font-weight: 700;
    margin-top: 3px;
    display: block;
}
.card .sub::before { content: "★ "; }

/* ---------- detail ---------- */
.detail { display: flex; gap: 28px; flex-wrap: wrap; }
.detail .coverbox { width: 240px; flex: none; }
.detail .coverbox img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: block;
}
.detail .info { flex: 1; min-width: 280px; }
.detail .info h1 { margin-bottom: 4px; }
.detail table.facts { margin: 14px 0; border-collapse: collapse; }
.detail table.facts td { padding: 4px 14px 4px 0; vertical-align: top; font-size: 14px; }
.detail table.facts td.k { color: var(--muted); white-space: nowrap; font-weight: 600; }

.tag {
    display: inline-block;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    padding: 2px 11px;
    margin: 0 5px 6px 0;
    font-size: 12.5px;
    color: var(--muted);
    background: var(--surface);
}
a.tag:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- chapter list ---------- */
ul.chapters { list-style: none; padding: 0; margin: 14px 0 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
ul.chapters li { border-bottom: 1px solid var(--border); }
ul.chapters li:last-child { border-bottom: none; }
ul.chapters li.empty { padding: 11px 14px; color: var(--muted); }
ul.chapters a.chapter-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--link);
}
ul.chapters a.chapter-row:hover { background: var(--panel); }
ul.chapters a.chapter-row:visited { color: var(--link-visited); }
ul.chapters a.chapter-row:visited .chapter-name { color: var(--link-visited); }
ul.chapters .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-weight: 400; }

/* ---------- forms ---------- */
form.stack { max-width: 520px; }
form.stack label { display: block; margin: 14px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
select {
    width: 100%;
    padding: 9px 11px;
    padding-right: 28px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus, input[type=number]:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 100px; resize: vertical; }

button, input[type=submit] {
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    border-radius: 6px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: filter .12s ease;
}
button:hover, input[type=submit]:hover { filter: brightness(1.08); }
button.secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border-strong); }
button.secondary:hover { border-color: var(--accent); filter: none; }
button.danger { background: var(--danger); }

.notice { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 11px 14px; margin: 12px 0; }
.error { border: 1px solid var(--danger); border-radius: var(--radius); color: var(--danger); background: var(--surface); padding: 11px 14px; margin: 12px 0; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.list th, table.list td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; font-size: 14px; }
table.list tr:last-child td { border-bottom: none; }
table.list th { background: var(--panel); font-weight: 700; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- filters ---------- */
.filters { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; margin-bottom: 22px; box-shadow: var(--shadow); }
.filters .row { margin-bottom: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters .row:last-child { margin-bottom: 0; }
.filters .row > label:first-child { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; min-width: 62px; }
.filters .checks { display: flex; flex-wrap: wrap; gap: 4px; }
.filters .checks label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    padding: 4px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    cursor: pointer;
    background: var(--surface);
    user-select: none;
    transition: background .1s ease, border-color .1s ease;
}
.filters .checks label:hover { border-color: var(--accent); color: var(--accent); }
.filters .checks input { accent-color: var(--accent); margin: 0; }
.filters .checks input:checked + span { color: var(--accent); font-weight: 700; }
.filters select { min-width: 160px; width: auto; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- avatar picker ---------- */
.avatarpick { display: flex; flex-wrap: wrap; gap: 10px; }
.avatarpick label { border-radius: 50%; padding: 2px; cursor: pointer; line-height: 0; }
.avatarpick input { display: none; }
.avatarpick input:checked + img { outline: 3px solid var(--accent); outline-offset: 1px; }
.avatarpick img { width: 58px; height: 58px; display: block; border-radius: 50%; border: 1px solid var(--border); }

.stars { font-size: 15px; color: var(--star); }
.rating-star { color: var(--star); }

/* ---------- reader ---------- */
.reader { max-width: 900px; margin: 0 auto; }
.reader .pages img { display: block; margin: 0 auto; max-width: 100%; }
.reader-pages img { display: block; margin: 0 auto; }
.reader-pages.single { position: relative; }

/* single-page frame with left/right tap zones */
.single-frame { position: relative; display: block; }
.single-frame img { display: block; margin: 0 auto; }
.tap-zone {
    position: absolute; top: 0; height: 100%; width: 50%;
    background: transparent; border: none; cursor: pointer;
    padding: 0; z-index: 5;
}
.tap-left { left: 0; }
.tap-right { right: 0; }

/* bottom page navigation */
.page-nav {
    display: flex; align-items: center; justify-content: center; gap: 18px;
    padding: 14px 6px; margin-top: 4px;
}
.page-nav-arrow {
    background: var(--surface); border: 1px solid var(--border-strong);
    color: var(--fg); border-radius: 8px;
    width: 44px; height: 40px; font-size: 22px; line-height: 1; cursor: pointer;
}
.page-nav-arrow:hover { border-color: var(--accent); color: var(--accent); }
.page-nav-label { color: var(--muted); font-size: 14px; min-width: 60px; text-align: center; }

.reader-toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    z-index: 30;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}
/* once scrolled past its natural spot, it fixes just below the sticky header */
.reader-toolbar.rd-stuck {
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    width: calc(100% - 40px);
    max-width: 900px;
    margin: 0 auto;
    border-radius: var(--radius);
    transition: transform .22s ease;
    transform: translateY(0);
    z-index: 40;
}
.reader-toolbar.rd-stuck.rd-hidden {
    transform: translateY(-200%);
}
.reader-toolbar a { font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.reader-toolbar a:hover { background: var(--accent-soft); }
.reader-toolbar .sep { flex: 1; }
.reader-toolbar select, .reader-toolbar button { font-size: 13px; padding: 5px 9px; }
.reader-stage.bg-white { background: #ffffff; }
.reader-stage.bg-gray { background: #6f6f6f; }
.reader-stage.bg-black { background: #0c0c0c; }
.reader-stage { padding: 0; border-radius: var(--radius); }

/* ---------- notifications ---------- */
.notif { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; background: var(--surface); }
.notif.unread { border-left: 3px solid var(--accent); background: var(--accent-soft); }

/* ---------- pagination ---------- */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.pager a, .pager span {
    padding: 6px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 14px;
    background: var(--surface);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager .current { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ---------- home blocks ---------- */
.home-block { margin-bottom: 34px; }
.block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 14px;
}
h2.flush { margin: 0; }
.see-all {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}
.see-all:hover { color: var(--accent); }

/* ranking rail */
.rank-rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 150px;
    gap: 16px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scroll-snap-type: x proximity;
}
.rank-rail::-webkit-scrollbar { height: 8px; }
.rank-rail::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.rank-card { position: relative; scroll-snap-align: start; display: block; }
.rank-card .cover {
    width: 150px;
    height: 210px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: block;
    background: var(--panel);
}
.rank-num {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 30px;
    height: 30px;
    padding: 0 7px;
    background: var(--accent);
    color: var(--accent-fg);
    font-weight: 800;
    font-size: 16px;
    line-height: 30px;
    text-align: center;
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 2;
}
.rank-card .rank-title {
    display: block;
    margin-top: 8px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--fg);
    line-height: 1.35;
    max-height: 2.7em;
    overflow: hidden;
}
.rank-card:hover .rank-title { color: var(--accent); }
.rank-card .sub { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; color: var(--star); }
.rank-card .sub::before { content: "★ "; }

/* update grid */
.update-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 18px 16px;
}
.update-item { display: block; }
.update-item .thumb { position: relative; display: block; }
.update-item .cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: block;
    background: var(--panel);
}
.update-item:hover .cover { border-color: var(--border-strong); }
.up-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 5px;
    line-height: 1.2;
}
.update-item .u-title {
    display: block;
    margin-top: 9px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--fg);
    line-height: 1.35;
    max-height: 2.7em;
    overflow: hidden;
}
.update-item:hover .u-title { color: var(--accent); }
.update-item .u-chapter {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.update-item .u-time { display: block; margin-top: 1px; font-size: 11.5px; color: var(--muted); }

/* ---------- password gate ---------- */
.gate-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.gate-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    text-align: center;
}
.gate-logo {
    font-weight: 800;
    font-size: 24px;
    letter-spacing: .08em;
    color: var(--fg);
    margin-bottom: 14px;
}
.gate-lead {
    color: var(--muted);
    font-size: 14px;
    margin: 0 0 20px;
    line-height: 1.5;
}
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-form input[type=password] { text-align: center; }
.gate-form button { width: 100%; padding: 11px; font-size: 15px; }
.gate-card .error { text-align: left; }

/* ---------- settings tabs + pfp ---------- */
.settings-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.settings-pfp { width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--border); }
.settings-head h1 { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; }
.tabs .tab {
    padding: 9px 16px;
    font-weight: 600;
    font-size: 14px;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--accent); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* header pfp */
.bar .util a.me { display: inline-flex; align-items: center; gap: 6px; }
.me-pfp { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); }

/* notification bell */
.bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 8px;
    color: var(--fg);
    flex: none;
}
.bell:hover { background: var(--accent-soft); color: var(--accent); }
.bell-badge {
    position: absolute;
    right: 3px; bottom: 3px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px;
    text-align: center; border-radius: 8px;
    box-shadow: 0 0 0 2px var(--surface);
}

/* user menu dropdown */
.usermenu { position: relative; flex: none; }
.usermenu-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid transparent;
    border-radius: 8px; padding: 4px 8px 4px 4px;
    cursor: pointer; color: var(--fg); font-family: inherit; font-size: 14px; font-weight: 600;
}
.usermenu-btn:hover { background: var(--accent-soft); }
.usermenu-caret { color: var(--muted); font-size: 11px; }
.usermenu-drop {
    position: absolute; right: 0; top: calc(100% + 6px);
    min-width: 170px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 6px; z-index: 60;
}
.usermenu-drop a, .usermenu-drop button {
    display: block; width: 100%; text-align: left;
    padding: 9px 12px; border-radius: 6px;
    color: var(--fg); font-size: 14px; font-weight: 500;
    background: transparent; border: none; cursor: pointer; font-family: inherit;
}
.usermenu-drop a:hover, .usermenu-drop button:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; }
.foot-inner {
    max-width: 1160px;
    margin: 0 auto;
    padding: 28px 20px 18px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.foot-brand p { margin: 6px 0 0; max-width: 320px; }
.foot-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.foot-links a { color: var(--muted); font-weight: 600; font-size: 14px; }
.foot-links a:hover { color: var(--accent); }
.foot-bottom {
    max-width: 1160px;
    margin: 0 auto;
    padding: 12px 20px 24px;
    border-top: 1px solid var(--border);
}

/* ---------- cover upload (admin) ---------- */
.cover-upload { display: flex; gap: 16px; align-items: flex-start; }
.cover-preview {
    width: 120px; height: 180px; flex: none;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--panel); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-empty { color: var(--muted); font-size: 12px; }
.cover-upload-controls { flex: 1; }

/* ---------- page manager (admin) ---------- */
.pm-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.pm-spacer { flex: 1; }
.pm-add {
    display: inline-block; cursor: pointer;
    background: var(--surface); color: var(--fg);
    border: 1px solid var(--border-strong); border-radius: 6px;
    padding: 9px 16px; font-size: 14px; font-weight: 600;
}
.pm-add:hover { border-color: var(--accent); }
.pm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin: 12px 0;
}
.pm-cell {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 6px;
    cursor: grab;
    text-align: center;
}
.pm-cell.dragging { opacity: .5; }
.pm-pos {
    position: absolute; top: 4px; left: 4px;
    background: var(--accent); color: var(--accent-fg);
    font-size: 11px; font-weight: 700;
    border-radius: 5px; padding: 1px 6px; z-index: 2;
}
.pm-thumb {
    width: 100%; height: 150px; object-fit: cover;
    border-radius: 4px; display: block; cursor: zoom-in;
    background: var(--surface);
}
.pm-name {
    display: block; font-size: 11px; color: var(--muted);
    margin-top: 4px; word-break: break-all; line-height: 1.3;
    max-height: 2.6em; overflow: hidden;
}
.pm-badge {
    position: absolute; top: 4px; right: 26px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 800;
    padding: 1px 5px; border-radius: 4px;
}
.pm-del {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px; padding: 0;
    border-radius: 5px; background: rgba(0,0,0,.55); color: #fff;
    font-size: 14px; line-height: 20px; border: none; cursor: pointer;
}
.pm-del:hover { background: var(--danger); }
.pm-lightbox {
    display: none; position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.85); align-items: center; justify-content: center;
    padding: 24px; cursor: zoom-out;
}
.pm-lightbox.open { display: flex; }
.pm-lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }
#pmLog { margin-top: 8px; color: var(--muted); }
#pmLog div { padding: 1px 0; }

/* ---------- userbox (detail) ---------- */
.userbox-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 8px;
}
.ub-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
}
.ub-card .ub-label {
    display: block;
    font-weight: 700; font-size: 12px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .04em;
    margin-bottom: 10px;
}
.ub-rate-line { display: flex; align-items: center; gap: 6px; }
.ub-follow { width: 100%; margin-top: 14px; }
.ub-card select { width: 100%; }
.ub-card select + select { margin-top: 8px; }
.ub-clear { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; color: var(--muted); font-size: 20px; line-height: 1; background: transparent; border: none; padding: 0; cursor: pointer; }
.ub-clear:hover { color: var(--danger); }
.primary-btn {
    background: var(--accent); color: var(--accent-fg);
    border: none; border-radius: 6px; padding: 9px 16px;
    font-weight: 600; font-size: 14px; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.08); }

/* star rating widget */
.star-rate { display: inline-flex; align-items: center; cursor: pointer; font-style: normal; line-height: 0; }
.star-rate .star {
    position: relative;
    width: 26px; height: 26px;
    display: inline-block;
    font-style: normal;
}
.star-rate .star::before {
    content: "★";
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 23px;
    color: var(--border-strong);
    font-style: normal;
}
.star-half {
    position: absolute; top: 0; height: 100%; z-index: 2;
}
.star-half.left { left: 0; width: 50%; overflow: hidden; }
.star-half.right { left: 50%; width: 50%; overflow: hidden; }
/* the filled overlay is always a full-size star pinned to the star's left
   edge, then clipped by the half's width so both halves match exactly */
.star-half::after {
    content: "★";
    position: absolute; top: 0; bottom: 0;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    font-size: 23px;
    color: var(--star);
    font-style: normal;
    opacity: 0;
}
.star-half.left::after { left: 0; }
.star-half.right::after { left: -100%; }
.star-half.on::after { opacity: 1; }

/* ---------- reader settings panel ---------- */
.rd-gear { font-size: 13px; }
.rd-modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.rd-modal-overlay[hidden] { display: none; }
.rd-modal {
    width: 100%; max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,.3);
    padding: 18px 20px;
}
.rd-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rd-modal-head strong { font-size: 16px; }
.rd-modal-close {
    background: transparent; border: none; color: var(--muted);
    font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.rd-modal-close:hover { color: var(--fg); }
.rd-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rd-field:last-child { margin-bottom: 0; }
.rd-field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.rd-field select, .rd-field input { width: 150px; }

/* ---------- inline filter fields ---------- */
.filters .inline-row { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.filters .field { display: flex; flex-direction: column; gap: 4px; }
.filters .field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.filters .field select, .filters .field input { width: auto; min-width: 150px; }
.filters .row-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.filters .row.checks { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }

/* ---------- burger (hidden on desktop) ---------- */
.burger { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .bar { flex-wrap: nowrap; gap: 10px; }
  .bar .logo { flex: 1; min-width: 0; }
  .burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px; height: 38px;
    flex: none;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    padding: 0 9px;
    cursor: pointer;
    order: 5;
  }
  .burger span {
    display: block; height: 2px; width: 100%;
    background: var(--fg); border-radius: 2px;
    transition: transform .18s ease, opacity .18s ease;
  }
  .burger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .burger.open span:nth-child(2) { opacity: 0; }
  .burger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* bell + usermenu stay on the top row beside the burger */
  .bell { order: 3; }
  .usermenu { order: 4; }
  .usermenu-name { display: none; }

  /* collapse panel drops below the top row, full width */
  .bar-collapse {
    display: none;
    order: 10;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    flex-basis: 100%;
  }
  .bar { flex-wrap: wrap; }
  .bar-collapse.open { display: flex; }
  .bar .spacer { display: none; }
  .bar nav { flex-direction: column; gap: 2px; }
  .bar nav a { padding: 10px 8px; border-radius: 6px; font-size: 15px; }
  .bar .util {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
  }
  .bar .util a { padding: 9px 8px; font-size: 15px; }
  .bar .util form.inline { display: block; }
  .bar .util select, .bar .util button.link { width: 100%; text-align: left; }

  main { padding: 16px 14px 44px; }
  h1 { font-size: 20px; }
  h2 { font-size: 16px; }

  /* denser cover grids on phones */
  .grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .update-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px 10px; }
  .rank-rail { grid-auto-columns: 120px; }
  .rank-card .cover { width: 120px; height: 168px; }

  /* detail stacks */
  .detail { gap: 18px; }
  .detail .coverbox { width: 160px; margin: 0 auto; }
  .detail .info { min-width: 0; }
  .detail table.facts td { font-size: 13.5px; }

  /* filters full width */
  .filters { padding: 14px; }
  .filters .inline-row { display: block; }
  .filters .field { display: block; margin: 0 0 12px; }
  .filters .field select, .filters .field input { width: 100%; min-width: 0; }
  .filters button[type=submit] { width: 100%; }

  /* userbox rows wrap comfortably */
  .userbox-cards { grid-template-columns: 1fr; }

  /* reader panel spans width */
  .rd-modal { max-width: none; }
  .rd-field select, .rd-field input { width: 150px; }
  .reader-toolbar { top: 0; }

  /* settings + tabs */
  .tabs { overflow-x: auto; }
  .tabs .tab { white-space: nowrap; padding: 9px 12px; }
  .settings-pfp { width: 52px; height: 52px; }

  /* page manager thumbs smaller */
  .pm-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .pm-thumb { height: 120px; }

  /* footer stacks */
  .foot-inner { flex-direction: column; gap: 16px; }

  /* cover upload stacks */
  .cover-upload { flex-direction: column; }

  /* tables scroll horizontally instead of breaking layout */
  table.list { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 460px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .update-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .card .title, .update-item .u-title { font-size: 12.5px; }
  .bar .logo { font-size: 18px; }
}

/* ---------- admin search bar ---------- */
.admin-search { display: flex; gap: 8px; align-items: center; margin: 12px 0 4px; flex-wrap: wrap; }
.admin-search input[type=text] { max-width: 420px; }
.admin-search a { color: var(--muted); }

/* footer brand logo + description */
.foot-logo-img { height: 150px; width: auto; max-width: 100%; border-radius: 10px; display: block; margin-bottom: 12px; }
.foot-desc { max-width: 640px; line-height: 1.6; }
