/**
 * dickybird.dev - Terminal Dashboard Styles
 * Clean, minimal dark theme
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --border: #333;
  --text: #e0e0e0;
  --accent: #4ade80;
  --danger: #ef4444;
  --warning: #fbbf24;
}

/* Custom Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
  background: #444;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', Monaco, monospace;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 44px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Header Menu Dropdown */
.header-menu {
  position: relative;
}

.header-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
  padding: 6px 0;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.dropdown-item:hover {
  background: #252525;
}

.dropdown-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Buttons */
.btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: #252525;
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn:hover {
  background: #333;
}
.btn-danger {
  color: var(--danger);
}

/* Title */
.title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

#session-title {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 8px;
  margin: -4px -8px;
  cursor: pointer;
  min-width: 80px;
  flex: 1;
}
#session-title:hover {
  background: #252525;
  border-color: var(--border);
}
#session-title:focus {
  outline: none;
  background: #252525;
  border-color: var(--accent);
  cursor: text;
}

/* Status Indicator */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.status-dot.connected {
  background: var(--accent);
}

/* Main Content Row - flex container for sidebars and terminal */
.main-content-row {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Terminal */
.terminal-container {
  flex: 1;
  padding: 4px;
  overflow: hidden;
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#terminal {
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  transition: box-shadow 0.15s ease;
}
#terminal.raw-mode {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.terminal-stream {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  background: #0a0a0a;
  overflow: auto;
  padding: 0;
  white-space: pre;
  word-wrap: break-word;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.0;
  color: #e0e0e0;
}
.terminal-stream:focus {
  outline: none;
}
.terminal-stream.hidden {
  display: none;
}
/* When stream is visible, hide the xterm terminal */
.terminal-container:has(.terminal-stream:not(.hidden)) #terminal {
  display: none;
}
#tib-stream.active {
  color: var(--accent);
}

/* Terminal Input Bar */
.terminal-input-bar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  max-height: 90%;
}

.terminal-input-bar.hidden {
  display: none;
}

.terminal-input-bar-resize {
  height: 4px;
  cursor: ns-resize;
  background: transparent;
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  z-index: 1;
  transition: background 0.15s;
}

.terminal-input-bar-resize:hover,
.terminal-input-bar-resize.active {
  background: var(--accent);
  opacity: 0.5;
}

.terminal-input-bar-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 1px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-input-bar-toolbar .toolbar-btn {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.terminal-input-bar-toolbar .btn {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

/* SVG icon buttons */
.btn svg, .toolbar-btn svg, .button svg, .fs-toolbar-btn svg, .dropdown-icon svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  position: relative;
  overflow: hidden;
}
.icon-btn:hover {
  background: transparent;
}

/* Clockwise border-trace animation */
.icon-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(from 0deg, var(--accent) 0%, var(--accent) var(--border-progress, 0%), transparent var(--border-progress, 0%));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.icon-btn:hover::before {
  opacity: 1;
  animation: border-trace 0.25s ease-out forwards;
}
@keyframes border-trace {
  0%   { --border-progress: 0%; }
  100% { --border-progress: 100%; }
}
@property --border-progress {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

.terminal-input-bar-toolbar .button {
  width: auto;
  margin: 0;
  padding: 4px 12px;
  font-size: 12px;
}

.terminal-input-bar-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.terminal-input-bar-status.dirty {
  background: var(--warning);
}

.tib-passthrough-hint {
  font-size: 10px;
  color: var(--warning);
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  pointer-events: none;
}
.tib-passthrough-hint.visible {
  opacity: 1;
}

.terminal-input-editor {
  flex: 0 1 auto;
  overflow-y: auto;
  min-height: 0;
}

.terminal-input-editor .ProseMirror {
  padding: 2px 10px;
  font-size: 13px;
  line-height: 1.4;
  min-height: 1.25rem;
}

.terminal-input-editor .ProseMirror > * + * {
  margin-top: 0.2em;
}

.terminal-input-editor .ProseMirror p {
  margin: 0;
}

.terminal-input-editor .ProseMirror p.is-editor-empty:first-child::before {
  color: #555;
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

/* Virtual Keyboard */
/* TIB key buttons (virtual keyboard) */
.tib-keys {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}
.tib-arrows {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 1px;
}
.tib-arrows .tib-key {
  padding: 0 3px;
  height: auto;
}
.tib-arrows .tib-key[data-key="up"],
.tib-arrows .tib-key[data-key="down"] {
  height: 12px;
  min-height: 0;
  line-height: 1;
  font-size: 9px !important;
}
.tib-key {
  font-size: 10px !important;
  padding: 0 5px;
  min-width: 0;
  width: auto !important;
  white-space: nowrap;
}

/* Modal/Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 320px;
  max-height: 90vh;
  border: 1px solid var(--border);
  overflow-y: auto;
  box-sizing: border-box;
}
.modal h2 {
  margin-bottom: 16px;
  font-size: 18px;
}
.modal h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

/* Form Elements */
.input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #252525;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  margin-top: 8px;
}
.input:focus {
  outline: 1px solid var(--accent);
}

.button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 12px;
}
.button-primary {
  background: var(--accent);
  color: #0a0a0a;
}
#tib-send:hover {
  background: #22c55e;
  color: #0a0a0a;
}
.button-danger {
  background: var(--danger);
  color: #fff;
}
.button-secondary {
  background: #333;
  color: var(--text);
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Messages */
.error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 13px;
}
.success {
  color: var(--accent);
  margin-top: 12px;
  font-size: 13px;
}

