:root {
  --bg-top: #0a2540;
  --bg-mid: #061828;
  --bg-bottom: #020a12;
  --bg: #061828;
  --bg2: rgba(15, 35, 55, 0.92);
  --bg3: rgba(29, 45, 65, 0.95);
  --line: rgba(56, 189, 248, 0.14);
  --text: #e8f1fa;
  --muted: #8ba3b8;
  --accent: #38bdf8;
  --accent2: #fcd34d;
  --danger: #ff6b6b;
  --ok: #4cd19a;
  --warn: #f2b84b;
  --glass: blur(18px) saturate(1.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ui: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  --fs: 15px;
  --nav-h: 58px;
  --top-main: 48px;
  --top-tabs: 42px;
  --touch: 44px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--ui); font-size: 15px;
  overflow: hidden; overscroll-behavior: none;
  position: fixed; inset: 0;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

#app {
  position: fixed; top: 0; left: 0; width: 100%; height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 420px at 85% -5%, rgba(56, 189, 248, 0.18), transparent 55%),
    radial-gradient(700px 380px at 8% 15%, rgba(252, 211, 77, 0.07), transparent 50%),
    linear-gradient(165deg, var(--bg-top) 0%, var(--bg-mid) 42%, var(--bg-bottom) 100%);
  padding-top: env(safe-area-inset-top);
}

.omdaa-code #app::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
}

/* ─── الشريط العلوي ─── */
#topbar {
  display: flex; flex-direction: column; flex: none;
  background: var(--bg2);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}
.topbar-row { display: flex; align-items: center; gap: 4px; min-height: var(--top-main); padding: 0 6px; }
.topbar-tabs { min-height: var(--top-tabs); padding: 0 4px 4px; border-top: 1px solid rgba(255,255,255,.04); }
.topbar-spacer { flex: 1; min-width: 4px; }
.ws-chip {
  max-width: 42vw; height: 36px; padding: 0 12px; border-radius: 999px;
  background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.28);
  color: var(--accent); font-size: 12px; font-weight: 600;
}
.ws-chip:active { background: rgba(56, 189, 248, 0.22); }
.ws-chip .wsel { max-width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; font-size: inherit; }
.ibtn {
  width: var(--touch); height: var(--touch); flex: none; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted);
}
.ibtn:active { background: var(--bg3); color: var(--text); transform: scale(0.96); }
.ibtn-accent { color: var(--accent); }
.ibtn-save { color: var(--accent2); }
.ibtn.sm { width: 38px; height: 38px; }
#tabs { flex: 1; min-width: 0; width: 100%; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 2px; scroll-snap-type: x proximity; }
#tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  max-width: 200px; height: 36px; padding: 0 8px 0 12px; border-radius: 10px;
  background: rgba(255,255,255,.04); color: var(--muted); font-size: 13px; font-family: var(--mono);
  scroll-snap-align: start; border: 1px solid transparent;
}
.tab.active { color: var(--text); background: rgba(56, 189, 248, 0.14); border-color: rgba(56, 189, 248, 0.35); box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.15); }
.tab.conflict { box-shadow: inset 0 -2px 0 var(--warn); }
.tab .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.tab .x { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 18px; line-height: 1; }
.tab .x:active { background: #ffffff18; }

/* ─── المحتوى ─── */
#main { flex: 1; min-height: 0; position: relative; display: flex; }
.view { display: none; flex: 1; min-width: 0; min-height: 0; flex-direction: column; background: var(--bg); position: relative; }
body[data-view="files"] #files,
body[data-view="editor"] #editor-view,
body[data-view="agents"] #agents-view,
body[data-view="git"] #git-view,
body[data-view="term"] #term-view { display: flex; }

.view-head { display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: none; }
.view-head .spacer { flex: 1; }

/* شجرة الملفات */
.files-scroll { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; overflow: hidden; }
.files-ptr {
  position: absolute; top: 0; left: 0; right: 0; height: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--accent); font-size: 12px; font-weight: 600; z-index: 2; pointer-events: none;
}
.files-ptr-ico { flex: none; opacity: 0.85; transition: transform 0.2s ease; }
.files-ptr.ready .files-ptr-ico { transform: rotate(180deg); color: var(--accent2); }
.files-ptr.refreshing .files-ptr-ico { animation: files-ptr-spin 0.75s linear infinite; color: var(--accent2); }
@keyframes files-ptr-spin { to { transform: rotate(360deg); } }
#tree, #tree ul { list-style: none; margin: 0; padding: 0; }
#tree {
  flex: 1; min-height: 0; overflow: auto; padding: 6px 0 24px;
  -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  will-change: transform;
}
#tree .row { display: flex; align-items: center; gap: 8px; min-height: 48px; padding-right: 4px; cursor: pointer; }
#tree .row:active { background: var(--bg3); }
#tree .row.cur { background: #1b2a3b; }
#tree .ico { width: 18px; flex: none; text-align: center; color: var(--muted); }
#tree .row.open .ico { color: var(--accent); }
#tree .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 14px; }
#tree .more { width: 36px; height: 36px; color: var(--muted); font-size: 20px; border-radius: 8px; flex: none; }
#tree .more:active { background: #ffffff14; }
#tree .msg { padding: 10px 16px; color: var(--muted); font-size: 13px; }

