/* ================= VoiceLipi ================= */
:root {
  --accent: #f6a723;
  --accent-soft: #fff4e0;
  --accent-ink: #2b1b00;
  --side: #1c1c1e;
  --side-2: #262628;
  --side-3: #2f2f32;
  --side-line: #333336;
  --side-text: #ececec;
  --side-mute: #9b9ba1;
  --bg: #f4f3ef;
  --paper: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #3a3a3c;
  --mute: #86868b;
  --line: #e7e5e0;
  --rec: #e5484d;
  --ok: #2fb36b;
  --radius: 14px;
  --editor-size: 20px;
  --ui: 'Inter', 'Noto Sans Bengali', 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-sans: 'Noto Sans Bengali', 'Noto Sans Devanagari', 'Inter', 'Nirmala UI', system-ui, sans-serif;
  --text-serif: 'Noto Serif Bengali', 'Noto Serif Devanagari', 'Georgia', 'Nirmala UI', serif;
  --text-font: var(--text-sans);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--ui); color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button { font: inherit; cursor: pointer; color: inherit; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--ui); font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 3px 6px;
}

/* ---------- Layout ---------- */
.app {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  grid-template-areas: "left main right";
}
.topbar { display: none; grid-area: top; }
.left { grid-area: left; }
.editor-wrap { grid-area: main; }
.right { grid-area: right; }
.ad-mobile { display: none; grid-area: ad; }

/* ---------- Panels (shared) ---------- */
.panel { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; }

