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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* Forms */
input[type="text"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  color: var(--text);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  width: auto;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.header h1 { font-size: 1.25rem; }

.auth-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.auth-badge.passkey {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--success);
}

.auth-badge.bypass {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #eab308;
}

/* Session List */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.session-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
  overflow: hidden;
}

.session-item-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
}

.session-item:hover {
  border-color: var(--accent);
}

.session-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-status.alive { background: var(--success); }
.session-status.dead { background: var(--danger); }

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

.session-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.session-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Session preview */
.session-preview {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 6.5px;
  line-height: 1.15;
  background: var(--bg);
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  height: 120px;
  overflow: hidden;
  white-space: pre;
  border-top: 1px solid var(--border);
}

.session-preview:empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 0.75rem;
}

.session-preview:empty::after {
  content: 'not running';
}

/* New session bar */
.new-session {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.new-session input {
  flex: 1;
  margin-bottom: 0;
}

.new-session .btn {
  width: auto;
  white-space: nowrap;
}

/* Terminal page */
.terminal-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #000;
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-bar-title {
  font-size: 0.85rem;
  font-weight: 500;
}

.terminal-bar-cwd {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Menlo', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-bar-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

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

/* Session Switcher Sidebar */
.session-switcher {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.switcher-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.switcher-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.switcher-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}

.switcher-item:hover {
  border-color: var(--accent);
}

.switcher-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.switcher-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}

.switcher-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher-item-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.switcher-preview {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
  font-size: 5.5px;
  line-height: 1.1;
  background: var(--bg);
  color: var(--text-muted);
  padding: 0.3rem 0.5rem;
  height: 80px;
  overflow: hidden;
  white-space: pre;
  border-top: 1px solid var(--border);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

/* Error / Info messages */
.message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.message.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.message.warning {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #eab308;
}

/* Responsive */
@media (max-width: 600px) {
  .container { padding: 1rem; }
  .session-item-header { flex-wrap: wrap; }
  .session-actions { width: 100%; justify-content: flex-end; }
  .session-switcher {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
    box-shadow: -4px 0 16px rgba(0,0,0,0.5);
  }
}
