:root{
  --paper:#F4F4EF; --surface:#FFFFFF; --ink:#21251F; --muted:#6C7168;
  --line:#E2E1D8; --accent:#136B60; --accent-soft:#E3EFEC; --on-accent:#FFFFFF;
  --amber:#B27812; --amber-soft:#F6EBD6; --star:#D9A013; --danger:#A8402F;
  --font-scale:1;
}
:root[data-theme="dark"]{
  --paper:#131714; --surface:#1C211D; --ink:#E9EBE4; --muted:#979C92;
  --line:#2B322C; --accent:#43B4A2; --accent-soft:#1E3630; --on-accent:#0E1512;
  --amber:#DFA453; --amber-soft:#3A2F1B; --star:#E4B23A; --danger:#D4705E;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#131714; --surface:#1C211D; --ink:#E9EBE4; --muted:#979C92;
    --line:#2B322C; --accent:#43B4A2; --accent-soft:#1E3630; --on-accent:#0E1512;
    --amber:#DFA453; --amber-soft:#3A2F1B; --star:#E4B23A; --danger:#D4705E;
  }
}

*{box-sizing:border-box; margin:0}
html{height:100%}
body{
  height:100dvh; display:flex; flex-direction:column;
  background:var(--paper); color:var(--ink);
  font-family:"Segoe UI",system-ui,Roboto,sans-serif;
  overflow-x:hidden;
}
/* длинные слова и ссылки не должны распирать экран телефона */
.card, .top-item, .fav-item, .reader-body{overflow-wrap:anywhere}
.reader-body pre{white-space:pre-wrap; overflow-x:auto; max-width:100%}
.reader-body code{overflow-wrap:anywhere}

.appbar{
  display:flex; align-items:baseline; gap:10px;
  padding:calc(10px + env(safe-area-inset-top)) 18px 8px;
}
.brand{font-family:Georgia,"Times New Roman",serif; font-size:21px; font-weight:700}
.appbar .date{color:var(--muted); font-size:13px; margin-left:auto}

#screen{flex:1; overflow-y:auto; padding:0 14px 16px; -webkit-overflow-scrolling:touch}

