:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e4e2dc;
  --accent: #0b8fd3;
  --accent-ink: #ffffff;
  --ok: #2e9e5b;
  --select: #fbe9e9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141416; --panel: #1c1c1f; --ink: #f2f2f4; --muted: #9a9aa2;
    --line: #2c2c31; --select: #3a2224; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141416; --panel: #1c1c1f; --ink: #f2f2f4; --muted: #9a9aa2;
  --line: #2c2c31; --select: #3a2224; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Noto Sans Bengali", sans-serif;
  display: flex; flex-direction: column;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.brand img { border-radius: 7px; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.phone.connected { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; padding: 7px 13px; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--accent); }
.btn:hover { filter: brightness(0.97); }

.layout { flex: 1; display: flex; min-height: 0; }
.side { width: 260px; border-right: 1px solid var(--line); padding: 12px; overflow: auto; flex-shrink: 0; }
.btn.new { width: 100%; margin-bottom: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 9px 10px; border-radius: 9px; cursor: pointer; margin-bottom: 2px; }
.list li:hover { background: color-mix(in srgb, var(--line) 50%, transparent); }
.list li.active { background: var(--select); }
.list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .m { color: var(--muted); font-size: 12px; }

.editor { flex: 1; display: flex; min-width: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); }
.doc { flex: 1; display: flex; flex-direction: column; max-width: 860px; width: 100%; margin: 0 auto; padding: 20px 24px; min-height: 0; }
.doc-head { display: flex; gap: 10px; align-items: center; }
.title {
  flex: 1; font-size: 24px; font-weight: 700; border: none; background: transparent; color: var(--ink);
  padding: 6px 0; outline: none; min-width: 0;
}
.text {
  flex: 1; resize: none; margin-top: 10px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); color: var(--ink); font: 19px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Bengali", sans-serif;
  outline: none; min-height: 240px;
}
.text:focus { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.doc-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; padding-top: 8px; flex-wrap: wrap; }

.modal { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.card { position: relative; background: var(--panel); border-radius: 16px; padding: 24px; width: min(560px, 100%); max-height: 100%; overflow: auto; }
.card h2 { margin: 0 0 8px; }
.close { position: absolute; top: 10px; right: 12px; border: none; background: none; font-size: 26px; color: var(--muted); }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--muted); }
.pair-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; }
.qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.code-box { flex: 1; min-width: 180px; }
.code-label { color: var(--muted); font-size: 13px; }
.code { font: 700 40px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 6px; margin: 6px 0; }
.code-sub { color: var(--muted); font-size: 12px; }
.more { margin-top: 18px; color: var(--muted); font-size: 13px; }
.more summary { cursor: pointer; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 12px; }

/* Web prompter */
.prompter { position: fixed; inset: 0; background: #000; color: #fff; z-index: 30; }
.p-scroll { position: absolute; inset: 0; overflow: hidden; }
.p-text {
  max-width: 1000px; margin: 0 auto; padding: 0 6vw; white-space: pre-wrap; word-wrap: break-word;
  font: 600 48px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Bengali", sans-serif;
  will-change: transform;
}
.prompter.mirror .p-text { transform-origin: center; }
.p-text .w { transition: color 0.25s; }
.p-text .w.read { color: #6b6b70; }
.p-text .w.now { color: #ffd84d; }
.p-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid rgb(229 72 77 / 0.55); pointer-events: none; }
.p-heard { position: absolute; left: 16px; right: 16px; bottom: 64px; text-align: center; color: #8a8a90; font-size: 14px; min-height: 20px; }
.p-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 10px 16px; background: linear-gradient(transparent, rgb(0 0 0 / 0.9) 40%);
}
.p-btn { background: #222; color: #ddd; border: 1px solid #333; border-radius: 9px; padding: 7px 12px; font-size: 14px; }
.p-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.p-ctl { display: flex; align-items: center; gap: 6px; color: #aaa; font-size: 13px; }
.p-ctl input { width: 90px; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .side { width: 100%; border-right: none; border-bottom: 1px solid var(--line); max-height: 34vh; }
  .doc { padding: 14px 16px; }
  .top { flex-wrap: wrap; }
  .p-text { font-size: 32px; }
}
