:root {
  --bar: #005C75; --bg: #04191F; --card: #1C3239; --text: #F0F4F5; --muted: #9DB0B7; --divider: #2A4650;
  --accent: #F2B134; --inactive: #8A98A6; --placeholder: #34546C;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 Roboto, "Segoe UI", Helvetica, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; cursor: pointer; }
.iconBtn { background: none; border: 0; color: inherit; font-size: 22px; width: 44px; height: 44px; border-radius: 22px; display: inline-flex; align-items: center; justify-content: center; }
.iconBtn svg { width: 24px; height: 24px; fill: currentColor; }
.iconBtn:hover { background: rgba(255,255,255,.1); }
.textBtn { background: none; text-decoration: none; display: inline-block; border: 0; color: var(--accent); font-weight: 600; padding: 8px 12px; border-radius: 6px; }
.textBtn.small { padding: 2px 8px; font-size: 13px; }
.primary { background: var(--accent); color: #1A1A1A; border: 0; font-weight: 700; padding: 10px 18px; border-radius: 6px; }
#app { display: flex; flex-direction: column; height: 100%; }
.bar { display: flex; align-items: center; gap: 6px; background: var(--bar); color: #fff; padding: 0 8px; height: 56px; flex: none; box-shadow: 0 2px 6px rgba(0,0,0,.4); z-index: 5; }
.bar h1 { font-size: 17px; font-weight: 500; margin: 0 8px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#search { width: 220px; max-width: 40vw; padding: 7px 10px; border-radius: 18px; border: 0; background: rgba(255,255,255,.15); color: #fff; }
.popup { position: absolute; top: 52px; right: 8px; background: var(--card); border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.5); z-index: 25; min-width: 240px; padding: 6px 0; }
.popupItem { padding: 11px 18px; cursor: pointer; }
.popupItem:hover { background: rgba(255,255,255,.08); }
.popupItem.on { color: var(--accent); }
.popupLabel { padding: 6px 18px 2px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.popupSep { height: 1px; background: var(--divider); margin: 6px 0; }
#dropHint { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--accent); background: rgba(4,25,31,.85); z-index: 12; pointer-events: none; }
#search::placeholder { color: rgba(255,255,255,.6); }
#sort { background: rgba(255,255,255,.15); color: #fff; border: 0; padding: 7px; border-radius: 6px; }
#sort option { color: #000; }
#main { flex: 1; overflow: auto; position: relative; }
#list { max-width: 980px; margin: 0 auto; padding: 8px; }
#drawer { position: absolute; top: 0; left: 0; bottom: 0; width: 300px; background: var(--card); z-index: 20; overflow: auto; box-shadow: 4px 0 16px rgba(0,0,0,.5); }
.drawerHead { padding: 22px 24px 12px; font-size: 20px; font-weight: 700; border-bottom: 1px solid var(--divider); background: var(--bar); color: #fff; }
.drawerItem { display: flex; align-items: center; gap: 16px; padding: 11px 24px; cursor: pointer; font-size: 15px; }
.drawerItem svg { width: 22px; height: 22px; fill: currentColor; flex: none; color: var(--muted); }
.drawerItem.selected svg { color: var(--accent); }
.drawerItem:hover { background: rgba(255,255,255,.06); }
.drawerItem.selected { color: var(--accent); }
.drawerItem .count { margin-left: auto; color: var(--muted); font-size: 13px; }
.drawerItem.sub { padding-left: 48px; }
.drawerSep { height: 1px; background: var(--divider); margin: 6px 0; }
#scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }
.panel { background: var(--card); border-radius: 10px; padding: 18px 22px; margin: 16px auto; max-width: 820px; }
.panel h2 { margin-top: 0; }
.panel code { background: rgba(0,0,0,.35); padding: 2px 6px; border-radius: 4px; user-select: all; }
.panel ol li { margin: 8px 0; }
.panel input[type=text] { width: 100%; padding: 10px; margin: 8px 0; border-radius: 6px; border: 1px solid var(--divider); background: var(--bg); color: var(--text); }
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.row.right { justify-content: flex-end; }

/* book rows, like the phone */
.book { display: flex; gap: 12px; background: var(--card); border-radius: 8px; padding: 7px; margin: 6px 0; }
.cover { width: 78px; height: 112px; flex: none; border-radius: 4px; background: var(--placeholder); display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; font-size: 11px; color: #fff; overflow: hidden; cursor: pointer; }
.cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.title { font-size: 15px; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.author { color: var(--muted); font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.pbar { height: 2px; background: var(--divider); margin: auto 0 2px; position: relative; }
.pbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); }
.actions { display: flex; justify-content: space-around; }
.actions button { background: none; border: 0; color: var(--inactive); width: 40px; height: 36px; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; position: relative; }
.actions button svg { width: 22px; height: 22px; fill: currentColor; }
.actions button sup { position: absolute; top: 2px; right: 4px; font-size: 10px; }
.actions button.on { color: var(--accent); }
.actions button:hover { background: rgba(255,255,255,.08); }
.missing { opacity: .55; }
#status { background: var(--card); padding: 10px 16px; border-top: 1px solid var(--divider); font-size: 14px; flex: none; }

/* reader */
#reader { position: fixed; inset: 0; display: flex; flex-direction: column; background: #fff; z-index: 30; }
.readerBar { transition: opacity .2s; }
.readerBar.off { opacity: 0; pointer-events: none; }
.titles { flex: 1; min-width: 0; }
.titles > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#rTitle { font-size: 16px; }
#rChapter { font-size: 12px; color: rgba(255,255,255,.75); }
#frameWrap { flex: 1; position: relative; min-height: 0; }
#frame { width: 100%; height: 100%; border: 0; display: block; background: transparent; }
.tapZone { position: absolute; top: 0; bottom: 0; width: 22%; }
#tapLeft { left: 0; } #tapRight { right: 0; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); color: #fff; font-size: 18px; }
#progress { flex: 1; accent-color: var(--accent); }
#pageInfo { min-width: 90px; text-align: center; font-size: 13px; }
.side { position: absolute; top: 56px; right: 0; bottom: 56px; width: 320px; max-width: 90vw; background: var(--card); color: var(--text); z-index: 40; overflow: auto; padding: 0 16px 16px; box-shadow: -4px 0 16px rgba(0,0,0,.5); }
.sideHead { display: flex; align-items: center; justify-content: space-between; font-weight: 700; padding: 12px 0; position: sticky; top: 0; background: var(--card); }
.side label { display: block; margin: 12px 0; }
.side select, .side input[type=range] { width: 100%; margin-top: 4px; }
.tocItem { padding: 10px 6px; cursor: pointer; border-bottom: 1px solid var(--divider); }
.tocItem.current { color: var(--accent); }
.tocItem.d1 { padding-left: 22px; } .tocItem.d2 { padding-left: 38px; }
#dialog { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 60; }
.dialogBox { background: var(--card); border-radius: 10px; padding: 18px; width: 420px; max-width: 92vw; max-height: 80vh; overflow: auto; }
.dialogBox label { display: block; padding: 6px 0; }
.dialogBox input[type=text] { width: 100%; padding: 8px; border-radius: 6px; border: 1px solid var(--divider); background: var(--bg); color: var(--text); }
@media (max-width: 640px) { .cover { width: 80px; height: 116px; } #search { display: none; } .bar h1 { font-size: 17px; } }

/* settings page, laid out like the phone's */
#settingsPanel { max-width: 760px; }
.setHead { display: flex; align-items: center; gap: 8px; margin: -6px 0 6px -8px; }
.setHead h2 { margin: 0; font-size: 20px; }
.setLabel { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 6px; padding-top: 10px; border-top: 1px solid var(--divider); }
.setLabel:first-of-type { border-top: 0; padding-top: 0; margin-top: 4px; }
.setHint { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.setRow { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 6px 0; }
.setRow label { display: flex; align-items: center; gap: 8px; }
.setRow select, .setRow input[type=number] { background: var(--bg); color: var(--text); border: 1px solid var(--divider); border-radius: 6px; padding: 6px 8px; }
.setRow input[type=range] { width: 160px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.swatch { width: 44px; height: 44px; border-radius: 22px; border: 3px solid transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.swatch.on { border-color: var(--accent); }
.swatch span { width: 18px; height: 18px; border-radius: 9px; }
.drawerPref { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.drawerPref .name { flex: 1; }
.drawerPref .textBtn.small { padding: 0 6px; }

/* ---- web 52: the reader's second and third rows, as on the phone ---- */
.subRow { flex: none; display: flex; align-items: center; gap: 10px; padding: 4px 12px; background: rgba(255,255,255,.95); color: rgba(0,0,0,.7); font-size: 13px; transition: opacity .2s; z-index: 4; }
.subRow.col { flex-direction: column; align-items: stretch; gap: 0; padding-bottom: 2px; }
.subRow.off, .subRow.hidden { opacity: 0; pointer-events: none; }
.subRow.hidden { display: none; }
.subRow input[type=range] { flex: 1; accent-color: #666; min-width: 0; }
.subRow .textBtn { color: rgba(0,0,0,.65); font-weight: 700; padding: 6px 8px; }
.subRow .iconBtn { color: rgba(0,0,0,.55); }
.aIcon { width: 28px; height: 28px; background: #777; color: #fff; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.pageRowTop { display: flex; align-items: center; gap: 8px; }
#pageLabel { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#optSwatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0 12px; }
#optSwatches i { display: block; height: 30px; border-radius: 6px; border: 2px solid rgba(128,128,128,.4); cursor: pointer; }
#optSwatches i.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.lbl { font-size: 13px; margin-top: 6px; color: var(--muted); }
.sideHead.sub { margin-top: 8px; font-size: 14px; color: var(--muted); }
#bmItems .bmItem, #searchItems .hit { padding: 8px 14px; cursor: pointer; border-bottom: 1px solid var(--divider); font-size: 14px; }
#bmItems .bmItem:hover, #searchItems .hit:hover { background: rgba(128,128,128,.15); }
#searchItems .hit small { display: block; color: var(--muted); }
#searchItems mark { background: var(--accent); color: #000; }
.searchBox { padding: 8px 12px; } .searchBox input { width: 100%; box-sizing: border-box; padding: 8px; border-radius: 6px; border: 1px solid var(--divider); background: var(--card); color: var(--text); font-size: 15px; }
#bmBtn.on { color: var(--accent); }
/* ---- library views: list (default), grid and bookshelf ---- */
#list.grid, #list.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
#list.grid .book, #list.shelf .book { flex-direction: column; align-items: center; margin: 0; padding: 6px; text-align: center; gap: 6px; }
#list.grid .cover, #list.shelf .cover { width: 100%; height: 150px; }
#list.grid .info, #list.shelf .info { width: 100%; }
#list.grid .author, #list.grid .meta, #list.grid .actions, #list.shelf .author, #list.shelf .meta, #list.shelf .actions { display: none; }
#list.grid .title, #list.shelf .title { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#list.shelf { background: linear-gradient(var(--bg), var(--bg)); padding: 14px 10px; }
#list.shelf .book { background: transparent; border-bottom: 12px solid #6b4a2b; border-radius: 2px; box-shadow: 0 6px 0 -2px rgba(0,0,0,.35); }
#list.shelf .cover { box-shadow: 3px 3px 6px rgba(0,0,0,.45); }

/* web 72: Continue card and statistics bars */
.continueCard { display: flex; align-items: center; gap: 12px; margin: 8px 8px 4px; padding: 12px 14px; background: var(--card); border-radius: 12px; cursor: pointer; }
.continueCard .cTxt { flex: 1; min-width: 0; }
.continueCard .cLab { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.continueCard .title { font-weight: 700; font-size: 16px; }
.continueCard .meta { font-size: 13px; opacity: .75; margin-top: 2px; }
.continueCard .pbar { margin-top: 8px; height: 3px; }
.continueCard .cListen { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--accent); color: #1C1C1C; display: flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.continueCard .cListen svg { width: 24px; height: 24px; fill: currentColor; }
.sbars { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin: 12px 0 4px; }
.sbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; padding-bottom: 16px; }
.sbar i { display: block; background: var(--accent); border-radius: 3px; }
.sbar i.l { opacity: .45; }
.sbar span { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 10px; opacity: .6; }
/* web 76 (review item 12): on a phone-width screen the shelf name had no room ("Readin…"); the buttons get narrower so the name shows */
@media (max-width: 480px) { .bar { padding-left: 2px; padding-right: 2px; gap: 1px; } .bar .iconBtn { width: 38px; min-width: 38px; } .bar h1 { margin: 0 4px; min-width: 0; font-size: 17px; } .bar #accountBtn { padding: 4px 6px; font-size: 13px; } }
@media (max-width: 380px) { .bar .iconBtn { width: 34px; min-width: 34px; } .bar .iconBtn svg { width: 22px; height: 22px; } .bar h1 { font-size: 16px; } }
/* license screen (license.js): covers the whole page on the Windows and web editions until a key is entered */
#licenseGate { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
#licenseGate .licBox { background: var(--card); border-radius: 10px; padding: 22px 26px; max-width: 560px; width: 100%; }
#licenseGate h1 { font-size: 22px; margin: 0 0 4px; }
#licenseGate h1 .muted { font-size: 16px; font-weight: 400; }
#licenseGate h2 { font-size: 18px; margin: 12px 0 8px; }
#licenseGate input[type=text] { width: 100%; padding: 10px; margin: 8px 0; border-radius: 6px; border: 1px solid var(--divider); background: var(--bg); color: var(--text); font-family: Consolas, monospace; }
#licenseGate .row { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; flex-wrap: wrap; }
#licenseGate .primary[disabled] { opacity: .6; cursor: default; }
#licenseGate .licMsg { margin: 6px 0 10px; }
#licenseGate .licErr { color: #FF8A80; font-weight: 600; margin: 6px 0 10px; }
#licenseGate a { color: var(--accent); }
/* web 82, tablets (owner 8 Nov): a wide screen shows the book list in two columns, and grid covers grow like the phone's tablet sizes */
@media (min-width: 1100px) { #list:not(.grid):not(.shelf) { max-width: 1400px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; } #list:not(.grid):not(.shelf) > :not(.book) { grid-column: 1 / -1; } }
@media (min-width: 900px) { #list.grid, #list.shelf { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; } #list.grid .cover, #list.shelf .cover { height: 196px; } }
