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

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-BoldItalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: block;
}

@font-face {
  font-family: 'Symbols Nerd Font Mono';
  src: url('/fonts/SymbolsNerdFontMono-Regular.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: block;
  unicode-range: U+23FB-23FE, U+2665, U+26A1, U+2B58, U+E000-E00A, U+E0A0-E0A3, U+E0B0-E0D7,
    U+E200-E2A9, U+E300-E3E3, U+E5FA-E6B7, U+E700-E8EF, U+EA60-EC1E, U+ED00-EFCE, U+F000-F381,
    U+F400-F533, U+F500-FD46, U+F0001-F1AF0;
}

@font-face {
  font-family: 'Symbols Nerd Font Mono';
  src: url('/fonts/SymbolsNerdFontMono-Regular.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: block;
  unicode-range: U+23FB-23FE, U+2665, U+26A1, U+2B58, U+E000-E00A, U+E0A0-E0A3, U+E0B0-E0D7,
    U+E200-E2A9, U+E300-E3E3, U+E5FA-E6B7, U+E700-E8EF, U+EA60-EC1E, U+ED00-EFCE, U+F000-F381,
    U+F400-F533, U+F500-FD46, U+F0001-F1AF0;
}

:root {
  --app-height: 100dvh;
  --bg-main: #1a1b26;
  --bg-panel: #16161e;
  --bg-elevated: #24283b;
  --border: #2f3549;
  --text-main: #c0caf5;
  --text-muted: #7aa2f7;
  --text-dim: #565f89;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --danger: #f7768e;
  --success: #9ece6a;
  --warning: #e0af68;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: var(--app-height, 100dvh);
  background: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

body.is-mobile .desktop-only {
  display: none !important;
}

body.is-mobile .mobile-only {
  display: inline-flex !important;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: inline-flex !important;
  }
}

/* Login Screen */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, var(--bg-elevated) 0%, var(--bg-panel) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.prompt-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: rgba(122, 162, 247, 0.15);
  color: var(--accent);
  font-family: monospace;
  font-size: 22px;
  font-weight: 700;
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
}

.login-logo p {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

#login-form label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text-main);
}

#login-password {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 16px;
  margin-bottom: 14px;
  outline: none;
}

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

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

.btn-primary {
  width: 100%;
  padding: 11px 16px;
  background: var(--accent);
  color: #15161e;
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary.small {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
}

.login-footer {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* Workspace Layout */
.workspace {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--app-height, 100dvh);
  padding-top: env(safe-area-inset-top, 0px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  gap: 8px;
  height: 42px;
  flex-shrink: 0;
}

.tabs-section {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  transition: background 0.2s, box-shadow 0.2s;
}

.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
  animation: pulse-dot 1.4s infinite;
}

.tabs-list {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-list::-webkit-scrollbar {
  display: none;
}

#btn-new-tab,
#btn-tabs-menu {
  flex-shrink: 0;
}

.icon-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg-elevated);
}

.tabs-dropdown {
  position: fixed;
  top: 44px;
  left: 8px;
  width: min(290px, calc(100vw - 16px));
  max-height: min(360px, calc(100dvh - 60px));
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 1050;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tabs-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid transparent;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tabs-dropdown-item:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.tabs-dropdown-item.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--accent);
  font-weight: 600;
}

.tabs-dropdown-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  max-width: 180px;
  flex-shrink: 0;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.15s;
}

.tab-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-item.active {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--accent);
  font-weight: 600;
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.tab-dot.idle {
  background: var(--success);
}

.tab-dot.busy {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.tab-dot.unread {
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
}

.tab-dot.exited {
  background: var(--danger);
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tab-dot.busy,
  .status-dot.disconnected {
    animation: none;
  }
}

.tab-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
}

.tab-close:hover {
  color: var(--danger);
  background: rgba(247, 118, 142, 0.15);
}

