@font-face {
  font-family: "JetBrains Mono";
  src: url("/vendor/fonts/JetBrainsMono-Regular.woff2?v=bf06933b82ec6b35") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  color-scheme: dark;
  --bg: #101319;
  --bar: #161a22;
  --panel: #131720;
  --line: #252b38;
  --fg: #c8cdd8;
  --dim: #8a93a3;
  --accent: #8ea3c0;
  --ok: #9db38f;
  --err: #c98a92;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: #1d2230;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
}

button:hover {
  background: #262d3f;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

#main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 12px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
  user-select: none;
}

#bar .brand {
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.4px;
}

#bar .spacer {
  flex: 1 1 auto;
}

#bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#status.ok {
  color: var(--ok);
}

#status.pending {
  color: var(--accent);
}

#hint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图标一律用内联 SVG，避免字体符号自身的基线/边距导致视觉偏心。 */
.ico {
  display: block;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#bar button .ico {
  width: 16px;
  height: 16px;
}

.ico.dots {
  fill: currentColor;
  stroke: none;
}

#tab-add .ico {
  width: 13px;
  height: 13px;
}

.tab-close,
#tab-menu .menu-close,
.pane-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-close .ico,
#tab-menu .menu-close .ico,
.pane-close .ico {
  width: 11px;
  height: 11px;
}

#find-bar .icon .ico {
  width: 12px;
  height: 12px;
}

/* PC 细指针：顶栏改成窄图标侧栏，省出垂直和水平空间。 */
@media (min-width: 900px) and (pointer: fine) {
  #app {
    flex-direction: row;
  }

  #bar {
    flex: 0 0 44px;
    width: 44px;
    height: auto;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  #bar .spacer,
  #bar #hint {
    display: none;
  }

  #bar .brand {
    font-size: 0;
    margin-bottom: 2px;
  }

  #bar .brand::before {
    content: ">_";
    font-size: 12px;
    letter-spacing: 0;
    color: var(--fg);
  }

  #bar #status {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin: 2px 0 6px;
    border-radius: 50%;
    background: #4a5268;
    font-size: 0;
  }

  #bar #status.ok {
    background: var(--ok);
  }

  #bar #status.pending {
    background: var(--accent);
  }

  #bar button {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 12px;
  }

  #bar button.icon {
    width: 30px;
    min-width: 0;
  }

  #bar #logout {
    margin-top: auto;
  }
}

#tabbar {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  height: 34px;
  padding: 0 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

#tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

#tab-list {
  display: flex;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.tab.collapsed {
  display: none;
}

#tab-more {
  flex: 0 0 auto;
  padding: 4px 8px;
  font-size: 14px;
}

#tab-more.active {
  border-color: var(--accent);
  color: var(--accent);
}

.tab {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 190px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1a1f2b;
  overflow: hidden;
}

.tab.active {
  background: #272f40;
  border-color: #3a4356;
}

.tab-label {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 5px 8px;
  font-size: 12px;
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab.active .tab-label {
  color: var(--fg);
}

.tab-close {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 5px 7px;
  font-size: 11px;
}

.tab-close:hover {
  color: var(--err);
}

.tab.down .tab-label {
  color: var(--err);
}

#tab-add {
  flex: 0 0 auto;
  padding: 4px 9px;
}

#tab-menu {
  position: fixed;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  max-width: min(280px, calc(100vw - 16px));
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 4px;
  background: #171b24;
  border: 1px solid #2a3042;
  border-radius: 8px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
}

#tab-menu[hidden] {
  display: none;
}

#tab-menu .menu-tab {
  display: flex;
  align-items: center;
  gap: 2px;
}

#tab-menu .menu-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 7px 8px;
  border-radius: 5px;
}

#tab-menu .menu-label:hover,
#tab-menu .menu-label.active {
  background: #222a3a;
  color: var(--fg);
}

#tab-menu .menu-close {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 6px 8px;
}

#tab-menu .menu-close:hover {
  color: var(--err);
}

#body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ------------------------------------------------------------- file panel */

#files {
  flex: 0 0 var(--files-width, 300px);
  min-width: 0;
  max-width: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  font-size: 13px;
}

#files[hidden] {
  display: none;
}

#files-resize {
  flex: 0 0 6px;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

