/* === CSS Variables === */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --accent-red: #ff6b6b;
  --accent-yellow: #feca57;
  --text-primary: #ffffff;
  --text-secondary: #ccc;
  --text-muted: #bbb;
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.15);
  --nav-height: 56px;
  --header-height: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  background-color: #0a0a14;
}

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
  background-color: #0a0a14;
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* === Login Screen === */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 300;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
}

.login-screen.hidden { display: none; }

.login-card {
  text-align: center;
  width: 100%;
  max-width: 320px;
}

.login-logo {
  height: 60px;
  width: auto;
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  background: linear-gradient(45deg, var(--accent-red), var(--accent-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-screen input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: 'SF Mono', 'Menlo', monospace;
  margin-bottom: 12px;
  outline: none;
  text-align: center;
  letter-spacing: 2px;
}

.login-screen input:focus {
  border-color: var(--accent-red);
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}

.login-error {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #ff4757;
}

/* === Header === */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  padding-top: calc(var(--safe-top) + 8px);
  height: calc(var(--header-height) + var(--safe-top));
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  position: relative;
}

.header-logo { height: 28px; width: auto; }

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(45deg, var(--accent-red), var(--accent-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* === Main Content === */
main {
  flex: 1;
  overflow: hidden;
  transition: margin-right 0.25s ease;
}

.view { display: none; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view.active { display: flex; flex-direction: column; }
.view-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; flex-shrink: 0; }
.view-header h2 { font-size: 1.3rem; font-weight: 700; }

/* === Terminal View === */
#view-terminal { overflow: hidden; }
.tmux-tabs { display: flex; gap: 2px; padding: 4px 8px; background: rgba(0, 0, 0, 0.3); overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.tmux-tabs::-webkit-scrollbar { display: none; }
.tmux-tab { padding: 6px 14px; min-height: 36px; border-radius: 6px; font-size: 0.8rem; font-weight: 500; white-space: nowrap; background: var(--glass-bg); border: 1px solid transparent; color: var(--text-muted); cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.tmux-tab.active { background: rgba(255, 107, 107, 0.2); border-color: rgba(255, 107, 107, 0.3); color: var(--accent-red); }
.tmux-tab:active { transform: scale(0.95); }
.tmux-tab-add { background: rgba(46, 213, 115, 0.2); color: #2ed573; border-color: rgba(46, 213, 115, 0.3); font-size: 1rem; font-weight: 700; padding: 6px 12px; }
/* Tab context menu */
.tab-context-menu { position: fixed; z-index: 9999; background: var(--glass-bg, rgba(30, 30, 50, 0.95)); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 8px; padding: 4px; min-width: 160px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
.tab-menu-item { display: block; width: 100%; padding: 10px 14px; border: none; background: none; color: var(--text-primary, #e0e0e0); font-size: 0.85rem; font-weight: 500; text-align: left; cursor: pointer; border-radius: 6px; transition: background 0.1s; }
.tab-menu-item:hover { background: rgba(255, 255, 255, 0.1); }
.tab-menu-item:disabled { opacity: 0.35; cursor: not-allowed; }
.tab-menu-item:disabled:hover { background: none; }
.tab-menu-item.tab-menu-danger { color: var(--accent-red, #ff6b6b); }
.tab-menu-item.tab-menu-danger:hover:not(:disabled) { background: rgba(255, 107, 107, 0.15); }
#terminal-container { flex: 1; padding: 2px; overflow: hidden; position: relative; transition: border-color 0.15s; border: 2px solid transparent; border-radius: 4px; }
#terminal-container.drop-active { border-color: var(--accent-yellow, #feca57); background: rgba(254, 202, 87, 0.05); }
#terminal-container .xterm { height: 100%; }
/* === Special Keys Toolbar === */
.special-keys { display: flex; gap: 4px; padding: 4px 8px; background: rgba(0, 0, 0, 0.5); overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.special-keys::-webkit-scrollbar { display: none; }
.skey { padding: 6px 12px; min-width: 40px; min-height: 32px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; font-family: 'SF Mono', 'Menlo', monospace; white-space: nowrap; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.15); color: var(--text-secondary); cursor: pointer; flex-shrink: 0; transition: all 0.1s; -webkit-user-select: none; user-select: none; }
.skey:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.2); }
.skey-toggle.active { background: rgba(255, 107, 107, 0.3); border-color: rgba(255, 107, 107, 0.5); color: var(--accent-red); }

.terminal-status { display: flex; align-items: center; gap: 8px; padding: 2px 12px; background: rgba(0, 0, 0, 0.4); font-size: 0.7rem; color: var(--text-muted); flex-shrink: 0; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4757; }
.status-dot.connected { background: #2ed573; }

/* === Cards === */
.card-list { display: flex; flex-direction: column; gap: 10px; padding: 0 16px 16px; overflow-y: auto; }
.card { background: var(--glass-bg); backdrop-filter: blur(10px); border-radius: 12px; padding: 16px; border: 1px solid var(--glass-border); transition: all 0.2s; }
.card:active { transform: scale(0.98); background: var(--glass-hover); }
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); }

/* === Session Cards === */
.session-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; }
.session-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.session-name { font-size: 1.05rem; font-weight: 700; word-break: break-all; line-height: 1.3; }
.session-badges { display: flex; flex-wrap: wrap; gap: 5px; flex-shrink: 0; }
.badge { font-size: 0.65rem; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.badge.attached { background: rgba(46, 213, 115, 0.15); color: #2ed573; }
.badge.protected { background: rgba(255, 202, 87, 0.15); color: var(--accent-yellow); }
.session-actions { display: flex; gap: 8px; }
.session-btn { flex: 1; padding: 8px 0; border-radius: 8px; font-size: 0.8rem; font-weight: 600; font-family: inherit; cursor: pointer; text-align: center; border: none; min-height: 36px; }
.session-btn-connect { background: rgba(46, 213, 115, 0.15); color: #2ed573; }
.session-btn-connect:active { background: rgba(46, 213, 115, 0.3); }
.session-btn-restart { background: rgba(255, 202, 87, 0.15); color: var(--accent-yellow); }
.session-btn-restart:active { background: rgba(255, 202, 87, 0.3); }
.session-btn-kill { background: rgba(255, 71, 87, 0.15); color: #ff4757; }
.session-btn-kill:active { background: rgba(255, 71, 87, 0.3); }

/* === Actions Grid === */
.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.action-btn { background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--glass-border); border-radius: 12px; padding: 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; transition: all 0.2s; color: var(--text-primary); font-family: inherit; }
.action-btn:active { transform: scale(0.95); background: var(--glass-hover); }
.action-icon { font-size: 1.8rem; }
.action-label { font-size: 0.8rem; font-weight: 500; }

/* === Action Output === */
.action-output { margin: 0 16px 16px; background: rgba(0, 0, 0, 0.6); border-radius: 12px; border: 1px solid var(--glass-border); overflow: hidden; }
.action-output.hidden { display: none; }
.action-output-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: rgba(0, 0, 0, 0.3); font-size: 0.8rem; font-weight: 600; }
.action-output pre { padding: 12px 14px; font-size: 0.75rem; font-family: 'SF Mono', 'Menlo', monospace; color: var(--text-secondary); white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow-y: auto; -webkit-user-select: text; user-select: text; }

/* === System Dashboard === */
.stat-card { display: flex; flex-direction: column; gap: 8px; }
.stat-header { display: flex; justify-content: space-between; align-items: baseline; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }
.stat-value { font-size: 1.2rem; font-weight: 700; }
.stat-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent-red), var(--accent-yellow)); transition: width 0.5s ease; }
.stat-detail { font-size: 0.75rem; color: var(--text-muted); }

/* === Buttons === */
.btn-accent { background: linear-gradient(135deg, var(--accent-red), var(--accent-yellow)); border: none; color: #fff; font-weight: 600; padding: 8px 16px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; font-family: inherit; }
.btn-accent:active { opacity: 0.8; }
.btn-icon { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; padding: 10px; min-height: 44px; min-width: 44px; }

/* === Bottom Navigation === */
.bottom-nav { display: flex; justify-content: space-around; align-items: center; height: calc(var(--nav-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #0a0a14; border-top: 1px solid var(--glass-border); position: relative; z-index: 100; flex-shrink: 0; }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; color: var(--text-muted); font-size: 0.6rem; cursor: pointer; padding: 6px 8px; min-height: 44px; min-width: 40px; transition: color 0.15s; font-family: inherit; }
.nav-btn.active { color: var(--accent-red); }
.nav-btn svg { width: 22px; height: 22px; }

/* === Modal === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: var(--bg-secondary); border-radius: 16px; padding: 24px; width: 100%; max-width: 340px; border: 1px solid var(--glass-border); }
.modal h3 { font-size: 1.1rem; margin-bottom: 16px; }
.modal input { width: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-primary); font-size: 1rem; font-family: inherit; margin-bottom: 16px; outline: none; }
.modal input:focus { border-color: var(--accent-red); }
.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; }
.btn-cancel { background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-secondary); padding: 8px 16px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; font-family: inherit; }

/* === Utilities === */
.hidden { display: none !important; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* === Terminal touch handling === */
#terminal-container .xterm {
  -webkit-user-select: text;
  user-select: text;
}
#terminal-container .xterm-screen {
  touch-action: none;
}

/* === App container === */
#app-container { display: flex; flex-direction: column; height: 100%; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary)); }
#app-container.hidden { display: none !important; }

/* === Files View === */
.files-header-actions { display: flex; gap: 8px; }

.files-locations {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.files-locations::-webkit-scrollbar { display: none; }
.files-locations:empty { display: none; }
.loc-chip {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 16px;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.loc-chip:active { opacity: 0.7; }
.files-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  overflow: hidden;
}

.bc-up {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 8px;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.bc-up:active { background: var(--glass-hover); }

.bc-segments {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.bc-segments::-webkit-scrollbar { display: none; }

.bc-segment {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 8px;
  min-height: 36px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
  border-radius: 6px;
}
.bc-segment:last-child { color: var(--text-primary); font-weight: 600; }
.bc-segment:active { background: var(--glass-bg); }

.bc-sep { color: var(--text-muted); opacity: 0.4; font-size: 0.8rem; flex-shrink: 0; }

.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
}

.file-icon { font-size: 1.5rem; flex-shrink: 0; width: 32px; text-align: center; }

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

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.file-chevron { color: var(--text-muted); flex-shrink: 0; opacity: 0.5; }

.file-download-icon { color: var(--accent-red); flex-shrink: 0; opacity: 0.6; }

.files-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
}
.files-empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.files-empty-text { font-size: 0.9rem; color: var(--text-muted); }

.files-loading, .files-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.files-error { color: #ff4757; }

.files-upload-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  margin: 0 16px 16px;
  border-radius: 10px;
}
.files-upload-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.files-upload-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-red), var(--accent-yellow));
  transition: width 0.2s ease;
}
.files-upload-progress span { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

.file-preview-icon { color: var(--text-muted); flex-shrink: 0; opacity: 0.5; }

/* === File Preview Modal === */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  flex-direction: column;
}
.preview-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  gap: 12px;
  background: rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}
.preview-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  font-family: inherit;
}
.preview-filename {
  flex: 1;
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preview-download-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.preview-download-btn:active { background: var(--glass-hover); }
.preview-content-area {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}
.preview-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.preview-video {
  max-width: 100%;
  max-height: 100%;
}
.preview-pdf {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}
.preview-code {
  width: 100%;
  padding: 16px;
  margin: 0;
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', 'Courier New', monospace;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
  align-self: flex-start;
}
.preview-audio-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px;
}
.preview-audio-icon { font-size: 4rem; }
.preview-audio-name { color: var(--text-secondary); font-size: 0.9rem; text-align: center; }
.preview-audio-wrap audio { width: 280px; max-width: 90vw; }
.preview-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 40px;
}

/* === Clipboard View === */
.clipboard-search {
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.clipboard-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.clipboard-search input:focus { border-color: var(--accent-red); }
.clipboard-search input::placeholder { color: var(--text-muted); }

.clipboard-entry { cursor: pointer; position: relative; transition: all 0.2s; }
.clipboard-entry-content {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-secondary);
  line-height: 1.4;
  -webkit-user-select: text;
  user-select: text;
  margin-bottom: 8px;
}
.clipboard-entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.clipboard-label {
  background: rgba(255, 107, 107, 0.15);
  color: var(--accent-red);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
}
.clipboard-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 32px;
  min-width: 32px;
  opacity: 0.5;
  line-height: 1;
}
.clipboard-delete:active { opacity: 1; color: #ff4757; }

.clipboard-entry.copied {
  border-color: rgba(46, 213, 115, 0.5);
  background: rgba(46, 213, 115, 0.1);
}

.clipboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
}
.clipboard-empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.clipboard-empty-text { font-size: 0.9rem; color: var(--text-muted); }

/* === Clipboard Paste Picker === */
.skey-clip { padding: 8px 10px; display: flex; align-items: center; justify-content: center; }
.skey-clip svg { display: block; }

.clip-pick-modal { max-height: 70vh; display: flex; flex-direction: column; }
.clip-pick-list { overflow-y: auto; max-height: 50vh; display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.clip-pick-item {
  padding: 10px 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.8rem;
}
.clip-pick-item:active { transform: scale(0.98); background: var(--glass-hover); }
.clip-pick-content {
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

/* === Build Notes === */
.build-note-card { padding: 14px; cursor: pointer; transition: border-color 0.15s; }
.build-note-card:active { transform: scale(0.995); }
.build-note-expanded { border-color: rgba(255, 107, 107, 0.3); cursor: default; }
.build-note-expanded:active { transform: none; }
.build-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.build-note-author {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.build-note-handle {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 6px;
}
.build-note-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
  text-transform: capitalize;
  white-space: nowrap;
  flex-shrink: 0;
}
.build-note-status-open { background: rgba(112, 161, 255, 0.15); color: #70a1ff; }
.build-note-status-in-progress { background: rgba(254, 202, 87, 0.15); color: #feca57; }
.build-note-status-done { background: rgba(46, 213, 115, 0.15); color: #2ed573; }
.build-note-status-wont-fix { background: rgba(180, 180, 180, 0.15); color: #999; }
.build-note-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 10px;
}
.build-note-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.build-note-status-select {
  margin-left: auto;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
.build-note-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 32px;
  min-width: 32px;
  opacity: 0.5;
  line-height: 1;
}
.build-note-delete:active { opacity: 1; color: #ff4757; }
.build-notes-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
}
.build-notes-empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.build-notes-empty-text { font-size: 0.9rem; color: var(--text-muted); }

.build-note-reply-count {
  font-size: 0.75rem;
  color: var(--accent-red);
  opacity: 0.8;
  cursor: pointer;
}
.build-note-thread {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}
.build-note-reply {
  padding: 8px 0 8px 12px;
  border-left: 2px solid var(--glass-border);
  margin-bottom: 8px;
  margin-left: 4px;
}
.build-note-reply-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.build-note-reply-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.build-note-reply-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.build-note-reply-content {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.build-note-reply-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.build-note-reply-input {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 8px 12px;
  outline: none;
  resize: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.4;
}
.build-note-reply-input:focus { border-color: var(--accent-red); }
.build-note-reply-input::placeholder { color: var(--text-muted); }
.build-note-reply-send {
  background: var(--accent-red);
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.build-note-reply-send:active { opacity: 0.8; }

.build-note-private {
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(162, 155, 254, 0.15);
  color: #a29bfe;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.build-note-is-private { border-color: rgba(162, 155, 254, 0.2); }
.build-note-private-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  cursor: pointer;
}
.build-note-private-toggle input[type="checkbox"] {
  accent-color: var(--accent-red);
  width: 16px;
  height: 16px;
}

/* === Login Form Toggle === */
.login-form.hidden { display: none; }
.login-toggle {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.login-toggle:active { color: var(--accent-red); }

/* === Header User Name === */
.header-user-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 10px;
  border-radius: 6px;
  margin-left: 8px;
}

/* === Session Viewers (terminal status bar) === */
.session-viewers {
  font-size: 0.7rem;
  color: var(--accent-yellow);
  margin-left: auto;
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

/* === Users Management Modal === */
.users-modal {
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.users-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.users-modal-header h3 { margin: 0; }
.users-list {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 12px;
}
.user-card-info { margin-bottom: 8px; }
.user-card-name { font-size: 0.95rem; font-weight: 600; }
.user-card-username { font-size: 0.8rem; color: var(--text-muted); }
.user-card-login { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }
.user-card-sessions { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.session-chip {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(112, 161, 255, 0.15);
  color: #70a1ff;
  font-weight: 500;
}
.user-card-actions { display: flex; gap: 6px; }

/* === Session Checkboxes (add/edit user) === */
.session-checkboxes {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}
.session-check-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}
.session-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.session-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-red);
}

/* === DM Badge === */
.dm-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  background: var(--accent-red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
#btn-messages { position: relative; }

/* === DM Panel (slides from right) === */
.dm-sidebar {
  position: fixed;
  top: calc(var(--header-height) + var(--safe-top));
  right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  width: 380px;
  z-index: 150;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.dm-sidebar.open { transform: translateX(0); }

.dm-sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 149;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.dm-sidebar-panel { display: flex; flex-direction: column; height: 100%; }
.dm-sidebar-panel.hidden { display: none; }

.dm-sidebar-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--glass-border);
}
.dm-sidebar-header h2 { font-size: 1.1rem; font-weight: 700; flex: 1; }

.dm-thread-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--glass-border);
}
.dm-thread-header h2 { font-size: 1.1rem; font-weight: 700; }

@media (max-width: 768px) {
  .dm-sidebar { width: 100%; }
  .dm-sidebar-scrim.open { opacity: 1; pointer-events: auto; }
}

/* === DM Conversation List === */
.dm-convo-list {
  overflow-y: auto;
  flex: 1;
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dm-convo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.dm-convo-item:active { background: var(--glass-hover); }
.dm-convo-info { flex: 1; min-width: 0; }
.dm-convo-name {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dm-convo-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.dm-convo-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 12px;
}
.dm-unread-pip {
  background: var(--accent-red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.dm-header-actions { display: flex; align-items: center; gap: 4px; }

/* === DM Search === */
.dm-search {
  padding: 0 16px 12px;
  flex-shrink: 0;
}
.dm-search.hidden { display: none; }
.dm-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.dm-search input:focus { border-color: var(--accent-red); }
.dm-search input::placeholder { color: var(--text-muted); }
.dm-search-from { color: var(--text-secondary); font-weight: 500; }

/* === DM User Picker === */
.dm-user-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.dm-pick-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.dm-pick-user:active { background: var(--glass-hover); }
.dm-pick-name { font-size: 0.9rem; font-weight: 600; }
.dm-pick-handle { font-size: 0.8rem; color: var(--text-muted); }

.dm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* === DM Thread === */
.dm-thread {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-break: break-word;
}
.dm-msg-self {
  align-self: flex-end;
  background: rgba(255, 107, 107, 0.2);
  border: 1px solid rgba(255, 107, 107, 0.25);
  border-bottom-right-radius: 4px;
}
.dm-msg-other {
  align-self: flex-start;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
}
.dm-msg-content { white-space: pre-wrap; }
.dm-msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
  opacity: 0.7;
}
.dm-msg-self .dm-msg-time { text-align: right; }

/* CLI message indicator */
.dm-msg-cli { border-left: 2px solid var(--accent-red); }

/* Auto-linked URLs */
.dm-link { color: var(--accent-red); text-decoration: underline; word-break: break-all; }

/* Code blocks */
.dm-code-block {
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}
.dm-code-lang {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border-bottom: 1px solid var(--glass-border);
}
.dm-code-block pre {
  margin: 0;
  padding: 10px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.dm-code-block code { font-family: 'SF Mono', 'Menlo', monospace; color: var(--text-primary); }

/* File attachment card */
.dm-file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s;
}
.dm-file-card:active { background: rgba(255,255,255,0.12); }
.dm-file-icon { font-size: 20px; }
.dm-file-name { flex: 1; font-weight: 500; word-break: break-word; }
.dm-file-size { font-size: 12px; color: var(--text-muted); }

/* Inline image preview in DM */
.dm-img-wrap { cursor: pointer; border-radius: 8px; overflow: hidden; }
.dm-img-preview {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  object-fit: contain;
}
.dm-img-name {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline video preview in DM */
.dm-video-wrap { border-radius: 8px; overflow: hidden; }
.dm-video-preview {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
}

/* Inline audio preview in DM */
.dm-audio-wrap { display: flex; flex-direction: column; gap: 6px; }
.dm-audio-label { font-size: 13px; font-weight: 500; }
.dm-audio-wrap audio { width: 100%; max-width: 280px; }

/* PDF file card in DM — click to preview */
.dm-doc-wrap {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  transition: background 0.15s;
}
.dm-doc-wrap:hover { background: rgba(255,255,255,0.1); }

/* DM drop zone */
.dm-sidebar-thread.dm-drop-active {
  outline: 2px dashed var(--accent-yellow);
  outline-offset: -2px;
  background: rgba(254, 202, 87, 0.05);
}


/* === DM Compose Bar (Instagram-style) === */
.dm-compose {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  flex-shrink: 0;
  background: #000;
  border: none;
}
.dm-compose textarea {
  flex: 1;
  padding: 10px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  margin: 0;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
}
.dm-compose textarea:focus { border-color: rgba(255, 255, 255, 0.25); }
.dm-compose textarea::placeholder { color: rgba(255, 255, 255, 0.35); }
.dm-send {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--accent-red);
  padding: 0;
}
.dm-send:active { opacity: 0.6; }
.dm-mic {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-muted);
  padding: 0;
  position: relative;
  transition: color 0.2s;
}
.dm-mic:active { opacity: 0.6; }
.dm-mic.recording {
  color: var(--accent-red);
  animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.dm-mic.transcribing { color: var(--accent-yellow); }
.dm-mic.mic-error { color: var(--accent-red); animation: mic-shake 0.3s ease-in-out; }
@keyframes mic-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.dm-mic-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: var(--accent-yellow);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dm-thread { background: linear-gradient(180deg, var(--bg-secondary) 0%, #0a0a14 100%); }

/* === Avatar === */
.avatar { line-height: 0; }
.avatar img { border-radius: 50%; }

/* === Presence Dots === */
.dm-convo-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: 12px;
}
.presence-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
}
.presence-online { background: #2ed573; }
.presence-offline { background: #636e72; }

/* === Date Separator === */
.dm-date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0 6px;
}
.dm-date-separator::before,
.dm-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}
.dm-date-separator span {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* === Typing Indicator === */
.dm-typing-indicator {
  padding: 10px 14px !important;
  max-width: 70px !important;
}
.dm-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.dm-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.4s infinite ease-in-out;
}
.dm-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dm-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* === Profile Dropdown === */
.header-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background 0.15s;
  position: relative;
}
.header-profile:hover { background: rgba(255,255,255,0.06); }

.profile-dropdown {
  position: absolute;
  top: calc(var(--header-height) + var(--safe-top) - 4px);
  left: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  z-index: 200;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.profile-dropdown.hidden { display: none; }
.profile-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.profile-dropdown-info {
  flex: 1;
  min-width: 0;
}
#profile-dropdown-name {
  font-size: 0.95rem;
  font-weight: 600;
}
#profile-dropdown-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.profile-avatar-upload-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  background: rgba(255,107,107,0.15);
  color: var(--accent-red);
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s;
}
.profile-avatar-upload-btn:hover { background: rgba(255,107,107,0.25); }
.profile-remove-btn {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: center;
  background: none;
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.profile-remove-btn:hover { border-color: rgba(255,255,255,0.2); color: var(--text-secondary); }

/* === Build Note Author Wrap === */
.build-note-author-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.build-note-reply-author-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* === DM Convo Item with avatar === */
.dm-convo-item {
  gap: 0;
}
.dm-pick-user {
  gap: 10px;
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Copy path button on file cards */
.file-copy-path {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  flex-shrink: 0;
}
.file-copy-path:hover {
  opacity: 1;
  background: rgba(255,255,255,0.1);
}
.file-card:hover .file-copy-path { opacity: 0.7; }

/* Toast notification for copy */
.copy-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-green);
  color: #111;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  animation: toastFade 1.5s ease forwards;
}
@keyframes toastFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