/* المحرر */
#editor { flex: 1; min-height: 0; direction: ltr; position: relative; }
#editor .cm-editor { height: 100%; font-size: var(--fs); background: var(--bg); }
#editor .cm-scroller { font-family: var(--mono); line-height: 1.5; overflow: auto; -webkit-overflow-scrolling: touch; }
#editor .cm-content { padding-bottom: 56px; }
#editor .cm-gutters { background: var(--bg); border-right: 1px solid var(--line); }
#editor .cm-activeLine, #editor .cm-activeLineGutter { background: #ffffff0a; }
#editor .cm-panels { background: var(--bg2); }
#editor .cm-panel input { font-size: 16px; }
#empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); line-height: 1.7; pointer-events: none; padding: 24px 24px calc(var(--nav-h) + 40px); }
.empty-hero { max-width: 280px; }
.empty-hero p { margin: 8px 0 0; }
.empty-hero strong { color: var(--text); font-size: 18px; }
.empty-sub { font-size: 14px; opacity: .85; }
.empty-sub b { color: var(--accent); font-weight: 700; }
.mobile-file-bar {
  flex: none; display: flex; align-items: center; gap: 8px; min-height: 36px;
  padding: 6px 12px; border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.2); font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.mobile-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; }
.mobile-file-dirty { color: var(--warn); font-size: 10px; flex: none; }

/* أشرطة المفاتيح */
.keys {
  display: flex; gap: 6px; flex: none; overflow-x: auto; scrollbar-width: none;
  padding: 6px; background: var(--bg2); border-top: 1px solid var(--line);
  touch-action: pan-x; direction: ltr;
}
.keys::-webkit-scrollbar { display: none; }
.keys .k {
  flex: none; min-width: 44px; height: 42px; padding: 0 14px; border-radius: 11px;
  background: rgba(255,255,255,.06); color: var(--text); font-family: var(--mono); font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none;
}
.keys .k:active, .keys .k.on { background: var(--accent); color: #04121f; }
.keys .k.wide { min-width: 58px; font-family: var(--ui); font-size: 13px; }
.keys .sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }

