:root {
  color-scheme: dark;
  --bg: #0d1017;
  --panel: rgba(22, 27, 39, .82);
  --panel-solid: #171d2a;
  --line: rgba(255, 255, 255, .1);
  --line-strong: rgba(255, 255, 255, .18);
  --text: #f2f5fb;
  --muted: #8f9aae;
  --muted-light: #b3bdcd;
  --accent: #9be7d5;
  --accent-strong: #5dd3bc;
  --violet: #a78bfa;
  --danger: #ff8e9d;
  --shadow: 0 24px 80px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 44px));
  height: 76px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark, .login-logo {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 11px;
  color: #10151b;
  background: linear-gradient(145deg, var(--accent), #d4fff4);
  box-shadow: 0 8px 25px rgba(93, 211, 188, .18);
  font-size: 21px;
  font-weight: 900;
}

.brand strong { display: block; font-size: 14px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--muted-light); font-size: 12px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 12px currentColor; }
.status-pill.ready i { color: var(--accent-strong); background: currentColor; }
.ghost-button, .page-button, .secondary-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted-light);
  background: rgba(255, 255, 255, .035);
  transition: border-color .2s, background .2s, color .2s, transform .2s;
}
.ghost-button { padding: 8px 12px; font-size: 12px; }
.ghost-button:hover, .page-button:hover, .secondary-button:hover { border-color: var(--line-strong); color: var(--text); background: rgba(255, 255, 255, .08); }

.page-shell { width: min(1180px, calc(100% - 44px)); margin: 0 auto; }
.hero-panel { padding: 96px 0 60px; }
.hero-panel h1 { max-width: 720px; margin: 15px 0 12px; font-size: clamp(42px, 6vw, 74px); line-height: .99; letter-spacing: -.065em; }
.hero-panel h1 em { color: var(--accent); font-style: normal; }
.hero-panel > p { max-width: 490px; margin: 0 0 33px; color: var(--muted); font-size: 15px; line-height: 1.8; }