/* Status Box */
.status-box {
  padding: 12px;
  background: #252525;
  border-radius: 8px;
  margin-bottom: 16px;
}
.status-label {
  font-size: 13px;
  color: #888;
}
.status-value {
  font-size: 14px;
  margin-top: 4px;
}

/* Utilities */
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Loading */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Command Palette */
.cmd-section {
  margin-bottom: 16px;
}
.section-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #252525;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.cmd-item:hover {
  background: #333;
  border-color: var(--border);
}
.cmd-item.danger:hover {
  border-color: var(--danger);
}
.cmd-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
}
.cmd-info {
  flex: 1;
  min-width: 0;
}
.cmd-label {
  font-size: 13px;
  font-weight: 500;
}
.cmd-meta {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #333;
  color: #888;
}
.cmd-badge.terminal {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}
.cmd-badge.exec {
  background: rgba(251, 191, 36, 0.15);
  color: var(--warning);
}
.cmd-badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}
.cmd-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 4px;
  transition:
    opacity 0.15s,
    color 0.15s;
}
.cmd-item:hover .cmd-delete {
  opacity: 1;
}
.cmd-delete:hover {
  color: var(--danger);
}

/* Sessions */
.session-btn {
  font-size: 12px;
  font-weight: 600;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #252525;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.session-item:hover {
  background: #333;
}
.session-item.active {
  border-color: var(--accent);
}
.session-item .session-info {
  flex: 1;
  min-width: 0;
}
.session-item .session-name {
  font-size: 13px;
  font-weight: 500;
}
.session-item .session-meta {
  font-size: 11px;
  color: #666;
}
.session-item .session-kill {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.session-item .session-kill:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

/* File Drop Zone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.05);
}
.dropzone-icon {
  font-size: 24px;
  margin-bottom: 8px;
}
.dropzone-text {
  color: #666;
  font-size: 13px;
}

/* File List */
.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
  background: #252525;
  border-radius: 4px;
  margin-top: 4px;
}
.file-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size {
  font-size: 11px;
  color: #666;
}
.file-remove {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 4px;
}
.file-remove:hover {
  color: var(--danger);
}

/* Google Drive Browser */
.gdrive-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #888;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
  min-height: 32px;
}
.gdrive-breadcrumb {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.gdrive-breadcrumb:hover {
  background: #252525;
}
.gdrive-breadcrumb-sep {
  color: #444;
}

.gdrive-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #252525;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: 4px;
}
.gdrive-file-item:hover {
  background: #333;
}
.gdrive-file-item.selected {
  border-color: var(--accent);
}
.gdrive-file-item.folder:hover {
  border-color: var(--warning);
}
.gdrive-file-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.gdrive-file-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
}
.gdrive-file-info {
  flex: 1;
  min-width: 0;
}
.gdrive-file-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gdrive-file-meta {
  font-size: 11px;
  color: #666;
}
.gdrive-file-size {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

.gdrive-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
#gdrive-selection-info {
  font-size: 12px;
  color: #888;
}

.gdrive-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.gdrive-empty {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 13px;
}

.gdrive-error {
  text-align: center;
  padding: 20px;
  color: var(--danger);
  font-size: 13px;
}

