/* Smriti — styles */
:root {
  --brand: #4338ca; --brand-2: #6d28d9; --brand-soft: #eef2ff; --accent: #ea580c; --accent-soft: #fff7ed;
  --bg: #f6f5fb; --card: #ffffff; --ink: #1c1b29; --ink-2: #4b4a5e; --muted: #8a89a0; --line: #e6e4f0;
  --good: #16a34a; --hard: #d97706; --again: #dc2626; --easy: #2563eb;
  --shadow: 0 1px 2px rgba(30, 27, 75, .06), 0 4px 16px rgba(30, 27, 75, .06);
  --r: 16px; --fs: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-font="s"] { --fs: 15px; }
:root[data-font="l"] { --fs: 18px; }
:root[data-font="xl"] { --fs: 20px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #818cf8; --brand-2: #a78bfa; --brand-soft: #23214a; --accent: #fb923c; --accent-soft: #3a2414;
    --bg: #0f0e17; --card: #1a1926; --ink: #ecebf5; --ink-2: #c4c2d6; --muted: #8d8ba5; --line: #2c2a3d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --btn: #5b5bd6; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #818cf8; --brand-2: #a78bfa; --brand-soft: #23214a; --accent: #fb923c; --accent-soft: #3a2414;
  --bg: #0f0e17; --card: #1a1926; --ink: #ecebf5; --ink-2: #c4c2d6; --muted: #8d8ba5; --line: #2c2a3d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --btn: #5b5bd6; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 400 var(--fs)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  min-height: 100vh; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.hi, [lang="hi"] { font-family: "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", "Mangal", sans-serif; }

/* layout */
#app { max-width: 760px; margin: 0 auto; padding: calc(var(--safe-t) + 0px) 0 calc(84px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 10px) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.25em; margin: 0; flex: 1; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar h1 .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .logo { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.page { padding: 4px 16px 24px; }
.iconbtn { border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  box-shadow: var(--shadow); cursor: pointer; font-size: 1.1em; flex: none; position: relative; }
.backbtn { background: transparent; box-shadow: none; font-size: 1.4em; width: 34px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
}
nav.tabs .in { display: flex; width: 100%; max-width: 760px; }
nav.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: .72em; font-weight: 600; padding: 4px 0; position: relative; }
nav.tabs a .i { display: block; font-size: 1.55em; line-height: 1.25; filter: grayscale(1); opacity: .75; }
nav.tabs a.on { color: var(--brand); }
nav.tabs a.on .i { filter: none; opacity: 1; }
.badge { position: absolute; top: 0; left: 55%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; }
.iconbtn .badge { left: auto; right: -4px; top: -4px; }

