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

body {
  background-color: #0d1117;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  color: #c9d1d9;
}

.header {
  background-color: #161b22;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #30363d;
}

.header h1 {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header h1 .logo {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #58a6ff, #8b5cf6);
  border-radius: 6px;
}

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

.system-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  background-color: #21262d;
  border-radius: 6px;
  font-size: 11px;
  font-family: monospace;
}

.system-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #8b949e;
}

.system-stat .stat-icon {
  color: #6e7681;
  font-size: 10px;
}

.system-stat span:last-child {
  color: #c9d1d9;
}

.session-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: #21262d;
  border-radius: 6px;
  font-size: 12px;
  color: #8b949e;
}

.session-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #3fb950;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8b949e;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f85149;
}

.status-dot.connected {
  background-color: #3fb950;
}

.btn-logout {
  padding: 6px 12px;
  background-color: transparent;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-logout:hover {
  background-color: #21262d;
  color: #c9d1d9;
  border-color: #8b949e;
}

.main-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#terminal-container {
  flex: 1;
  padding: 10px;
  background-color: #0d1117;
  overflow: hidden;
}

#terminal {
  height: 100%;
}

.sidebar {
  position: relative;
  width: 320px;
  background-color: #161b22;
  border-left: 1px solid #30363d;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  border-bottom: 1px solid #30363d;
}

.sidebar-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.sidebar-header:hover {
  background-color: #21262d;
}

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 600;
  color: #c9d1d9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-header .count {
  background-color: #30363d;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  color: #8b949e;
}

.sidebar-content {
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.tunnel-form {
  padding: 12px;
  display: flex;
  gap: 8px;
}

.tunnel-form input {
  flex: 1;
  padding: 8px 12px;
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 13px;
}

.tunnel-form input:focus {
  outline: none;
  border-color: #58a6ff;
}

.tunnel-form input::placeholder {
  color: #6e7681;
}

.btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background-color: #238636;
  color: #fff;
}

.btn-primary:hover {
  background-color: #2ea043;
}

.btn-primary:disabled {
  background-color: #21262d;
  color: #484f58;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.btn-danger {
  background-color: transparent;
  color: #f85149;
}

.btn-danger:hover {
  background-color: rgba(248, 81, 73, 0.1);
}

.btn-ghost {
  background-color: transparent;
  color: #8b949e;
}

.btn-ghost:hover {
  background-color: #21262d;
  color: #c9d1d9;
}

.item-card {
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.item-card.active {
  border-color: #58a6ff;
}

.item-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.item-title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.item-status.active {
  background-color: rgba(46, 160, 67, 0.2);
  color: #3fb950;
}

.item-status.connecting {
  background-color: rgba(187, 128, 9, 0.2);
  color: #d29922;
}

.item-status.error, .item-status.stopped {
  background-color: rgba(110, 118, 129, 0.2);
  color: #8b949e;
}

.item-meta {
  font-size: 11px;
  color: #6e7681;
}

.item-url {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.item-url input {
  flex: 1;
  padding: 5px 8px;
  background-color: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #58a6ff;
  font-size: 11px;
  font-family: monospace;
}

.item-url input:focus {
  outline: none;
}

.btn-copy {
  padding: 5px 8px;
  background-color: #21262d;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.btn-copy:hover {
  background-color: #30363d;
}

.btn-copy.copied {
  background-color: #238636;
  border-color: #238636;
}

.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: #6e7681;
  font-size: 12px;
}

.reconnect-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.reconnect-overlay.show {
  display: flex;
}

.reconnect-box {
  background-color: #161b22;
  padding: 30px 40px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid #30363d;
}

.reconnect-box h2 {
  color: #fff;
  margin-bottom: 12px;
  font-size: 18px;
}

.reconnect-box p {
  color: #8b949e;
  margin-bottom: 20px;
  font-size: 14px;
}

.reconnect-btn {
  background-color: #238636;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.reconnect-btn:hover {
  background-color: #2ea043;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 340px;
  background-color: #161b22;
  border: 1px solid #30363d;
  padding: 12px 16px;
  border-radius: 8px;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 1001;
  animation: slideIn 0.3s ease;
}

.toast.show {
  display: flex;
}

.toast.success {
  border-color: #238636;
}

.toast.error {
  border-color: #f85149;
}

/* View Controls */
.view-controls {
  display: flex;
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 0 12px;
  gap: 4px;
}

.view-btn {
  padding: 8px 16px;
  font-size: 13px;
  color: #8b949e;
  background-color: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-btn:hover {
  color: #c9d1d9;
  background-color: #21262d;
}

.view-btn.active {
  color: #c9d1d9;
  border-bottom-color: #58a6ff;
}

.view-icon {
  font-size: 14px;
  font-family: monospace;
}

/* Panel Resizer */
.panel-resizer {
  width: 4px;
  background-color: #30363d;
  cursor: col-resize;
  flex-shrink: 0;
  display: none;
  transition: background-color 0.15s ease;
}

.panel-resizer:hover,
.panel-resizer.dragging {
  background-color: #58a6ff;
}

body.resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.resizing * {
  cursor: col-resize !important;
}

/* Split View Mode */
.main-container.split-view .panel-resizer {
  display: block;
}

.main-container.split-view #terminal-container,
.main-container.split-view #editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Editor Container */
#editor-container {
  flex: 1;
  display: none;
  flex-direction: column;
  background-color: #0d1117;
  overflow: hidden;
}

#editor-container.active {
  display: flex;
}