#files-resize:hover,
#files-resize.dragging {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.files-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.files-head .spacer {
  flex: 1 1 auto;
}

#crumb {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  white-space: nowrap;
  min-width: 0;
}

#crumb button {
  border: 0;
  background: transparent;
  padding: 2px 3px;
  color: var(--fg);
}

#crumb button:hover {
  background: #232a3b;
}

#crumb .sep {
  color: #4a5268;
}

#crumb button.active {
  color: var(--fg);
}

button.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  font-size: 13px;
  line-height: 1.4;
}

/* 文件工具栏固定成方形，避免不同符号宽度导致图标看着偏心。 */
.files-head button.icon {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

#files-cwd-sync {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 55%, var(--line));
  background: color-mix(in srgb, var(--ok) 18%, #1d2230);
}

#files-cwd-sync:hover {
  background: color-mix(in srgb, var(--ok) 28%, #1d2230);
}

#files-cwd-sync.off,
#files-cwd-sync.off:hover {
  color: var(--dim);
  border-color: var(--line);
  background: #1d2230;
  opacity: 0.55;
}

#file-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  /* 每行等高，虚拟滚动用行高计算总高度和窗口位置。触摸端在媒体查询里改大。 */
  --tree-row-height: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  /* 和终端 .xterm-viewport 保持同一种细滚动条。 */
  scrollbar-width: thin;
  scrollbar-color: #333a48 transparent;
}

#file-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#file-list .tree-node,
#file-list .tree-spacer {
  list-style: none;
}

#file-list .entry .caret {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  line-height: 1;
}

/* 行内图标用 CSS mask 画，而不是每行三个 <svg>：3000 项时每行少 8 个节点，
   整棵树的 HTML 解析从约 160ms 降到约 60ms。 */
#file-list .entry .caret::before,
#file-list .entry .actions .icon::before {
  content: "";
  display: block;
  background-color: currentColor;
  -webkit-mask: var(--file-icon) center / contain no-repeat;
  mask: var(--file-icon) center / contain no-repeat;
}

#file-list [data-act="download"] {
  --file-icon: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='round'%20stroke-linejoin='round'><path%20d='M8%202.5v8'/><path%20d='M4.5%207%208%2010.5%2011.5%207'/><path%20d='M3.5%2013h9'/></svg>");
}

#file-list [data-act="rename"] {
  --file-icon: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='round'%20stroke-linejoin='round'><path%20d='M3%2013l1-3%207-7%202%202-7%207z'/><path%20d='M9.5%203.5l2%202'/></svg>");
}

#file-list [data-act="delete"] {
  --file-icon: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='round'%20stroke-linejoin='round'><path%20d='M4%204l8%208'/><path%20d='M12%204l-8%208'/></svg>");
}

#file-list [data-act="toggle"] {
  --file-icon: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%20fill='none'%20stroke='%23000'%20stroke-width='1.4'%20stroke-linecap='round'%20stroke-linejoin='round'><path%20d='M6%204l4%204-4%204'/></svg>");
}

#file-list .entry .caret::before {
  width: 10px;
  height: 10px;
  transition: transform 120ms;
}

#file-list .entry .caret.open::before {
  transform: rotate(90deg);
}

#file-list .entry .caret:hover {
  color: var(--fg);
  background: transparent;
}

#file-list .entry .caret-spacer {
  flex: 0 0 16px;
  width: 16px;
}

#file-list .entry.selected {
  background-color: #222b3c;
}

#file-list .entry.selected .name {
  color: var(--fg);
}

#file-list .entry {
  display: flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  height: var(--tree-row-height);
  min-width: 0;
  /* 左右内边距由每行的缩进内联覆盖 padding-left。 */
  padding: 2px 4px;
  border-radius: 4px;
  /* 拍平后的树用背景画每一层祖先的竖导引线（原来靠嵌套 ul 的左边框）。 */
  background-image: repeating-linear-gradient(to right, #252b38 0 1px, transparent 1px 17px);
  background-position: 13px 0;
  background-size: max(0px, calc(var(--indent, 13px) - 13px)) 100%;
  background-repeat: no-repeat;
}

#file-list .entry:hover {
  background-color: #1c2231;
}