/* Filesystem Browser */
.fs-browser-layout {
  display: flex;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.fs-sidebar {
  width: 140px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding-right: 12px;
}

.fs-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.fs-section {
  margin-bottom: 16px;
}

.fs-section-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.fs-quick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fs-quick-item:hover {
  background: #252525;
}

.fs-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.fs-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: #888;
  padding: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex-wrap: wrap;
  min-height: 32px;
}

.fs-breadcrumb {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fs-breadcrumb:hover {
  background: #252525;
}
.fs-breadcrumb.current {
  color: var(--text);
  cursor: default;
}
.fs-breadcrumb.current:hover {
  background: transparent;
}

.fs-breadcrumb-sep {
  color: #444;
}

.fs-content {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

.fs-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: 4px;
}
.fs-file-item:hover {
  background: #333;
}
.fs-file-item.folder:hover {
  border-color: var(--warning);
}
.fs-file-item.file {
  opacity: 0.6;
  cursor: default;
}
.fs-file-item.file:hover {
  background: #252525;
}

.fs-file-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.fs-file-info {
  flex: 1;
  min-width: 0;
}

.fs-file-name {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fs-file-meta {
  font-size: 11px;
  color: #666;
}

.fs-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  gap: 12px;
}

.fs-path-display {
  flex: 1;
  font-size: 11px;
  color: #888;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #666;
}

.fs-empty {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 13px;
}

.fs-error {
  text-align: center;
  padding: 20px;
  color: var(--danger);
  font-size: 13px;
}

/* Filesystem Toolbar */
.fs-toolbar {
  display: flex;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.fs-toolbar-btn {
  font-size: 12px;
  padding: 0 8px;
}
.fs-toolbar-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Filesystem file item interactions */
.fs-file-item.selected {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--accent);
}
.fs-file-item.selected:hover {
  background: rgba(74, 222, 128, 0.25);
}

.fs-file-item.cut {
  opacity: 0.4;
}
.fs-file-item.cut.selected {
  opacity: 0.6;
}

.fs-file-item.file {
  opacity: 1;
  cursor: pointer;
}
.fs-file-item.file:hover {
  background: #333;
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
  min-width: 150px;
  z-index: 20000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.context-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.context-item:hover {
  background: var(--accent);
  color: var(--bg);
}
.context-item.danger:hover {
  background: var(--danger);
}
.context-item.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Command Preview */
.fs-command-preview {
  display: block;
  background: #1a1a1a;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent);
  font-family: monospace;
  word-break: break-all;
  overflow-wrap: anywhere;
  max-width: 100%;
  overflow-x: hidden;
}

/* Toast Notification */
.fs-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 6px;
  z-index: 2001;
  max-width: 90%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.fs-toast code {
  display: block;
  color: var(--accent);
  font-family: monospace;
  font-size: 11px;
  margin-bottom: 4px;
  word-break: break-all;
}

.fs-toast span {
  font-size: 13px;
}

.fs-toast.error {
  border-color: var(--danger);
}
.fs-toast.error code {
  color: var(--danger);
}

.fs-toast.success {
  border-color: var(--accent);
}

/* Danger button */
.button-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.button-danger:hover {
  background: #dc2626;
}

/* Drag and drop */
.fs-content.drag-over {
  background: rgba(74, 222, 128, 0.1);
  border: 2px dashed var(--accent);
  border-radius: 6px;
}

/* Upload progress overlay */
.fs-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  border-radius: 6px;
}

.fs-upload-text {
  color: var(--text);
  font-size: 14px;
}

/* Two-Factor Authentication Styles */
.qrcode-container {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #1a1a1a;
  border-radius: 8px;
  margin: 16px 0;
}

.qrcode-container canvas,
.qrcode-container img {
  border-radius: 4px;
}

.secret-display {
  display: flex;
  align-items: center;
  background: #252525;
  padding: 12px;
  border-radius: 8px;
  margin-top: 8px;
}

.secret-display code {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--accent);
}

.warning-box {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--warning);
}

.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.backup-code {
  display: block;
  background: #252525;
  padding: 10px;
  border-radius: 6px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  text-align: center;
  color: var(--accent);
  letter-spacing: 1px;
}

.backup-codes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.backup-code-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #252525;
  padding: 10px 12px;
  border-radius: 6px;
}

.backup-code-item.used {
  opacity: 0.5;
}

.backup-code-item code {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
  color: var(--text);
}

