/* Ekagra — calm, paper-like, low-salience by design (no red, no badges, no counts that shout). */
:root {
  --bg: #F6F1E7; --surface: #FFFCF6; --ink: #1F1B16; --muted: #6B6257; --line: #E4DCCD; --outside: #E9E2D4;
  --c-news: #3E5C76; --c-ai: #5B6C3A; --c-shayari: #7A4E6B; --c-kabir: #9A5B26;
  --c-curiosity: #2F6F6A; --c-words: #5E5089; --c-mind: #4E7A55;
  --serif: "Literata", Georgia, serif; --sans: "Inter", system-ui, sans-serif;
  --deva: "Noto Serif Devanagari", "Literata", serif;
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16140F; --surface: #1E1B16; --ink: #ECE5D8; --muted: #A39A8C; --line: #2E2A23; --outside: #0E0D0A;
    --c-news: #8FB0CC; --c-ai: #AFC07F; --c-shayari: #D3A3C4; --c-kabir: #E0A770;
    --c-curiosity: #7FC4BD; --c-words: #B3A6DE; --c-mind: #95C39C;
  }
}
:root[data-theme="dark"] {
  --bg: #16140F; --surface: #1E1B16; --ink: #ECE5D8; --muted: #A39A8C; --line: #2E2A23; --outside: #0E0D0A;
  --c-news: #8FB0CC; --c-ai: #AFC07F; --c-shayari: #D3A3C4; --c-kabir: #E0A770;
  --c-curiosity: #7FC4BD; --c-words: #B3A6DE; --c-mind: #95C39C;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--outside); color: var(--ink); font-family: var(--sans); font-size: 16px; }
#app {
  position: relative; max-width: 440px; height: 100dvh; margin: 0 auto; background: var(--bg);
  overflow: hidden; display: flex; flex-direction: column;
}
@media (min-width: 600px) {
  #app { height: min(calc(100dvh - 40px), 920px); margin-top: 20px; border-radius: 32px;
         box-shadow: 0 20px 60px rgba(0,0,0,.18); border: 1px solid var(--line); }
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; }
.view { flex: 1; display: flex; flex-direction: column; padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; }
.top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.brand { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: .2px; }
.brand small { font-family: var(--deva); font-weight: 400; color: var(--muted); font-size: 15px; margin-left: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
h1 { font-family: var(--serif); font-weight: 500; font-size: 28px; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 24px 0 10px; }
p.lead { font-family: var(--serif); font-size: 18px; line-height: 1.6; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.spacer { flex: 1; }
.btn { display: block; width: 100%; padding: 15px 18px; border-radius: 14px; font-weight: 500; text-align: center;
       background: var(--ink); color: var(--bg); margin-top: 10px; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .4; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
.chip-opt[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.field { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
         color: var(--ink); font: inherit; margin-top: 6px; }
textarea.field { min-height: 110px; font-family: var(--serif); font-size: 17px; line-height: 1.5; resize: vertical; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 4px 0 16px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--ink); }

/* Pause screen */
.breath-wrap { display: grid; place-items: center; margin: 28px 0 8px; }
.breath { width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, var(--surface) 0%, var(--line) 100%);
          border: 1px solid var(--line); animation: breathe 8s ease-in-out infinite; display: grid; place-items: center; }
.breath span { font-family: var(--serif); color: var(--muted); font-size: 15px; }
@keyframes breathe { 0%,100% { transform: scale(.72); } 50% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .breath { animation: none; } }
.fade-in { animation: fade .8s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.mood { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mood button { padding: 16px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.mood b { display: block; font-weight: 500; margin-top: 4px; }
.mood span { font-size: 22px; }
.stats { display: flex; gap: 10px; margin-top: 18px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { font-family: var(--serif); font-size: 22px; font-weight: 500; display: block; }
.stat span { font-size: 12px; color: var(--muted); }

/* Story viewer */
.viewer { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.bars { display: flex; gap: 4px; padding: 12px 16px 0; }
.bars i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bars i.on { background: var(--accent, var(--ink)); }
.vhead { display: flex; align-items: center; gap: 8px; padding: 10px 12px 0 16px; }
.tag { font-size: 13px; font-weight: 500; color: var(--accent); letter-spacing: .3px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { font-size: 13px; color: var(--muted); }
.slide { flex: 1; overflow-y: auto; padding: 18px 24px 12px; display: flex; flex-direction: column; justify-content: center;
         user-select: none; -webkit-user-select: none; cursor: pointer; }
.slide.top-align { justify-content: flex-start; padding-top: 28px; }
.slide .kick { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--accent); margin-bottom: 10px; font-weight: 600; }
.slide h2.title { font-family: var(--serif); font-size: 27px; line-height: 1.28; font-weight: 600; margin: 0 0 16px; }
.slide .txt { font-family: var(--serif); font-size: 20px; line-height: 1.6; }
.slide .deva { font-family: var(--deva); font-size: clamp(19px, 5.6vw, 23px); line-height: 1.8; text-align: center; text-wrap: balance; }
.slide .roman { font-family: var(--serif); font-style: italic; color: var(--muted); text-align: center; font-size: 16px; line-height: 1.6; margin-top: 14px; }
.slide .by { text-align: center; color: var(--accent); margin-top: 18px; font-size: 14px; letter-spacing: .4px; }
.slide .meaning-hi { font-family: var(--deva); font-size: 19px; line-height: 1.8; margin-bottom: 16px; }
.slide .word { font-family: var(--serif); font-size: 42px; font-weight: 600; text-align: center; }
.slide .pos { text-align: center; color: var(--muted); font-style: italic; margin-top: 6px; }
.slide .hint { text-align: center; color: var(--muted); margin-top: 28px; font-size: 14px; }
.slide .src { font-size: 13px; color: var(--muted); margin-top: 18px; }
.slide .src a { color: var(--accent); }
.vfoot { display: flex; align-items: center; gap: 8px; padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.vfoot .pill { padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; }
.vfoot .pill.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.vfoot .love[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.vfoot .grow { flex: 1; }

/* Read-fully sheet */
.sheet { position: absolute; inset: 0; background: var(--bg); z-index: 5; display: flex; flex-direction: column; animation: up .25s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .top { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sheet article { flex: 1; overflow-y: auto; padding: 22px 24px 60px; }
.sheet article h2 { font-size: 26px; font-weight: 600; margin-top: 0; line-height: 1.3; }
.sheet article p { font-family: var(--serif); font-size: 19px; line-height: 1.7; margin: 0 0 16px; }
.focusbar { height: 3px; background: var(--line); }
.focusbar i { display: block; height: 100%; width: 0; background: var(--accent, var(--ink)); transition: width .3s; }

/* Library */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 8px -20px 6px; padding-left: 20px; padding-right: 20px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .chip-opt { white-space: nowrap; padding: 8px 12px; font-size: 14px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li button { display: block; width: 100%; text-align: left; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.list .t { font-family: var(--serif); font-size: 17px; line-height: 1.4; }
.list .k { font-size: 12px; color: var(--muted); margin-top: 3px; }
.done-mark { font-size: 46px; text-align: center; margin-top: 30px; }
.hold { position: relative; overflow: hidden; }
.hold i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--line); z-index: 0; }
.hold span { position: relative; z-index: 1; }
.setting { padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting label { font-weight: 500; display: block; margin-bottom: 8px; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg);
         padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 10; }
#toast.show { opacity: 1; }
.err { color: var(--c-shayari); font-size: 14px; margin-top: 6px; }
