:root {
  --bg: #070b12;
  --surface: #0c1220;
  --surface2: #101826;
  --surface3: #18263a;
  --border: #1c2b3e;
  --border2: #223347;
  --accent: #00d4ff;
  --accent2: #7c3aed;
  --accent3: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #526480;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Noto Sans Bengali', sans-serif;
  --radius: 10px;
  --header-h: 56px;
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  overscroll-behavior: none;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ══════════════════════════════════
   HEADER
══════════════════════════════════ */
.header {
  position: sticky; top:0; z-index:200;
  height: var(--header-h);
  background: rgba(7,11,18,0.97);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 10px; gap: 6px;
}
.logo {
  font-family: var(--mono);
  font-size: 18px; font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap; flex-shrink:0;
}
.logo span { color: var(--text3); font-size: 9px; display: block; font-weight:400; letter-spacing:0; }
.header-spacer { flex:1; min-width:4px; }

.hbtn {
  height: 34px; padding: 0 11px;
  border-radius: 7px; border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text2);
  font-size: 12px; font-family: var(--sans);
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  transition: all 0.15s; white-space: nowrap; flex-shrink:0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.hbtn:hover { background: var(--surface3); color: var(--text); }
.hbtn.accent { background: var(--accent3); border-color: var(--accent3); color:#000; font-weight:600; }
.hbtn.accent:hover { filter: brightness(1.1); }
.hbtn:disabled { opacity:0.3; pointer-events:none; }

.undo-badge {
  background: var(--border2); color: var(--text3);
  font-size: 9px; font-family: var(--mono);
  padding: 1px 4px; border-radius: 3px;
}

/* ── HISTORY DRAWER ── */
.hist-panel-backdrop {
  display:none; position:fixed; inset:0; z-index:2000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
}
.hist-panel-backdrop.open { display:block; }
.hist-drawer {
  position:fixed; bottom:0; left:0; right:0; z-index:2001;
  background: var(--surface2);
  border-top: 1px solid var(--border2);
  border-radius: 14px 14px 0 0;
  padding: 0 0 28px;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  max-height: 72vh; overflow:hidden;
  display: flex; flex-direction: column;
}
.hist-drawer.open { transform: translateY(0); }
.hist-drawer-handle {
  width: 36px; height: 4px; border-radius:2px;
  background: var(--border2); margin: 10px auto 0; flex-shrink:0;
}
.hist-drawer-title {
  font-size:13px; font-weight:600; color: var(--text2);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items:center; justify-content:space-between;
  flex-shrink:0;
}
.hist-drawer-title span { font-size:11px; color: var(--text3); font-family: var(--mono); font-weight:400; }
.hist-list { overflow-y:auto; flex:1; padding: 6px 0; }
.hist-entry {
  display: flex; align-items: flex-start; gap:10px;
  padding: 10px 16px; cursor:pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.hist-entry:hover { background: var(--surface3); }
.hist-entry:last-child { border-bottom:none; }
.hist-entry-num {
  font-family: var(--mono); font-size:11px;
  color: var(--accent); background: var(--surface3);
  padding: 2px 6px; border-radius:4px; flex-shrink:0; margin-top:1px;
}
.hist-entry-info { flex:1; }
.hist-entry-label { font-size:13px; color: var(--text); margin-bottom:2px; }
.hist-entry-meta { font-size:11px; color: var(--text3); font-family: var(--mono); }
.hist-entry-lines { font-size:11px; color: var(--accent3); margin-top:1px; }
.hist-empty { text-align:center; padding:30px 16px; color: var(--text3); font-size:13px; }

/* ══════════════════════════════════
   TOASTS
══════════════════════════════════ */
#toastContainer {
  position:fixed; bottom:90px; right:14px; z-index:9999;
  display: flex; flex-direction:column-reverse; gap:6px;
  pointer-events:none;
}
.toast {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent3);
  color: var(--text);
  padding: 9px 13px; border-radius:8px;
  font-size:13px; max-width:260px;
  animation: toastIn 0.22s ease, toastOut 0.3s ease 2.4s forwards;
  pointer-events:all;
}
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity:0; transform: translateX(12px); } to { opacity:1; transform: none; } }
@keyframes toastOut { to { opacity:0; transform: translateX(12px); } }