#terminal-container.hidden {
  display: none;
}

/* Terminal Tabs */
.terminal-tabs {
  display: flex;
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
  overflow-x: auto;
  min-height: 35px;
  align-items: center;
}

.terminal-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #8b949e;
  background-color: #0d1117;
  border-right: 1px solid #30363d;
  cursor: pointer;
  white-space: nowrap;
}

.terminal-tab:hover {
  background-color: #161b22;
}

.terminal-tab.active {
  color: #c9d1d9;
  background-color: #161b22;
}

.terminal-tab-close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.terminal-tab-close:hover {
  background-color: #30363d;
}

.terminal-tab-new {
  width: 28px;
  height: 28px;
  margin: 0 4px;
  background-color: transparent;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #8b949e;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.terminal-tab-new:hover {
  background-color: #21262d;
  color: #c9d1d9;
}

.terminal-tab .tmux-badge {
  color: #3fb950;
  font-size: 10px;
}

.editor-tabs {
  display: flex;
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
  overflow-x: auto;
  min-height: 35px;
}

.editor-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: #8b949e;
  background-color: #0d1117;
  border-right: 1px solid #30363d;
  cursor: pointer;
  white-space: nowrap;
}

.editor-tab:hover {
  background-color: #161b22;
}

.editor-tab.active {
  color: #c9d1d9;
  background-color: #161b22;
}

.editor-tab.modified::after {
  content: '';
  width: 6px;
  height: 6px;
  background-color: #d29922;
  border-radius: 50%;
}

.editor-tab-close {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.editor-tab-close:hover {
  background-color: #30363d;
}

#monaco-editor {
  flex: 1;
  min-height: 0;
}

.editor-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6e7681;
  font-size: 14px;
}