#file-list .entry .name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 3px 4px;
  color: var(--fg);
}

#file-list .entry.directory .name {
  color: var(--accent);
}

#file-list .entry .size {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #5f6880;
  font-size: 11px;
}

#file-list .entry .actions {
  flex: 0 0 auto;
  display: none;
  gap: 2px;
}

#file-list .entry:hover .actions {
  display: inline-flex;
}

#file-list .entry .actions .icon {
  padding: 1px 5px;
  font-size: 11px;
  color: var(--dim);
}

#file-list .entry .actions .icon::before {
  width: 12px;
  height: 12px;
}

#file-list .empty {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: var(--tree-row-height);
  padding: 0 8px;
  color: var(--dim);
}

#notice {
  margin: 0;
  padding: 6px 10px;
  min-height: 26px;
  font-size: 11px;
  color: var(--dim);
  border-top: 1px solid var(--line);
  word-break: break-word;
}

#notice.error {
  color: var(--err);
}

/* --------------------------------------------------------------- panes */

#workspace {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  background: var(--line);
}

.tab-workspace {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  grid-auto-flow: row;
}

.tab-workspace[hidden] {
  display: none;
}

.pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  border: 1px solid transparent;
}

.pane.active {
  border-color: #2b3342;
}

/* 悬浮标题栏：不占布局高度，悬停/聚焦/出错时浮出。 */
.pane-bar {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 12px);
  height: 22px;
  padding: 0 4px 0 7px;
  background: rgb(20 24 33 / 0.92);
  border: 1px solid #2a3244;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.35);
  font-size: 11px;
  color: var(--dim);
  user-select: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.pane:hover .pane-bar,
.pane:focus-within .pane-bar,
.pane-bar.attention {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

@media (hover: none) {
  .pane.active .pane-bar {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}

.pane-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4a5268;
}

.pane-dot.ok {
  background: var(--ok);
}

.pane-dot.error {
  background: var(--err);
}

.pane-dot.pending {
  background: var(--accent);
}

.pane-status {
  cursor: default;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane-status.error {
  color: var(--err);
  cursor: pointer;
}

.pane-status.ok {
  color: var(--ok);
}

.pane-close {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 0 4px;
  font-size: 11px;
}

.pane-close:hover {
  color: var(--err);
  background: transparent;
}

.pane-term {
  flex: 1 1 auto;
  min-height: 0;
  padding: 6px 8px;
  overflow: hidden;
}

.pane-term .xterm {
  height: 100%;
}

.pane-term .xterm-viewport {
  /* xterm.css 默认把 viewport 底色写死为 #000；行数取整后底部会露出一条黑边。 */
  background-color: transparent !important;
  scrollbar-width: thin;
  scrollbar-color: #333a48 transparent;
}

.pane-term .xterm {
  background-color: var(--bg);
}

/* -------------------------------------------------------------- editor */

#editor-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(8 10 14 / 0.72);
  backdrop-filter: blur(2px);
  z-index: 20;
}

#editor-overlay[hidden] {
  display: none;
}

.editor {
  width: min(1000px, calc(100vw - 40px));
  height: min(760px, calc(100vh - 60px));
  display: flex;
  flex-direction: column;
  background: #171b24;
  border: 1px solid #2a3042;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.5);
  overflow: hidden;
}

.editor header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--dim);
}

.editor header .spacer {
  flex: 1 1 auto;
}

.editor header #editor-save,
.editor header #editor-close {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
}

.editor header #editor-save .ico,
.editor header #editor-close .ico {
  width: 14px;
  height: 14px;
}

#editor-path {
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#editor {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 0;
  outline: none;
  padding: 12px 14px;
  background: #0f1115;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  tab-size: 4;
}

.editor footer {
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--dim);
}

@media (max-width: 820px) {
  #hint {
    display: none;
  }

  .editor header {
    gap: 6px;
    padding: 6px 8px;
  }

  .editor header #editor-save,
  .editor header #editor-close {
    width: 32px;
    height: 32px;
  }

  .editor header #editor-save .ico,
  .editor header #editor-close .ico {
    width: 15px;
    height: 15px;
  }

  #files {
    max-width: none;
    width: min(320px, 88vw);
    position: absolute;
    top: 38px;
    bottom: 0;
    left: 0;
    z-index: 5;
    flex-basis: min(320px, 88vw);
    box-shadow: 12px 0 32px rgb(0 0 0 / 0.45);
  }

  #files-resize {
    display: none;
  }

  #body {
    position: relative;
  }

  .pane-term {
    padding: 2px;
  }
}