.metrics-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.metric-pill {
  font-size: 11px;
  padding: 3px 7px;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: monospace;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.tool-btn, .icon-btn, .theme-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  outline: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.desktop-settings-btn {
  display: none;
}

.tool-btn:hover, .icon-btn:hover, .theme-select:hover {
  background: var(--border);
  border-color: var(--accent);
}

.tool-btn.active {
  background: var(--accent);
  color: #15161e;
  border-color: var(--accent-hover);
  font-weight: 700;
}

.tool-btn.danger {
  color: var(--danger);
}

.tool-btn.danger:hover {
  background: rgba(247, 118, 142, 0.15);
}

/* Split Pane Container */
.main-area {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.split-container {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg-main);
}

.split-container.mode-vertical {
  flex-direction: row;
}

.split-container.mode-horizontal {
  flex-direction: column;
}

.split-slot {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  transition: border-color 0.15s;
  border: 1px solid transparent;
}

.split-container.mode-single > .slot-0,
.split-container.mode-single .slot-0 {
  flex: 1 1 100%;
  width: 100%;
  height: 100%;
}

.split-slot.active-pane {
  border-color: rgba(122, 162, 247, 0.4);
}

.split-divider {
  background: var(--border);
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.mode-vertical .split-divider {
  width: 6px;
  height: 100%;
  cursor: col-resize;
}

.mode-horizontal .split-divider {
  height: 6px;
  width: 100%;
  cursor: row-resize;
}

.divider-handle {
  background: var(--text-dim);
  border-radius: 3px;
}

.mode-vertical .divider-handle {
  width: 2px;
  height: 24px;
}

.mode-horizontal .divider-handle {
  height: 2px;
  width: 24px;
}

.split-divider:hover .divider-handle,
.split-container.is-resizing .divider-handle {
  background: var(--accent);
}

.terminal-pane-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-pane-wrapper.pc-width-mode {
  overflow-x: auto;
}

.terminal-pane-wrapper.pc-width-mode .xterm-pane-container {
  min-width: 820px;
}

.xterm-pane-container {
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 4px;
  overflow: hidden;
}

/* Seamless theme-matched IME composition underline inside xterm.js */
.xterm .composition-view {
  background: var(--bg-elevated, #24283b);
  color: var(--text-main, #c0caf5);
  border-bottom: 2px solid var(--accent, #7aa2f7);
  font-family: 'JetBrains Mono', 'Symbols Nerd Font Mono', monospace;
  padding: 0;
  z-index: 6;
  pointer-events: none;
}

/* Floating Search Bar */
.search-bar {
  position: absolute;
  top: 8px;
  right: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.search-bar input {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 13px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

/* Command Palette */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 1050;
}

.palette-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.palette-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.palette-search-icon {
  font-size: 16px;
  color: var(--accent);
}

.palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 16px;
}

.palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.palette-item:hover, .palette-item.selected {
  background: var(--bg-elevated);
}

.palette-item.selected {
  outline: 1px solid var(--accent);
}

.palette-icon {
  font-size: 16px;
  width: 22px;
  text-align: center;
}

.palette-text {
  flex: 1;
  min-width: 0;
}

.palette-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-detail {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-category {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.palette-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* File Drawer */
.file-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
  font-size: 14px;
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drawer-path-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border);
}

.drawer-path-bar input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  outline: none;
}

.drawer-filter-bar {
  padding: 4px 10px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.drawer-filter-bar input {
  width: 100%;
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
  outline: none;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
}

.file-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.file-entry:hover {
  background: var(--bg-elevated);
}

.entry-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.entry-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-size {
  font-size: 11px;
  color: var(--text-dim);
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.7;
}

.file-entry:hover .entry-actions {
  opacity: 1;
}

.entry-btn {
  background: none;
  border: none;
  color: var(--text-main);
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.entry-btn:hover {
  background: var(--border);
}

.entry-btn.danger:hover {
  color: var(--danger);
  background: rgba(247, 118, 142, 0.15);
}

/* Rich Editor / Viewer Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 12px;
}

.modal-card {
  width: 100%;
  height: 100%;
  max-width: 1100px;
  max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.editor-filepath {
  font-size: 13px;
  font-weight: 600;
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.editor-body-wrapper {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background: var(--bg-main);
}

.editor-gutter {
  width: 48px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  font-family: monospace;
  font-size: 13px;
  line-height: 20px;
  padding: 8px 6px;
  text-align: right;
  user-select: none;
  overflow: hidden;
}

.editor-text-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-overlay {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 8px 12px;
  font-family: monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: var(--text-main);
}

#editor-textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 8px 12px;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text-main);
  border: none;
  outline: none;
  font-family: monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  overflow: auto;
  resize: none;
}

/* Syntax Highlight Tokens */
.tok-comment { color: var(--text-dim); font-style: italic; }
.tok-string { color: var(--success); }
.tok-number { color: var(--warning); }
.tok-keyword { color: var(--accent); font-weight: 600; }

/* Markdown & Media Preview */
.editor-preview {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--bg-main);
}

.markdown-body {
  max-width: 860px;
  margin: 0 auto;
  line-height: 1.6;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 24px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.markdown-body code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.markdown-body pre {
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 14px 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 12px;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.media-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
}

.media-preview-container.pdf-container {
  height: 100%;
  width: 100%;
}

.pdf-iframe {
  width: 100%;
  flex: 1;
  border: none;
  border-radius: 6px;
  background: #fff;
}

.media-img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

.media-video {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

/* Mobile Shortcut & Sentinel Bar */
.mobile-sentinel {
  position: fixed;
  bottom: 46px;
  left: 8px;
  width: 24px;
  height: 24px;
  opacity: 0.01;
  color: transparent;
  background: transparent;
  caret-color: transparent;
  font-size: 16px;
  line-height: 20px;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  resize: none;
  pointer-events: none;
  z-index: 20;
}

.mobile-cmd-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#mobile-cmd-input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-family: "JetBrains Mono", "Symbols Nerd Font Mono", monospace;
  font-size: 16px;
  outline: none;
}

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

.btn-send-cmd {
  padding: 7px 12px;
  background: var(--accent);
  color: #15161e;
  font-weight: 700;
  font-size: 13px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.shortcut-bar {
  display: flex;
  align-items: center;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) 6px;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  min-height: calc(38px + env(safe-area-inset-bottom, 0px));
  height: auto;
}

.shortcut-bar::-webkit-scrollbar {
  display: none;
}

.key-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  transition: all 0.1s;
}

.key-btn:active, .key-btn.active {
  background: var(--accent);
  color: #15161e;
  font-weight: 700;
}

.key-btn.danger-key {
  color: var(--danger);
}

/* Mobile Bottom Sheet */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
}

.mobile-sheet {
  width: 100%;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
}

.sheet-metrics {
  display: flex;
  gap: 6px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sheet-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.sheet-btn:hover {
  background: var(--border);
}

.sheet-btn.danger-full {
  background: rgba(247, 118, 142, 0.15);
  color: var(--danger);
  border-color: rgba(247, 118, 142, 0.3);
  text-align: center;
}

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Enterprise Accessible Dialogs & Non-Blocking Toast Notifications */
.toast-container {
  position: fixed;
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  right: 14px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 28px);
}

.toast-item {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-item.toast-success {
  border-left-color: var(--success);
}

.toast-item.toast-error {
  border-left-color: var(--danger);
}

.toast-item.toast-leaving {
  opacity: 0;
  transform: translateY(6px);
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 15, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1150;
  padding: 16px;
}

.dialog-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dialog-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.dialog-message {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.dialog-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 16px;
  outline: none;
}

.dialog-input:focus {
  border-color: var(--accent);
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.dialog-btn-danger {
  background: var(--danger) !important;
  color: #15161e !important;
}

body:not(.is-mobile) .sheet-overlay {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

body:not(.is-mobile) .mobile-sheet {
  max-width: 420px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

/* Desktop Progressive 1-Row Topbar Compaction */
@media (max-width: 1360px) {
  .metrics-bar {
    display: none !important;
  }

  .toolbar-actions .btn-label {
    display: none;
  }
}

@media (max-width: 1120px) {
  .toolbar-actions {
    gap: 4px;
  }

  .toolbar-actions .tool-btn {
    padding: 5px 7px;
  }

  .toolbar-actions #theme-select,
  .toolbar-actions #btn-font-dec,
  .toolbar-actions #btn-font-inc,
  .toolbar-actions #btn-logout {
    display: none;
  }

  body:not(.is-mobile) .desktop-settings-btn {
    display: inline-flex;
  }
}

@media (max-width: 960px) {
  .brand-badge .brand-name {
    display: none;
  }
}

/* Mobile Responsive Refinements */
@media (max-width: 768px) {
  .drawer-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .entry-actions {
    opacity: 1;
    gap: 4px;
  }

  .entry-btn {
    padding: 5px 7px;
  }

  .modal-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-end;
  }
}