.editor-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* File Tree */
.file-tree {
  font-size: 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.file-item:hover {
  background-color: #21262d;
}

.file-item.active {
  background-color: rgba(56, 139, 253, 0.15);
}

.file-item-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.file-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item.directory > .file-item-icon {
  color: #58a6ff;
}

.file-item.file > .file-item-icon {
  color: #8b949e;
}

.file-children {
  margin-left: 12px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 11px;
  color: #8b949e;
  border-bottom: 1px solid #30363d;
  overflow-x: auto;
}

.breadcrumb-item {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.breadcrumb-item:hover {
  background-color: #21262d;
  color: #c9d1d9;
}

.breadcrumb-sep {
  color: #484f58;
}

/* File Search */
.file-search {
  padding: 8px 12px;
  border-bottom: 1px solid #30363d;
}

.file-search input {
  width: 100%;
  padding: 6px 10px;
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-size: 12px;
}

.file-search input:focus {
  outline: none;
  border-color: #58a6ff;
}

.file-search input::placeholder {
  color: #6e7681;
}


/* Context Menu */
.context-menu {
  position: fixed;
  background-color: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 150px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.context-menu-item {
  padding: 8px 12px;
  font-size: 12px;
  color: #c9d1d9;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.context-menu-item:hover {
  background-color: #21262d;
}

.context-menu-item.danger {
  color: #f85149;
}

.context-menu-divider {
  height: 1px;
  background-color: #30363d;
  margin: 4px 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background-color: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 20px;
  min-width: 300px;
}

.modal h3 {
  margin-bottom: 16px;
  font-size: 16px;
  color: #c9d1d9;
}

.modal input {
  width: 100%;
  padding: 8px 12px;
  background-color: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  font-size: 14px;
  margin-bottom: 16px;
}

.modal input:focus {
  outline: none;
  border-color: #58a6ff;
}

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

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Mobile Toggle Button */
.mobile-sidebar-toggle {
  display: none;
  width: 44px;
  height: 44px;
  background-color: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.mobile-sidebar-toggle:hover,
.mobile-sidebar-toggle:active {
  background-color: #30363d;
  color: #c9d1d9;
}

/* Mobile Sidebar Close */
.sidebar-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background-color: transparent;
  border: none;
  border-radius: 6px;
  color: #8b949e;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-close:hover {
  background-color: #21262d;
  color: #c9d1d9;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .header {
    padding: 10px 12px;
    min-height: 56px;
  }

  .header h1 {
    font-size: 16px;
    gap: 8px;
  }

  .header h1 .logo {
    width: 24px;
    height: 24px;
  }

  .header-right {
    gap: 10px;
  }

  .system-info {
    display: none;
  }

  .session-indicator {
    display: none !important;
  }

  .status {
    gap: 6px;
  }

  .status span {
    display: none;
  }

  .status-dot {
    width: 10px;
    height: 10px;
  }

  .btn-logout {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
  }

  .mobile-sidebar-toggle {
    display: flex;
  }

  .view-controls {
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 13px;
    justify-content: center;
    min-height: 44px;
  }

  /* Disable split view on mobile */
  .main-container.split-view .panel-resizer {
    display: none;
  }

  .main-container.split-view #editor-container {
    display: none;
  }

  .main-container.split-view #terminal-container {
    flex: 1;
  }

  .main-container {
    flex-direction: column;
    position: relative;
    flex: 1;
    overflow: hidden;
  }

  #terminal-container {
    padding: 4px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #terminal-container #terminal {
    flex: 1;
    min-height: 0;
  }

  #editor-container {
    flex: 1;
    overflow: hidden;
  }

  .terminal-tabs {
    min-height: 40px;
    flex-shrink: 0;
  }

  .terminal-tab {
    padding: 10px 14px;
    font-size: 12px;
    min-height: 40px;
  }

  .terminal-tab-new {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .terminal-tab-close {
    width: 20px;
    height: 20px;
    font-size: 16px;
  }

  .editor-tabs {
    min-height: 40px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
  }

  .editor-tab {
    padding: 10px 14px;
    font-size: 12px;
    min-height: 40px;
  }

  .editor-tab-close {
    width: 20px;
    height: 20px;
    font-size: 16px;
  }

  /* Sidebar as overlay on mobile */
  .sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    height: 100dvh;
    border-left: 1px solid #30363d;
    transition: right 0.25s ease-out;
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 50px;
  }

  .sidebar.open {
    right: 0;
  }

  .sidebar-close {
    display: flex;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.25s ease-out;
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .sidebar-header {
    padding: 14px 16px;
    min-height: 48px;
  }

  .sidebar-content {
    max-height: none;
    padding: 8px 12px;
  }

  #files-content {
    max-height: 40vh !important;
  }

  .tunnel-form {
    padding: 12px;
    flex-direction: column;
    gap: 10px;
  }

  .tunnel-form input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }

  .tunnel-form .btn {
    width: 100%;
    padding: 12px;
    min-height: 44px;
  }

  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .reconnect-box {
    margin: 20px;
    padding: 24px;
    width: calc(100% - 40px);
  }

  .reconnect-btn {
    padding: 14px 24px;
    min-height: 48px;
    width: 100%;
  }

  .breadcrumb {
    padding: 10px 12px;
    font-size: 12px;
  }

  .breadcrumb-item {
    padding: 4px 8px;
  }

  .file-search {
    padding: 10px 12px;
  }

  .file-search input {
    padding: 10px 12px;
    font-size: 16px;
  }

  .file-item {
    padding: 10px 12px;
    min-height: 44px;
  }

  .item-card {
    padding: 12px;
  }

  .item-url {
    flex-direction: column;
    gap: 8px;
  }

  .item-url input {
    width: 100%;
    padding: 10px;
    font-size: 13px;
  }

  .btn-copy {
    width: 100%;
    text-align: center;
    padding: 10px;
    min-height: 40px;
  }

  .context-menu {
    min-width: 160px;
  }

  .context-menu-item {
    padding: 12px 16px;
    min-height: 44px;
  }

  .modal {
    width: calc(100% - 32px);
    margin: 16px;
  }

  .modal input {
    padding: 12px;
    font-size: 16px;
  }

  .modal-actions .btn {
    padding: 10px 16px;
    min-height: 40px;
  }
}

/* Small mobile */
@media (max-width: 480px) {
  .header h1 span {
    display: none;
  }

  .header h1 .logo {
    width: 28px;
    height: 28px;
  }

  .btn-logout {
    padding: 6px 10px;
    font-size: 11px;
  }

  .view-icon {
    display: none;
  }

  .view-btn {
    font-size: 12px;
  }

  .sidebar {
    width: 100%;
    max-width: none;
  }
}
