/* ReadingLog. Four looks set per person: little, kid, teen, grownup. Light and dark follow the device. */
:root {
  --bg: #fbf8f3; --card: #ffffff; --ink: #1f2a33; --muted: #66727c; --line: #e4ddd2;
  --accent: #2f6f8f; --accent-ink: #fff; --soft: #e8f1f5; --warn: #b4540a; --bad: #b42318; --ok: #2e7d32;
  --radius: 12px; --gap: 14px; --tile: 120px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --size: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14191d; --card: #1d242a; --ink: #e9eef2; --muted: #9aa7b1; --line: #2f3a43; --accent: #6bb3d6; --accent-ink: #0b1418; --soft: #22323c; --warn: #f0a35b; --bad: #ff8a80; --ok: #81c784; }
}
.theme-kid { --accent: #e0662f; --soft: #fdeee4; --radius: 18px; --tile: 140px; --size: 17px; }
.theme-little { --accent: #7b4fd6; --soft: #efe8fb; --radius: 26px; --tile: 190px; --size: 20px; }
.theme-teen { --accent: #3d7a5c; --soft: #e5f1ea; --tile: 120px; }
@media (prefers-color-scheme: dark) {
  .theme-kid { --accent: #ff9a66; --soft: #3a2a20; } .theme-little { --accent: #b79cff; --soft: #2c2440; } .theme-teen { --accent: #7cc8a0; --soft: #1f3329; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--size)/1.45 var(--font); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
h1 { font-size: 1.6em; margin: .3em 0 .4em; } h2 { font-size: 1.2em; margin: 1.2em 0 .5em; } h3 { margin: 1em 0 .5em; }
h1 small { font-size: .6em; color: var(--muted); font-weight: normal; }
.muted { color: var(--muted); } .small { font-size: .87em; } .center { text-align: center; }
.loading { color: var(--muted); padding: 2em 0; text-align: center; }
section { margin-bottom: 1.2em; }

/* header and bottom navigation */
#top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.1em; }
.brand .logo { font-size: 1.4em; } #env { color: var(--bad); font-size: .7em; }
#nav { flex: 1; display: flex; gap: 4px; justify-content: center; }
#nav a { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink); }
#nav a.on { background: var(--soft); color: var(--accent); font-weight: 600; }
.me { margin-left: auto; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 4px 12px 4px 4px; font: inherit; cursor: pointer; }
.av { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; background: var(--soft); }
.av.big { width: 84px; height: 84px; font-size: 48px; }
@media (max-width: 760px) {
  #nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  #nav a { flex-direction: column; gap: 0; padding: 4px 6px; font-size: .72em; border-radius: 10px; }
  #nav a .i { font-size: 1.6em; }
  .me .t { display: none; } .me { padding: 4px; }
}
@media (min-width: 761px) { body { padding-bottom: 24px; } }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.big { padding: 14px 22px; font-size: 1.1em; }
.btn.small { padding: 5px 10px; min-height: 34px; font-size: .9em; }
.btn.on { background: var(--soft); border-color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 4px; text-decoration: underline; }
.danger { color: var(--bad) !important; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 44px; width: 100%; }
textarea { min-height: 80px; }
input.short, .short { width: 7em; }
input[type=color] { padding: 2px; width: 60px; }
input[type=checkbox] { width: auto; min-height: 0; transform: scale(1.3); }
label { display: block; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: normal; }
label.check { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > label { flex: 1; }
.wrap { flex-wrap: wrap; }
.row.inline { margin: 8px 0; } .row.inline input { flex: 1; }
fieldset { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card.narrow { max-width: 440px; margin: 8vh auto; }
.note { background: var(--soft); padding: 8px 12px; border-radius: 10px; }
.alert { background: var(--soft); border-left: 4px solid var(--warn); padding: 4px 16px 12px; border-radius: 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .92em; cursor: pointer; }
.chip.on { background: var(--soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip small { color: var(--muted); font-size: .8em; }
.whopick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.whopick .chip { border-left: 5px solid var(--c, var(--line)); opacity: .55; }
.whopick .chip.on { opacity: 1; }
.filters { margin: 10px 0; } .filters select { width: auto; min-height: 36px; padding: 4px 8px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--soft); font-size: .85em; margin: 2px; border: 1px solid transparent; font-family: inherit; color: var(--ink); }
button.tag { cursor: pointer; } button.tag.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.due { font-size: .88em; color: var(--muted); } .due.soon { color: var(--warn); font-weight: 600; } .due.overdue { color: var(--bad); font-weight: 700; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.list > li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
ul.list > li > div:first-child { flex: 1; min-width: 200px; }
.mini { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; flex: 1; min-width: 200px; }

/* covers and tiles */
.cover { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; background: var(--soft); box-shadow: 0 1px 3px #0002; display: block; }
.cover.blank { display: grid; place-items: center; padding: 8px; text-align: center; background: hsl(var(--h) 45% 55%); color: #fff; font-weight: 700; font-size: .85em; overflow: hidden; }
.cover.small { width: 54px; } .cover.tiny { width: 40px; font-size: .5em; } .cover.large { width: 180px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: var(--gap); }
.tile { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); background: none; border: 0; padding: 0; font: inherit; text-align: left; cursor: pointer; }
.tile .tt { font-weight: 600; font-size: .92em; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .ta, .tile .tx { font-size: .8em; color: var(--muted); }
.tile-wrap { display: flex; flex-direction: column; gap: 6px; }
.results { display: flex; flex-direction: column; gap: 6px; }
.result { display: flex; gap: 12px; align-items: center; text-align: left; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.result:hover { border-color: var(--accent); }

/* a book */
.book-head { display: flex; gap: 18px; align-items: flex-start; }
.book-head > .cover, .book-head > img.cover { width: 110px; flex: none; }
.book-head.big .cover-wrap { display: flex; flex-direction: column; gap: 8px; align-items: center; flex: none; }
.book-head h1, .book-head h2 { margin-top: 0; } .book-head .sub { margin: -.3em 0 .3em; font-size: 1.05em; } .authors { font-size: 1.1em; margin: 0; }
.actions { margin-top: 12px; }
@media (max-width: 560px) { .book-head.big { flex-direction: column; align-items: center; text-align: center; } .book-head.big .actions { justify-content: center; } .cover.large { width: 150px; } }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }
.reads > li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.reads .who { display: flex; gap: 6px; flex-wrap: wrap; }
.reads .chip { border-left: 5px solid var(--c, var(--line)); cursor: default; }
.review { margin: 4px 0; padding: 8px 12px; background: var(--soft); border-radius: 10px; }
.review p { margin: 6px 0 0; white-space: pre-wrap; }
.rv-who { font-size: .85em; color: var(--muted); margin-right: 8px; }
.feeling { font-size: 1.4em; } .stars { color: #e3a008; letter-spacing: 1px; }
.desc { white-space: pre-wrap; max-width: 70ch; }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.choice .i { font-size: 2em; } .choice.on { border-color: var(--accent); background: var(--soft); font-weight: 600; }
.tree { list-style: none; padding-left: 22px; margin: 0; border-left: 2px solid var(--line); }
.tree.top { padding-left: 0; border: 0; }
.place { display: flex; align-items: center; gap: 10px; padding: 8px 0; flex-wrap: wrap; }
.place > a:first-child { font-weight: 600; text-decoration: none; }

/* review form */
.feelings { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.feel { font-size: 2em; width: 58px; height: 58px; border-radius: 50%; border: 2px solid transparent; background: var(--soft); cursor: pointer; }
.feel.on { border-color: var(--accent); transform: scale(1.12); }
.starpick { display: flex; justify-content: center; gap: 4px; }
.starpick button { font-size: 2.4em; background: none; border: 0; color: var(--line); cursor: pointer; padding: 0 4px; }
.starpick button.on { color: #e3a008; }
.themepick { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.themepick input { width: 8em; min-height: 32px; padding: 3px 8px; }
.emojis { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.emojis button { font-size: 1.5em; background: var(--soft); border: 2px solid transparent; border-radius: 10px; width: 46px; height: 46px; cursor: pointer; }
.emojis button.on { border-color: var(--accent); }

/* profiles and PIN */
.who-grid { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin: 20px 0; }
.who { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--card); border: 3px solid var(--c, var(--line)); border-radius: 22px; padding: 16px 20px; min-width: 130px; font: inherit; font-size: 1.15em; font-weight: 600; color: var(--ink); cursor: pointer; }
.who .av { background: transparent; }
.who-grid.small .who { min-width: 100px; padding: 10px 14px; font-size: 1em; } .who-grid.small .av.big { width: 56px; height: 56px; font-size: 34px; }
.pinpad { display: inline-flex; flex-direction: column; gap: 12px; margin: 10px auto; }
.pinpad .dots { font-size: 1.6em; letter-spacing: 8px; min-height: 1.6em; text-align: center; }
.pinpad .keys { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; }
.pinpad .keys button { height: 64px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 1.5em; cursor: pointer; }
.pinpad.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* dialog, toast, celebrate, scanner */
dialog { border: 0; border-radius: var(--radius); padding: 18px 20px; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px #0005; }
dialog.wide { width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: #0006; }
dialog h2 { margin-top: 0; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; transition: .25s; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 20; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.celebrate { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; z-index: 30; pointer-events: none; animation: pop 1.6s forwards; }
.celebrate span { font-size: 120px; } .celebrate b { font-size: 2em; color: var(--accent); text-shadow: 0 2px 0 var(--card); }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 20% { transform: scale(1.1); opacity: 1; } 70% { opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.scanner { position: fixed; inset: 0; background: #000; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: #fff; }
.scanner video { width: 100%; max-height: 70vh; object-fit: cover; }
.scanner .frame { position: absolute; top: 35%; left: 12%; right: 12%; height: 18%; border: 3px solid #fff8; border-radius: 12px; pointer-events: none; }

.hello h1 { margin-bottom: .1em; } .stats { margin: 0 0 12px; } .stats.big { font-size: 1.3em; }

/* little: big, simple, pictures first */
.theme-little .tiles.big .tt { font-size: 1em; }
.theme-little #nav a .t { font-size: 1em; }
.theme-little .btn { min-height: 56px; }
/* grown-ups: tighter */
.theme-grownup .tile .tt { font-size: .88em; }