.backup-code-item .used-label {
  font-size: 11px;
  color: var(--danger);
}

.backup-code-item .available-label {
  font-size: 11px;
  color: var(--accent);
}

/* TOTP input styling */
.totp-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 4px;
  font-family: 'SF Mono', Monaco, monospace;
}

/* Spinner for loading states */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Trusted Devices */
.trusted-devices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
}

.trusted-device-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #252525;
  padding: 12px;
  border-radius: 6px;
  gap: 12px;
}

.device-info {
  flex: 1;
  min-width: 0;
}

.device-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.device-meta {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.button-small {
  padding: 6px 12px;
  font-size: 11px;
  flex-shrink: 0;
}

/* Checkbox styling */
.checkbox-label input[type='checkbox'] {
  accent-color: var(--accent);
}

/* ============================================
   Audit Panel
   ============================================ */

.audit-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.audit-filter-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: #252525;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #888;
  cursor: pointer;
  transition: all 0.15s ease;
}

.audit-filter-btn:hover {
  background: #333;
  color: var(--text);
}

.audit-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.audit-status {
  margin-left: auto;
  font-size: 12px;
  color: #666;
}

.audit-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-event {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  border-left: 3px solid #666;
}

.audit-event.success {
  border-left-color: var(--accent);
}

.audit-event.failure {
  border-left-color: var(--danger);
}

.audit-event-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audit-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.audit-action {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 12px;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-status-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 500;
  flex-shrink: 0;
}

.audit-status-badge.success {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}

