/* fs - IntelliJ New UI Dark, adapted to phone. All theme tokens live in :root below. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/fonts/inter-cyrillic-wght-normal.woff2) format('woff2-variations'), url(vendor/fonts/inter-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(vendor/fonts/inter-latin-wght-normal.woff2) format('woff2-variations'), url(vendor/fonts/inter-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url(vendor/fonts/jetbrains-mono-cyrillic-wght-normal.woff2) format('woff2-variations'), url(vendor/fonts/jetbrains-mono-cyrillic-wght-normal.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url(vendor/fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2-variations'), url(vendor/fonts/jetbrains-mono-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ============================================================ theme tokens (one place) */
:root {
  color-scheme: dark;

  /* surfaces */
  --bg-editor: #1E1F22;
  --bg-panel: #2B2D30;
  --bg-header: #2B2D30;
  --bg-popup: #2B2D30;
  --bg-field: #1E1F22;
  --bg-chip: #393B40;
  --border: #393B40;
  --border-field: #4E5157;
  --border-strong: #1E1F22;

  /* text */
  --text: #DFE1E5;
  --text-2: #6F737A;
  --text-3: #9DA0A8;
  --text-on-accent: #FFFFFF;
  --accent: #3574F0;
  --accent-hover: #3069DB;
  --link: #548AF7;
  --danger: #DB5C5C;
  --warning-bg: #3D3223;
  --warning-fg: #D6AE58;

  /* states */
  --sel: #2E436E;
  --sel-inactive: #43454A;
  --hover: #393B40;
  --pressed: #43454A;
  --focus: #3574F0;
  --stripe-sel: #3574F0;

  /* git file status (Project tree, tabs) */
  --git-m: #6C9FE9;   /* modified */
  --git-a: #5FAD65;   /* added */
  --git-d: #6F737A;   /* deleted */
  --git-u: #D1675A;   /* unversioned (?) */
  --git-i: #6F737A;   /* ignored (!) */

  /* availability dots */
  --online: #5FAD65;
  --offline: #6F737A;

  /* editor / syntax (IntelliJ New UI Dark scheme) */
  --code-fg: #BCBEC4;
  --code-gutter: #4B5059;
  --code-gutter-active: #A1A3AB;
  --code-line-hl: #26282E;
  --code-target: #2E436E;
  --syn-keyword: #CF8E6D;
  --syn-string: #6AAB73;
  --syn-number: #2AACB8;
  --syn-comment: #7A7E85;
  --syn-doc: #5F826B;
  --syn-function: #56A8F5;
  --syn-annotation: #B3AE60;
  --syn-builtin: #8888C6;
  --syn-self: #94558D;
  --syn-constant: #C77DBB;
  --syn-tag: #D5B778;
  --syn-attr: #BABABA;
  --syn-regex: #42C3D4;
  --syn-deleted: #D5756C;
  --chess-a: #2B2D30;
  --chess-b: #393B40;

  /* typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-ui: 13px;
  --fs-small: 11px;
  --fs-code: 13px;
  --lh-code: 20px;
  --fs-input: 16px; /* >= 16px: iOS Safari does not zoom on focus */

  /* metrics */
  --titlebar-h: 44px;
  --tab-h: 36px;
  --tree-row-h: 24px;
  --tree-indent: 18px;
  --toolbar-h: 48px;
  --stripe-w: 44px;
  --side-w: 320px;
  --hit: 44px;
  --radius: 4px;
  --radius-popup: 10px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
:root.big-rows { --tree-row-h: 32px; }

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-editor);
  color: var(--text);
  font: var(--fs-ui)/1.35 var(--font-ui);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
html { touch-action: manipulation; }
body { overflow: hidden; position: fixed; inset: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--link); text-decoration: none; }
[hidden] { display: none !important; }
svg { flex: none; }
::selection { background: #214283; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============================================================ app shell */
.app {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: grid;
  grid-template-areas: "title" "work" "bar";
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg-editor);
}
.app.wide {
  grid-template-areas: "title title" "bar work";
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: calc(var(--stripe-w) + var(--safe-l)) minmax(0, 1fr);
}

