:root {
  --bg: #f6f4ef; --card: #ffffff; --ink: #1d1f24; --soft: #5b606b; --line: #e3e0d8;
  --accent: #e2711d; --accent-ink: #ffffff; --chip: #efece4; --good: #2f8f4e; --bad: #b8433a;
  --shadow: 0 2px 10px rgba(0,0,0,.07);
}
:root[data-theme="dark"] {
  --bg: #14161c; --card: #1e2129; --ink: #eceae4; --soft: #a3a7b1; --line: #2e323c;
  --accent: #f08a3e; --accent-ink: #14161c; --chip: #272b35; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --card: #1e2129; --ink: #eceae4; --soft: #a3a7b1; --line: #2e323c;
    --accent: #f08a3e; --accent-ink: #14161c; --chip: #272b35; --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 19px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-size: 21px; margin: 0; flex: 1; }
.streak { font-weight: 700; color: var(--accent); }
.iconbtn { background: none; border: 0; font-size: 22px; padding: 4px 6px; }
main { max-width: 680px; margin: 0 auto; padding: 12px 16px; }
.h { font-size: 22px; margin: 8px 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.row.sticky { position: sticky; top: 58px; z-index: 4; background: var(--bg); padding: 8px 0; }
.row button, .small-print button, .linkbtn {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px;
}
button.big { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.loader { text-align: center; color: var(--soft); padding: 26px 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  margin: 0 0 18px; box-shadow: var(--shadow);
}
.card img.pic { width: 100%; max-height: 260px; object-fit: cover; display: block; background: var(--chip); }
.card .body { padding: 16px 18px 12px; }
.tag { display: inline-block; font-size: 14px; background: var(--chip); color: var(--soft); padding: 3px 10px; border-radius: 99px; }
.why { font-size: 14px; color: var(--soft); margin-left: 6px; }
.card h2 { font-size: 24px; line-height: 1.25; margin: 10px 0 8px; }
.card p { margin: 0 0 10px; }
.card .more { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.card .more h3 { font-size: 20px; margin: 18px 0 6px; }
.card .more h4 { font-size: 18px; margin: 14px 0 4px; color: var(--soft); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.actions button {
  border: 1px solid var(--line); background: transparent; border-radius: 12px; padding: 8px 12px; min-width: 48px; min-height: 44px;
}
.actions button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions .read { margin-left: auto; font-weight: 700; }
.card.gone .body > *:not(.gonemsg) { display: none; }
.card.gone img { display: none; }
.gonemsg { color: var(--soft); font-size: 16px; }
.mini { font-size: 15px; color: var(--soft); }

.group { margin: 18px 0 6px; font-size: 17px; color: var(--soft); text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 9px 14px; font-size: 17px;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.welcome h2 { margin: 6px 0 4px; }
.small-print { color: var(--soft); font-size: 15px; margin: 30px 0; }
.otd { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; }
.otd b { color: var(--accent); }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; background: none; border: 0; padding: 8px 0 6px; font-size: 20px; display: flex; flex-direction: column; align-items: center; color: var(--soft); }
.tabs button span { font-size: 12px; }
.tabs button.on { color: var(--accent); }
.tabs button[hidden] { display: none; }
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 16px; z-index: 9; max-width: 90vw;
}
input[type=search], input[type=text], textarea {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
}

/* books */
.searchrow { display: flex; gap: 8px; margin-bottom: 12px; }
.searchrow input { flex: 1; }
.sub { font-size: 19px; margin: 20px 0 8px; }
.bookrow { display: flex; gap: 12px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 8px; align-items: center; }
.bookrow .cover, .bookrow .nocover { width: 54px; height: 80px; object-fit: cover; border-radius: 6px; flex: none; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.bk { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bk b { font-size: 18px; line-height: 1.3; }
.bk span { font-size: 15px; color: var(--soft); }
.badge { font-size: 13px !important; color: var(--accent) !important; }
.bookhead { display: flex; gap: 14px; margin: 12px 0; align-items: flex-start; }
.bookhead h2 { margin: 0 0 4px; font-size: 23px; line-height: 1.25; }
.bookhead p { margin: 0; color: var(--soft); }
.bigcover { width: 110px; border-radius: 8px; flex: none; }
.bigcover.nocover { height: 160px; background: var(--chip); display: flex; align-items: center; justify-content: center; font-size: 40px; }
a.linkbtn { text-decoration: none; color: var(--ink); display: inline-block; }
.cardform { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.cardform .sub { margin: 4px 0 0; }
.reader { font-size: 20px; line-height: 1.7; }
.reader h3 { margin: 22px 0 8px; }
.readnav { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; }
.readnav button { flex: 1; }

/* my shelf */
.pdfpage { display: block; width: 100%; border-radius: 8px; background: #fff; }
.epub { width: 100%; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.bk.plain { background: none; border: 0; text-align: left; flex: 1; padding: 0; }

/* kweeklee extras */
.card { touch-action: pan-y; transition: transform .15s ease, opacity .15s ease; }
.try { background: var(--chip); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 17px; }
.try .actions { margin-top: 6px; }
.review { background: var(--card); border: 2px solid var(--accent); border-radius: 18px; padding: 12px 16px; margin-bottom: 18px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0; }
select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.bigidea { font-size: 22px; font-weight: 700; line-height: 1.35; }

/* ===== KRANIAC: electric theme, splash, pictures, listen bar, viewer ===== */
:root { --accent: #6c3cff; --accent-ink: #ffffff; --spark: #00b8d9; }
:root[data-theme="dark"] { --bg: #0b0b14; --card: #15151f; --line: #262636; --chip: #1f1f2c; --accent: #8f6bff; --accent-ink: #0b0b14; --spark: #22e1ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg: #0b0b14; --card: #15151f; --line: #262636; --chip: #1f1f2c; --accent: #8f6bff; --accent-ink: #0b0b14; --spark: #22e1ff; } }
.wm { font-weight: 900; letter-spacing: .14em; background: linear-gradient(90deg, #22e1ff, #8f6bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.splash { position: fixed; inset: 0; z-index: 50; background: radial-gradient(circle at 50% 40%, #1a1440 0%, #0b0b14 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; animation: splashAuto .4s ease 2.4s forwards; cursor: pointer; }
.splash.out { opacity: 0; transition: opacity .4s ease; pointer-events: none; }
@keyframes splashAuto { to { opacity: 0; visibility: hidden; pointer-events: none; } }
.splash .wm.big { font-size: 44px; animation: rise .7s ease .35s both; }
.splash .slogan { color: #a9a6c9; letter-spacing: .3em; text-transform: uppercase; font-size: 13px; animation: rise .7s ease .6s both; }
.brain { width: 190px; height: 152px; }
.brain .lobe { fill: none; stroke: url(#kg); stroke-width: 5; stroke-dasharray: 520; stroke-dashoffset: 520; animation: draw 1s ease forwards; }
.brain .fold { fill: none; stroke: url(#kg); stroke-width: 3; stroke-linecap: round; opacity: .55; stroke-dasharray: 300; stroke-dashoffset: 300; animation: draw 1s ease .25s forwards; }
.brain .bolt { fill: #fff; opacity: 0; transform-origin: 100px 80px; animation: zap .5s ease .7s forwards; filter: drop-shadow(0 0 8px #22e1ff); }
.brain .spark { fill: #22e1ff; animation: pulse 1.2s ease-in-out infinite; }
.brain .s2, .brain .s3 { fill: #8f6bff; animation-delay: .4s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes zap { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; transform: scale(1.15); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .splash, .splash * { animation-duration: .01s !important; animation-delay: 0s !important; } }
.brand .wm { font-size: 22px; }
.picbox { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #1a1440, #0e2a3a); overflow: hidden; }
.picbox .pic, .card img.pic { width: 100%; height: 100%; max-height: none; object-fit: cover; display: block; }
.nopic { display: flex; align-items: center; justify-content: center; font-size: 48px; height: 100%; }
.s.speaking { background: color-mix(in srgb, var(--spark) 30%, transparent); border-radius: 4px; }
.actions .listen { font-weight: 700; }
.listenbar { position: fixed; left: 8px; right: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 8; background: var(--card); border: 1px solid var(--accent); border-radius: 16px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.35); max-width: 680px; margin: 0 auto; }
.lb-row { display: flex; gap: 8px; align-items: center; }
.lb-row + .lb-row { margin-top: 6px; }
.lb-play { font-size: 22px; min-width: 48px; min-height: 44px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); }
.lb-text { flex: 1; font-size: 15px; line-height: 1.35; max-height: 2.7em; overflow: hidden; }
.lb-row button:not(.lb-play) { background: none; border: 1px solid var(--line); border-radius: 10px; min-width: 40px; min-height: 40px; }
.lb-voice { flex: 1; min-width: 0; }
body.listening main { padding-bottom: 120px; }
.listenall { width: 100%; }
.viewer { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.vw-top { display: flex; gap: 8px; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--line); }
.vw-title { flex: 1; font-size: 15px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.viewer iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.vw-msg { padding: 24px 18px; }
button.linkbtn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 14px; }
.article .card { margin-bottom: 12px; }

/* growth */
.level { display: flex; flex-direction: column; gap: 3px; background: none; border: 0; padding: 2px 4px; font-size: 13px; color: var(--soft); align-items: flex-start; }
.bar { display: block; width: 70px; height: 5px; border-radius: 9px; background: var(--chip); overflow: hidden; }
.bar.wide { width: 100%; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #22e1ff, #8f6bff); }
.surprise { border-color: var(--accent); }
.quote blockquote { font-size: 24px; line-height: 1.4; margin: 14px 0 6px; font-weight: 700; }
.answer { display: block; width: 100%; text-align: left; margin: 8px 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.answer.good { background: #1f7a45; color: #fff; } .answer.bad { background: #8a2b2b; color: #fff; }
.rabbit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.rabbit .chip { font-size: 15px; padding: 6px 10px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; align-items: center; border-bottom: 1px solid var(--line); }
.rabbitpanel { overflow-y: auto; }