.search-bar { display: flex; align-items: center; width: min(730px, 100%); height: 58px; padding: 5px 5px 5px 18px; border: 1px solid var(--line-strong); border-radius: 15px; background: rgba(255, 255, 255, .06); box-shadow: 0 14px 55px rgba(0, 0, 0, .16); }
.search-icon { margin-right: 11px; color: var(--accent); font-size: 25px; line-height: 1; transform: rotate(-20deg); }
.search-bar input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 15px; }
.search-bar input::placeholder { color: #667085; }
.search-bar button, .primary-button { border: 0; border-radius: 10px; color: #10151b; background: var(--accent); font-weight: 800; transition: transform .2s, background .2s, box-shadow .2s; }
.search-bar button { height: 46px; padding: 0 21px; }
.search-bar button:hover, .primary-button:hover { background: #c8fff2; box-shadow: 0 10px 28px rgba(93, 211, 188, .2); transform: translateY(-1px); }

.filter-row { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 22px; }
.filter-row label { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.filter-row select { min-width: 118px; padding: 9px 28px 9px 11px; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--muted-light); background: rgba(255, 255, 255, .035); font-size: 12px; }
.filter-row select:focus { border-color: var(--accent-strong); }
.check-label { display: flex !important; align-items: center; gap: 8px !important; height: 34px; padding: 0 4px; }
.check-label input { accent-color: var(--accent-strong); }

.results-section { padding-bottom: 85px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.section-heading h2 { margin: 8px 0 0; font-size: 25px; letter-spacing: -.03em; }
.muted-label { color: var(--muted); font-size: 12px; }
.results-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.book-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 12px 35px rgba(0, 0, 0, .12); transition: transform .25s, border-color .25s, background .25s; }
.book-card:hover { border-color: rgba(155, 231, 213, .38); background: rgba(28, 36, 51, .93); transform: translateY(-5px); }
.cover-frame { position: relative; aspect-ratio: 3 / 4.25; overflow: hidden; background: linear-gradient(145deg, #263247, #141923); }
.cover-frame img { width: 100%; height: 100%; display: block; object-fit: cover; }
.cover-fallback { display: grid; place-items: center; color: rgba(255, 255, 255, .5); background: linear-gradient(145deg, #263247, #141923); font-size: 52px; font-weight: 900; }
.cover-format { position: absolute; top: 10px; left: 10px; padding: 5px 7px; border-radius: 6px; color: #10151b; background: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.book-info { padding: 15px 15px 14px; }
.book-title { display: -webkit-box; overflow: hidden; min-height: 41px; margin: 0 0 8px; color: var(--text); font-size: 14px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.book-author { overflow: hidden; margin: 0 0 10px; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.book-meta { display: flex; gap: 6px; min-height: 19px; color: var(--muted); font-size: 10px; }
.book-meta span + span::before { margin-right: 6px; content: "·"; color: var(--line-strong); }
.card-actions { display: flex; gap: 7px; margin-top: 14px; }
.card-actions button, .card-actions a { flex: 1; padding: 8px 5px; border-radius: 8px; text-align: center; font-size: 11px; }
.card-detail { border: 1px solid var(--line); color: var(--muted-light); background: transparent; }
.card-detail:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
.card-read { border: 0; color: #0e1517; background: var(--accent); font-weight: 800; }
.card-read:hover { background: #c8fff2; }
.card-read[disabled] { cursor: default; color: var(--muted); background: rgba(255, 255, 255, .08); }

.empty-state, .loading-state { padding: 90px 20px; border: 1px dashed var(--line); border-radius: 17px; text-align: center; }
.empty-state h3 { margin: 21px 0 8px; font-size: 18px; }
.empty-state p, .loading-state { margin: 0; color: var(--muted); font-size: 13px; }
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; }
.loader { width: 14px; height: 14px; border: 2px solid rgba(155, 231, 213, .25); border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; color: var(--muted); font-size: 12px; }
.page-button { padding: 9px 13px; }
.page-button:disabled { cursor: default; opacity: .35; }

.overlay, .modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; }
.overlay { background: rgba(6, 8, 12, .78); backdrop-filter: blur(15px); }
.login-card { width: min(400px, 100%); padding: 37px; border: 1px solid var(--line-strong); border-radius: 21px; background: rgba(22, 27, 39, .94); box-shadow: var(--shadow); }
.login-logo { width: 46px; height: 46px; margin-bottom: 30px; border-radius: 14px; font-size: 27px; }
.login-card h2 { margin: 10px 0 10px; font-size: 25px; letter-spacing: -.04em; }
.login-card p { margin: 0 0 26px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.input-label { display: block; margin-bottom: 8px; color: var(--muted-light); font-size: 12px; }
.login-card input { width: 100%; height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: 0; color: var(--text); background: rgba(255, 255, 255, .05); }
.login-card input:focus { border-color: var(--accent-strong); }
.login-card .primary-button { width: 100%; height: 45px; margin-top: 14px; }
.form-error { min-height: 19px; margin-top: 11px; color: var(--danger); font-size: 12px; }
.login-note { display: block; margin-top: 22px; color: #687489; font-size: 10px; line-height: 1.6; }
code { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.modal { z-index: 15; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 8, 12, .72); backdrop-filter: blur(8px); }
.detail-card { position: relative; width: min(780px, 100%); max-height: min(700px, calc(100vh - 40px)); overflow: auto; padding: 34px; border: 1px solid var(--line-strong); border-radius: 20px; background: var(--panel-solid); box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 13px; right: 16px; width: 31px; height: 31px; border: 0; border-radius: 50%; color: var(--muted); background: rgba(255, 255, 255, .06); font-size: 22px; line-height: 1; }
.detail-layout { display: grid; grid-template-columns: 205px 1fr; gap: 31px; }
.detail-cover { aspect-ratio: 3 / 4.25; overflow: hidden; border-radius: 10px; }
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-copy { padding-top: 8px; }
.format-badge { display: inline-block; padding: 5px 8px; border-radius: 5px; color: #10151b; background: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.detail-copy h2 { margin: 14px 0 8px; font-size: clamp(25px, 4vw, 38px); line-height: 1.12; letter-spacing: -.05em; }
.detail-authors { margin: 0 0 20px; color: var(--accent); font-size: 13px; }
.meta-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 15px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.meta-item span { display: block; color: var(--muted); font-size: 10px; }
.meta-item strong { display: block; margin-top: 3px; color: var(--muted-light); font-size: 12px; font-weight: 500; }
.detail-description { max-height: 130px; overflow: auto; margin: 18px 0; color: var(--muted); font-size: 12px; line-height: 1.75; white-space: pre-line; }
.detail-actions { display: flex; gap: 10px; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; font-size: 12px; }
.secondary-button { border-color: var(--line-strong); }

.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(370px, calc(100% - 44px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--muted-light); background: #1c2331; box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .25s, transform .25s; }
.toast.visible { opacity: 1; transform: translateY(0); }
.hidden { display: none !important; }

@media (max-width: 960px) {
  .results-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .topbar, .page-shell { width: min(100% - 28px, 1180px); }
  .topbar { height: 66px; }
  .topbar-actions { gap: 10px; }
  .status-pill { display: none; }
  .hero-panel { padding: 64px 0 47px; }
  .hero-panel h1 { font-size: 48px; }
  .search-bar button { padding: 0 15px; }
  .filter-row { gap: 8px; }
  .filter-row label { flex: 1; }
  .filter-row select { width: 100%; min-width: 0; }
  .check-label { flex: 0 0 auto !important; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .book-info { padding: 12px; }
  .card-actions { flex-direction: column; }
  .detail-card { padding: 25px 20px; }
  .detail-layout { grid-template-columns: 115px 1fr; gap: 18px; }
  .detail-copy h2 { font-size: 23px; }
  .meta-list { grid-template-columns: 1fr; gap: 8px; }
  .detail-actions { flex-direction: column; }
}