/* ---------- Left panel ---------- */
.left { padding: 22px 16px calc(14px + var(--safe-b)); border-right: 1px solid #000; }
.brand-block { padding: 2px 6px 18px; border-bottom: 1px solid var(--side-line); margin-bottom: 14px; }
.brand { font-size: 28px; font-weight: 300; color: #e8e8e8; letter-spacing: -.02em; text-decoration: none; display: inline-flex; align-items: center; }
.brand-dot { background: var(--accent); color: var(--side); font-weight: 600; border-radius: 999px; padding: 0 9px 1px; margin-left: 2px; font-size: 21px; }
.tagline { margin: 6px 0 0; font-size: 12px; color: var(--side-mute); font-family: var(--text-sans); }

/* Drafts | Saved tabs */
.list-head { display: flex; align-items: center; gap: 6px; padding: 0 0 6px; }
.list-tabs { flex: 1; display: flex; background: var(--side-2); border-radius: 10px; padding: 3px; gap: 2px; min-width: 0; }
.list-tabs button {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; border: 0; border-radius: 8px; background: none; color: var(--side-mute);
  font-size: 13px; font-weight: 600; transition: background .15s, color .15s;
}
.list-tabs button:hover { color: #fff; }
.list-tabs button.active { background: var(--side-3); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.list-tabs svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
#tabSaved.active svg { stroke: var(--accent); }
.count { font-size: 10.5px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: rgba(255,255,255,.08); color: var(--side-mute); }
.count:empty { display: none; }
.list-tabs button.active .count { background: var(--accent); color: var(--accent-ink); }
.list-head .add { height: 38px; padding: 0 9px; }
#refreshSaved svg { width: 16px; height: 16px; stroke-width: 2; }
#refreshSaved.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-note { margin: 2px 6px 10px; font-size: 11.5px; line-height: 1.5; color: var(--side-mute); font-family: var(--text-sans); }
.list-note:empty { display: none; }
.add {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: none;
  color: var(--accent); font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
}
.add:hover { background: var(--side-2); }
.add svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.drafts { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 60px; overflow-y: auto; }
.drafts li {
  display: flex; align-items: center; gap: 2px; min-height: 40px;
  padding: 5px 5px 5px 12px; border-radius: 8px; margin-bottom: 3px; cursor: pointer;
  font-family: var(--text-sans); font-size: 14.5px; color: var(--side-text);
}
.drafts li:hover { background: var(--side-2); }
.drafts li.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.drafts li .item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drafts li .meta { font-family: var(--ui); font-size: 11px; color: var(--side-mute); margin-top: 1px; }
.drafts li.active .meta { color: rgba(43,27,0,.65); }
.drafts li .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drafts li .title.untitled { opacity: .75; }
.drafts li input {
  flex: 1; min-width: 0; height: 28px; border: 0; outline: 2px solid var(--accent); border-radius: 5px;
  padding: 0 8px; font: inherit; color: var(--ink); background: #fff;
}
.drafts li.empty {
  flex-direction: column; justify-content: center; gap: 10px; text-align: center; cursor: default;
  padding: 22px 14px; border: 1.5px dashed var(--side-line); border-radius: 12px; background: none;
}
.drafts li.empty svg { width: 30px; height: 30px; fill: none; stroke: var(--side-mute); stroke-width: 1.5; stroke-linejoin: round; }
.drafts li.empty p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--side-mute); }
.empty-btn { border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; padding: 8px 16px; }
.d-btn {
  border: 0; background: none; width: 28px; height: 28px; border-radius: 6px; padding: 0;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s, background .15s;
}
.d-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.drafts li:hover .d-btn, .drafts li.active .d-btn { opacity: .65; }
.d-btn:hover { opacity: 1 !important; background: rgba(0,0,0,.12); }

.guides { border-top: 1px solid var(--side-line); padding-top: 12px; margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.guide-link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 0; background: var(--side-2); color: var(--side-text); font-size: 11.5px; font-weight: 500;
  padding: 10px 4px 8px; border-radius: 10px; transition: background .15s, color .15s;
}
.guide-link:hover { background: var(--side-3); color: var(--accent); }
.guide-link img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1.5px var(--accent); }
.guide-link svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pages { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 12px 8px 0; margin-top: 8px; border-top: 1px solid var(--side-line); }
.pages a { color: var(--side-mute); font-size: 12px; text-decoration: none; }
.pages a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Right panel ---------- */
.right { border-left: 1px solid #000; }
.right-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px calc(16px + var(--safe-b)); display: flex; flex-direction: column; }

.ad-box { flex: 1; min-height: 280px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: 18px; }
.ads-label { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: #6f6f75; align-self: flex-start; }
.ad-box .ads-slot { flex: 1; width: 100%; min-height: 250px; display: flex; justify-content: center; align-items: stretch; overflow: hidden; }
.ad-box .ad-placeholder { height: 100%; }
.ads-slot .adsbygoogle { width: 100%; }
.ad-placeholder {
  width: 100%; min-height: inherit; border: 1.5px dashed #46464b; border-radius: 12px;
  display: grid; place-items: center; text-align: center; color: #77777d; font-size: 12px; padding: 12px; line-height: 1.6;
}

.block { margin-bottom: 14px; }
.side-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.side-row .lang-switch button { height: 32px; padding: 0 12px; }
.shortcut { display: flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 700; font-size: 13px; }
.row-label { font-size: 12px; color: var(--side-mute); font-family: var(--text-sans); }

.lang-switch { display: inline-flex; background: var(--side-3); border-radius: 999px; padding: 3px; gap: 2px; }
.lang-switch.wide { display: flex; }
.lang-switch.wide button { flex: 1; }
.lang-switch button {
  border: 0; background: transparent; color: var(--side-mute);
  font-size: 13px; font-weight: 600; height: 34px; padding: 0 12px; border-radius: 999px; min-width: 40px;
  font-family: var(--ui); transition: background .15s, color .15s;
}
.lang-switch button:hover { color: #fff; }
.lang-switch button.active { background: var(--accent); color: var(--accent-ink); }

.voice-card { background: var(--side-2); border-radius: 12px; padding: 12px 14px; }
.voice-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5a5a5e; flex-shrink: 0; }
.dot.on { background: var(--rec); box-shadow: 0 0 0 4px rgba(229,72,77,.25); }
.meter { height: 6px; background: var(--side-3); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: #4ade80; border-radius: 3px; transition: width .08s linear; }
.mic-name { margin-top: 6px; font-size: 11px; color: var(--side-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { display: none; margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--side-mute); font-family: var(--text-sans); }
.hint.show { display: block; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.info-btn {
  margin-left: auto; width: 26px; height: 26px; border: 0; border-radius: 50%; padding: 0;
  background: none; color: var(--side-mute); display: grid; place-items: center; transition: color .15s, background .15s;
}
.info-btn:hover, .info-btn.active { color: var(--accent); background: var(--side-3); }
.info-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.hint.err { color: #ffb4b4; }
.hint kbd { font-size: 9.5px; padding: 1px 5px; }

/* Account dialog */
#accountDlg { width: min(420px, 94vw); }
.acc-body { padding: 20px 22px 18px; }
.acc-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.acc-sub { margin: 0 0 16px; font-size: 14px; line-height: 1.65; color: var(--ink-2); font-family: var(--text-sans); }
.gsi { display: flex; justify-content: center; }
.acc-links { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.acc-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 8px; border: 0; border-radius: 10px;
  background: none; color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none; text-align: left;
}
.acc-link:hover { background: var(--accent-soft); color: var(--ink); }
.acc-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gsi { min-height: 40px; }
.gsi:empty { display: none; }
.gsi-fallback {
  width: 100%; height: 44px; border: 1px solid #dadce0; border-radius: 999px; background: #fff; color: #1f1f1f;
  font-weight: 500; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.gsi-fallback svg { width: 18px; height: 18px; }
/* Profile (signed in) */
.profile { display: flex; align-items: center; gap: 12px; }
.profile img { width: 52px; height: 52px; border-radius: 50%; background: #eee; object-fit: cover; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
.profile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(47,179,107,.2); flex-shrink: 0; }
#signedIn.offline .sync i { background: #d0a13b; box-shadow: 0 0 0 3px rgba(208,161,59,.2); }
.out-btn {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--ink); font-size: 13px; font-weight: 500;
}
.out-btn:hover { border-color: var(--rec); color: var(--rec); }
.out-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-btn { border: 0; background: none; color: var(--side-mute); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; padding: 4px 0; }
.link-btn:hover { color: var(--accent); }

/* ---------- Editor ---------- */
.editor-wrap { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.paper {
  flex: 1; min-height: 0; display: flex; justify-content: center;
  margin: 18px 18px 0; background: var(--paper); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
#editor {
  width: 100%; max-width: 860px; height: 100%; border: 0; outline: 0; resize: none; background: transparent;
  padding: 40px 44px 120px; color: var(--ink);
  font-family: var(--text-font); font-size: var(--editor-size); font-weight: 400;
  line-height: 1.85; letter-spacing: .005em; word-spacing: .04em;
  font-feature-settings: "kern", "liga";
}
#editor::placeholder { color: #b9b7b1; line-height: 1.85; }

.statusbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 18px 18px; padding: 10px 14px 10px 18px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius);
  font-size: 12.5px; color: var(--mute);
}
.stats { display: flex; align-items: center; gap: 12px; min-width: 0; white-space: nowrap; overflow: hidden; }
.stats > * { flex-shrink: 0; }
.tools { display: flex; align-items: center; gap: 6px; padding-right: 84px; }
.badge { background: var(--ink); color: #fff; font-weight: 700; font-size: 10.5px; letter-spacing: .08em; padding: 3px 8px; border-radius: 5px; }
.saved { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.saved i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); transition: background .2s; }
.saved b { font-weight: 500; }
.saved.dirty i { background: #d0cdc6; }
.saved.error i { background: var(--rec); }
.tool {
  display: inline-grid; place-items: center; height: 34px; min-width: 34px;
  border: 1px solid transparent; background: none; color: var(--ink-2);
  border-radius: 9px; padding: 0 8px; font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.tool em { font-style: normal; white-space: nowrap; }
.tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { border-color: var(--line); background: var(--accent-soft); color: var(--ink); }
.tool svg { width: 17px; height: 17px; }
.tool.cloud .i-ok { display: none; }
.tool.cloud.done .i-up { display: none; }
.tool.cloud.done .i-ok { display: block; }
.tool.cloud.done { color: #1f9a5a; }
.tool.cloud:not(.done) { color: #b9770a; }
.tool:disabled { opacity: .5; cursor: progress; }
#fontStyle span { font-family: var(--text-serif); font-size: 15px; }

.interim {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 92px;
  width: min(640px, calc(100% - 140px));
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--rec);
  box-shadow: 0 10px 30px rgba(0,0,0,.10); border-radius: 10px;
  padding: 10px 14px; font-family: var(--text-font); font-size: 16px; color: #555; line-height: 1.6;
}

.mic {
  position: absolute; right: 34px; bottom: 30px; width: 64px; height: 64px; z-index: 5;
  border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; box-shadow: 0 10px 26px rgba(246,167,35,.45);
  transition: transform .15s, background .2s, box-shadow .2s;
}
.mic:hover { transform: scale(1.05); }
.mic:active { transform: scale(.96); }
.mic svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; position: relative; }
.mic .mic-ring { position: absolute; inset: 0; border-radius: 50%; }
.mic.on { background: var(--rec); color: #fff; box-shadow: 0 10px 26px rgba(229,72,77,.45); }
.mic.on .mic-ring { animation: pulse 1.4s ease-out infinite; border: 3px solid var(--rec); }
@keyframes pulse { from { transform: scale(1); opacity: .8; } to { transform: scale(1.7); opacity: 0; } }

.scrim { display: none; }

/* ---------- Dialogs ---------- */
dialog {
  width: min(780px, 94vw); max-height: 86vh; border: 0; border-radius: 16px; padding: 0;
  box-shadow: 0 30px 80px rgba(0,0,0,.3); color: var(--ink);
}
#suggest { width: min(520px, 94vw); }
dialog::backdrop { background: rgba(20,20,20,.55); backdrop-filter: blur(2px); }
.help-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1;
}
.help-head h3 { margin: 0; font-size: 17px; flex: 1; }
.help-head .icon-btn { order: 2; }
.tabs { display: flex; gap: 4px; order: 3; width: 100%; flex-wrap: wrap; }
.tabs button { border: 0; background: #f2f1ed; border-radius: 8px; padding: 7px 14px; font-size: 13px; font-family: var(--text-sans); }
.tabs button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.help-body { padding: 18px 20px 24px; overflow-y: auto; }
.help-body h4 { margin: 18px 0 8px; font-size: 11.5px; letter-spacing: .08em; color: var(--mute); text-transform: uppercase; }
.help-body h4:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.cell { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.cell code { font-size: 13px; color: #666; }
.cell b { font-family: var(--text-sans); font-size: 18px; font-weight: 500; }
.examples { display: grid; gap: 6px; font-family: var(--text-sans); font-size: 15.5px; line-height: 1.65; }
.examples code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: #f4f3ef; padding: 2px 6px; border-radius: 4px; }
.steps { margin: 0; padding-left: 20px; font-family: var(--text-sans); font-size: 15px; line-height: 1.75; }
.keys { border-collapse: collapse; }
.keys td { padding: 6px 12px 6px 0; font-size: 14px; font-family: var(--text-sans); vertical-align: top; }

.form-body { padding: 16px 20px 20px; display: grid; gap: 12px; }
.form-note { margin: 0; font-family: var(--text-sans); font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.form-body label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); font-family: var(--text-sans); }
.form-body textarea, .form-body input {
  font: 400 15px/1.6 var(--text-sans); color: var(--ink); border: 1px solid #d9d6cf; border-radius: 10px; padding: 10px 12px; resize: vertical;
}
.form-body textarea:focus, .form-body input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.primary {
  height: 42px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 14px;
}
.primary:disabled { opacity: .6; }

.icon-btn { border: 0; background: none; padding: 8px; display: grid; place-items: center; color: inherit; border-radius: 8px; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; line-height: 1.5;
  font-family: var(--text-sans); opacity: 0; pointer-events: none; transition: .25s; z-index: 60;
  max-width: min(520px, 92vw); text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= Responsive ================= */

/* Drawers, used below 1100px */
@media (max-width: 1099px) {
  .topbar {
    display: flex; align-items: center; gap: 8px;
    padding: calc(8px + var(--safe-t)) 10px 8px 6px; background: var(--side); color: #fff;
  }
  .brand-sm { font-weight: 600; font-size: 17px; letter-spacing: -.01em; margin-right: auto; }
  .brand-sm span { color: var(--accent); }
  .topbar .lang-switch button { height: 30px; padding: 0 11px; min-width: 38px; }
  .avatar-btn {
    width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; overflow: hidden;
    background: var(--side-3); color: #ddd; display: grid; place-items: center;
  }
  .avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
  .avatar-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

  .left {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: min(300px, 86vw);
    padding-top: calc(22px + var(--safe-t));
    transform: translateX(-102%); visibility: hidden;
    transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s;
  }
  .left.open { transform: none; visibility: visible; box-shadow: 20px 0 40px rgba(0,0,0,.25); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
  .d-btn { opacity: .6; }
}

/* Tablet: right panel stays, left panel is a drawer */
@media (max-width: 1099px) and (min-width: 761px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top top" "main right";
  }
  .avatar-btn { display: none; }
  .topbar .top-lang { display: none; }
  .tool em { display: none; }
  #fontStyle em { display: inline; }
}
@media (max-width: 900px) and (min-width: 761px) { #saved b, .chars { display: none; } }

/* Phone: both panels are drawers, ad strip at the bottom */
@media (max-width: 760px) {
  :root { --editor-size: 18px; --radius: 0px; }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "main" "ad";
  }
  .paper { margin: 0; border: 0; box-shadow: none; }
  #editor { padding: 18px 18px 110px; line-height: 1.8; }

  .statusbar { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 8px 10px 8px 14px; gap: 6px; }
  .stats { gap: 8px; font-size: 12px; }
  #saved b { display: none; }
  .tools { gap: 4px; padding-right: 0; }
  .tool { height: 38px; min-width: 38px; }
  .tool em { display: none; }
  .hide-sm { display: none; }
  .chars { display: none; }
  .badge { padding: 3px 6px; }
  .toast { bottom: calc(150px + var(--safe-b)); font-size: 13.5px; }
  .drafts li { min-height: 46px; font-size: 15px; }
  .d-btn { width: 34px; height: 34px; }
  .drafts li input { font-size: 16px; height: 34px; }   /* 16px stops iOS zooming */
  .list-tabs button { height: 36px; }
  .guide-link { padding: 12px 4px 10px; }
  .pages { padding-bottom: 4px; }
  .acc-body { padding: 18px 18px calc(18px + var(--safe-b)); }
  .form-body textarea, .form-body input { font-size: 16px; }
  .help-body { padding: 14px 16px 22px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }

  .mic { right: 50%; transform: translateX(50%); bottom: 64px; width: 66px; height: 66px; }
  .mic:hover { transform: translateX(50%); }
  .mic:active { transform: translateX(50%) scale(.96); }
  .interim { bottom: 142px; width: calc(100% - 28px); }

  .ad-mobile { display: block; background: #fff; border-top: 1px solid var(--line); padding: 6px 8px calc(6px + var(--safe-b)); }
  .ad-mobile .ads-slot { height: 54px; display: flex; justify-content: center; }
  .ad-mobile .ad-placeholder { min-height: 0; height: 54px; border-color: #d6d3cc; color: #aaa69d; font-size: 11px; padding: 4px; border-radius: 8px; }

  .right {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; width: min(330px, 88vw);
    transform: translateX(102%); visibility: hidden;
    transition: transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s linear .28s;
  }
  .right.open { transform: none; visibility: visible; box-shadow: -20px 0 40px rgba(0,0,0,.25); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
  .right-scroll { padding-top: calc(18px + var(--safe-t)); }
  .right .ad-box { display: none; }   /* phone uses the bottom strip */

  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  #suggest, #accountDlg { width: 100vw; }
}

@media (hover: none) { .d-btn { opacity: .6; } }

/* Small phones */
@media (max-width: 370px) {
  .topbar { gap: 4px; }
  .brand-sm { font-size: 15px; }
  .topbar .lang-switch button { padding: 0 8px; min-width: 32px; font-size: 12px; }
  .tools { gap: 0; }
  .tool { min-width: 34px; padding: 0 6px; }
  .stats { gap: 6px; }
}

/* Landscape phones: keep the mic and editor usable */
@media (max-height: 480px) and (max-width: 1099px) {
  .ad-mobile { display: none; }
  .mic { bottom: 56px; width: 56px; height: 56px; }
  #editor { padding-bottom: 90px; }
}
