/* Chandamama Books - phone app styles */
:root {
  --cream: #FBF3E3; --paper: #FFFFFF; --ink: #1E2550; --muted: #4A4F6A;
  --accent: #B8540B; --gold: #F2C14E; --ok: #1E6B3A; --radius: 16px;
  --font: 'Noto Sans Telugu', 'Kohinoor Telugu', 'Telugu Sangam MN', 'Nirmala UI', 'Gautami', system-ui, sans-serif;
  --num: system-ui, 'Segoe UI', Roboto, sans-serif;
}
html { font-size: 18px; -webkit-text-size-adjust: 100%; }
html.ts-2 { font-size: 21px; }
html.ts-3 { font-size: 24px; }
@media (min-width: 900px) { html { font-size: 20px; } html.ts-2 { font-size: 23px; } html.ts-3 { font-size: 26px; } }
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font); line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
img { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num { font-family: var(--num); }

/* ---------- shared ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: max(1rem, env(safe-area-inset-top)) 1rem 3rem; display: flex; flex-direction: column; gap: 1.4rem; }
.btn { min-height: 3rem; padding: 0 1rem; border-radius: 0.8rem; border: 2px solid var(--ink); background: var(--paper);
  font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; }
.btn:active { transform: scale(0.98); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.on { background: var(--ink); color: #fff; }
.btn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.btn[disabled] { opacity: 0.6; }
.en { font-weight: 700; color: var(--muted); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.sec { display: flex; flex-direction: column; gap: 0.8rem; }
.sec-title { font-size: 1.35rem; font-weight: 800; }
.sec-title .en { font-size: 0.9rem; display: block; }
.empty { font-size: 1.05rem; color: var(--muted); background: var(--paper); border-radius: var(--radius); padding: 1rem 1.2rem; }
.banner { background: #FFF8E1; border: 2px solid var(--gold); border-radius: var(--radius); padding: 0.8rem 1rem; font-size: 1rem; font-weight: 700; }
.banner.warn { background: #FDECEC; border-color: #C0392B; }

/* ---------- header ---------- */
.top { display: flex; flex-direction: column; gap: 0.9rem; }
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand img { width: 3rem; height: 3rem; border-radius: 50%; }
.brand h1 { font-size: 1.9rem; font-weight: 800; }
.brand p { margin: 0; font-size: 0.95rem; }
.nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
@media (min-width: 700px) { .top { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; } .nav { display: flex; flex-wrap: wrap; } }

/* ---------- continue / install cards ---------- */
.cont { background: var(--paper); border-radius: 1.2rem; padding: 1rem; display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; align-items: center;
  box-shadow: 0 6px 20px rgba(30,37,80,0.10); }
.cont .cv { width: 6.5rem; aspect-ratio: 3/4; border-radius: 0.6rem; overflow: hidden; background: #D8C9A8; box-shadow: 0 4px 12px rgba(0,0,0,0.22); }
.cont .cv img { width: 100%; height: 100%; object-fit: cover; }
.cont .info { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.cont .kicker { color: var(--accent); font-weight: 800; font-size: 0.95rem; }
.cont h2 { font-size: 1.4rem; font-weight: 800; }
.cont .meta { font-size: 1rem; color: var(--muted); font-weight: 700; }
.cont .go { grid-column: 1 / -1; }
@media (min-width: 700px) { .cont { grid-template-columns: 8rem 1fr auto; } .cont .cv { width: 8rem; } .cont .go { grid-column: auto; } }
.bar { height: 0.7rem; border-radius: 0.35rem; background: #EDE3CF; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.big-go { min-height: 3.6rem; padding: 0 1.6rem; font-size: 1.25rem; border-radius: 0.9rem; width: 100%; }
@media (min-width: 700px) { .big-go { width: auto; } }

/* ---------- decades ---------- */
.decades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
@media (min-width: 700px) { .decades { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); } }
.decade { color: #fff; border-radius: 1rem; padding: 0.9rem; min-height: 6.2rem; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 4px 12px rgba(30,37,80,0.18); }
.decade b { font-size: 1.9rem; line-height: 1; font-family: var(--num); }
.decade span { font-size: 0.95rem; font-weight: 700; }

/* ---------- cover rows / grids ---------- */
.row { display: flex; gap: 0.8rem; overflow-x: auto; padding: 0.2rem 0.1rem 0.6rem; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.row .card { flex: 0 0 7.4rem; scroll-snap-align: start; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); } }
.card { display: flex; flex-direction: column; gap: 0.3rem; border-radius: 0.8rem; }
.cover { position: relative; aspect-ratio: 3 / 4; border-radius: 0.7rem; overflow: hidden; background: #D8C9A8; box-shadow: 0 4px 12px rgba(30,37,80,0.2); }
.cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.cover img.in { opacity: 1; }
.cover .ph { position: absolute; inset: auto 0.5rem 0.5rem 0.5rem; color: #5A4A2A; font-weight: 800; font-size: 0.9rem; }
.badge { position: absolute; background: #fff; border-radius: 1rem; padding: 0.05rem 0.5rem; font-size: 0.78rem; font-weight: 800; box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.badge.read { top: 0.4rem; right: 0.4rem; color: var(--ok); }
.badge.fav { top: 0.4rem; left: 0.4rem; color: var(--accent); }
.badge.saved { bottom: 0.4rem; left: 0.4rem; color: var(--ink); }
.card .t { font-size: 1.15rem; font-weight: 800; line-height: 1.2; }
.card .s { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.card .bar { height: 0.45rem; }

/* ---------- year page ---------- */
.yhead { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem; }
.yhead h1 { font-size: 1.9rem; font-weight: 800; }
.yhead .sum { font-size: 0.95rem; width: 100%; }
@media (min-width: 700px) { .yhead .sum { width: auto; } }
.pills { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.3rem; }
.pills.wrap-pills { flex-wrap: wrap; overflow: visible; }
.pill { flex: none; min-width: 4.6rem; min-height: 2.8rem; border-radius: 1.4rem; border: 2px solid var(--ink); background: var(--paper);
  font-weight: 800; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; font-family: var(--num); }
.pill.on { background: var(--ink); color: #fff; }
.ynav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.7rem; }

/* ---------- forms / gate ---------- */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.gate .box { width: min(30rem, 100%); background: var(--paper); border-radius: 1.4rem; padding: 1.6rem 1.3rem; display: flex; flex-direction: column; gap: 1rem;
  box-shadow: 0 10px 30px rgba(30,37,80,0.15); text-align: center; }
.gate img { width: 5rem; height: 5rem; margin: 0 auto; border-radius: 50%; }
.gate h1 { font-size: 1.9rem; font-weight: 800; }
.field { width: 100%; min-height: 3.6rem; border-radius: 0.9rem; border: 2px solid var(--ink); padding: 0 1rem; font-size: 1.3rem; background: #fff; text-align: center; }
.err { color: #B3261E; font-weight: 800; font-size: 1rem; min-height: 1.4rem; margin: 0; }
.find { display: flex; flex-direction: column; gap: 0.6rem; }
@media (min-width: 700px) { .find { flex-direction: row; } .find .field { text-align: left; } }
.ylist { display: flex; flex-direction: column; gap: 0.9rem; }
.ylist h3 { font-size: 1.15rem; }

/* ---------- saved list ---------- */
.slist { display: flex; flex-direction: column; gap: 0.7rem; }
.sitem { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: 0.8rem; align-items: center; background: var(--paper); border-radius: 0.9rem; padding: 0.6rem; }
.sitem .cover { border-radius: 0.4rem; }
.sitem b { font-size: 1.1rem; }
.sitem span { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 700; }

/* ---------- reader ---------- */
body.reading { overflow: hidden; }
.reader { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--r-frame); color: var(--r-ui); }
.r-top, .r-foot { background: var(--r-panel); display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; }
.r-top { border-bottom: 2px solid var(--r-line); padding-top: max(0.45rem, env(safe-area-inset-top)); }
.r-top h1 { flex: 1; min-width: 0; font-size: 1.1rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-top .pg { font-size: 1rem; font-weight: 800; font-family: var(--num); white-space: nowrap; }
.r-foot { border-top: 2px solid var(--r-line); padding-bottom: max(0.45rem, env(safe-area-inset-bottom)); }
.r-body { flex: 1; min-height: 0; display: flex; gap: 0.8rem; padding: 0.5rem; position: relative; }
.stage { position: relative; flex: 1; min-width: 0; overflow: auto; border-radius: 0.8rem; background: var(--r-well); padding: 0.5rem; touch-action: manipulation;
  -webkit-overflow-scrolling: touch; }
.stage:focus { outline: none; }
.stage canvas { display: block; margin: 0 auto; background: #fff; box-shadow: 0 6px 22px rgba(0,0,0,0.35); border-radius: 3px; }
.stage .msg { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.8rem; text-align: center;
  padding: 1rem; font-size: 1.25rem; font-weight: 800; pointer-events: none; }
.stage .msg .btn, .stage .msg a { pointer-events: auto; }
.prog { width: min(18rem, 80%); height: 0.9rem; border-radius: 0.45rem; background: var(--r-line); overflow: hidden; }
.prog > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ruler { position: absolute; left: 0; height: 3rem; background: rgba(242,193,78,0.25); border-top: 4px solid var(--gold);
  border-bottom: 4px solid var(--gold); pointer-events: none; display: none; }
.stage.ruler-on .ruler { display: block; }
.rbtn { min-height: 2.9rem; min-width: 2.9rem; border-radius: 0.75rem; border: 2px solid var(--r-ui); background: transparent; color: var(--r-ui); font-weight: 700;
  font-size: 0.98rem; padding: 0 0.7rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.rbtn.wide { justify-content: flex-start; text-align: left; width: 100%; }
.rbtn.on { background: var(--r-ui); color: var(--r-panel); }
.rbtn.acc { background: var(--accent); border-color: var(--accent); color: #fff; }
.rbtn svg { width: 1.25rem; height: 1.25rem; flex: none; }
.r-foot .rbtn { min-height: 3.3rem; font-size: 1.05rem; font-weight: 800; padding: 0 0.9rem; }
.r-foot .rbtn.next { background: var(--accent); border-color: var(--accent); color: #fff; }
.slide { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.slide input { width: 100%; accent-color: var(--accent); height: 2rem; }
.slide span { font-size: 0.8rem; font-weight: 700; text-align: center; font-family: var(--num); }
.lbl-long { display: none; }
@media (min-width: 700px) { .lbl-long { display: inline; } .r-top h1 { font-size: 1.35rem; } }

/* panel: bottom sheet on phones, side panel on wide screens */
.panel { background: var(--r-panel); display: flex; flex-direction: column; gap: 0.8rem; overflow: auto; }
.panel h3 { font-size: 1rem; font-weight: 800; }
.panel .grp { display: flex; flex-direction: column; gap: 0.45rem; }
.zoom { display: flex; align-items: center; gap: 0.5rem; }
.zoom .rbtn { flex: 1; font-size: 1.35rem; font-family: var(--num); }
.zoom output { min-width: 4.4rem; text-align: center; font-weight: 800; font-size: 1.05rem; font-family: var(--num); }
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.swatch { width: 1.3rem; height: 1.3rem; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.theme.sel { outline: 4px solid var(--accent); outline-offset: 1px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; }
.two .rbtn { font-size: 0.9rem; }
.sheet-close { display: flex; justify-content: space-between; align-items: center; }
.scrim { display: none; }
@media (max-width: 999px) {
  .panel { position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; z-index: 20; padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
    border-radius: 1.2rem 1.2rem 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,0.4); transform: translateY(105%); transition: transform .2s; }
  .reader.sheet-open .panel { transform: none; }
  .reader.sheet-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 19; }
}
@media (min-width: 1000px) {
  .panel { width: 19rem; flex: none; border-radius: 0.9rem; padding: 1rem; }
  .sheet-close, .menu-btn { display: none !important; }
  .r-top, .r-foot { padding-left: 1rem; padding-right: 1rem; gap: 0.8rem; }
}
.endcard { position: fixed; left: 50%; transform: translateX(-50%); bottom: 5.2rem; width: min(36rem, calc(100% - 1.2rem)); z-index: 15;
  background: var(--r-panel); border: 3px solid var(--accent); border-radius: 1rem; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.6rem;
  font-size: 1.1rem; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,0.35); }

/* reading themes */
.reader.th-cream    { --r-frame:#F3E6CC; --r-panel:#FFFFFF; --r-well:#E6D5B3; --r-ui:#1E2550; --r-line:#E2D3B5; }
.reader.th-contrast { --r-frame:#FFFFFF; --r-panel:#FFFFFF; --r-well:#BDBDBD; --r-ui:#000000; --r-line:#000000; }
.reader.th-night    { --r-frame:#10142B; --r-panel:#1B1F38; --r-well:#070A18; --r-ui:#F4EFE3; --r-line:#2E3458; }
.reader.th-original { --r-frame:#ECECEC; --r-panel:#FFFFFF; --r-well:#D5D5D5; --r-ui:#1E2550; --r-line:#D0D0D0; }
.reader.th-cream canvas    { filter: sepia(0.22) contrast(1.15) brightness(1.04); }
.reader.th-contrast canvas { filter: grayscale(1) contrast(1.7) brightness(1.08); }
.reader.th-night canvas    { filter: invert(0.92) hue-rotate(180deg) grayscale(0.5) contrast(1.3) brightness(0.95); background: #000; }

/* settings dialog */
dialog { border: none; border-radius: 1.2rem; padding: 0; max-width: 38rem; width: calc(100% - 1.2rem); color: var(--ink); background: var(--paper);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
dialog::backdrop { background: rgba(16,20,43,0.55); }
.dlg { padding: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.dlg .head { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; }
.dlg h2 { font-size: 1.5rem; font-weight: 800; }
.dlg .grp { display: flex; flex-direction: column; gap: 0.45rem; }
.dlg .grp > b { font-size: 1.05rem; }
.choices { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.dlg small { font-size: 0.9rem; color: var(--muted); font-weight: 700; }
