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

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
}

body {
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* Login Screen */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #0d1117 0%, #161b22 100%);
}

.login-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.terminal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

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

.input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* Main App */
.main-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.hidden {
  display: none !important;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  height: 48px;
  flex-shrink: 0;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--accent);
}

.tab:hover {
  color: var(--text-primary);
}

.tab-close {
  font-size: 16px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.tab-close:hover {
  opacity: 1;
  color: var(--danger);
}

.new-tab-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.new-tab-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.root-tab-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--warning);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
}

.root-tab-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.tab.root-tab {
  border-color: var(--danger);
}

.tab.root-tab .tab-title::before {
  content: "# ";
  color: var(--danger);
}

.claude-tab-btn {
  width: 28px;
  height: 28px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #bc8cff;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 4px;
}

.claude-tab-btn:hover {
  background: #8b5cf6;
  color: #fff;
  border-color: #8b5cf6;
}

.tab.claude-tab {
  border-color: #8b5cf6;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, var(--bg-tertiary) 100%);
}

.tab.claude-tab.active {
  border-color: #a855f7;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, var(--bg-primary) 100%);
}

.tab.claude-tab .tab-title::before {
  content: "🤖 ";
}

.top-bar-right {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

/* Content Wrapper */
.content-wrapper {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s;
}

.sidebar.collapsed {
  width: 0;
  border: none;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.file-path {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.file-nav-btn {
  width: 24px;
  height: 24px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
}

.file-nav-btn:hover {
  background: var(--accent);
  color: #fff;
}

#current-path {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

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

.file-item:hover {
  background: var(--bg-tertiary);
}

.file-item.directory {
  color: var(--accent);
}

.history-search {
  width: 100%;
  padding: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  margin-bottom: 8px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
}

.history-item {
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Terminal Area */
.terminal-area {
  flex: 1;
  overflow: hidden;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.terminal-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px;
  min-height: 0;
  height: 100%;
}

.terminal-wrapper .xterm {
  flex: 1;
  height: 100% !important;
}

.terminal-wrapper .xterm-viewport {
  height: 100% !important;
}

.terminal-wrapper .xterm-screen {
  height: 100% !important;
}

/* Stats Panel */
.stats-panel {
  width: 240px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 16px;
  overflow-y: auto;
}

.stats-panel h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.stat-item {
  margin-bottom: 16px;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.stat-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.stat-fill.warning {
  background: var(--warning);
}

.stat-fill.danger {
  background: var(--danger);
}

.stat-value {
  font-size: 12px;
  color: var(--text-primary);
}

.stat-info {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-info div {
  margin-bottom: 8px;
}

.stat-info strong {
  color: var(--text-primary);
}

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

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 48px;
    bottom: 0;
    z-index: 100;
  }

  .sidebar.collapsed {
    width: 0;
  }

  .stats-panel {
    position: absolute;
    right: 0;
    top: 48px;
    bottom: 0;
    z-index: 100;
  }
}