/* ---------- навигация ---------- */
.tabbar{
  display:flex; border-top:1px solid var(--line); background:var(--surface);
  padding:6px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button{
  flex:1; background:none; border:none; color:var(--muted);
  font:inherit; font-size:11px; padding:6px 2px 2px; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:3px; border-radius:12px;
}
.tabbar button svg{width:22px; height:22px; stroke:currentColor; fill:none; stroke-width:1.8}
.tabbar button.active{color:var(--accent); font-weight:600}
.tabbar button:focus-visible{outline:2px solid var(--accent); outline-offset:-2px}

/* ---------- общие ---------- */
h2.sect{font-family:Georgia,serif; font-size:calc(19px * var(--font-scale)); margin:18px 4px 10px; text-wrap:balance}
.chips{display:flex; gap:8px; overflow-x:auto; padding:2px 2px 6px; scrollbar-width:none}
.chip{
  border:1px solid var(--line); background:var(--surface); color:var(--ink);
  border-radius:999px; padding:6px 13px; font:inherit; font-size:13px;
  white-space:nowrap; cursor:pointer;
}
.chip.on{background:var(--accent); color:var(--on-accent); border-color:var(--accent)}
.chip:focus-visible{outline:2px solid var(--accent); outline-offset:2px}

.card{
  background:var(--surface); border:1px solid var(--line); border-radius:16px;
  padding:14px; margin-bottom:10px; cursor:pointer; position:relative;
}
.card:focus-visible{outline:2px solid var(--accent)}
.card .cover{border-radius:10px; overflow:hidden; margin:-2px 0 10px; max-height:180px}
.card .cover img{width:100%; height:100%; object-fit:cover; display:block}
.card h3{
  font-family:Georgia,serif; font-size:calc(16.5px * var(--font-scale));
  line-height:1.3; margin-bottom:6px; padding-right:30px; text-wrap:balance;
}
.card p.sum{font-size:calc(13.5px * var(--font-scale)); line-height:1.45}
.card p.why{font-size:calc(12.5px * var(--font-scale)); margin-top:7px; color:var(--amber); line-height:1.4}
.meta{display:flex; align-items:center; gap:8px; margin-top:9px; font-size:12px; color:var(--muted); flex-wrap:wrap}
.badge{background:var(--accent-soft); color:var(--accent); border-radius:6px; padding:2px 7px; font-size:11px; font-weight:600}
.star{
  position:absolute; top:10px; right:10px; background:none; border:none;
  font-size:20px; cursor:pointer; color:var(--line); line-height:1; padding:4px;
}
.star.on{color:var(--star)}
.star:focus-visible{outline:2px solid var(--accent); border-radius:6px}

.top-wrap{background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:4px 14px; margin-bottom:10px}
.top-item{display:flex; gap:10px; padding:11px 4px; border-bottom:1px solid var(--line); cursor:pointer}
.top-item:last-child{border-bottom:none}
.top-item .dot{width:8px; height:8px; border-radius:50%; background:var(--accent); margin-top:7px; flex:none}
.top-item .dot.hot{background:var(--danger)}
.top-item h4{font-family:Georgia,serif; font-size:calc(15px * var(--font-scale)); line-height:1.35; font-weight:600}
.top-item p{font-size:calc(12.5px * var(--font-scale)); color:var(--muted); margin-top:3px; line-height:1.4}

.morebtn{
  width:100%; border:1px solid var(--line); background:var(--surface); color:var(--ink);
  border-radius:14px; padding:12px; font:inherit; font-size:14px; cursor:pointer; margin:6px 0 14px;
}
.hint{color:var(--muted); font-size:13px; margin:4px 4px 12px; line-height:1.5}
.day-head{font-size:13px; color:var(--muted); margin:16px 4px 8px; text-transform:capitalize}
mark{background:var(--amber-soft); color:var(--amber); border-radius:3px; padding:0 2px}

/* ---------- статья ---------- */
.subbar{display:flex; align-items:center; gap:8px; padding:14px 4px 6px}
.subbar .back{
  background:var(--surface); border:1px solid var(--line); border-radius:10px;
  width:36px; height:36px; font-size:18px; cursor:pointer; color:var(--ink); flex:none;
}
.subbar .grow{flex:1}
.pillbtn{
  border:1px solid var(--line); background:var(--surface); color:var(--ink);
  border-radius:10px; padding:8px 12px; font:inherit; font-size:13px; cursor:pointer;
}
.pillbtn.acc{background:var(--accent); border-color:var(--accent); color:var(--on-accent); font-weight:600}
.pillbtn:focus-visible{outline:2px solid var(--accent); outline-offset:2px}

article.reader{padding:4px 4px 20px}
article.reader .src{display:flex; align-items:center; gap:8px; font-size:13px; color:var(--muted); margin:6px 0 10px; flex-wrap:wrap}
article.reader h1{
  font-family:Georgia,serif; font-size:calc(23px * var(--font-scale));
  line-height:1.25; margin:4px 0 10px; text-wrap:balance;
}
.reader-body{max-width:62ch}
.reader-body p, .reader-body li{
  font-family:Georgia,serif; font-size:calc(16px * var(--font-scale));
  line-height:1.62; margin:0 0 14px;
}
.reader-body h2, .reader-body h3{font-family:Georgia,serif; margin:18px 0 10px; line-height:1.3}
.reader-body img{max-width:100%; height:auto; border-radius:10px; margin:6px 0}
.reader-body figcaption{font-size:13px; color:var(--muted); margin-top:-2px; margin-bottom:12px}
.reader-body a{color:var(--accent)}
.reader-body blockquote{border-left:3px solid var(--line); padding-left:12px; color:var(--muted); margin:0 0 14px}
.actionrow{display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 14px; align-items:center}

/* ---------- избранное ---------- */
.folder{background:var(--surface); border:1px solid var(--line); border-radius:14px; margin-bottom:10px; overflow:hidden}
.folder>button{
  width:100%; display:flex; align-items:center; gap:10px; padding:13px 14px;
  background:none; border:none; font:inherit; font-size:15px; font-weight:600; color:var(--ink); cursor:pointer;
}
.folder>button .cnt{margin-left:auto; color:var(--muted); font-weight:400; font-size:13px}
.folder .items{border-top:1px solid var(--line); padding:4px 14px 10px}
.fav-item{display:flex; align-items:baseline; gap:8px; padding:10px 0; border-bottom:1px solid var(--line)}
.fav-item:last-child{border-bottom:none}
.fav-item h4{flex:1; font-family:Georgia,serif; font-size:calc(14.5px * var(--font-scale)); font-weight:600; line-height:1.35; cursor:pointer}
.fav-item .mini{background:none; border:none; color:var(--muted); cursor:pointer; font-size:13px; padding:2px 4px}

/* ---------- поиск ---------- */
.searchbox{
  display:flex; align-items:center; gap:8px; background:var(--surface);
  border:1px solid var(--line); border-radius:14px; padding:11px 14px; margin:12px 0 10px;
}
.searchbox input{flex:1; border:none; background:none; font:inherit; font-size:15px; color:var(--ink); outline:none}

/* ---------- настройки ---------- */
.setrow{
  display:flex; align-items:center; gap:10px; background:var(--surface);
  border:1px solid var(--line); border-radius:14px; padding:13px 14px; margin-bottom:9px; font-size:14.5px;
}
.setrow .grow{flex:1}
.seg{display:flex; border:1px solid var(--line); border-radius:10px; overflow:hidden}
.seg button{background:var(--surface); border:none; padding:7px 11px; font:inherit; font-size:13px; cursor:pointer; color:var(--ink)}
.seg button.on{background:var(--accent); color:var(--on-accent)}
.switch{
  width:40px; height:24px; border-radius:999px; background:var(--line); border:none;
  position:relative; cursor:pointer; flex:none; transition:background .15s;
}
.switch::after{
  content:""; position:absolute; top:3px; left:3px; width:18px; height:18px;
  border-radius:50%; background:var(--surface); transition:left .15s; box-shadow:0 1px 3px rgba(0,0,0,.25);
}
.switch.on{background:var(--accent)}
.switch.on::after{left:19px}

/* ---------- плеер ---------- */
.player{display:flex; align-items:center; gap:10px; background:var(--surface); border-top:1px solid var(--line); padding:9px 14px}
.player[hidden]{display:none}
.player .pp{width:38px; height:38px; border-radius:50%; border:none; cursor:pointer; background:var(--accent); color:var(--on-accent); font-size:15px; flex:none}
.player .info{flex:1; min-width:0}
.player .info b{font-size:13px; display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.player .bar{height:3px; background:var(--line); border-radius:2px; margin-top:6px; overflow:hidden}
.player .bar i{display:block; height:100%; width:0%; background:var(--accent)}

/* ---------- тост ---------- */
.toast{
  position:fixed; left:50%; bottom:96px; transform:translateX(-50%) translateY(8px);
  background:var(--ink); color:var(--paper); font-size:13px; padding:9px 16px;
  border-radius:999px; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; z-index:40;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0)}

@media (prefers-reduced-motion: reduce){
  *{transition:none !important; animation:none !important}
}
