/* Base reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; line-height: 1.6; color: #222; background: #fff; }

/* Layout */
header { background: #1a1a2e; color: #fff; padding: .75rem 1.5rem; }
header nav { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { color: #fff; font-size: 1.25rem; font-weight: bold; text-decoration: none; }
header nav ul { list-style: none; display: flex; gap: 1rem; margin-left: auto; }
header nav ul a { color: #ccc; text-decoration: none; font-size: .9rem; }
header nav ul a:hover { color: #fff; }

main { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }
footer { text-align: center; padding: 2rem; color: #888; font-size: .85rem; margin-top: 4rem; border-top: 1px solid #eee; }

/* Flash messages */
.flash { padding: .75rem 1rem; border-radius: 4px; margin-bottom: 1rem; }
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.notice { background: #fff3cd; color: #856404; border: 1px solid #ffc107; padding: .75rem 1rem; border-radius: 4px; margin-bottom: 1.5rem; }

/* Forms */
form div { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%; padding: .5rem .75rem; border: 1px solid #ccc; border-radius: 4px;
    font-size: 1rem; font-family: inherit;
}
textarea { resize: vertical; }
small { color: #666; font-size: .8rem; }
button[type=submit], a.button {
    background: #1a1a2e; color: #fff; border: none; padding: .6rem 1.25rem;
    border-radius: 4px; font-size: 1rem; cursor: pointer;
}
button[type=submit]:hover { background: #2d2d4e; }

/* Submission list */
.submission-list { list-style: none; }
.submission-card { border: 1px solid #ddd; border-radius: 6px; padding: 1.25rem; margin-bottom: 1rem; }
.submission-card h2 { font-size: 1.15rem; margin-bottom: .25rem; }
.submission-card h2 a { text-decoration: none; color: #1a1a2e; }
.submission-card h2 a:hover { text-decoration: underline; }
.meta { color: #666; font-size: .85rem; margin-bottom: .5rem; }
.synopsis { color: #444; font-size: .95rem; margin-bottom: .75rem; }
.stats { font-size: .8rem; color: #888; }

/* Status badges */
.status-badge { display: inline-block; padding: .15rem .5rem; border-radius: 3px; font-size: .75rem; font-weight: 600; }
.status-open   { background: #d4edda; color: #155724; }
.status-closed { background: #e2e3e5; color: #383d41; }

/* Article content */
.submission-content { background: #fafafa; border: 1px solid #eee; border-radius: 4px; padding: 1.5rem; margin: 1.5rem 0; white-space: pre-wrap; font-family: Georgia, serif; line-height: 1.8; }
.submission-header blockquote { border-left: 3px solid #ccc; padding-left: 1rem; color: #555; margin: .75rem 0; }

/* Feedback */
.feedback-section { margin-top: 2rem; border-top: 2px solid #eee; padding-top: 1.5rem; }
.feedback-item { background: #f7f7f7; border-radius: 4px; padding: 1rem; margin-bottom: 1rem; }
.feedback-author { font-size: .85rem; color: #666; margin-bottom: .5rem; }

/* Hero */
.hero { text-align: center; padding: 4rem 1rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; color: #555; margin-bottom: 2rem; }
.hero a { display: inline-block; margin: .25rem; padding: .75rem 1.5rem; border-radius: 4px; text-decoration: none; }
.hero a:first-of-type { background: #1a1a2e; color: #fff; }
.hero a:last-of-type  { border: 1px solid #1a1a2e; color: #1a1a2e; }

/* Section headings */
section { margin-bottom: 2.5rem; }
section h2 { font-size: 1.25rem; border-bottom: 2px solid #eee; padding-bottom: .5rem; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; }
section h2 small a { font-size: .85rem; font-weight: normal; }

/* Genre picker */
.genre-section { margin-top: 1.5rem; }
.genre-section > label { font-weight: 600; display: block; margin-bottom: .5rem; }
.genre-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.genre-controls button { padding: .3rem .75rem; font-size: .85rem; background: #eee; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }
.genre-controls input[type=text] { width: auto; flex: 1; min-width: 160px; padding: .3rem .6rem; font-size: .85rem; }
.genre-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; max-height: 420px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; padding: .75rem; background: #fafafa; }
@media (max-width: 900px) { .genre-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .genre-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 380px) { .genre-grid { grid-template-columns: 1fr; } }
.genre-pill { display: flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border: 1px solid #ccc; border-radius: 6px; font-size: .8rem; cursor: pointer; background: #fff; transition: background .15s, border-color .15s; overflow: hidden; }
.genre-pill:hover { background: #f0f0f0; }
.genre-pill input[type=checkbox] { width: auto; flex-shrink: 0; margin: 0; }
.genre-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.genre-pill:has(input:checked) { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }

/* Notification bell */
.notif-bell { position: relative; display: inline-flex; align-items: center; text-decoration: none; font-size: 1.1rem; }
.notif-badge { position: absolute; top: -6px; right: -10px; background: #e74c3c; color: #fff; font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; }

/* Notification list */
.notification-list { list-style: none; }
.notification-item { display: flex; align-items: flex-start; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid #eee; position: relative; transition: background .15s; }
.notification-item:first-child { border-top: 1px solid #eee; }
.notification-item.unread { background: #f0f4ff; }
.notification-item:hover { background: #f7f7f7; }
.notif-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: .1rem; }
.notif-body { flex: 1; }
.notif-body a { color: #1a1a2e; text-decoration: none; font-weight: 500; }
.notif-body a:hover { text-decoration: underline; }
.notif-body time { display: block; font-size: .78rem; color: #999; margin-top: .2rem; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #3b82f6; flex-shrink: 0; margin-top: .45rem; }

/* Credits */
.credit-nav { color: #f0c040; text-decoration: none; font-size: .9rem; font-weight: 600; }
.credit-nav:hover { color: #fff; }
.credit-pill { font-size: .85rem; color: #666; }
.credit-pill a { color: #1a1a2e; }
.credits-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.credit-balance { display: flex; align-items: center; gap: .4rem; background: #1a1a2e; color: #f0c040; padding: .5rem 1.25rem; border-radius: 30px; }
.credit-coin { font-size: 1.4rem; }
.credit-amount { font-size: 2rem; font-weight: 700; line-height: 1; }
.credit-label { font-size: .85rem; opacity: .8; }
.credits-explainer { background: #f7f7f7; border: 1px solid #eee; border-radius: 6px; padding: 1rem 1.25rem; margin-bottom: 2rem; }
.credits-explainer ul { list-style: none; display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.credits-explainer li::before { content: ''; }

/* Transactions */
.transaction-list { list-style: none; }
.transaction-item { display: flex; align-items: flex-start; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid #eee; }
.tx-amount { font-size: 1.1rem; font-weight: 700; min-width: 3rem; text-align: right; flex-shrink: 0; }
.transaction-item.earn .tx-amount { color: #27ae60; }
.transaction-item.spend .tx-amount { color: #e74c3c; }
.tx-body { flex: 1; }
.tx-desc { display: block; }
.tx-body time { font-size: .78rem; color: #999; }

/* Boost */
.boosted { border-color: #f0c040; box-shadow: 0 0 0 2px #f0c04033; }
.boost-badge { display: inline-block; background: #f0c040; color: #1a1a2e; font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 3px; vertical-align: middle; margin-left: .4rem; }
.btn-boost { background: transparent; border: 1px solid #f0c040; color: #856404; padding: .35rem .8rem; font-size: .82rem; border-radius: 4px; cursor: pointer; }
.btn-boost:hover { background: #fff8e1; }
.submission-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }

/* Helpful feedback */
.is-helpful { border-left: 3px solid #f0c040; }
.helpful-badge { display: inline-block; background: #fff8e1; color: #856404; font-size: .75rem; padding: .1rem .45rem; border-radius: 3px; margin-left: .5rem; }
.btn-helpful { background: none; border: 1px solid #ccc; color: #666; padding: .1rem .5rem; font-size: .75rem; border-radius: 3px; cursor: pointer; margin-left: .5rem; }
.btn-helpful:hover { border-color: #f0c040; color: #856404; }

/* Avatar */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0; line-height: 1; }

/* Reputation badge */
.rep-badge { display: inline-block; padding: .15rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 700; color: #fff; vertical-align: middle; margin-left: .3rem; }

/* Profile page */
.profile-header { display: flex; gap: 1.5rem; align-items: flex-start; margin-bottom: 2rem; flex-wrap: wrap; }
.profile-avatar-wrap { flex-shrink: 0; }
.profile-meta { flex: 1; }
.profile-meta h1 { font-size: 1.6rem; margin-bottom: .2rem; display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.profile-username { color: #888; font-size: .9rem; margin-bottom: .25rem; }
.profile-since { color: #aaa; font-size: .8rem; margin-bottom: .6rem; }
.profile-bio { color: #444; max-width: 600px; }
.btn-edit-profile { display: inline-block; margin-top: .75rem; padding: .4rem 1rem; border: 1px solid #1a1a2e; border-radius: 4px; font-size: .85rem; color: #1a1a2e; text-decoration: none; }
.btn-edit-profile:hover { background: #1a1a2e; color: #fff; }

/* Stats row */
.profile-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem; margin-bottom: 2rem; }
@media (max-width: 700px) { .profile-stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 420px) { .profile-stats { grid-template-columns: repeat(2, 1fr); } }
.stat-card { background: #f7f7f7; border: 1px solid #eee; border-radius: 8px; padding: .75rem .5rem; text-align: center; }
.stat-number { display: block; font-size: 1.8rem; font-weight: 700; color: #1a1a2e; line-height: 1; }
.stat-label { display: block; font-size: .72rem; color: #888; margin-top: .25rem; }

/* Genre tags */
.genre-tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.genre-tag { display: inline-block; background: #f0f0f0; border: 1px solid #ddd; border-radius: 20px; padding: .2rem .7rem; font-size: .78rem; color: #444; }
.genre-tag.small { font-size: .72rem; padding: .1rem .5rem; }

/* Feedback activity list */
.feedback-activity-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.feedback-activity-list li { font-size: .9rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.activity-time { color: #aaa; font-size: .78rem; margin-left: auto; }
.author-link { color: inherit; text-decoration: none; font-weight: 600; }
.author-link:hover { text-decoration: underline; }

/* Profile edit */
.profile-preview { display: flex; align-items: center; gap: 1rem; background: #f7f7f7; border: 1px solid #eee; border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; font-size: 1.1rem; font-weight: 600; }
.color-picker-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
input[type=color] { width: 48px; height: 36px; padding: 2px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; }

/* Submission form — chapter toggle */
.chapter-toggle-row { margin: 1rem 0; }
.toggle-label { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; font-size: .95rem; }
.toggle-label input[type=checkbox] { width: auto; margin: 0; }

/* Multi-chapter builder */
.chapter-block { border: 1px solid #ddd; border-radius: 6px; padding: 1.25rem; margin-bottom: 1rem; background: #fafafa; }
.chapter-block-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.chapter-num-label { font-weight: 700; font-size: 1rem; color: #1a1a2e; }
.btn-remove-chapter { background: none; border: 1px solid #e74c3c; color: #e74c3c; padding: .2rem .6rem; border-radius: 4px; font-size: .8rem; cursor: pointer; }
.btn-remove-chapter:hover { background: #fdf0f0; }
.btn-add-chapter { background: #f0f4ff; border: 1px dashed #3b82f6; color: #1d4ed8; padding: .5rem 1.25rem; border-radius: 4px; font-size: .9rem; cursor: pointer; width: 100%; margin-top: .25rem; }
.btn-add-chapter:hover { background: #dbeafe; }
.multi-total-count { margin-top: .6rem; font-size: .85rem; color: #666; }
.chapter-wc { color: #888; font-size: .78rem; }

/* Multi-chapter reader */
.chapter-nav { margin-bottom: 1.5rem; }
.chapter-nav-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.chapter-nav-link { display: inline-flex; flex-direction: column; padding: .4rem .75rem; border: 1px solid #ddd; border-radius: 6px; text-decoration: none; color: #444; font-size: .8rem; background: #fafafa; transition: background .15s; min-width: 60px; }
.chapter-nav-link:hover { background: #f0f0f0; border-color: #aaa; }
.chapter-nav-link.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.ch-num { font-weight: 700; font-size: .75rem; }
.ch-title { font-size: .72rem; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.chapter-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .75rem; flex-wrap: wrap; gap: .5rem; }
.chapter-title { font-size: 1.2rem; font-weight: 700; }
.chapter-pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #eee; flex-wrap: wrap; gap: .5rem; }
.btn-chapter-nav { display: inline-block; padding: .5rem 1.1rem; background: #1a1a2e; color: #fff; border-radius: 4px; text-decoration: none; font-size: .9rem; }
.btn-chapter-nav:hover { background: #2d2d4e; }
.chapter-progress { color: #888; font-size: .85rem; }
.chapter-end { color: #27ae60; font-size: .85rem; font-weight: 600; }

/* Multi-chapter badge */
.multi-badge { display: inline-block; background: #e0e7ff; color: #3730a3; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 3px; }

/* Genre multi-select on submission form */
select[multiple] { height: auto; padding: .25rem; font-size: .9rem; }
select[multiple] option { padding: .3rem .6rem; border-radius: 3px; }
select[multiple] option:checked { background: #1a1a2e; color: #fff; }

/* ── Admin ───────────────────────────────────────────────────────────────── */
.admin-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 2rem; }
@media (max-width: 700px) { .admin-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.admin-stat { background: #f7f7f7; border: 1px solid #eee; border-radius: 8px; padding: .9rem; text-align: center; font-size: .8rem; color: #666; }
.admin-stat span { display: block; font-size: 2rem; font-weight: 700; color: #1a1a2e; line-height: 1.1; }
.admin-stat.warn { border-color: #f5c6cb; background: #fdf0f0; }
.admin-stat.warn span { color: #c0392b; }

.admin-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
@media (max-width: 700px) { .admin-grid-2 { grid-template-columns: 1fr; } }

.admin-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.admin-table-full { table-layout: fixed; }
.admin-table th { background: #1a1a2e; color: #fff; padding: .45rem .65rem; text-align: left; font-weight: 600; white-space: nowrap; }
.admin-table td { padding: .4rem .65rem; border-bottom: 1px solid #eee; vertical-align: top; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.admin-table tr:hover td { background: #f7f7f7; }
.row-warn td { background: #fdf5f5; }
.row-spend td { background: #fdf5f5; }
.row-warn:hover td { background: #fdecea; }
.muted { color: #aaa; font-size: .82rem; }
.text-warn { color: #c0392b; font-weight: 700; }
.text-ok { color: #27ae60; font-weight: 700; }
.ua-cell { color: #888; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.feedback-preview { color: #555; font-size: .78rem; white-space: normal; }
.badge-ok   { background: #d4edda; color: #155724; padding: .1rem .45rem; border-radius: 3px; font-size: .75rem; font-weight: 600; }
.badge-fail { background: #f8d7da; color: #721c24; padding: .1rem .45rem; border-radius: 3px; font-size: .75rem; font-weight: 600; }
.action-tag { background: #e0e7ff; color: #3730a3; padding: .1rem .4rem; border-radius: 3px; font-size: .72rem; font-weight: 600; }
.role-badge { padding: .15rem .5rem; border-radius: 3px; font-size: .72rem; font-weight: 700; }
.role-admin  { background: #1a1a2e; color: #f0c040; }
.role-reader { background: #dbeafe; color: #1d4ed8; }
.role-writer { background: #d1fae5; color: #065f46; }
.role-pending{ background: #f3f4f6; color: #6b7280; }

.admin-user-header { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; padding: 1rem; background: #f7f7f7; border-radius: 8px; border: 1px solid #eee; }
.admin-user-header > div { flex: 1; }
.admin-user-header h1 { font-size: 1.4rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.btn-back { display: inline-block; padding: .4rem 1rem; border: 1px solid #ccc; border-radius: 4px; font-size: .85rem; text-decoration: none; color: #444; white-space: nowrap; }

.admin-alert { background: #fdf5e4; border: 1px solid #f0c040; border-radius: 6px; padding: .75rem 1rem; margin-bottom: 1.5rem; font-size: .9rem; }
.admin-alert a { color: #1a1a2e; font-weight: 600; }

.admin-tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; border-bottom: 2px solid #eee; padding-bottom: .5rem; }
.tab-btn { background: #f0f0f0; border: 1px solid #ddd; border-radius: 4px 4px 0 0; padding: .4rem .9rem; font-size: .82rem; cursor: pointer; color: #444; }
.tab-btn.active { background: #1a1a2e; color: #fff; border-color: #1a1a2e; }
.tab-panel { display: none; overflow-x: auto; }
.tab-panel.active { display: block; }