/* الطرفية */
.term-bar { display: flex; align-items: center; height: 42px; flex: none; padding: 0 4px; border-bottom: 1px solid var(--line); background: var(--bg2); }
#term-tabs { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#term-tabs::-webkit-scrollbar { display: none; }
.ttab { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px 0 10px; border-radius: 8px; background: var(--bg3); color: var(--muted); font-size: 13px; }
.ttab.active { color: var(--text); background: #243142; }
.ttab .st { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.ttab .st.on { background: var(--ok); }
.ttab .st.connecting { background: var(--warn); }
.ttab .st.off { background: var(--danger); }
.ttab .x { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; font-size: 18px; line-height: 1; }
#term-host { flex: 1; min-height: 0; position: relative; background: #0b0f14; padding: 6px 4px 0 8px; overflow: hidden; }
.term-box { position: absolute; inset: 6px 4px 0 8px; display: none; }
.term-box.active { display: block; }
.term-box .xterm { height: 100%; }
.term-box .xterm-viewport { overflow-y: auto !important; -webkit-overflow-scrolling: touch; }

/* الشريط السفلي */
#bottomnav {
  display: flex; flex: none;
  background: var(--bg2);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 32px rgba(0,0,0,.35);
  z-index: 40;
}
#bottomnav button {
  flex: 1; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 9px; font-weight: 600; position: relative; padding-top: 4px;
}
@media (max-width: 380px) {
  #bottomnav .nav-git span { display: none; }
  #bottomnav .nav-git svg { width: 20px; height: 20px; }
}
#bottomnav button:active { color: var(--text); background: rgba(255,255,255,.04); }
#bottomnav button svg { opacity: .85; }
.nav-jazab .nav-jazab-label {
  font-weight: 800;
  font-size: 8px;
  letter-spacing: 0.02em;
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2, #fcd34d));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
body[data-view="files"] #bottomnav [data-go="files"],
body[data-view="editor"] #bottomnav [data-go="editor"],
body[data-view="agents"] #bottomnav [data-go="agents"],
body[data-view="git"] #bottomnav [data-go="git"],
body[data-view="term"] #bottomnav [data-go="term"] {
  color: var(--accent);
}
body[data-view="files"] #bottomnav [data-go="files"]::before,
body[data-view="editor"] #bottomnav [data-go="editor"]::before,
body[data-view="agents"] #bottomnav [data-go="agents"]::before,
body[data-view="git"] #bottomnav [data-go="git"]::before,
body[data-view="term"] #bottomnav [data-go="term"]::before {
  content: ""; position: absolute; top: 0; left: 18%; right: 18%; height: 3px; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
body.kb #bottomnav { display: none; }
body.kb #editor-keys, body.kb #term-keys { border-bottom: none; }

/* نوافذ منبثقة */
#modal { position: fixed; inset: 0; z-index: 50; background: #000a; display: flex; align-items: flex-end; justify-content: center; }
#modal-box {
  width: 100%; max-width: 520px; max-height: 82%; overflow: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}
#modal-box h3 { margin: 0 0 12px; font-size: 16px; }
#modal-box p { margin: 0 0 14px; color: var(--muted); line-height: 1.7; }
#modal-box input[type="text"] {
  width: 100%; height: 46px; padding: 0 12px; border-radius: 10px; font-size: 16px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); direction: ltr; text-align: left;
}
#modal-box input[type="text"]:focus, #login input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btns { display: flex; gap: 8px; margin-top: 14px; }
.btns button, .primary, .listbtn {
  flex: 1; height: 46px; border-radius: 10px; background: var(--bg3); color: var(--text); font-size: 15px;
}
.btns button.primary, .primary { background: var(--accent); color: #04121f; font-weight: 700; }
.btns button.danger { background: var(--danger); color: #240606; font-weight: 700; }
.listbtn { display: flex; align-items: center; width: 100%; padding: 0 14px; margin-bottom: 6px; text-align: start; justify-content: flex-start; gap: 10px; }
.listbtn.danger { color: var(--danger); }
.listbtn.mono { font-family: var(--mono); font-size: 14px; direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 46px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.setrow:last-of-type { border-bottom: 0; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; background: var(--bg3); font-size: 20px; }
.switch { width: 52px; height: 30px; border-radius: 15px; background: var(--bg3); position: relative; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(-22px); }

/* صفحة الهبوط (عام) */
.landing-pro {
  position: fixed; inset: 0; z-index: 90; overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.landing-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(165deg, var(--bg-top), var(--bg-bottom));
}
.landing-head { margin-top: 8vh; margin-bottom: 24px; }
.landing-tagline { color: var(--muted); font-size: 15px; margin: 12px 0 0; max-width: 320px; }
.landing-feats { list-style: none; padding: 0; margin: 0 0 28px; max-width: 340px; text-align: start; }
.landing-feats li { padding: 10px 14px; margin-bottom: 8px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--line); font-size: 14px; }
.landing-cta { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; }
.landing-cta .primary, .landing-cta .ghost { height: 52px; border-radius: 14px; font-weight: 700; font-size: 16px; }
.landing-cta .ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.landing-foot { margin-top: auto; padding-top: 24px; font-size: 12px; color: var(--muted); }

/* تسجيل الدخول */
#login {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}
.login-bg {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(600px 400px at 50% 0%, rgba(56, 189, 248, 0.25), transparent 60%),
    linear-gradient(165deg, var(--bg-top), var(--bg-bottom));
}
#login form {
  position: relative; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: center;
  padding: 24px 20px; border-radius: 20px;
  background: rgba(15, 35, 55, 0.75); backdrop-filter: var(--glass); -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--line); box-shadow: 0 24px 64px rgba(0,0,0,.45);
}
.login-brand { margin-bottom: 8px; }
.login-logo { font-size: 32px; font-weight: 800; color: #fff; letter-spacing: -0.02em; }
.login-tag { font-size: 22px; font-weight: 700; color: var(--accent); margin-inline-start: 4px; }
.login-sub { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.login-tabs { display: flex; gap: 8px; margin-bottom: 4px; }
.login-tab {
  flex: 1; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0,0,0,.2); color: var(--muted); font-weight: 600; font-size: 14px;
}
.login-tab.on { background: rgba(56,189,248,.15); color: var(--accent); border-color: rgba(56,189,248,.4); }
#login input[type="email"], #login input[type="text"], #login input[type="password"] {
  height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(0,0,0,.25); color: var(--text); font-size: 16px;
}
#login input[type="password"] { text-align: center; }
#login .primary { height: 52px; border-radius: 14px; box-shadow: 0 8px 24px rgba(56, 189, 248, 0.25); }
#login-err { min-height: 20px; color: var(--danger); font-size: 14px; }
#login .google-btn {
  height: 50px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: #1f2937;
  font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px;
}
#login .login-hint { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.4; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 200; max-width: 88%; padding: 10px 16px; border-radius: 12px; background: #243142; color: var(--text); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; box-shadow: 0 8px 24px #0008; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #4a1d22; color: #ffd6d6; }
#toast.ok { background: #153a2c; color: #c7f5e0; }
body.kb #toast { bottom: 70px; }