.audit-status-badge.failure {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.audit-time {
  font-size: 11px;
  color: #666;
  flex-shrink: 0;
}

.audit-details {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
  font-family: 'SF Mono', Monaco, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-empty {
  text-align: center;
  color: #666;
  padding: 32px;
  font-size: 13px;
}

.audit-error {
  text-align: center;
  color: var(--danger);
  padding: 32px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.audit-error .error-icon {
  font-size: 24px;
}
.audit-error .retry-btn {
  margin-top: 8px;
}

/* ============================================
   COMMAND MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #888;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  line-height: 1;
}

.modal-close:hover {
  background: #252525;
  color: var(--text);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-description {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
  line-height: 1.5;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 6px;
}

.form-group .input,
.form-group textarea,
.form-group select {
  width: 100%;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.checkbox-label input[type='checkbox'] {
  width: auto;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-processing {
  text-align: center;
  padding: 32px;
}

.modal-processing .spinner {
  margin: 0 auto 16px;
}

.modal-success {
  text-align: center;
  padding: 24px;
}

.modal-success .modal-description {
  margin-bottom: 0;
}

.success-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(74, 222, 128, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--accent);
}

.error-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: rgba(239, 68, 68, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--danger);
}

/* Result Details Styling */
.result-details {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Compact execution summary */
.result-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-family: 'SF Mono', 'Consolas', monospace;
  padding: 6px 8px;
  background: #1a1a1a;
  border-radius: 4px;
  margin-bottom: 10px;
}

.summary-duration {
  color: #888;
}

.summary-exit-ok {
  color: var(--accent);
}

.summary-exit-err {
  color: var(--danger);
}

.summary-status-ok {
  color: var(--accent);
  font-weight: bold;
}

.summary-status-err {
  color: var(--danger);
  font-weight: bold;
}

.result-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  color: var(--danger);
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.result-output {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  color: #ccc;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 8px 0 0 0;
}

/* Git Result Styling */
.git-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-repo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.repo-label {
  color: #666;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.repo-path {
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--text);
  word-break: break-all;
}

.git-state {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
}

.git-branch {
  color: var(--accent);
  font-weight: 500;
}

.git-commit {
  color: #f0a000;
  font-family: 'SF Mono', 'Consolas', monospace;
}

.git-dirty {
  color: var(--warning);
}

.git-clean {
  color: var(--accent);
}

.git-files {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
}

.git-file {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 11px;
  color: #ccc;
  padding: 2px 0;
}

.git-file-more {
  font-size: 11px;
  color: #888;
  font-style: italic;
  padding: 4px 0 0 0;
}

/* Service Result Styling */
.service-result {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.service-status {
  font-size: 12px;
  color: var(--accent);
}

.modal-error-content {
  padding: 8px 0;
}

/* ============================================
   SYSTEM OPERATIONS MENU
   ============================================ */

.system-ops-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.menu-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.menu-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.menu-item {
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 6px;
}

.menu-item:last-child {
  margin-bottom: 0;
}

.menu-item:hover {
  background: #252525;
  border-color: var(--accent);
}

.menu-item:active {
  transform: scale(0.98);
}

/* ============================================
   AUDIT PANEL ENHANCEMENTS
   ============================================ */

.audit-search {
  width: 100%;
  margin-bottom: 12px;
}

.filter-group {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: #888;
  font-size: 12px;
  text-transform: capitalize;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  background: #252525;
  border-color: var(--accent);
  color: var(--text);
}

.filter-btn.active {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.audit-category {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
  margin-right: 8px;
}

.audit-expand-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  margin-right: 8px;
}

.audit-expand-btn:hover {
  color: var(--accent);
}

.audit-trace-tree {
  margin-top: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  border-left: 2px solid var(--accent);
}

.audit-trace-child {
  padding: 6px 8px;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.audit-trace-child.success {
  border-left: 2px solid var(--accent);
}

.audit-trace-child.failure {
  border-left: 2px solid var(--danger);
}

.audit-trace-empty {
  color: #666;
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.audit-duration {
  font-size: 11px;
  color: #666;
  margin-left: auto;
}

/* Filesystem Browser Overlay - must appear above command modal */
#fs-overlay {
  z-index: 10001;
}

/* Filesystem dialogs must appear above the file browser overlay */
#fs-rename-dialog,
#fs-delete-dialog,
#fs-mkdir-dialog {
  z-index: 10003;
}

/* ============================================
   EDITOR SIDEBAR
   ============================================ */

.editor-sidebar {
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  transition: width 0.2s ease;
  position: relative;
}

.editor-sidebar.open {
  width: var(--editor-width, 50vw);
}

.editor-sidebar.hidden {
  pointer-events: none;
}

.editor-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  z-index: 1;
}

.editor-resize-handle:hover {
  background: var(--accent);
  opacity: 0.5;
}

.editor-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: var(--editor-width, 50vw);
  min-width: 320px;
  overflow: hidden;
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toolbar */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.editor-toolbar-group {
  display: flex;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 8px;
}

.editor-toolbar-group:last-child {
  border-right: none;
  margin-right: 0;
  padding-right: 0;
}

.toolbar-btn {
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
}

.toolbar-btn:hover {
  background: #252525;
  color: var(--text);
}

.toolbar-btn.active {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
  border-color: var(--accent);
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
}

.editor-title-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.editor-path {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-family: 'SF Mono', Monaco, monospace;
  padding: 4px 8px;
  margin: -4px -8px;
  cursor: pointer;
  min-width: 80px;
  flex: 1;
}
.editor-path:hover {
  background: #252525;
  border-color: var(--border);
}
.editor-path:focus {
  outline: none;
  background: #252525;
  border-color: var(--accent);
  cursor: text;
}
.editor-path:read-only {
  cursor: default;
}
.editor-path:read-only:hover {
  background: transparent;
  border-color: transparent;
}

.editor-dirty-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.editor-body {
  flex: 1;
  overflow: auto;
  padding: 0;
}

.editor-wysiwyg {
  height: 100%;
  padding: 20px 24px;
}

.editor-textarea {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 20px 24px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.editor-status {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: #666;
}

/* ProseMirror (Tiptap) content styles */
.ProseMirror {
  outline: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100%;
}

.ProseMirror > * + * {
  margin-top: 0.75em;
}

.ProseMirror h1 {
  font-size: 1.8em;
  font-weight: 700;
  margin-top: 1.2em;
}

.ProseMirror h2 {
  font-size: 1.4em;
  font-weight: 600;
  margin-top: 1em;
}

.ProseMirror h3 {
  font-size: 1.15em;
  font-weight: 600;
  margin-top: 0.8em;
}

.ProseMirror code {
  background: #252525;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 0.9em;
}

.ProseMirror pre {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  overflow-x: auto;
}

.ProseMirror pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.ProseMirror blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 16px;
  color: #aaa;
  margin-left: 0;
}

.ProseMirror ul,
.ProseMirror ol {
  padding-left: 24px;
}

.ProseMirror li {
  margin-top: 0.25em;
}

.ProseMirror a {
  color: var(--accent);
  text-decoration: underline;
}

.ProseMirror hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5em 0;
}

.ProseMirror mark {
  background: rgba(251, 191, 36, 0.3);
  color: inherit;
  padding: 1px 2px;
  border-radius: 2px;
}

.ProseMirror ul[data-type='taskList'] {
  list-style: none;
  padding-left: 0;
}

.ProseMirror ul[data-type='taskList'] li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ProseMirror ul[data-type='taskList'] li label {
  flex-shrink: 0;
  margin-top: 4px;
}

.ProseMirror ul[data-type='taskList'] li label input[type='checkbox'] {
  accent-color: var(--accent);
  cursor: pointer;
}

.ProseMirror ul[data-type='taskList'] li > div {
  flex: 1;
}

.ProseMirror p.is-editor-empty:first-child::before {
  color: #555;
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
}

/* ============================================
   MDSERVER DOCUMENT BROWSER
   ============================================ */

.mdserver-doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #252525;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: 4px;
}