.fab { position: fixed; right: max(18px, calc(50vw - 362px)); bottom: calc(86px + var(--safe-b)); z-index: 25;
  width: 58px; height: 58px; border-radius: 20px; border: 0; color: #fff; font-size: 30px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 24px rgba(67, 56, 202, .35); }

/* cards & blocks */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.hero { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.hero .muted { color: rgba(255,255,255,.8); }
.hero .btn { background: #fff; color: var(--brand); }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.tiny { font-size: .75em; }
.big { font-size: 2em; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
h2 { font-size: 1.05em; margin: 22px 2px 10px; color: var(--ink-2); letter-spacing: .01em; }
h2:first-child { margin-top: 6px; }
.sp { height: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 650; cursor: pointer; background: var(--btn, var(--brand)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.plain { background: transparent; color: var(--brand); padding: 8px 10px; }
.btn.danger { background: #fee2e2; color: #b91c1c; }
.btn.lg { padding: 15px 18px; font-size: 1.05em; border-radius: 14px; }
.btn:disabled { opacity: .5; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: .88em; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75em; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

/* forms */
label.f { display: block; margin: 0 0 12px; }
label.f > span { display: block; font-size: .82em; font-weight: 650; color: var(--ink-2); margin: 0 0 5px 2px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=time], input[type=date], input[type=number], select, textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 13px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.search { position: relative; }
.search input { padding-left: 42px; height: 52px; border-radius: 16px; font-size: 1.05em; box-shadow: var(--shadow); border-color: transparent; }
.search::before { content: "🔎"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); opacity: .6; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch input[type=checkbox] { width: 46px; height: 28px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 99px; position: relative; cursor: pointer; flex: none; transition: .2s; }
.switch input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input[type=checkbox]:checked { background: var(--brand); }
.switch input[type=checkbox]:checked::after { left: 21px; }
input[type=range] { width: 100%; accent-color: var(--brand); }

/* lists */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.li { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.li:last-child { border-bottom: 0; }
.li:active { background: var(--brand-soft); }
.li .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3em; flex: none; }
.li .t { font-weight: 650; }
.li .s { font-size: .85em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--line); }
.lvl.l1 { background: #f87171; } .lvl.l2 { background: #fbbf24; } .lvl.l3 { background: #a3e635; } .lvl.l4 { background: #34d399; } .lvl.l5 { background: #6366f1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; cursor: pointer; text-decoration: none; color: inherit; position: relative; }
.tile .ic { font-size: 1.6em; }
.tile .n { font-weight: 700; margin-top: 4px; line-height: 1.25; }
.tile .c { font-size: .8em; color: var(--muted); }
.tile .due { position: absolute; right: 10px; top: 10px; }

/* word display */
.word { font-size: 2em; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; word-break: break-word; }
.ipa { color: var(--muted); font-size: 1.05em; }
.say { border: 0; background: var(--brand-soft); color: var(--brand); width: 42px; height: 42px; border-radius: 50%; cursor: pointer; font-size: 1.15em; flex: none; }
.say.sm { width: 32px; height: 32px; font-size: .95em; }
.pos { font-style: italic; color: var(--accent); font-weight: 600; font-size: .9em; }
.def { font-size: 1.08em; margin: 4px 0; }
.ex { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 8px 0; color: var(--ink-2); font-style: italic; }
.hiblock { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.hiblock .lbl { font-size: .72em; font-weight: 800; letter-spacing: .06em; color: var(--accent); text-transform: uppercase; }
.sense { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.sense:last-child { border-bottom: 0; }
.sense.sel { background: var(--brand-soft); margin: 0 -10px; padding: 10px; border-radius: 10px; border-bottom-color: transparent; }
.saved { display: flex; align-items: center; gap: 10px; background: #dcfce7; color: #166534; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; font-size: .92em; }
:root[data-theme="dark"] .saved { background: #14361f; color: #86efac; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .saved { background: #14361f; color: #86efac; } }
.photo { width: 100%; max-height: 320px; object-fit: cover; border-radius: 12px; margin-top: 10px; }

/* review */
.rv { display: flex; flex-direction: column; min-height: calc(100vh - 160px); }
.rv .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 0 0 12px; }
.rv .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .3s; }
.flash { flex: 1; display: flex; flex-direction: column; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 22px 20px; min-height: 340px; }
.flash .front { text-align: center; padding: 18px 0 8px; }
.flash .q { color: var(--muted); font-size: .9em; margin-top: 14px; }
.flash .back { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; position: sticky; bottom: calc(76px + var(--safe-b)); padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }
.rate button { border: 0; border-radius: 14px; padding: 10px 4px; color: #fff; font-weight: 750; cursor: pointer; line-height: 1.2; }
.rate button small { display: block; font-weight: 600; opacity: .85; font-size: .78em; margin-top: 2px; }
.rate .a { background: var(--again); } .rate .h { background: var(--hard); } .rate .g { background: var(--good); } .rate .e { background: var(--easy); }
.showbtn { position: sticky; bottom: calc(76px + var(--safe-b)); padding: 12px 0 4px; background: linear-gradient(transparent, var(--bg) 30%); }
.kbd { font-size: .7em; opacity: .6; }

/* principle */
.principle { background: linear-gradient(135deg, #fff7ed, #ffedd5); border: 1px solid #fed7aa; }
:root[data-theme="dark"] .principle { background: linear-gradient(135deg, #2a1a0e, #3a2414); border-color: #5b3216; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .principle { background: linear-gradient(135deg, #2a1a0e, #3a2414); border-color: #5b3216; } }
.principle .ttl { font-size: 1.2em; font-weight: 750; line-height: 1.35; }

/* heatmap */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--line); }
.heat i.h1 { background: #c7d2fe; } .heat i.h2 { background: #818cf8; } .heat i.h3 { background: #4f46e5; } .heat i.h4 { background: #312e81; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.bars div { flex: 1; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; opacity: .85; }
.bars div span { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.6em; line-height: 1.1; }
.stat span { font-size: .78em; color: var(--muted); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* sheet / modal */
.scrim { position: fixed; inset: 0; background: rgba(15, 14, 30, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s; }
@keyframes fadein { from { opacity: 0; } }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b)); animation: up .22s ease-out; }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 14px; font-size: 1.2em; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + var(--safe-b)); z-index: 60; background: #1c1b29; color: #fff;
  padding: 11px 16px; border-radius: 12px; font-size: .92em; box-shadow: 0 8px 24px rgba(0,0,0,.25); display: flex; gap: 12px; align-items: center; max-width: 92vw; animation: fade .2s; }
.toast button { background: transparent; border: 0; color: #a5b4fc; font-weight: 700; cursor: pointer; }

/* auth */
.auth { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 20px 40px; }
.auth .logo { width: 84px; height: 84px; border-radius: 24px; display: block; margin: 0 auto 14px; box-shadow: 0 10px 30px rgba(67,56,202,.3); }
.auth h1 { text-align: center; margin: 0; font-size: 2em; letter-spacing: -.02em; }
.auth .tag { text-align: center; color: var(--muted); margin: 4px 0 26px; }
.tabs2 { display: flex; background: var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs2 button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 650; cursor: pointer; color: var(--ink-2); }
.tabs2 button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.err { color: var(--again); font-size: .9em; min-height: 1.2em; margin: 4px 2px 10px; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .e { font-size: 2.6em; }
.offline { background: #fef3c7; color: #92400e; text-align: center; font-size: .82em; padding: 4px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.sel-bar { position: fixed; left: 0; right: 0; bottom: calc(64px + var(--safe-b)); z-index: 26; display: flex; justify-content: center; padding: 8px; }
.sel-bar .in { background: #1c1b29; color: #fff; border-radius: 14px; padding: 8px 10px; display: flex; gap: 6px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.sel-bar button { background: transparent; color: #fff; border: 0; padding: 8px 10px; font-weight: 650; cursor: pointer; border-radius: 8px; }
.cb { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }
code.bm { display: block; word-break: break-all; background: var(--line); padding: 8px; border-radius: 8px; font-size: .75em; }