.term-box .xterm-viewport { background-color: transparent !important; }

/* لوحة مفاتيح فعلية (ماوس): لا حاجة لأشرطة المفاتيح. iPad يبقى له الشريط */
@media (min-width: 900px) and (pointer: fine) {
  #editor-keys, #term-keys { display: none; }
}

/* ─── موبايل: مساحة المحرر + لوحة المفاتيح ─── */
@media (min-width: 900px) {
  .files-ptr { display: none !important; }
  #tree { transform: none !important; }
}
@media (max-width: 899px) {
  .view-head { min-height: 48px; padding: 0 8px; }
  .view-head strong { font-size: 15px; }
  #editor-view { padding-bottom: 0; }
  #editor-keys, #term-keys {
    position: relative; z-index: 25;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,.25);
  }
  body:not(.kb) #editor-keys, body:not(.kb) #term-keys { margin-bottom: 0; }
  #editor .cm-gutters { min-width: 2.5em; }
  #editor .cm-lineNumbers .cm-gutterElement { min-width: 2em; padding: 0 6px 0 4px; font-size: 12px; }
  #upbar { bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
  .mobile-file-bar { display: flex; }
}
/* ─── شاشات كبيرة: تقسيم مثل VS Code ─── */
@media (min-width: 900px) {
  body[data-view="agents"] #main > .view:not(#agents-view) { display: none !important; }
  body[data-view="agents"] #agents-view { display: flex !important; flex: 1; max-width: none; width: 100%; }
  #bottomnav { display: none; }
  .mobile-file-bar { display: none !important; }
  #topbar { flex-direction: row; align-items: center; flex-wrap: nowrap; min-height: 46px; }
  .topbar-main { flex: none; min-height: 46px; }
  .topbar-tabs { flex: 1; min-width: 0; display: flex !important; align-items: center; border-top: 0; padding: 0 6px; min-height: 46px; }
  .ws-chip { max-width: 140px; }
  #tabs { flex: 1; }
  #main { display: grid; grid-template-columns: 290px 1fr; grid-template-rows: 1fr minmax(120px, 32%); direction: ltr; }
  #main > .view { display: flex !important; direction: rtl; }
  #files { grid-column: 1; grid-row: 1 / span 2; border-right: 1px solid var(--line); }
  #editor-view { grid-column: 2; grid-row: 1; }
  #git-view { grid-column: 2; grid-row: 1; display: none !important; }
  body[data-view="git"] #editor-view { display: none !important; }
  body[data-view="git"] #git-view { display: flex !important; }
  #term-view { grid-column: 2; grid-row: 2; border-top: 1px solid var(--line); }
}