.mdserver-doc-item:hover {
  background: #333;
  border-color: var(--accent);
}

.mdserver-doc-id {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
}

.mdserver-doc-info {
  flex: 1;
  min-width: 0;
}

.mdserver-doc-preview {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mdserver-doc-meta {
  font-size: 11px;
  color: #666;
}

.mdserver-doc-delete {
  opacity: 0;
  background: transparent;
  border: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  transition: opacity 0.15s, color 0.15s;
}

.mdserver-doc-item:hover .mdserver-doc-delete {
  opacity: 1;
}

.mdserver-doc-delete:hover {
  color: var(--danger);
}

.mdserver-empty {
  text-align: center;
  padding: 40px;
  color: #666;
  font-size: 13px;
}

.mdserver-pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.mdserver-pagination button {
  padding: 4px 12px;
  background: #252525;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.mdserver-pagination button:hover {
  background: #333;
}

.mdserver-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   CAPTURE VIEWER (fullscreen iframe overlay)
   ============================================ */

.capture-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a0a0a;
}

.capture-viewer-close {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 10000;
  width: 36px;
  height: 36px;
  font-size: 18px;
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid #444;
  border-radius: 6px;
  backdrop-filter: blur(4px);
}

.capture-viewer-close:hover {
  background: rgba(60, 60, 60, 0.9);
  border-color: #666;
}

.capture-viewer-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #0a0a0a;
}

/* ============================================
   NOTES PANEL
   ============================================ */

.notes-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px 12px;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.notes-header h3 {
  margin: 0;
  font-size: 13px;
}

.notes-search {
  width: 100%;
  padding: 6px 10px;
  background: #252525;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  margin-bottom: 8px;
  outline: none;
  box-sizing: border-box;
}

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

.notes-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.note-item {
  padding: 5px 8px;
  background: #252525;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.note-item:hover {
  background: #2a2a2a;
  border-color: #444;
}

.note-item.pinned {
  border-left: 3px solid var(--accent);
}

.note-item-header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.note-item-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.note-item-meta {
  font-size: 10px;
  color: #666;
  white-space: nowrap;
  flex-shrink: 0;
}

.note-input-btn {
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
  min-width: 0 !important;
  flex-shrink: 0;
}

.note-pin-btn {
  width: 22px !important;
  height: 22px !important;
  padding: 0 !important;
  min-width: 0 !important;
  flex-shrink: 0;
}

#btn-notes.active {
  background: transparent;
  color: var(--accent);
}
#btn-notes.active::before {
  opacity: 1;
  --border-progress: 100%;
}

/* ============================================
   FILESYSTEM SIDEBAR (LEFT)
   ============================================ */

.fs-sidebar-panel {
  flex-shrink: 0;
  width: 0;
  overflow: hidden;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  transition: width 0.2s ease;
  position: relative;
}

.fs-sidebar-panel.open {
  width: var(--fs-width, 300px);
}

.fs-sidebar-panel.hidden {
  pointer-events: none;
}

.fs-sidebar-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  z-index: 1;
}

.fs-sidebar-resize-handle:hover {
  background: var(--accent);
  opacity: 0.5;
}

.fs-sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: var(--fs-width, 300px);
  min-width: 200px;
  overflow: hidden;
}

.fs-sidebar-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.fs-sidebar-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 6px;
}

