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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  height: 100vh;
  overflow: hidden;
}

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

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #010409;
  border-bottom: 1px solid #21262d;
  height: 44px;
}

#brand {
  font-size: 16px;
  font-weight: 700;
  color: #f0f6fc;
  white-space: nowrap;
  letter-spacing: -0.5px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#brand .accent {
  color: #58a6ff;
}

#new-chat {
  padding: 4px 12px;
  background: #21262d;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

#new-chat:hover {
  background: #30363d;
  color: #e6edf3;
}

#status {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

#status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #484f58;
  transition: background 0.3s;
}

#status-dot.active {
  background: #3fb950;
  box-shadow: 0 0 6px #3fb95066;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#status-dot.error {
  background: #f85149;
}

#status-text {
  font-size: 12px;
  color: #484f58;
}

#current-url {
  font-size: 12px;
  color: #484f58;
  font-family: 'SF Mono', 'Fira Code', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

#main {
  flex: 1;
  overflow: hidden;
  display: flex;
}

/* Spectator panel — shows rendered pages (side by side) */
#spectator-panel {
  background: #fff;
  flex: 3;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid #21262d;
}

#spectator-panel[hidden] {
  display: none !important;
}

#spectator-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  gap: 8px;
}

#spectator-url {
  flex: 1;
  font-size: 12px;
  color: #8b949e;
  font-family: 'SF Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#close-spectator {
  background: none;
  border: none;
  color: #8b949e;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
}

#close-spectator:hover {
  color: #f85149;
}

#spectator {
  flex: 1;
  border: none;
  width: 100%;
  min-height: 400px;
}

#terminal {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 300px;
  max-width: 25%;
  height: 100%;
  background: #0d1117;
}

/* Welcome screen with sample prompts */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 24px;
}

.welcome h2 {
  font-size: 24px;
  font-weight: 500;
  color: #e6edf3;
}

#samples {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 700px;
}

.sample {
  padding: 10px 18px;
  background: #161b22;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.sample:hover {
  background: #1f2937;
  color: #c9d1d9;
  border-color: #58a6ff;
}

#result-panel, .result-archive {
  margin: 12px 20px;
  padding: 16px;
  background: #0d1f0d;
  border: 1px solid #1a3a1a;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #a3e6a3;
  max-height: 50vh;
  overflow-y: auto;
}

#result-panel {
  position: relative;
}

.result-archive {
  opacity: 0.72;
  max-height: 280px;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: #1a3a1a;
  color: #3fb950;
  border: 1px solid #2a4a2a;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  z-index: 1;
}

.copy-btn:hover {
  background: #2a4a2a;
  color: #a3e6a3;
}

#result-panel h1, #result-panel h2, #result-panel h3,
.result-archive h1, .result-archive h2, .result-archive h3 {
  color: #3fb950;
  margin: 12px 0 6px;
  font-size: 15px;
}

#result-panel h1, .result-archive h1 { font-size: 18px; }
#result-panel h2, .result-archive h2 { font-size: 16px; }

#result-panel p, .result-archive p { margin: 6px 0; }

#result-panel strong, .result-archive strong { color: #e6edf3; }

#result-panel ul, #result-panel ol,
.result-archive ul, .result-archive ol {
  padding-left: 20px;
  margin: 6px 0;
}

#result-panel li, .result-archive li { margin: 4px 0; }

#result-panel a, .result-archive a {
  color: #58a6ff;
  text-decoration: none;
}

#result-panel a:hover, .result-archive a:hover { text-decoration: underline; }

#result-panel table, .result-archive table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

#result-panel th, #result-panel td,
.result-archive th, .result-archive td {
  border: 1px solid #1a3a1a;
  padding: 6px 10px;
  text-align: left;
}

#result-panel th, .result-archive th {
  background: #0a1a0a;
  color: #3fb950;
}

#result-panel code, .result-archive code {
  background: #0a1a0a;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', monospace;
  font-size: 13px;
}

#output {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.7;
}

#output::-webkit-scrollbar {
  width: 6px;
}

#output::-webkit-scrollbar-track {
  background: transparent;
}

#output::-webkit-scrollbar-thumb {
  background: #21262d;
  border-radius: 3px;
}

#input-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid #21262d;
  background: #010409;
}

#prompt-char {
  color: #3fb950;
  font-size: 15px;
  font-weight: bold;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

#task-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-family: inherit;
  font-size: 15px;
  outline: none;
  caret-color: #3fb950;
}

#task-input::placeholder {
  color: #30363d;
}

#stop-btn {
  padding: 6px 14px;
  background: #21262d;
  color: #f85149;
  border: 1px solid #f8514933;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

#stop-btn:hover {
  background: #f8514922;
  border-color: #f85149;
}

/* Log entry types */
.line {
  padding: 2px 0;
  word-wrap: break-word;
}

.line-cmd {
  color: #f0f6fc;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 8px 0 4px;
}

.line-step {
  color: #21262d;
  font-size: 1px;
  height: 1px;
  margin: 8px 0;
  border-bottom: 1px solid #21262d;
}

.line-action {
  color: #58a6ff;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
}

.line-mcp {
  color: #8b949e;
  font-size: 13px;
}

.line-thinking {
  color: #d2a8ff;
  font-style: italic;
}

.line-result {
  color: #e6edf3;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 0;
  white-space: pre-wrap;
}

.line-error {
  color: #f85149;
}

.line-status {
  color: #484f58;
  font-size: 12px;
}

/* Mobile: browser on top, terminal on bottom */
@media (max-width: 768px) {
  #main {
    flex-direction: column;
  }

  #spectator-panel {
    flex: none;
    height: 50vh;
    border-left: none;
    border-bottom: 1px solid #21262d;
    order: -1; /* browser on top */
  }

  #terminal {
    max-width: 100%;
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .welcome {
    padding: 20px 16px;
    gap: 16px;
  }

  .welcome h2 {
    font-size: 18px;
  }

  #samples {
    flex-direction: column;
    align-items: stretch;
  }

  .sample {
    font-size: 13px;
    text-align: left;
  }

  #result-panel {
    margin: 8px 12px;
    padding: 12px;
    max-height: 25vh;
    flex-shrink: 0;
  }

  #output {
    padding: 8px 12px;
    flex: 1;
    min-height: 0;
  }

  #input-line {
    padding: 14px 12px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    min-height: 56px;
    flex-shrink: 0;
  }

  #task-input {
    font-size: 16px;
  }

  header {
    padding: 8px 12px;
    flex-shrink: 0;
  }

  #brand {
    font-size: 14px;
  }

  #current-url {
    display: none;
  }
}