/* --------------------------------------------------------------- prompt */

#prompt-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(8 10 14 / 0.72);
  backdrop-filter: blur(2px);
  z-index: 25;
}

#prompt-overlay[hidden] {
  display: none;
}

.prompt-card {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  background: #171b24;
  border: 1px solid #2a3042;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.5);
}

.prompt-card h1 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

#prompt-input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #2f3648;
  border-radius: 7px;
  background: #0f1115;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  outline: none;
}

#prompt-input:focus {
  border-color: var(--accent);
}

#prompt-error {
  min-height: 18px;
  margin: 6px 0 2px;
  color: var(--err);
  font-size: 12px;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.prompt-actions button {
  min-width: 72px;
  padding: 7px 12px;
}

#prompt-ok {
  background: #232a36;
  border-color: #333b4b;
}

#prompt-message {
  margin: 0 0 4px;
  color: var(--fg);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

#prompt-ok.danger {
  border-color: var(--err);
  color: var(--err);
}

/* --------------------------------------------------------------- login */

#login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(8 10 14 / 0.82);
  backdrop-filter: blur(3px);
  z-index: 30;
}

#login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(360px, calc(100vw - 32px));
  padding: 24px;
  background: #171b24;
  border: 1px solid #2a3042;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgb(0 0 0 / 0.5);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 16px;
}

.login-card .sub {
  margin: 0 0 16px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
}

#login-password {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #2f3648;
  border-radius: 7px;
  background: #0f1115;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  outline: none;
}

#login-password:focus {
  border-color: var(--accent);
}

#login-error {
  min-height: 18px;
  margin: 8px 0 4px;
  color: var(--err);
  font-size: 12px;
}

#login-submit {
  width: 100%;
  padding: 9px 14px;
  background: #232a36;
  border-color: #333b4b;
}

.login-card .ttl {
  margin: 10px 0 0;
  color: #5f6880;
  font-size: 11px;
  text-align: center;
}

#files.drop {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* --------------------------------------------------------- find / keys */

#find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 6px 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

#find-bar[hidden] {
  display: none;
}

#find-input {
  width: min(260px, 40vw);
  padding: 4px 8px;
  border: 1px solid #2f3648;
  border-radius: 5px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  outline: none;
}

#find-input:focus {
  border-color: var(--accent);
}

#find-count {
  min-width: 46px;
  color: var(--dim);
  font-size: 11px;
}

#keys {
  display: none;
  flex: 0 0 auto;
  gap: 4px;
  padding: 5px 6px;
  overflow-x: auto;
  background: var(--bar);
  border-top: 1px solid var(--line);
}

#keys button {
  flex: 0 0 auto;
  min-width: 36px;
  padding: 7px 9px;
  font-size: 12px;
}

#keys button.active {
  border-color: var(--accent);
  color: var(--accent);
}

@media (pointer: coarse) {
  #keys {
    display: flex;
  }
}

@media (max-width: 820px) {
  #keys {
    display: flex;
  }
}

/* 底部按键条已经有 ^C；窄屏/触摸设备不再显示顶栏里重复的那个。
   注意用 #bar #send-interrupt 压过前面的 #bar button { display:inline-flex }。 */
@media (max-width: 820px), (pointer: coarse) {
  #bar #send-interrupt {
    display: none;
  }
}

/* 键盘快捷键提示对触屏设备（包括带精确指针的混合本）没有意义，只会挤占顶栏。 */
@media (any-pointer: coarse) {
  #bar #hint {
    display: none;
  }
}

/* ------------------------------------------------------ upload progress */

#upload-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 11px;
}

#upload-progress[hidden] {
  display: none;
}

#upload-progress .bar {
  flex: 1 1 auto;
  height: 4px;
  background: #252b38;
  border-radius: 2px;
  overflow: hidden;
}

#uprog-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 120ms linear;
}

#uprog-text {
  white-space: nowrap;
}

#upload-progress .icon {
  padding: 1px 5px;
}