/* ══════════════════════════════════
   VIDEO SECTION
══════════════════════════════════ */
.video-section {
  position: sticky;
  top: var(--header-h);
  z-index:100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.video-container {
  position:relative; width:100%; background:#000;
  display:none;
}
.video-container.visible { display:flex; justify-content:center; align-items:center; }
#videoPlayer {
  width:100%; height:auto; max-height:34vh;
  object-fit:contain; display:block;
}
@media (orientation:landscape) { #videoPlayer { max-height:56vh; } }

.video-upload-placeholder { padding:0; }
.video-upload-btn {
  display:flex; align-items:center; justify-content:center; gap:12px;
  padding:16px 18px;
  background: linear-gradient(135deg, rgba(0,212,255,0.06) 0%, rgba(124,58,237,0.06) 100%);
  border: 1.5px dashed rgba(0,212,255,0.35);
  border-radius:10px; margin:10px 14px;
  cursor:pointer; transition:all 0.2s;
  position:relative; overflow:hidden;
}
.video-upload-btn:hover { border-color: var(--accent); background: rgba(0,212,255,0.09); }
.video-upload-btn:active { transform: scale(0.99); }
.vub-icon { font-size:26px; flex-shrink:0; filter: drop-shadow(0 0 8px rgba(0,212,255,0.5)); }
.vub-text { display:flex; flex-direction:column; gap:2px; }
.vub-title { font-size:14px; font-weight:600; color: var(--accent); }
.vub-sub { font-size:11px; color: var(--text3); font-family: var(--mono); }
.vub-arrow { margin-left:auto; color: var(--accent); font-size:18px; opacity:0.5; }

/* video overlay controls */
.vov { position:absolute; z-index:20; display:flex; gap:5px; }

.vov.tl { top:7px; left:7px; }
.vov.tr { top:7px; right:7px; }
.vbtn {
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 4px 8px; border-radius:5px;
  cursor:pointer; font-size:11px; font-weight:600;
  backdrop-filter: blur(6px); white-space:nowrap;
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
.vbtn:active { background: rgba(0,0,0,0.95); }
.vbtn.active-p { background: rgba(0,212,255,0.35); color: var(--accent); border-color: rgba(0,212,255,0.6); }

/* set-time button on video */
.vbtn.settime { color: var(--warn); border-color: rgba(245,158,11,0.5); }

/* ── POSITIONING TOOLBAR ── */
.pos-toolbar {
  display: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: rgba(7,11,18,0.97);
  border-top: 1px solid rgba(0,212,255,0.2);
}
.pos-toolbar::-webkit-scrollbar { display:none; }
.pos-toolbar.visible { display: block; }
/* inner: flex row, min-width:max-content ensures no wrap + enables centering */
.pos-toolbar-inner {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  min-width: max-content;
  margin: 0 auto; /* center when content narrower than container */
}

/* fullscreen portrait: directly below top row, full width scroll container */
.pos-toolbar.in-fs-portrait {
  position: absolute;
  left: 0; right: 0;
  bottom: auto;
  top: 44px; /* will be overridden by JS */
  z-index: 2000;
  background: transparent;
  border: none;
  padding: 0;
}
.pos-toolbar.in-fs-portrait .pos-toolbar-inner {
  padding: 4px 8px;
}
/* in portrait, pbtn buttons styled like vbtn */
.pos-toolbar.in-fs-portrait .pbtn {
  height: auto;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  background: rgba(0,0,0,0.75);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
  backdrop-filter: blur(6px);
}
.pos-toolbar.in-fs-portrait .pbtn.on {
  background: rgba(0,212,255,0.35);
  color: var(--accent);
  border-color: rgba(0,212,255,0.6);
}
.pos-toolbar.in-fs-portrait .pbtn.warn {
  background: rgba(245,158,11,0.25);
  border-color: rgba(245,158,11,0.5);
  color: var(--warn);
}
.pos-toolbar.in-fs-portrait .pbtn.green {
  background: rgba(16,185,129,0.22);
  border-color: rgba(16,185,129,0.45);
  color: var(--accent3);
}
.pos-toolbar.in-fs-portrait .pbtn.danger {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.4);
  color: #fca5a5;
}
.pos-toolbar.in-fs-portrait .pos-sep { display: none; }
/* fullscreen landscape: same row between tl and tr */
.pos-toolbar.in-fs-landscape {
  position: absolute;
  top: 7px;
  bottom: auto;
  z-index: 2000;
  background: transparent;
  border: none;
  padding: 0;
}
.pos-toolbar.in-fs-landscape .pos-toolbar-inner {
  padding: 0;
  gap: 4px;
}
/* in landscape, pbtn buttons exactly same size as vbtn */
.pos-toolbar.in-fs-landscape .pbtn {
  height: auto;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  background: rgba(0,0,0,0.75);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
  backdrop-filter: blur(6px);
}
.pos-toolbar.in-fs-landscape .pbtn.on {
  background: rgba(0,212,255,0.35);
  color: var(--accent);
  border-color: rgba(0,212,255,0.6);
}
.pos-toolbar.in-fs-landscape .pbtn.warn {
  background: rgba(245,158,11,0.25);
  border-color: rgba(245,158,11,0.5);
  color: var(--warn);
}
.pos-toolbar.in-fs-landscape .pbtn.green {
  background: rgba(16,185,129,0.22);
  border-color: rgba(16,185,129,0.45);
  color: var(--accent3);
}
.pos-toolbar.in-fs-landscape .pbtn.danger {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.4);
  color: #fca5a5;
}
/* hide separator in landscape to save space */
.pos-toolbar.in-fs-landscape .pos-sep {
  display: none;
}