/* iOS 27 status bar: opaque fill of the top inset (height 0 when the page is not under the bar) */
.sb-fill { position: fixed; top: 0; left: 0; right: 0; height: var(--safe-t); background: var(--bg-header); z-index: 5; pointer-events: none; }

/* ---------- title bar (IDEA main toolbar) */
.titlebar {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: 2px;
  height: calc(var(--titlebar-h) + var(--safe-t));
  padding: var(--safe-t) max(4px, var(--safe-r)) 0 max(4px, var(--safe-l));
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-strong);
  min-width: 0;
}
.tb-widget {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  min-width: 0;
  max-width: 100%;
}
.tb-widget:active, .tb-widget[aria-expanded="true"] { background: var(--pressed); }
.tb-widget .tb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-widget .tb-sub { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-project { flex: 0 1 auto; min-width: 0; height: var(--hit); }
.tb-machine { flex: 0 1 auto; color: var(--text-3); gap: 6px; }
.tb-branch { flex: 0 1 auto; color: var(--text-3); min-width: 0; }
.tb-branch .tb-sub { color: var(--text); }
.tb-spacer { flex: 1 1 0; min-width: 0; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--offline); flex: none; }
.dot.on { background: var(--online); }

.avatar {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: var(--av, #5E7ADB);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .2px;
  flex: none;
}
.avatar.lg { width: 28px; height: 28px; border-radius: 7px; font-size: 12px; }

/* ---------- icon buttons */
.ib {
  display: inline-grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  padding: 0;
  border: 0;
  background: none;
  flex: none;
  position: relative;
}
.ib > .ib-face {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
}
.ib:active > .ib-face { background: var(--pressed); }
.ib[aria-pressed="true"] > .ib-face { background: var(--sel); }
.ib.star[aria-pressed="true"] > .ib-face { background: none; }
.ib:disabled { opacity: .35; cursor: default; }
.ib.sm { width: 36px; height: 36px; }
.ib.sm > .ib-face { width: 26px; height: 26px; }
@media (hover: hover) {
  .ib:hover > .ib-face { background: var(--hover); }
  .tb-widget:hover { background: var(--hover); }
}

/* ---------- workspace (side tool window + editor) */
.workspace {
  grid-area: work;
  position: relative;
  display: flex;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.side {
  position: absolute;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(88vw, 360px);
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-strong);
  transform: translateX(-102%);
  transition: transform .22s cubic-bezier(.3, .7, .3, 1);
  padding-left: var(--safe-l);
  will-change: transform;
}
.side.open { transform: none; box-shadow: 8px 0 24px rgba(0, 0, 0, .35); }
.scrim {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.app.wide .side {
  position: relative;
  transform: none;
  transition: none;
  box-shadow: none;
  width: var(--side-w);
  max-width: 40vw;
  flex: none;
  padding-left: 0;
  padding-bottom: var(--safe-b);
}
.app.wide .side:not(.open) { display: none; }
.app.wide .scrim { display: none; }

.editor {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-editor);
}
.app.wide .editor { padding-right: var(--safe-r); padding-bottom: var(--safe-b); }

/* ---------- tool window header */
.tw { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.tw-head {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 0 0 12px;
  flex: none;
}
.tw-title { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-head .ib { width: 36px; height: 40px; }
.tw-head .ib > .ib-face { width: 26px; height: 26px; }

/* ---------- inputs */
.field {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 4px 0 8px;
  background: var(--bg-field);
  border: 1px solid var(--border-field);
  border-radius: var(--radius);
  min-width: 0;
}
.field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  font-size: var(--fs-input);
  padding: 0;
}
.field input::placeholder { color: var(--text-2); }
.field input::-webkit-search-cancel-button, .field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.field .ib { width: 32px; height: 32px; }
.field .ib > .ib-face { width: 24px; height: 24px; }
.field > svg { opacity: .8; }
.tw-field { margin: 0 8px 6px; }

/* ---------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hit);
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-field);
  background: transparent;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}
.btn:active { background: var(--pressed); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.btn-primary:active { background: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: var(--fs-ui); }
.btn:disabled { opacity: .5; }
.btn svg { width: 16px; height: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 16px;
  border: 1px solid var(--border-field);
  background: none;
  white-space: nowrap;
  flex: none;
}
.chip[aria-pressed="true"] { background: var(--sel); border-color: var(--accent); }
.chip:active { background: var(--pressed); }

.seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border-field);
  border-radius: 6px;
  flex: none;
}
.seg button {
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-3);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--sel-inactive); color: var(--text); }
.seg .seg-ic { display: none; place-items: center; }
.app.wide.short .seg .seg-ic { display: grid; }
.app.wide.short .seg .seg-tx { display: none; }
.app.wide.short .seg button { padding: 0 8px; }

/* ---------- breadcrumbs */
.crumbs {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 8px 0 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: none;
  border-bottom: 1px solid var(--border);
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs .ib { width: 36px; height: 40px; }
.crumbs .ib > .ib-face { width: 24px; height: 24px; }
.crumb {
  flex: none;
  height: 36px;
  min-width: 32px;
  padding: 0 6px;
  border: 0;
  background: none;
  border-radius: var(--radius);
  color: var(--text-3);
  white-space: nowrap;
}
.crumb:last-child { color: var(--text); }
.crumb:active { background: var(--pressed); }
.crumb-sep { flex: none; display: grid; place-items: center; width: 12px; opacity: .6; }
.crumb-sep svg { width: 12px; height: 12px; }

/* ---------- banners */
.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 12px;
  flex: none;
}
.banner .dot { background: var(--warning-fg); }
.banner.err { background: #402929; color: #E0A5A5; }

/* ---------- Project tree */
.tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 0 calc(16px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.app.wide .tree { padding-bottom: 16px; }
.row {
  display: flex;
  align-items: center;
  gap: 5px;
  height: var(--tree-row-h);
  padding: 0 8px 0 calc(6px + var(--d, 0) * var(--tree-indent));
  margin: 0 6px;
  border-radius: var(--radius);
  white-space: nowrap;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.row:active { background: var(--hover); }
.row.sel { background: var(--sel); }
.row.focus-dir { background: var(--sel-inactive); }
.row .chev { width: 16px; height: 16px; display: grid; place-items: center; flex: none; }
.row .chev svg { transition: transform .12s; }
.row[aria-expanded="true"] .chev svg { transform: rotate(90deg); }
.row .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.row .sec { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 0; }
.row.root .nm { font-weight: 600; }
.row.dim .nm { color: var(--text-2); }
.row.msg { color: var(--text-2); font-style: italic; }
.row.msg.err { color: #E0A5A5; font-style: normal; }
.row.msg .btn { font-style: normal; }

.ic { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; flex: none; }
.ic-link { position: absolute; left: -3px; bottom: -3px; width: 9px; height: 9px; transform: scaleX(-1) rotate(90deg); }
.ic-link svg { width: 9px; height: 9px; }

.git-M .nm, .git-M.nm { color: var(--git-m); }
.git-A .nm, .git-A.nm { color: var(--git-a); }
.git-D .nm, .git-D.nm { color: var(--git-d); text-decoration: line-through; }
.git-\? .nm, .git-\?.nm { color: var(--git-u); }
.git-\! .nm, .git-\!.nm { color: var(--git-i); }

/* name-search hits in tree */
.hit-row { height: auto; min-height: var(--hit); padding-top: 4px; padding-bottom: 4px; align-items: flex-start; }
.hit-row .hit-text { display: flex; flex-direction: column; min-width: 0; }
.hit-row .hit-text .nm, .hit-row .hit-text .sec { flex: none; }
.hit-row .ic { margin-top: 1px; }
.tree-note { padding: 6px 14px; color: var(--text-2); font-size: 12px; }
.tree-note a { color: var(--link); }
.li.link-row { color: var(--link); min-height: 40px; margin: 0 6px; width: auto; }
.li.link-row .li-title { white-space: normal; }

/* skeletons */
.skel-row { display: flex; align-items: center; gap: 8px; height: var(--tree-row-h); padding-left: calc(28px + var(--d, 0) * var(--tree-indent)); margin: 0 6px; }
.skel {
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, #36383D 0%, #44464C 40%, #36383D 80%);
  background-size: 300% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skel.ic-skel { width: 14px; height: 14px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .side, .sheet { transition: none !important; } }

/* ---------- editor tabs */
.tabs {
  display: flex;
  height: var(--tab-h);
  flex: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-editor);
  touch-action: pan-x;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 2px 0 10px;
  flex: none;
  max-width: 240px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  color: var(--text);
  transition: transform .15s, opacity .15s;
}
.tab .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .tab-dir { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.tab.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
.tab .tab-x { width: 32px; height: 100%; border: 0; background: none; display: grid; place-items: center; opacity: .55; padding: 0; }
.tab.active .tab-x { opacity: 1; }
.tab .tab-x span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 3px; }
.tab .tab-x:active span { background: var(--pressed); }

/* ---------- file header + toolbar */
.file-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 0 0 12px;
  flex: none;
}
.file-head .ic { width: 16px; height: 16px; }
.file-title { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.file-title .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-title .meta { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  padding: 0 2px 0 8px;
  flex: none;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.file-tools .tools-left { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.file-tools .tools-left::-webkit-scrollbar { display: none; }
.file-tools .tools-right { display: flex; align-items: center; flex: none; }
.zoom-label { min-width: 46px; text-align: center; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; }
.app.wide .file-head + .file-tools { border-top: 0; }

/* landscape: header and tools in one row */
.app.wide.short .file-bar { display: flex; align-items: center; border-bottom: 1px solid var(--border); min-width: 0; }
.app.wide.short .file-bar .file-head { flex: 1 1 auto; min-width: 0; padding-right: 0; }
.app.wide.short .file-bar .file-tools { border-bottom: 0; flex: none; padding-left: 4px; }
.app.wide.short .file-bar .file-tools .tools-left { flex: none; overflow: visible; }

/* ---------- viewer area */
.viewer { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.viewer-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* code */
.code-scroll { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: var(--bg-editor); }
.code-scroll pre {
  margin: 0;
  padding: 8px 0 calc(24px + var(--safe-b));
  font: var(--fs-code)/var(--lh-code) var(--font-code);
  font-variant-ligatures: none;
  color: var(--code-fg);
  tab-size: 4;
  background: none;
  counter-reset: ln;
}
.code-scroll pre > code { display: block; width: max-content; min-width: 100%; font: inherit; }
.code-scroll .line { display: block; white-space: pre; padding-right: 16px; min-height: var(--lh-code); }
.code-scroll .line::before {
  counter-increment: ln;
  content: counter(ln);
  position: sticky;
  left: 0;
  z-index: 1;
  display: inline-block;
  width: calc(var(--gw, 3ch) + 26px);
  padding: 0 14px 0 8px;
  margin-right: 8px;
  text-align: right;
  color: var(--code-gutter);
  background: var(--bg-editor);
  user-select: none;
  -webkit-user-select: none;
}
.code-scroll .line.target { background: var(--code-target); }
.code-scroll .line.target::before { background: var(--code-target); color: var(--code-gutter-active); }
.code-scroll.wrap pre > code { width: auto; }
.code-scroll.wrap .line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding-left: calc(var(--gw, 3ch) + 34px);
  position: relative;
}
.code-scroll.wrap .line::before { position: absolute; left: 0; top: 0; }
.trunc-note {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--warning-bg);
  color: var(--warning-fg);
  font-size: 12px;
  flex: none;
}

/* syntax: Pygments classes -> IntelliJ New UI Dark */
.highlight { color: var(--code-fg); }
.highlight :is(.c, .c1, .cm, .ch, .cs, .cpf) { color: var(--syn-comment); }
.highlight .sd { color: var(--syn-doc); font-style: italic; }
.highlight :is(.k, .kc, .kd, .kn, .kp, .kr, .kt, .ow) { color: var(--syn-keyword); }
.highlight :is(.s, .s1, .s2, .sb, .sc, .sh, .sx, .ss, .dl) { color: var(--syn-string); }
.highlight :is(.se, .si, .sa) { color: var(--syn-keyword); }
.highlight .sr { color: var(--syn-regex); }
.highlight :is(.m, .mi, .mf, .mh, .mo, .mb, .il) { color: var(--syn-number); }
.highlight :is(.nf, .fm) { color: var(--syn-function); }
.highlight .nd { color: var(--syn-annotation); }
.highlight .cp { color: var(--syn-annotation); }
.highlight .nb { color: var(--syn-builtin); }
.highlight .bp { color: var(--syn-self); }
.highlight :is(.no, .nv, .vi, .vc, .vg, .vm) { color: var(--syn-constant); }
.highlight .nt { color: var(--syn-tag); }
.highlight .na { color: var(--syn-attr); }
.highlight :is(.gh, .gu) { color: var(--syn-keyword); font-weight: 600; }
.highlight .gd { color: var(--syn-deleted); }
.highlight .gi { color: var(--syn-string); }
.highlight .ge { font-style: italic; }
.highlight .gs { font-weight: 700; }
.highlight .gp { color: var(--syn-comment); }
.highlight .err { color: inherit; background: none; border: 0; }
:is([data-lang="json"], [data-lang="json5"], [data-lang="jsonld"]) .highlight .nt { color: var(--syn-constant); }
:is([data-lang="yaml"], [data-lang="toml"]) .highlight .nt { color: var(--syn-keyword); }
:is([data-lang="bash"], [data-lang="sh"], [data-lang="shell"]) .highlight .nv { color: var(--syn-constant); }
:is([data-lang="css"], [data-lang="scss"], [data-lang="less"]) .highlight :is(.nc, .nt, .nn) { color: var(--syn-tag); }

/* markdown preview */
.md-body {
  max-width: 860px;
  padding: 16px 16px calc(32px + var(--safe-b));
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  overflow-wrap: break-word;
}
.md-body > :first-child { margin-top: 0; }
.md-body :is(h1, h2, h3, h4, h5, h6) { margin: 1.4em 0 .6em; line-height: 1.25; font-weight: 600; scroll-margin-top: 12px; }
.md-body h1 { font-size: 1.75em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h2 { font-size: 1.4em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.2em; }
.md-body h4 { font-size: 1em; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body table, .md-body pre { margin: 0 0 1em; }
.md-body ul, .md-body ol { padding-left: 1.6em; }
.md-body li + li { margin-top: .25em; }
.md-body li.task-list-item { list-style: none; margin-left: -1.4em; }
.md-body li.task-list-item input { margin: 0 .5em 0 0; accent-color: var(--accent); vertical-align: -1px; }
.md-body blockquote { padding: 0 1em; color: var(--text-3); border-left: 3px solid #4B5059; }
.md-body code { font: .88em var(--font-code); background: var(--bg-panel); padding: .15em .4em; border-radius: 4px; }
.md-body pre { padding: 12px; background: var(--bg-panel); border-radius: 6px; overflow: auto; font: 13px/1.5 var(--font-code); }
.md-body pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
.md-body .highlight { margin: 0 0 1em; }
.md-body .highlight pre { margin: 0; }
.md-body img { max-width: 100%; height: auto; border-radius: 4px; }
.md-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md-body a { color: var(--link); }
.md-body .table-wrap { overflow-x: auto; margin: 0 0 1em; -webkit-overflow-scrolling: touch; }
.md-body table { border-collapse: collapse; font-size: 14px; margin: 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md-body th { background: var(--bg-panel); font-weight: 600; }
.md-body .toc { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 1em; }
.md-body .toc ul { margin: 0; }
.mermaid-box { margin: 0 0 1em; padding: 12px; background: var(--bg-panel); border-radius: 6px; overflow-x: auto; text-align: center; }
.mermaid-box svg { max-width: 100%; height: auto; }
.mermaid-box.pending { color: var(--text-2); font-size: 12px; text-align: left; }
.mermaid-err { color: #E0A5A5; font-size: 12px; text-align: left; white-space: pre-wrap; }

/* image stage */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  background: var(--bg-editor);
}
.stage.chess {
  background-color: var(--chess-a);
  background-image: conic-gradient(var(--chess-b) 25%, transparent 0 50%, var(--chess-b) 0 75%, transparent 0);
  background-size: 16px 16px;
}
.stage > .stage-content {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  max-width: none;
}
.stage.pixel > .stage-content { image-rendering: pixelated; }
.stage-ctrl {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 0 2px;
  border-radius: 10px;
  background: rgba(43, 45, 48, .94);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
.stage-ctrl .zoom-label { min-width: 44px; }
.stage-hint { position: absolute; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); padding: 4px 10px; border-radius: 12px; background: rgba(30, 31, 34, .8); color: var(--text-3); font-size: 11px; pointer-events: none; }

/* media + cards */
.media-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; background: #000; }
.media-wrap video { max-width: 100%; max-height: 100%; width: 100%; background: #000; }
.frame { flex: 1; min-height: 0; width: 100%; border: 0; background: #fff; }
.frame.pdf { background: #525659; }
.card-center { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + var(--safe-b)); }
.file-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  text-align: center;
}
.file-card .big-ic svg { width: 56px; height: 56px; }
.file-card .fc-name { font-weight: 600; font-size: 15px; word-break: break-word; }
.file-card .fc-meta { color: var(--text-3); }
.file-card .fc-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; width: 100%; }
.file-card .fc-actions .btn { flex: 1 1 120px; }
.file-card audio { width: 100%; margin-top: 6px; }
.file-card .fc-note { color: var(--text-2); font-size: 12px; }

/* viewer states */
.state {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-3);
}
.state .state-title { color: var(--text); font-weight: 600; font-size: 15px; }
.state .state-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.code-skel { padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.code-skel .skel { height: 11px; }

.empty-editor { flex: 1; min-height: 0; overflow: auto; padding: 32px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 18px; }
.empty-editor .hint { color: var(--text-2); text-align: center; line-height: 1.6; }
.empty-editor .hint b { color: var(--text-3); font-weight: 500; }
.recent-files { width: 100%; max-width: 420px; }
.recent-files h3 { margin: 0 0 6px; font-size: 12px; color: var(--text-2); font-weight: 500; text-transform: none; }

/* ---------- list rows (switcher, search, settings, menus) */
.list { display: flex; flex-direction: column; }
.li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--hit);
  padding: 4px 12px;
  border: 0;
  background: none;
  text-align: left;
  width: 100%;
  border-radius: 6px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  color: var(--text);
}
.li:active { background: var(--hover); }
.li .li-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.li .li-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-sub { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; }
.li .li-end { color: var(--text-2); font-size: 12px; flex: none; }
.li.disabled { opacity: .5; }
.li.danger { color: var(--danger); }

/* search tool window */
.search-scope { display: flex; align-items: center; gap: 6px; padding: 0 12px 6px; color: var(--text-2); font-size: 12px; min-width: 0; flex: none; }
.search-scope .scope-path { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.search-mode { display: flex; padding: 0 8px 8px; gap: 8px; align-items: center; flex: none; }
.results { flex: 1; min-height: 0; overflow: auto; padding: 0 6px calc(16px + var(--safe-b)); overscroll-behavior: contain; }
.res-file { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 6px; margin-top: 4px; font-weight: 500; position: sticky; top: 0; background: var(--bg-panel); z-index: 1; }
.res-file .sec { color: var(--text-2); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.res-file .nm { white-space: nowrap; flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.res-line {
  display: flex;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  align-items: center;
  padding: 2px 6px 2px 28px;
  border: 0;
  background: none;
  text-align: left;
  border-radius: var(--radius);
  font: 12px/1.4 var(--font-code);
  color: var(--code-fg);
}
.res-line:active { background: var(--hover); }
.res-line .ln { color: var(--code-gutter-active); min-width: 3ch; text-align: right; flex: none; }
.res-line .tx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
mark { background: #3B514D; color: inherit; border-radius: 2px; padding: 0 1px; box-shadow: 0 0 0 1px #4A6A63; }

/* ---------- bottom tool window bar / left stripe */
.toolbar {
  grid-area: bar;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--toolbar-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--bg-panel);
  border-top: 1px solid var(--border-strong);
  z-index: 40;
}
.tw-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 10.5px;
  padding: 0 2px;
  position: relative;
}
.tw-btn .tw-ic { display: grid; place-items: center; width: 34px; height: 26px; border-radius: 6px; position: relative; }
.tw-btn .tw-ic svg { width: 18px; height: 18px; }
.tw-btn .tw-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tw-btn[aria-pressed="true"] { color: var(--text); }
.tw-btn[aria-pressed="true"] .tw-ic { background: var(--stripe-sel); }
.tw-btn[aria-pressed="true"] .tw-ic svg :is(path, rect, circle)[stroke] { stroke: #fff; }
.tw-btn[aria-pressed="true"] .tw-ic svg :is(path, rect, circle)[fill]:not([fill="none"]) { fill: #fff; }
.tw-btn:active .tw-ic { background: var(--pressed); }
.tw-btn.soon { color: var(--text-2); }
.tw-btn.soon .tw-ic svg { opacity: .45; }
.tw-btn .soon-badge {
  position: absolute;
  top: -5px;
  right: -14px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--bg-chip);
  color: var(--text-3);
  font-size: 9px;
  line-height: 13px;
  font-weight: 500;
}
.app.wide .toolbar {
  flex-direction: column;
  justify-content: flex-start;
  height: auto;
  padding: 6px 0 calc(6px + var(--safe-b)) var(--safe-l);
  border-top: 0;
  border-right: 1px solid var(--border-strong);
  gap: 2px;
}
.app.wide .tw-btn { flex: none; height: 44px; font-size: 0; gap: 0; }
.app.wide .tw-btn .tw-label { display: none; }
.app.wide .tw-btn .soon-badge { top: -4px; right: -8px; font-size: 8px; padding: 0 3px; }
.app.wide .tw-btn.bottom-group { margin-top: auto; }
.app.wide .tw-btn.bottom-group ~ .tw-btn.bottom-group { margin-top: 0; }
:root.kb .app:not(.wide) .toolbar { display: none; }

/* ---------- sheets, dialogs, menus */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity .2s;
}
.overlay.show { opacity: 1; }
.sheet {
  position: fixed;
  z-index: 101;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: calc(100dvh - var(--safe-t) - 24px);
  display: flex;
  flex-direction: column;
  background: var(--bg-popup);
  border-radius: 14px 14px 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .45);
  transform: translateY(105%);
  transition: transform .24s cubic-bezier(.3, .7, .3, 1);
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
}
.sheet.show { transform: none; }
.sheet.full { top: 0; max-height: none; border-radius: 0; border-top: 0; padding-top: var(--safe-t); }
.app-wide-sheet .sheet:not(.full) { left: 50%; right: auto; width: min(480px, 100vw); margin-left: max(-240px, -50vw); }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: #4E5157; margin: 6px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 4px 0 16px; flex: none; }
.sheet-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body { flex: 1; min-height: 0; overflow: auto; padding: 0 8px 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-section { margin: 6px 0 14px; }
.sheet-label { padding: 6px 8px 4px; color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.menu-title { padding: 10px 16px 4px; color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-cancel { margin: 6px 8px 8px; }

/* switcher */
.open-path { padding: 4px 8px 4px; display: flex; flex-direction: column; gap: 8px; }
.open-path .row-inline { display: flex; gap: 8px; align-items: center; }
.open-path .row-inline .field { flex: 1; height: var(--hit); }
.machine-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.machine-chips::-webkit-scrollbar { display: none; }
.mgroup { margin: 8px 0 12px; border-top: 1px solid var(--border); padding-top: 6px; }
.mgroup-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 2px; min-height: 36px; }
.mgroup-head .mg-name { font-weight: 600; }
.mgroup-head .mg-os { color: var(--text-2); font-size: 12px; }
.mgroup-head .mg-state { color: var(--text-2); font-size: 12px; margin-left: auto; white-space: nowrap; }
.mgroup-err { color: var(--text-2); font-size: 12px; padding: 0 8px 4px 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgroup-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 6px; }
.mg-sub { padding: 6px 12px 2px; color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.mg-empty { padding: 4px 12px 6px; color: var(--text-2); font-size: 12px; }

/* settings */
.set-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 12px; border-radius: 8px; }
.set-row .li-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.set-row .li-sub { color: var(--text-2); font-size: 12px; }
.switch { position: relative; width: 42px; height: 26px; flex: none; }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; width: 42px; height: 26px; border-radius: 13px; background: #4E5157; transition: background .15s; cursor: pointer; }
.switch input:checked { background: var(--accent); }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked::after { transform: translateX(16px); }
.set-row select { height: 36px; border-radius: var(--radius); border: 1px solid var(--border-field); background: var(--bg-field); padding: 0 8px; font-size: var(--fs-input); max-width: 50%; }

/* dialog */
.dialog {
  position: fixed;
  z-index: 102;
  left: 50%;
  top: calc(var(--safe-t) + 72px);
  width: min(360px, calc(100vw - 32px));
  transform: translateX(-50%) scale(.96);
  opacity: 0;
  transition: transform .15s, opacity .15s;
  background: var(--bg-popup);
  border: 1px solid var(--border);
  border-radius: var(--radius-popup);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dialog.show { transform: translateX(-50%); opacity: 1; }
.dialog h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dialog .field { height: var(--hit); }
.dialog .dlg-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* toasts */
.toasts {
  position: fixed;
  z-index: 200;
  left: 0;
  right: 0;
  bottom: calc(var(--toolbar-h) + var(--safe-b) + 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 12px;
}
.app-wide-sheet .toasts, :root.kb .toasts { bottom: calc(12px + var(--safe-b)); }
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, 100%);
  min-height: 44px;
  padding: 6px 6px 6px 14px;
  border-radius: 8px;
  background: #3C3F44;
  border: 1px solid #4E5157;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  color: var(--text);
  animation: toast-in .18s ease-out;
}
.toast.err { background: #4A2B2B; border-color: #6E3A3A; }
.toast .toast-msg { flex: 1; min-width: 0; padding: 4px 0; overflow-wrap: anywhere; }
.toast .btn { min-height: 32px; padding: 0 10px; border-color: transparent; color: var(--link); }
.toast .toast-x { width: 32px; height: 32px; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* code fonts: no ligatures (IDEA default) */
pre, code, .res-line, .md-body pre, .md-body code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

/* ---------- login page */
.login-page { position: static; overflow: auto; min-height: 100dvh; }
.login {
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(var(--safe-t) + 12vh) 20px calc(var(--safe-b) + 24px);
}
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.login-brand img { width: 48px; height: 48px; border-radius: 11px; }
.login-brand h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.login-brand p { margin: 2px 0 0; color: var(--text-3); }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login label.lbl { display: flex; flex-direction: column; gap: 6px; color: var(--text-3); }
.login .field { height: var(--hit); }
.login-error { margin: 0; color: #E0A5A5; min-height: 0; }
.login-or { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 12px; margin: 4px 0; }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login .btn { width: 100%; }
.login .btn svg { width: 20px; height: 20px; }
.login-foot { color: var(--text-2); font-size: 12px; text-align: center; margin-top: 8px; }