.fs-sidebar-quick {
  padding-bottom: 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.fs-sidebar-quick .fs-section {
  margin-bottom: 0;
}

.fs-sidebar-quick-resize {
  height: 4px;
  flex-shrink: 0;
  cursor: row-resize;
  background: transparent;
  position: relative;
  transition: background 0.15s;
}

.fs-sidebar-quick-resize::after {
  content: '';
  position: absolute;
  left: 25%;
  right: 25%;
  top: 1px;
  height: 2px;
  border-radius: 1px;
  background: var(--border);
  opacity: 0;
  transition: opacity 0.15s;
}

.fs-sidebar-quick-resize:hover::after,
.fs-sidebar-quick-resize.active::after {
  opacity: 1;
}

.fs-sidebar-quick-resize:hover,
.fs-sidebar-quick-resize.active {
  background: var(--border);
}

.fs-sidebar-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.fs-sidebar-main .fs-breadcrumbs {
  flex-shrink: 0;
}

.fs-sidebar-main .fs-content {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
}

.fs-sidebar-path {
  padding: 8px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: #888;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Left sidebar button active states */
#btn-hub.active,
#btn-fs-sidebar.active {
  background: transparent;
  color: var(--accent);
}
#btn-hub.active::before,
#btn-fs-sidebar.active::before {
  opacity: 1;
  --border-progress: 100%;
}

/* Hub View (inside left sidebar) */
.hub-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.hub-view.hidden {
  display: none;
}
.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.hub-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hub-header h3 {
  margin: 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hub-sections {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}
.hub-section {
  margin-bottom: 12px;
}
.hub-section-label {
  font-size: 10px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding: 0 2px;
}

/* Hub session items */
.hub-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s;
}
.hub-session-item:hover {
  background: #252525;
}
.hub-session-item.active {
  background: #1a2a1a;
  color: var(--accent);
}
.hub-session-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}
.hub-session-item.active .hub-session-dot {
  background: var(--accent);
}
.hub-session-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-session-kill {
  opacity: 0;
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  flex-shrink: 0;
  transition: opacity 0.1s, color 0.1s;
}
.hub-session-item:hover .hub-session-kill {
  opacity: 1;
}
.hub-session-kill:hover {
  color: var(--danger);
}
.hub-new-session {
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  font-size: 11px;
  background: transparent;
  border: 1px dashed #333;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.hub-new-session:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Hub command items */
.hub-cmd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  transition: background 0.1s;
}
.hub-cmd-item:hover {
  background: #252525;
}
.hub-cmd-icon {
  flex-shrink: 0;
  font-size: 12px;
  width: 18px;
  text-align: center;
}
.hub-cmd-info {
  flex: 1;
  min-width: 0;
}
.hub-cmd-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-cmd-cwd {
  font-size: 9px;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-cmd-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #252525;
  color: #888;
  flex-shrink: 0;
}
.hub-cmd-delete {
  opacity: 0;
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 12px;
  padding: 0 4px;
  flex-shrink: 0;
}
.hub-cmd-item:hover .hub-cmd-delete {
  opacity: 1;
}
.hub-cmd-delete:hover {
  color: var(--danger);
}
.hub-add-cmd {
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  font-size: 11px;
  background: transparent;
  border: 1px dashed #333;
  border-radius: 6px;
  color: #888;
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.hub-add-cmd:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* File browser view (inside left sidebar) */
.fs-browser-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.fs-browser-view.hidden {
  display: none;
}

/* ============================================
   KEY GENERATOR
   ============================================ */

.keygen-field-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-top: 10px;
  margin-bottom: 4px;
}

.keygen-result-block {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.keygen-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #252525;
  border-bottom: 1px solid var(--border);
}

.keygen-result-label {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.keygen-result-pre {
  padding: 10px;
  margin: 0;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--accent);
  background: #1a1a1a;
  max-height: 200px;
  overflow-y: auto;
}

.keygen-copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.keygen-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================
   WINDOW MANAGER
   ============================================ */

.window-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.window-frame {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  min-width: 240px;
  min-height: 160px;
  overflow: hidden;
}

.window-frame.focused {
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--accent);
}

.window-frame.maximized {
  inset: 0 !important;
  width: auto !important;
  height: auto !important;
  border-radius: 0;
}

.window-frame.minimized {
  display: none;
}

.window-titlebar {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 34px;
  padding: 0 8px;
  background: var(--bg);
  cursor: grab;
  user-select: none;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-title {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}

.window-controls {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex-shrink: 0;
}

.window-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}

.window-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

.window-btn-close:hover {
  background: var(--danger);
  color: #fff;
  opacity: 1;
}

