/* ভাষাবন্ধু — মোবাইল-ফার্স্ট স্টাইল */
:root {
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #17231c;
  --muted: #6b7a71;
  --line: #e2e9e4;
  --brand: #0f7b45;
  --brand-2: #12a05a;
  --brand-soft: #e7f5ec;
  --accent: #ffb703;
  --bad: #d64545;
  --bad-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(16, 40, 26, .06), 0 4px 14px rgba(16, 40, 26, .06);
  --radius: 16px;
  --tab-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --card: #18211c;
    --text: #e6eee9;
    --muted: #93a39a;
    --line: #26312b;
    --brand: #2fbf73;
    --brand-2: #3dd585;
    --brand-soft: #173325;
    --bad: #ff7676;
    --bad-soft: #3a1f1f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow-x: hidden; }
body {
  font-family: 'Hind Siliguri', 'Nirmala UI', 'Noto Sans Bengali', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
svg { width: 22px; height: 22px; display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top & tabs ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand img { width: 32px; height: 32px; border-radius: 9px; background: #fff; }
.net { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.18); }
.net.off { background: #ffb703; color: #3b2a00; }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: var(--lock-h, 0px); z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; color: var(--muted); }
.tabbar button .i { padding: 3px 18px; border-radius: 99px; transition: background .15s; }
.tabbar button.on { color: var(--brand); font-weight: 600; }
.tabbar button.on .i { background: var(--brand-soft); }

/* ---------- common ---------- */
.h { font-size: 17px; margin: 18px 0 10px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.chips { display: flex; gap: 8px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); font-size: 15px; white-space: nowrap;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 12px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand);
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.small { padding: 6px 14px; font-size: 14px; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn:active, .chip:active, .pill:active, .activity:active, .lesson:active { transform: scale(.97); }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--muted); }
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
.icon-btn.live { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(214,69,69,.15); } }
.tip { font-size: 14px; color: var(--muted); background: var(--brand-soft); padding: 8px 12px; border-radius: 10px; margin: 0 0 12px; }

/* ---------- learn ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; color: var(--brand); line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }
.lang-progress { margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; transition: width .3s; }

.lessons { display: grid; gap: 10px; margin-top: 10px; }
.lesson {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.lesson .l-ico { width: 48px; height: 48px; flex: none; display: grid; place-items: center; font-size: 24px; border-radius: 14px; background: var(--brand-soft); }
.lesson .l-body { flex: 1; min-width: 0; }
.lesson .l-body b { display: block; font-size: 16px; }
.lesson .l-body small { color: var(--muted); }
.lesson.done .l-ico { background: var(--brand); }

.subhead { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.subhead-title { font-size: 19px; font-weight: 700; }

.phrases { display: grid; gap: 10px; }
.phrase { padding: 14px 14px 10px; }
.phrase.learned { border-color: var(--brand); }
.ph-bn { font-size: 14px; color: var(--muted); }
.ph-fx { font-size: 24px; font-weight: 600; line-height: 1.35; margin: 2px 0; word-break: break-word; }
.ph-fx[dir="rtl"] { font-size: 27px; }
.ph-roman { font-size: 14px; color: var(--brand); font-style: italic; }
.ph-pron { font-size: 15px; margin-top: 2px; }
.ph-pron em { font-style: normal; color: var(--muted); font-size: 13px; }
.ph-actions { display: flex; gap: 6px; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.ph-actions .pill { flex: 1; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 10px; border-radius: 99px; font-size: 14px; background: var(--bg); border: 1px solid var(--line);
}
.pill .i svg { width: 18px; height: 18px; }
.pill.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- practice ---------- */
.field { display: grid; gap: 6px; margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.field select { padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 16px; color: var(--text); }
.activities { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.activity {
  text-align: left; padding: 14px; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 2px;
}
.activity .a-ico { font-size: 28px; }
.activity small { color: var(--muted); font-size: 13px; line-height: 1.35; }

.run-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.run-top .bar { flex: 1; margin: 0; }
.run-count { font-size: 14px; color: var(--muted); min-width: 48px; text-align: right; }
.q-card { padding: 22px 16px; text-align: center; }
.q-label { font-size: 14px; color: var(--muted); }
.q-text { font-size: 28px; font-weight: 700; margin: 8px 0; line-height: 1.35; word-break: break-word; }
.q-sub { color: var(--brand); font-style: italic; }
.big-speak { width: 84px; height: 84px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; margin: 8px auto; }
.big-speak svg { width: 38px; height: 38px; }
.options { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--card);
  border: 2px solid var(--line); font-size: 17px; line-height: 1.4;
}
.opt.right { border-color: var(--brand); background: var(--brand-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
.feedback.good { background: var(--brand-soft); color: var(--brand); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }

.flash { perspective: 1000px; height: 260px; cursor: pointer; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 20px; text-align: center; border-radius: 20px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.flash-face.back { transform: rotateY(180deg); background: var(--brand-soft); }
.flash-face .q-text { margin: 0; }
.flash-hint { font-size: 13px; color: var(--muted); }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.result { text-align: center; padding: 26px 16px; }
.result .big { font-size: 56px; }
.result h3 { margin: 6px 0; font-size: 22px; }

/* ---------- write (translator) ---------- */
.mode-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius); background: var(--brand-soft); color: var(--brand);
  border: 1px solid transparent; text-align: left;
}
.mode-txt b { display: block; font-size: 17px; }
.mode-txt small { color: var(--muted); font-size: 13px; }
.chev svg { width: 22px; height: 22px; }

.io { margin-top: 12px; padding: 10px 14px 12px; }
#view-write > .io:first-child { margin-top: 0; }
.seg.src-seg { grid-template-columns: repeat(3, 1fr); margin-bottom: 6px; }
.in-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.mic-big {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 99px; background: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 4px 12px rgba(15, 123, 69, .3);
}
.mic-big.live { background: var(--bad); animation: pulse 1.2s infinite; }
.to-row { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px 8px; }
.to-label { font-weight: 600; color: var(--brand); }
.link-btn { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); padding: 4px 6px; }
.link-btn .chev svg { width: 18px; height: 18px; }
.to-label small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.lang-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 360px) { .lang-grid { grid-template-columns: repeat(3, 1fr); } }
.lang-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px 4px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line);
  line-height: 1.25; min-height: 54px;
}
.lang-tile .lt-name { font-size: 15px; font-weight: 600; }
.lang-tile .lt-native { font-size: 11px; color: var(--muted); }
.lang-tile:hover { border-color: var(--brand); }
.lang-tile.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.lang-tile.on .lt-native { color: rgba(255,255,255,.85); }
.lang-tile:active { transform: scale(.96); }
.mode-line { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }
.mode-line b { color: var(--text); font-weight: 600; }
.pron {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--brand-soft); border-left: 4px solid var(--brand);
}
.pron-label { font-size: 12px; font-weight: 600; color: var(--brand); }
#pron { font-size: 20px; line-height: 1.5; font-weight: 500; word-break: break-word; }
.s-pron { font-size: 14px; color: var(--brand); }
.io-head { display: flex; align-items: center; justify-content: space-between; min-height: 38px; }
.io-lang { font-weight: 600; font-size: 14px; color: var(--brand); }
.tools { display: flex; gap: 2px; }
textarea {
  width: 100%; border: 0; outline: 0; resize: vertical; background: transparent;
  font-size: 20px; line-height: 1.5; min-height: 110px; padding: 2px 0;
}
.examples { display: flex; flex-wrap: wrap; gap: 6px; }
.examples button { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--bg); border: 1px dashed var(--line); color: var(--muted); }
.bn-preview {
  margin: 4px 0 10px; padding: 8px 12px; border-radius: 12px;
  background: #fff8e6; border: 1px dashed #f0c45a;
}
@media (prefers-color-scheme: dark) { .bn-preview { background: #2b2410; border-color: #6b5520; } }
.bp-label { font-size: 12px; font-weight: 600; color: #a06b00; }
.bp-text { font-size: 20px; line-height: 1.5; font-weight: 500; }
.bp-alts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.bp-alts:empty { display: none; }
.bp-alts button { padding: 3px 12px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); font-size: 15px; }
.bp-alts button:hover { border-color: var(--brand); color: var(--brand); }
.out { background: var(--card); }
.output { font-size: 22px; line-height: 1.5; min-height: 70px; white-space: pre-wrap; word-break: break-word; }
.output:empty::before { content: 'ফলাফল এখানে দেখাবে…'; color: var(--muted); font-size: 16px; }
.roman { font-size: 15px; color: var(--brand); font-style: italic; margin-top: 4px; }
.status { font-size: 12px; color: var(--muted); }
.out-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.out-actions .pill { flex-direction: column; gap: 0; border-radius: 12px; font-size: 12px; padding: 7px 4px; }

/* ---------- mode sheet (screenshot format) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.35); animation: fadebg .2s; }
@keyframes fadebg { from { opacity: 0; } }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  max-height: 82vh; display: flex; flex-direction: column;
  background: var(--card); border-radius: 20px 20px 0 0; padding: 8px 0 env(safe-area-inset-bottom);
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 9px; background: var(--line); margin: 2px auto 8px; }
.sheet-handle, .jump { flex: none; }
.jump { padding: 0 14px 8px; border-bottom: 1px solid var(--line); }
.jump .chip { padding: 5px 12px; font-size: 13px; }
.mode-list { overflow-y: auto; padding: 4px 8px 16px; }
.mode-group { font-size: 14px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; }
.mode-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; }
.mode-item b { display: block; font-size: 17px; font-weight: 700; }
.mode-item small { display: block; color: var(--muted); font-size: 14px; }
.mode-item:hover { background: var(--bg); }
.mode-item.on { background: var(--brand-soft); }
.mode-item.on b { color: var(--brand); }

/* ---------- saved ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { padding: 8px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand-soft); color: var(--brand); }
.saved-list { display: grid; gap: 10px; margin-top: 12px; }
.s-item { padding: 12px 14px; }
.s-mode { font-size: 12px; color: var(--brand); font-weight: 600; }
.s-in { color: var(--muted); font-size: 14px; margin-top: 2px; }
.s-out { font-size: 18px; margin-top: 2px; word-break: break-word; }
.s-actions { display: flex; gap: 2px; justify-content: flex-end; margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 40px; }
.settings { padding: 4px 14px; }
.settings .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.settings .row:last-child { border-bottom: 0; }
.settings input[type=range] { width: 45%; accent-color: var(--brand); }
.voice-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 12px; font-size: 13px; }
.voice-list span { padding: 3px 9px; border-radius: 99px; background: var(--bg); }
.voice-list span.yes { background: var(--brand-soft); color: var(--brand); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--lock-h, 0px) + 18px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1d2a22; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px;
  transition: .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