.wsel { flex: none; max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); }
.badge { margin-inline-start: 8px; background: var(--warn); color: #1a1200; font-size: 11px; padding: 2px 7px; border-radius: 999px; }
#tree .row.sel { background: #1a2430; }
#tree .chev { width: 14px; flex: none; opacity: .5; display: inline-flex; transition: transform .15s; }
#tree .chev.o { transform: rotate(-90deg); opacity: 1; }
#tree small { color: var(--muted); font-size: 11px; flex: none; }
.note { padding: 12px 14px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.note.err { color: var(--danger); }
#modals { position: fixed; inset: 0; z-index: 120; pointer-events: none; }
#modals .backdrop { pointer-events: auto; position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .2s; }
#modals .backdrop.in { opacity: 1; }
#modals .sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 8px 14px calc(16px + env(safe-area-inset-bottom)); transform: translateY(8px); transition: transform .2s; }
#modals .backdrop.in .sheet { transform: none; }
#modals .sheet.full { max-height: 96vh; border-radius: 16px 16px 0 0; }
#modals .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 6px auto 12px; }
#modals h3 { margin: 0 0 12px; font-size: 16px; }
#modals .msg { margin: 0 0 14px; color: var(--muted); line-height: 1.7; }
#modals input, #modals textarea, #modals select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; margin-bottom: 8px; }
#modals .field { display: block; margin-bottom: 10px; }
#modals .field.check { display: flex; align-items: center; gap: 10px; }
#modals .field small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
#modals .mono { font-family: var(--mono); direction: ltr; text-align: left; }
#upbar { position: fixed; left: 12px; right: 12px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 90; height: 8px; background: var(--bg3); border-radius: 8px; overflow: hidden; }
#upfill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#uplabel { position: absolute; top: -22px; inset-inline-start: 0; font-size: 12px; color: var(--muted); }
.git-panel { flex: 1; overflow: auto; padding: 8px 10px 24px; }
.ghead, .gcommit, .grow, .gsec { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--bg3); font-size: 13px; }
.grow { padding: 8px 6px; border-radius: 10px; background: var(--bg2); }
.gname { flex: 1; text-align: start; font-family: var(--mono); font-size: 13px; background: none; color: inherit; }
.gs { width: 1.2em; font-weight: 700; font-family: var(--mono); }
.s-u .gs { color: var(--warn); }
.s-a .gs, .da { color: var(--ok); }
.s-m .gs, .dk { color: var(--accent); }
.s-d .gs, .dd { color: var(--danger); }
.diff { font-family: var(--mono); font-size: 12px; max-height: 50vh; overflow: auto; background: #0b0f14; padding: 8px; border-radius: 10px; }
.diff .dl { white-space: pre-wrap; word-break: break-all; padding: 1px 4px; }
.btns.col { flex-direction: column; }
.btns.col button { width: 100%; }
.btns.row { flex-wrap: wrap; }
.mini { font-size: 12px; padding: 4px 8px; height: auto; flex: none; background: var(--bg3); border-radius: 8px; }
.sp, .spacer { flex: 1; }
.trow { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.tmeta { flex: 1; min-width: 0; }
.tmeta small { display: block; color: var(--muted); font-size: 12px; }
.ailog { max-height: 40vh; overflow: auto; background: var(--bg); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.aimsg { margin-bottom: 10px; }
.aimsg pre { white-space: pre-wrap; margin: 4px 0 0; font-family: var(--mono); font-size: 13px; }
#files.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.keys .kgroup.selgroup { display: none; }
.keys.has-sel .kgroup.selgroup { display: contents; }
.keys.has-sel .k.accept { display: none; }
body.no-file #editor { visibility: hidden; }
body:not(.no-file) #empty { display: none; }