.window-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* Resize handles */
.window-resize-handle {
  position: absolute;
}

.window-resize-n {
  top: -3px; left: 12px; right: 12px; height: 6px;
  cursor: n-resize;
}

.window-resize-s {
  bottom: -3px; left: 12px; right: 12px; height: 6px;
  cursor: s-resize;
}

.window-resize-e {
  right: -3px; top: 12px; bottom: 12px; width: 6px;
  cursor: e-resize;
}

.window-resize-w {
  left: -3px; top: 12px; bottom: 12px; width: 6px;
  cursor: w-resize;
}

.window-resize-ne {
  top: -3px; right: -3px; width: 12px; height: 12px;
  cursor: ne-resize;
}

.window-resize-nw {
  top: -3px; left: -3px; width: 12px; height: 12px;
  cursor: nw-resize;
}

.window-resize-se {
  bottom: -3px; right: -3px; width: 12px; height: 12px;
  cursor: se-resize;
}

.window-resize-sw {
  bottom: -3px; left: -3px; width: 12px; height: 12px;
  cursor: sw-resize;
}

/* Snap preview */
.window-snap-preview {
  position: absolute;
  background: rgba(74, 222, 128, 0.1);
  border: 2px solid var(--accent);
  border-radius: 8px;
  pointer-events: none;
  z-index: 89;
  transition: all 0.15s ease;
}

/* Thumbnail bar */
.window-thumbnail-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  gap: 6px;
  pointer-events: auto;
  z-index: 29;
  padding: 4px 8px;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.window-thumbnail-bar:empty,
.window-thumbnail-bar[style*="display: none"] {
  visibility: hidden;
}

.window-thumbnail {
  width: 120px;
  height: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
}

.window-thumbnail:hover {
  border-color: var(--accent);
}

.window-thumbnail-title {
  font-size: 10px;
  color: var(--text);
  padding: 4px 6px;
  background: var(--bg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.window-thumbnail-preview {
  font-size: 8px;
  color: var(--text);
  opacity: 0.4;
  padding: 4px 6px;
  overflow: hidden;
  flex: 1;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .terminal-input-bar {
    height: var(--input-bar-height, 120px);
  }

  .editor-sidebar.open {
    width: 100vw;
  }

  .editor-sidebar-inner {
    width: 100vw;
    min-width: 0;
  }

  /* Windows: full width on mobile, no resize handles */
  .window-frame {
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    border-radius: 0;
  }

  .window-resize-handle {
    display: none;
  }

  .window-thumbnail {
    width: 80px;
    height: 56px;
  }

  .window-thumbnail-title {
    font-size: 9px;
  }
}

/* ── ANSI terminal colour classes (ansi_up with use_classes) ── */
.ansi-black-fg   { color: #0a0a0a; }
.ansi-red-fg     { color: #ef4444; }
.ansi-green-fg   { color: #4ade80; }
.ansi-yellow-fg  { color: #fbbf24; }
.ansi-blue-fg    { color: #3b82f6; }
.ansi-magenta-fg { color: #a855f7; }
.ansi-cyan-fg    { color: #22d3ee; }
.ansi-white-fg   { color: #e0e0e0; }
.ansi-bright-black-fg   { color: #666666; }
.ansi-bright-red-fg     { color: #f87171; }
.ansi-bright-green-fg   { color: #86efac; }
.ansi-bright-yellow-fg  { color: #fcd34d; }
.ansi-bright-blue-fg    { color: #60a5fa; }
.ansi-bright-magenta-fg { color: #c084fc; }
.ansi-bright-cyan-fg    { color: #67e8f9; }
.ansi-bright-white-fg   { color: #ffffff; }
.ansi-black-bg   { background-color: #0a0a0a; }
.ansi-red-bg     { background-color: #ef4444; }
.ansi-green-bg   { background-color: #4ade80; }
.ansi-yellow-bg  { background-color: #fbbf24; }
.ansi-blue-bg    { background-color: #3b82f6; }
.ansi-magenta-bg { background-color: #a855f7; }
.ansi-cyan-bg    { background-color: #22d3ee; }
.ansi-white-bg   { background-color: #e0e0e0; }
.ansi-bold { font-weight: bold; }
.ansi-underline { text-decoration: underline; }
.ansi-italic { font-style: italic; }
.ansi-strikethrough { text-decoration: line-through; }