.pbtn {
  height: 28px; padding: 0 9px;
  border-radius: 6px; border: 1px solid var(--border2);
  background: var(--surface3); color: var(--text2);
  font-size: 11px; font-family: var(--mono);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: all 0.13s;
  display: flex; align-items: center; gap: 4px;
}
.pbtn:active { transform: scale(0.88); }
.pbtn.on { background: rgba(0,212,255,0.22); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.pbtn.warn { border-color: rgba(245,158,11,0.4); color: var(--warn); background: rgba(245,158,11,0.08); }
.pbtn.danger { border-color: rgba(239,68,68,0.35); color: #fca5a5; background: rgba(239,68,68,0.07); }
.pbtn.green { border-color: rgba(16,185,129,0.4); color: var(--accent3); background: rgba(16,185,129,0.08); }


.pos-sep {
  width: 1px; height: 20px;
  background: var(--border2); flex-shrink: 0; margin: 0 2px;
}

/* subtitle overlay */
.sub-overlay {
  position:absolute; bottom:14%;
  left:50%; transform: translateX(-50%);
  width:96%;
  text-align:center; color:#fff;
  font-size:20px; font-weight:700;
  line-height:1.35;
  text-shadow: -1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000,0 3px 8px rgba(0,0,0,0.95);
  display:none; z-index:10;
  transition: bottom 0.35s cubic-bezier(0.25,1,0.5,1);
  pointer-events:auto; touch-action:pan-y;
}
.sub-overlay.visible { display:block; }
.sub-span {
  display:inline-block;
  padding: 2px 6px; border-radius:6px;
  border: 1px solid transparent;
  cursor:grab; user-select:none; -webkit-user-select:none;
  transition: all 0.18s;
}
.sub-span.editing {
  cursor:text; user-select:text; -webkit-user-select:text;
  background: rgba(0,0,0,0.85);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0,212,255,0.3);
  text-shadow:none; outline:none;
}
.sub-span.sec { color:#fde68a; font-size:0.88em; margin-top:1px; display:block; }
/* Positioning mode: strip all invisible spacing so text can reach exact corners */
.sub-overlay.pos-mode { line-height:1.2; }
.sub-overlay.pos-mode .sub-span {
  padding: 0;
  border-radius: 0;
  border-color: transparent;
}
.sub-overlay.pos-mode .sub-span.sec { margin-top: 2px; }

/* P-off mode এ positioned line এ ছোট reset badge */
.pos-reset-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  background: rgba(0,0,0,0.65);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  cursor: pointer;
  vertical-align: middle;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1.6;
  text-shadow: none;
  letter-spacing: 0.02em;
}

/* ══════════════════════════════════
   MAIN
══════════════════════════════════ */
.main { padding: 12px 14px 100px; }

/* UPLOAD CARDS */
.upload-row { display:flex; gap:10px; margin-bottom:12px; }
.upload-card {
  flex:1; background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 12px 8px;
  cursor:pointer; text-align:center;
  transition: all 0.15s;
  display:flex; flex-direction:column; align-items:center; gap:4px;
}
.upload-card:hover { border-color: var(--accent); background: var(--surface2); }
.upload-card.loaded { border-style:solid; border-color: var(--accent3); }
.upload-card input[type=file] { display:none; }
.upload-card .uc-icon { font-size:18px; }
.upload-card .uc-label { font-size:11px; color: var(--text2); font-weight:600; letter-spacing:0.5px; }
.upload-card .uc-fname {
  font-size:11px; color: var(--accent); font-family: var(--mono);
  max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* STATS BAR */
.stats-bar { display:flex; gap:6px; margin-bottom:10px; flex-wrap:wrap; align-items:center; }
.stat-pill {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius:20px; padding: 3px 11px;
  font-size:12px; color: var(--text3);
  font-family: var(--mono);
}
.stat-pill b { color: var(--accent); font-weight:600; }

/* TOOLBAR */
.toolbar { display:flex; gap:6px; margin-bottom:10px; flex-wrap:wrap; }

.search-wrap {
  flex:1; min-width:160px;
  position:relative; display:flex; align-items:center;
}
.search-icon { position:absolute; left:9px; color: var(--text3); font-size:13px; pointer-events:none; }
.search-input {
  width:100%; padding: 8px 8px 8px 28px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size:13px; font-family: var(--sans);
  outline:none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

.tbtn {
  height: 36px; padding: 0 11px;
  border-radius: var(--radius); border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text2);
  font-size:12px; font-family: var(--sans);
  cursor:pointer; display:flex; align-items:center; gap:4px;
  transition: all 0.15s; white-space:nowrap;
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
.tbtn:hover { background: var(--surface3); color: var(--text); }
.tbtn.danger { background:#1c0a0a; border-color:#3d1515; color:#fca5a5; }
.tbtn.danger:hover { background:#2d0e0e; }
.tbtn.primary { background:#0c2a1c; border-color:#1a4d32; color: var(--accent3); }
.tbtn.primary:hover { background:#0f3321; }
.tbtn:active { transform: scale(0.95); }

/* FIND & REPLACE */
.fnr-panel {
  display:none;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px; margin-bottom:10px;
  gap:8px; flex-direction:column;
}
.fnr-panel.open { display:flex; }
.fnr-row { display:flex; gap:8px; align-items:center; }
.fnr-input {
  flex:1; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius:8px; color: var(--text); font-size:13px;
  font-family: var(--sans); outline:none;
}
.fnr-input:focus { border-color: var(--accent); }
.fnr-count { font-size:11px; font-family: var(--mono); color: var(--text3); white-space:nowrap; min-width:54px; }

/* SUBTITLE LIST */
#subtitleContainer { display:flex; flex-direction:column; gap:10px; }
.empty-state { text-align:center; padding:56px 20px; color: var(--text3); }
.empty-state .es-icon { font-size:38px; margin-bottom:12px; }
.empty-state p { font-size:14px; }

.sub-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  display:none;
}
.sub-item.visible { display:block; }
.sub-item.active-line {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,212,255,0.12), inset 0 0 20px rgba(0,212,255,0.03);
}
.sub-item.highlighted {
  border-color: var(--warn);
  box-shadow: 0 0 0 1px rgba(245,158,11,0.2);
}
/* overlap warning */
.sub-item.overlap-warn {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(239,68,68,0.15);
}
.overlap-badge {
  display:inline-flex; align-items:center; gap:3px;
  font-size:10px; color: var(--danger);
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25);
  border-radius:4px; padding: 1px 5px;
  font-family: var(--mono); white-space:nowrap; flex-shrink:0;
}
.tg-label-row {
  display:flex; align-items:center; gap:5px; margin-bottom:3px; flex-wrap:wrap;
}

/* sub header */
.sub-header {
  display:flex; align-items:center; gap:8px;
  margin-bottom:10px; padding-bottom:8px;
  border-bottom: 1px solid var(--border);
}
.sub-num {
  background: var(--surface3);
  color: var(--accent); width:26px; height:26px;
  border-radius:6px; display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:700; font-family: var(--mono);
  flex-shrink:0;
}
.sub-num.active { background: var(--accent); color:#000; }

/* TIMING ROW — improved for mobile */
.timing-actions-wrap {
  display:flex; align-items:center; gap:4px; flex:1; min-width:0; overflow:hidden;
}
.timing-row {
  display:flex; align-items:center; gap:4px; flex:1; min-width:0;
}
.timing-pair {
  display:flex; align-items:center; gap:4px;
}
.timing-label {
  font-family: var(--mono); font-size:9px;
  color: var(--text3); width:14px; flex-shrink:0; text-align:right;
}
.timing-input {
  font-family: var(--mono); font-size:11px;
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--accent); padding: 4px 5px;
  border-radius:5px; outline:none;
  width: 108px;
  transition: border-color 0.15s;
}
.timing-input:focus { border-color: var(--accent); background: #0a1929; }
.timing-input.invalid { border-color: var(--danger); color: var(--danger); }

/* char count */
.char-count {
  font-size:10px; font-family: var(--mono);
  color: var(--text3); margin-top:2px;
  text-align:right;
}
.char-count.warn { color: var(--warn); }
.char-count.over { color: var(--danger); font-weight:600; }

.timing-sep { color: var(--text3); font-size:11px; font-family: var(--mono); }

/* SET TIME button — always visible, compact like overlap badge */
.set-time-btn {
  height: 22px; padding: 0 6px;
  border-radius: 4px; border: 1px solid rgba(245,158,11,0.4);
  background: rgba(245,158,11,0.08); color: var(--warn);
  font-size: 10px; font-family: var(--mono);
  cursor: pointer; white-space: nowrap;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.set-time-btn:hover { background: rgba(245,158,11,0.18); }
.set-time-btn:active { transform: scale(0.90); }
.set-time-btn.hidden { display:none; }

/* SUB ACTIONS */
.sub-actions { display:flex; gap:3px; flex-shrink:0; align-items:center; }
.sub-act-btn {
  width:34px; height:26px; border-radius:6px;
  border: 1px solid var(--border2); background: var(--surface3);
  color: var(--text2); font-size:13px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: all 0.12s;
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
  font-weight:600; padding:0; flex-shrink:0;
}
.sub-act-btn:active { transform: scale(0.82); }
.sub-act-btn.merge:active { color: var(--accent2); border-color: var(--accent2); }
.sub-act-btn.split:active { color: var(--warn); }
.sub-act-btn.add-below:active { color: var(--accent3); }
.sub-act-btn.del-line:active { color: var(--danger); }

@media (max-width: 600px) {
  .timing-row { flex-direction:column; align-items:flex-start; gap:3px; }
  .timing-sep { display:none; }
  .timing-input { width:108px; font-size:11px; padding:4px 5px; }
  .sub-actions { gap:2px; }
  .sub-act-btn { width:30px; height:36px; font-size:14px; border-radius:7px; }
}

/* HTML FORMATTING BAR — hidden until textarea focused */
.html-fmt-bar {
  display:none;
  gap:5px; flex-wrap:nowrap; overflow-x:auto;
  margin-top:6px; padding: 7px 0 4px;
  border-top: 1px solid var(--border);
  animation: fmtFadeIn 0.15s ease;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.html-fmt-bar::-webkit-scrollbar { display:none; }
.html-fmt-bar.show { display:flex; }
@keyframes fmtFadeIn { from { opacity:0; transform: translateY(-4px); } to { opacity:1; transform:none; } }

.fmt-btn {
  height:34px; padding: 0 11px;
  border-radius:7px; border: 1px solid var(--border2);
  background: var(--surface3); color: var(--text2);
  font-size:13px; font-family: var(--sans);
  cursor:pointer; display:flex; align-items:center; flex-shrink:0;
  transition: all 0.12s; white-space:nowrap;
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
.fmt-btn:active { transform: scale(0.88); background: var(--surface2); color: var(--text); border-color: var(--accent); }
.fmt-btn.clr { border-color:#3d1515; color:#fca5a5; background:#1c0a0a; }
.fmt-btn.src-active { background: #1c1500; border-color: var(--warn); color: var(--warn); }

/* SCROLL TO TOP */
.scroll-top-btn {
  position:fixed; right:14px; bottom:90px; z-index:160;
  width:40px; height:40px; border-radius:50%;
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--text2); font-size:16px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  opacity:0; pointer-events:none;
  transition: opacity 0.2s, transform 0.15s;
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
.scroll-top-btn.visible { opacity:1; pointer-events:auto; }
.scroll-top-btn:active { transform: scale(0.88); }

/* TEXT AREAS */
.text-group { margin-bottom:8px; }
.text-group:last-child { margin-bottom:0; }
.tg-label { font-size:10px; color: var(--text3); margin-bottom:3px; font-weight:600; letter-spacing:0.6px; }
.tg-label.sec { color: #a78bfa; }
.sub-textarea {
  width:100%; min-height:58px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 9px 10px;
  border-radius:7px; resize:none;
  font-size:14px; font-family: var(--sans);
  line-height:1.5; outline:none;
  transition: border-color 0.15s;
  display:block; cursor:text; overflow-y:auto; word-break:break-word;
  white-space:pre-wrap;
}
.sub-textarea[contenteditable]:empty:before {
  content: attr(data-placeholder);
  color: var(--text3);
  pointer-events:none;
}
.sub-textarea:focus { border-color: var(--accent); background: #090e18; }
.sub-textarea.sec:focus { border-color: #a78bfa; }

.sub-source {
  display:none; width:100%; min-height:58px;
  background: #0a0f1a; border: 1px solid var(--warn);
  color: #fde68a; padding: 9px 10px;
  border-radius:7px; resize:vertical;
  font-size:13px; font-family: var(--mono);
  line-height:1.6; outline:none;
  transition: border-color 0.15s;
}
.sub-source:focus { border-color: #f59e0b; }
.sub-source.visible { display:block; }

mark.highlight { background: rgba(245,158,11,0.32); color: var(--text); border-radius:2px; }

/* ══════════════════════════════════
   MODAL
══════════════════════════════════ */
.modal-backdrop {
  display:none; position:fixed; inset:0; z-index:3000;
  background: rgba(0,0,0,0.82); backdrop-filter: blur(4px);
  align-items:center; justify-content:center;
  padding:16px;
}
.modal-backdrop.open { display:flex; }
.modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius:14px; padding:20px;
  width:100%; max-width:370px;
  max-height:88vh; overflow-y:auto;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.95) translateY(10px); } to { opacity:1; transform:none; } }
.modal h3 { font-size:15px; margin-bottom:14px; padding-bottom:10px; border-bottom: 1px solid var(--border); }

.radio-group { display:flex; flex-direction:column; gap:7px; margin: 7px 0; }
.radio-label {
  display:flex; align-items:center; gap:8px;
  font-size:14px; cursor:pointer; padding: 8px 10px;
  border-radius:8px; border: 1px solid var(--border);
  background: var(--surface); transition: all 0.15s;
}
.radio-label:hover { border-color: var(--border2); background: var(--surface3); }
.radio-label input { accent-color: var(--accent); width:14px; height:14px; }

.fmt-row { display:flex; gap:7px; margin: 7px 0; }
.fmt-label {
  flex:1; display:flex; align-items:center; justify-content:center; gap:5px;
  font-size:13px; cursor:pointer; padding: 9px 4px;
  border-radius:8px; border: 1px solid var(--border);
  background: var(--surface); transition: all 0.15s; text-align:center;
  font-family: var(--mono);
}
.fmt-label:hover { border-color: var(--accent); }
.fmt-label input { accent-color: var(--accent); }

.section-title { font-size:11px; color: var(--text3); margin-bottom:5px; text-transform:uppercase; letter-spacing:0.6px; }
.modal-footer { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }
.mbtn {
  height:35px; padding: 0 15px;
  border-radius:8px; border: 1px solid var(--border2);
  background: var(--surface3); color: var(--text2);
  font-size:13px; font-family: var(--sans);
  cursor:pointer; transition: all 0.15s;
  touch-action:manipulation;
}
.mbtn:hover { color: var(--text); }
.mbtn.primary { background: var(--accent3); border-color: var(--accent3); color:#000; font-weight:600; }
.mbtn.primary:hover { filter: brightness(1.08); }

/* Go To Line Modal input */
.goto-input {
  width:100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius:8px; color: var(--text); font-size:16px;
  font-family: var(--mono); outline:none; text-align:center;
  margin-bottom:4px;
}
.goto-input:focus { border-color: var(--accent); }
.goto-hint { font-size:11px; color: var(--text3); text-align:center; font-family: var(--mono); }

/* KEYBOARD SHORTCUTS */
.kb-grid { display:grid; grid-template-columns: 1fr 1fr; gap:6px; margin-top:8px; }
.kb-item { display:flex; flex-direction:column; gap:2px; }
.kb-key {
  font-family: var(--mono); font-size:10px;
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--accent); padding: 3px 6px; border-radius:4px;
  display:inline-block;
}
.kb-desc { font-size:11px; color: var(--text3); }

/* ══════════════════════════════════
   BOTTOM FAB BAR
══════════════════════════════════ */
.fab-bar {
  position:fixed; bottom:0; left:0; right:0; z-index:150;
  background: rgba(7,11,18,0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display:flex; flex-direction:column;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.fab-bar-top {
  display:flex; align-items:center; gap:6px;
  padding: 6px 10px 4px;
  border-bottom: 1px solid var(--border);
}

/* EXPORT INFO BOX */
.export-info {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius:8px; padding:10px;
  font-size:12px; color: var(--text3);
  margin-top:10px;
}
.export-info b { color: var(--warn); }

/* MOBILE: header compact */
@media (max-width: 480px) {
  .hbtn { padding: 0 8px; font-size: 11px; }
}