/* ------------------------------------------------------------ splitters */

.splitter {
  position: absolute;
  z-index: 4;
  background: transparent;
  /* 触摸拖动分栏时不要让浏览器把它当成滚动/缩放。 */
  touch-action: none;
}

.splitter:hover,
.splitter.dragging {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
}

.splitter.v {
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  transform: translateX(-50%);
}

.splitter.h {
  left: 0;
  right: 0;
  height: 8px;
  cursor: row-resize;
  transform: translateY(-50%);
}

/* --------------------------------------------------------- editor gutter */

.editor-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--bg);
}

#editor-gutter {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 8px 12px 12px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg);
  color: #5f6880;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  text-align: right;
  user-select: none;
}

#editor {
  padding: 12px 14px;
}

#file-list .entry.drop-target {
  background-color: #222c3f;
  outline: 1px dashed var(--accent);
  outline-offset: -1px;
}

/* --------------------------------------------------------- touch / mobile */

/* 顶栏按钮多，窄屏隐藏品牌并收紧间距，避免横向溢出。 */
@media (max-width: 620px) {
  #bar {
    gap: 4px;
    padding: 0 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  #bar::-webkit-scrollbar {
    display: none;
  }

  #bar .brand {
    display: none;
  }

  #bar button {
    padding: 4px 7px;
    font-size: 11px;
  }
}

/* 触摸设备没有 hover：文件操作必须常显，点击区域也要够大。 */
@media (hover: none), (pointer: coarse) {
  /* 悬浮标题栏在手机上会盖住终端首行；改成固定在 pane 顶部。 */
  .pane-bar {
    position: static;
    order: -1;
    max-width: none;
    height: 26px;
    padding: 0 6px;
    background: var(--panel);
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .pane-status {
    flex: 1 1 auto;
    min-width: 0;
  }

  .pane-close {
    min-width: 30px;
    min-height: 24px;
  }

  /* 触摸端没有 hover 提示，给分栏加一个可见的抓取点并放大热区。 */
  .splitter.v {
    width: 16px;
  }

  .splitter.h {
    height: 16px;
  }

  .splitter.v::after,
  .splitter.h::after {
    content: "";
    position: absolute;
    background: #4a5268;
    border-radius: 2px;
    pointer-events: none;
  }

  .splitter.v::after {
    left: 50%;
    top: 50%;
    width: 3px;
    height: 36px;
    transform: translate(-50%, -50%);
  }

  .splitter.h::after {
    left: 50%;
    top: 50%;
    width: 36px;
    height: 3px;
    transform: translate(-50%, -50%);
  }

  #prompt-input,
  #login-password {
    /* iOS 在字体小于 16px 时会自动放大页面。 */
    font-size: 16px;
  }

  #tabbar {
    height: 38px;
    padding: 0 6px;
  }

  .tab-label,
  .tab-close,
  #tab-more,
  #tab-add,
  #tab-menu .menu-label,
  #tab-menu .menu-close {
    min-height: 32px;
  }

  #bar {
    height: 44px;
  }

  #files {
    top: 44px;
  }

  #bar button {
    min-height: 34px;
    padding: 5px 9px;
  }

  #bar button.icon {
    min-width: 34px;
  }

  #files-resize {
    flex-basis: 12px;
  }

  #file-list {
    --tree-row-height: 30px;
  }

  #file-list .entry {
    padding: 5px 4px;
  }

  #file-list .entry .name {
    padding: 5px 4px;
  }

  #file-list .entry .caret {
    width: 22px;
    height: 26px;
    font-size: 13px;
  }

  #file-list .entry .caret-spacer {
    flex-basis: 22px;
    width: 22px;
  }

  #file-list .entry .actions {
    display: inline-flex;
  }

  #file-list .entry .actions .icon {
    min-width: 30px;
    min-height: 30px;
    padding: 2px 6px;
    font-size: 13px;
  }

  .files-head {
    padding: 6px;
  }

  .files-head button {
    min-width: 32px;
    min-height: 32px;
    padding: 4px 6px;
  }

  #keys {
    padding-bottom: calc(5px + env(safe-area-inset-bottom, 0px));
  }

  #keys button {
    min-height: 40px;
    padding: 8px 10px;
  }
}
