:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface-2: #1a1a24;
  --border: rgba(255,255,255,0.1);
  --cyan: #00f0ff;
  --magenta: #ff00aa;
  --green: #00cc66;
  --text: #e8e8f0;
  --muted: #6a6a7a;
}

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

.hidden {
  display: none !important;
}

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

#app-header-nav {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#app-header-nav .ah-brand {
  color: #ffffff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  margin-right: 20px;
}

#app-header-nav .ah-brand:hover {
  color: #58a6ff;
}

#app-header-nav .ah-links {
  display: flex;
  align-items: center;
}

#app-header-nav .ah-links[hidden] {
  display: none;
}

#app-header-nav .ah-link {
  color: #8b949e;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
}

#app-header-nav .ah-link:hover,
#app-header-nav .ah-link.ah-active {
  color: #58a6ff;
}

#app-header-nav .ah-spacer {
  margin-left: auto;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-size: 2rem;
  color: var(--cyan);
}

@supports (-webkit-background-clip: text) and (-webkit-text-fill-color: transparent) {
  h1 {
    background: linear-gradient(135deg, var(--cyan), var(--magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
}

/* Keep find-in-page and text selection readable against the dark theme. */
::selection {
  background: #ffd54f;
  color: #111111;
  -webkit-text-fill-color: #111111;
}

::-moz-selection {
  background: #ffd54f;
  color: #111111;
  -webkit-text-fill-color: #111111;
}

/* Firefox can hide highlighted text when webkit text fill is transparent. */
@-moz-document url-prefix() {
  h1 {
    background: none;
    color: var(--cyan);
    -webkit-text-fill-color: currentColor;
  }
}

.subtitle {
  color: var(--muted);
  margin-top: 6px;
}

#app-header-nav #auth-area {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

#app-header-nav #auth-area .auth-email {
  font-size: 0.82rem;
  color: var(--muted);
}

#app-header-nav #auth-area .auth-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

#app-header-nav #auth-area .auth-btn:hover {
  border-color: var(--cyan);
}

.access-gate {
  max-width: 720px;
  margin: 20px auto 24px;
  padding: 28px 24px;
  border-radius: 14px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), rgba(255, 0, 170, 0.08));
  text-align: center;
}

.access-gate h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.access-gate p {
  color: var(--muted);
}

.access-gate-footnote {
  margin-top: 10px;
  font-size: 0.82rem;
  opacity: 0.8;
}

.access-gate .btn {
  margin-top: 16px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--cyan);
  color: var(--bg);
}

.btn-primary:hover {
  background: #00d8e6;
}

.btn-primary:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--cyan);
}

.btn-danger {
  background: #3d1119;
  color: #ff9db0;
  border: 1px solid rgba(255, 68, 102, 0.35);
}

.btn-danger:hover {
  background: #511724;
  border-color: rgba(255, 68, 102, 0.6);
}

/* Search bar */
.search-bar {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-bottom: 16px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 500px;
}

.search-input-wrap input {
  width: 100%;
  padding: 10px 16px;
  padding-right: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--cyan);
}

.search-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--muted);
  pointer-events: none;
}

.create-app-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Semantic search results dropdown */
.search-results {
  max-width: 700px;
  margin: 0 auto 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px 0;
}

.search-results.hidden {
  display: none;
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.search-result-item:hover {
  background: var(--surface-2);
}

.search-result-name {
  color: var(--cyan);
  font-weight: 500;
}

.search-result-score {
  color: var(--muted);
  font-size: 0.8rem;
  min-width: 50px;
  text-align: right;
  margin-top: 2px;
}

.search-result-desc {
  color: var(--muted);
  font-size: 0.82rem;
  margin-left: 12px;
  flex: 1;
  white-space: normal;
  line-height: 1.35;
  max-height: 5.4em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status messages */
.status {
  text-align: center;
  padding: 10px;
  margin-bottom: 16px;
  border-radius: 8px;
  display: none;
}

.status.visible {
  display: block;
}

.status.loading {
  background: rgba(0, 240, 255, 0.1);
  color: var(--cyan);
}

.status.error {
  background: rgba(255, 68, 102, 0.1);
  color: #ff4466;
}

.status.success {
  background: rgba(0, 204, 102, 0.1);
  color: var(--green);
}

.panel-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 10px;
}

.panel-status.ok {
  color: var(--green);
}

.panel-status.error {
  color: #ff4466;
}


.gateway-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
}

.gateway-header,
.gateway-run-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.gateway-header h3,
.gateway-run-header h4 {
  color: var(--cyan);
  font-size: 1rem;
}

.gateway-header p,
.gateway-run-header p {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
  line-height: 1.35;
}

.gateway-form,
.gateway-run-form {
  margin-bottom: 10px;
}

.gateway-form-grid,
.gateway-run-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gateway-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gateway-field span {
  color: var(--muted);
  font-size: 0.78rem;
}

.gateway-field input,
.gateway-field select,
.gateway-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.gateway-field input,
.gateway-field select {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Noto Sans Mono', 'Courier New', monospace;
}

.gateway-field textarea {
  min-height: 104px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.gateway-field input:focus,
.gateway-field select:focus,
.gateway-field textarea:focus {
  outline: none;
  border-color: var(--cyan);
}

.gateway-field-wide {
  grid-column: span 3;
}

.gateway-form-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gateway-connections {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gateway-connection-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.gateway-connection-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gateway-connection-title {
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
}

.gateway-connection-subtitle,
.gateway-connection-meta,
.gateway-connection-host,
.gateway-connection-readiness,
.gateway-connection-system,
.gateway-connection-apps {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-top: 3px;
}

.gateway-connection-id {
  color: var(--cyan);
}

.gateway-connection-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.gateway-summary-block {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.02);
}

.gateway-summary-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gateway-summary-value {
  color: var(--text);
  font-size: 0.86rem;
  margin-top: 5px;
  line-height: 1.4;
}

.gateway-summary-value.error {
  color: #ff8097;
}

.gateway-summary-value.ok {
  color: #7ee787;
}

.gateway-summary-value.warn {
  color: #f2cc60;
}

.gateway-connection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gateway-advanced {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.gateway-advanced summary {
  cursor: pointer;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
}

.gateway-advanced-copy {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.gateway-connection-gap-list,
.create-target-gap-list {
  margin: 6px 0 0 18px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.gateway-connection-gap-list li,
.create-target-gap-list li {
  margin-bottom: 2px;
}

.gateway-remote-apps {
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
}

.gateway-remote-apps-title {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.gateway-remote-apps-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gateway-remote-app-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.gateway-remote-app-copy {
  min-width: 0;
}

.gateway-remote-app-name,
.gateway-remote-app-link {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 500;
}

.gateway-remote-app-link:hover {
  color: var(--cyan);
}

.gateway-remote-app-desc,
.gateway-remote-app-meta {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 3px;
}

.gateway-run-panel {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.gateway-run-output {
  background: #07070d;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 180px;
  max-height: 360px;
  overflow-y: auto;
  padding: 10px;
  color: #d7dbe0;
  font-size: 0.82rem;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Noto Sans Mono', 'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.gateway-run-output.empty::before {
  content: 'Remote run output will appear here.';
  color: var(--muted);
}

.gateway-run-events {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.gateway-run-event {
  border: 1px solid rgba(88, 166, 255, 0.16);
  background: rgba(88, 166, 255, 0.04);
  border-radius: 8px;
  padding: 8px 10px;
}

.gateway-run-event-time {
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
}

.gateway-run-event-message {
  color: var(--text);
  font-size: 0.81rem;
  line-height: 1.4;
}

.agent-console-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
}

.agent-console-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.agent-console-header h3 {
  color: var(--cyan);
  font-size: 1rem;
}

.agent-console-header p {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 3px;
  line-height: 1.35;
}

.agent-console-header code {
  background: rgba(0, 240, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 5px;
  padding: 0 4px;
}

.agent-console-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.agent-console-cwd-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.agent-console-cwd-row label {
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.agent-console-cwd-row input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

.agent-console-cwd-row select {
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: 'Courier New', monospace;
}

.agent-console-cwd-row select:focus {
  outline: none;
  border-color: var(--cyan);
}

.agent-console-cwd-row input:focus {
  outline: none;
  border-color: var(--cyan);
}

.agent-console-status {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
  min-height: 1.2em;
}

.agent-console-status.running {
  color: var(--green);
}

.agent-console-status.stopping {
  color: var(--cyan);
}

.agent-console-status.error {
  color: #ff4466;
}

.agent-console-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.agent-console-pane {
  min-width: 0;
}

.agent-console-pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.agent-console-pane-header {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.agent-console-output-pane {
  background: #07070d;
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 300px;
  overflow-y: auto;
  padding: 10px;
  color: #d7dbe0;
  font-size: 0.82rem;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Noto Sans Mono', 'Courier New', monospace;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.agent-console-output-pane.empty::before {
  content: 'Console output will appear here.';
  color: var(--muted);
}

.agent-console-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  white-space: normal;
}

.agent-console-summary.empty::before {
  content: 'Readable agent events will appear here.';
}

.agent-console-summary-item {
  border: 1px solid rgba(126, 231, 135, 0.16);
  border-radius: 8px;
  background: rgba(126, 231, 135, 0.04);
  padding: 9px 10px;
}

.agent-console-summary-item.plain {
  border-color: rgba(88, 166, 255, 0.16);
  background: rgba(88, 166, 255, 0.04);
}

.agent-console-summary-item.error {
  border-color: rgba(255, 68, 102, 0.24);
  background: rgba(255, 68, 102, 0.06);
}

.agent-console-summary-meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.agent-console-summary-title {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.agent-console-summary-detail {
  color: #d7dbe0;
  font-size: 0.79rem;
  line-height: 1.45;
  margin-top: 3px;
  white-space: pre-wrap;
  word-break: break-word;
}

.agent-console-input-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-console-input-row input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Noto Sans Mono', 'Courier New', monospace;
}

.agent-console-input-row input:focus {
  outline: none;
  border-color: var(--cyan);
}

.agent-console-input-row input:disabled {
  opacity: 0.65;
}

/* Server tab bar (top-level) */
.server-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.server-tab-bar::-webkit-scrollbar { display: none; }

.server-tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.server-tab:hover { color: var(--text); }
.server-tab.active {
  color: var(--cyan);
  border-bottom-color: var(--cyan);
}

/* Sub-tab bar (second-level) */
.sub-tab-bar {
  display: flex;
  gap: 0;
  align-items: center;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sub-tab-bar .create-app-btn {
  margin-left: auto;
  margin-bottom: 6px;
}

.sub-tab {
  padding: 8px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.84rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active {
  color: var(--text);
  border-bottom-color: var(--cyan);
}

.tab-content {
  min-height: 200px;
}

.configure-content {
  padding: 8px 0;
}

.configure-section {
  margin-bottom: 24px;
}
.configure-section h4 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.configure-meta {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.6;
}
.configure-meta strong {
  color: var(--text);
}
.configure-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* Project list */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.project-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 16px;
  background: transparent;
  cursor: pointer;
  color: inherit;
  transition: background 0.15s ease;
}

.project-row:hover {
  background: rgba(255,255,255,0.02);
}

.project-row:focus {
  outline: 1px solid var(--cyan);
  outline-offset: -1px;
}

.project-row.expanded {
  background: rgba(0, 240, 255, 0.05);
}

.project-favicon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
  background: var(--surface-2);
}

.project-favicon-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

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

.project-name {
  color: var(--cyan);
  font-weight: 500;
  font-size: 0.95rem;
}

.project-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-title-link {
  color: var(--cyan);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
}

.project-title-link:hover,
.project-title-link:focus {
  text-decoration: underline;
}

.project-desc {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: normal;
  line-height: 1.35;
  max-height: 5.4em;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.project-desc.expanded {
  max-height: none;
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.project-meta {
  flex-shrink: 0;
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
  align-self: flex-start;
}

.project-loc {
  color: var(--green);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.project-loc-link {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.project-loc-link:hover,
.project-loc-link:focus {
  color: #7ee787;
}

.project-loc-link:focus {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 3px;
}

.subtitle-sep {
  color: var(--muted);
}

.project-domain {
  color: var(--text);
  opacity: 0.5;
  font-size: 0.78rem;
}

.project-time {
  margin-top: 2px;
}

.project-list-empty {
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  color: var(--muted);
}

/* Footer controls */
.footer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Project row wrap (row + action button) */
.project-row-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  transition: background 0.15s;
}

.project-row-wrap:hover {
  background: var(--surface-2);
}

.project-row-wrap.dimmed {
  opacity: 0.15;
}

.project-row-wrap .project-row {
  flex: 1;
  min-width: 0;
}

.project-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.project-action-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.project-action-btn.label {
  width: auto;
  min-width: 44px;
  padding: 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.project-row-wrap:hover .project-actions {
  opacity: 1;
}

.project-action-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--cyan);
}

.project-action-btn.delete:hover {
  border-color: rgba(255, 68, 102, 0.35);
  color: #ff6f8a;
}

.static-field {
  display: flex;
  align-items: center;
  min-height: 42px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.create-modal-content {
  max-width: 860px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--cyan);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--cyan);
}

.form-group input.input-readonly {
  opacity: 0.6;
  cursor: default;
}

.validation-msg {
  font-size: 0.82rem;
  margin-top: 4px;
  min-height: 1.2em;
}

.validation-msg.valid {
  color: var(--green);
}

.validation-msg.error {
  color: #ff4466;
}

.validation-msg ul {
  margin-top: 6px;
}

.btn-full {
  width: 100%;
  margin-top: 4px;
}

.danger-note {
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 68, 102, 0.35);
  border-radius: 8px;
  background: rgba(255, 68, 102, 0.08);
  color: #ff9db0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.modal-tip {
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 8px;
  background: rgba(0, 240, 255, 0.08);
  color: var(--cyan);
  font-size: 0.8rem;
  line-height: 1.4;
}

.create-simulate-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.create-simulate-toggle input {
  width: auto;
  margin: 0;
}

.modal-progress {
  padding: 20px 0;
}

.modal-progress.hidden {
  display: none;
}

.modal-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-logs {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: monospace;
  margin-top: 12px;
  text-align: left;
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
  line-height: 1.55;
}

.create-progress-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.create-progress-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-result.hidden {
  display: none;
}

.result-success {
  padding: 16px;
  background: rgba(0, 204, 102, 0.08);
  border: 1px solid rgba(0, 204, 102, 0.2);
  border-radius: 10px;
}

.result-success h3 {
  color: var(--green);
  margin-bottom: 8px;
}

.result-success p {
  margin: 4px 0;
  font-size: 0.9rem;
}

.result-list {
  margin: 4px 0 8px 20px;
  font-size: 0.83rem;
  line-height: 1.4;
  color: #8ddca0;
}

.result-list li {
  margin-bottom: 2px;
}

.result-list.warnings {
  color: #ffd27d;
}

.result-warning-block {
  margin: 12px 0;
  padding: 12px 14px;
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 10px;
}

.result-warning-block h4 {
  margin: 0 0 6px;
  color: #ffd27d;
}

.result-warning-block p {
  margin: 0;
  color: #ffe4a6;
}

.result-detail-text {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 17, 23, 0.72);
  color: #dbe7f3;
  font: 0.84rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 320px;
}

.result-success a {
  color: var(--cyan);
}

.result-error {
  padding: 16px;
  background: rgba(255, 68, 102, 0.08);
  border: 1px solid rgba(255, 68, 102, 0.2);
  border-radius: 10px;
}

.result-error h3 {
  color: #ff4466;
  margin-bottom: 8px;
}

.result-error p {
  font-size: 0.9rem;
}

/* Recent Builds section */
.builds-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.builds-section.hidden {
  display: none;
}

.builds-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.builds-header:hover {
  background: var(--surface-2);
}

.builds-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.builds-count {
  font-size: 0.8rem;
  color: var(--muted);
  margin-left: 6px;
}

.builds-chevron {
  color: var(--muted);
  font-size: 0.7rem;
  transition: transform 0.2s;
}

.builds-chevron.expanded {
  transform: rotate(90deg);
}

.builds-list {
  display: flex;
  flex-direction: column;
}

.builds-list.hidden {
  display: none;
}

.build-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.build-item:hover {
  background: var(--surface-2);
}

.build-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.build-status-dot.running {
  background: var(--cyan);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.build-status-dot.completed {
  background: var(--green);
}

.build-status-dot.failed {
  background: #ff4466;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

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

.build-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.build-prompt {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.build-meta {
  flex-shrink: 0;
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
}

.build-open-btn {
  margin-top: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}

.build-open-btn:hover {
  border-color: var(--cyan);
}

.build-error {
  font-size: 0.78rem;
  color: #ff4466;
}

.build-expanded {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
}

.build-expanded-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.build-log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.build-log-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.build-log-copy-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 0.72rem;
  cursor: pointer;
}

.build-log-copy-btn:hover {
  border-color: var(--cyan);
}

.build-log-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.build-log-tab {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.build-log-tab.active {
  color: var(--text);
  border-color: var(--cyan);
}

.build-log-stack {
  display: block;
}

.build-log-pane {
  min-width: 0;
}

.build-log-pane.hidden {
  display: none;
}

.build-log-container {
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.build-log-container .log-line {
  padding: 1px 0;
}

.build-log-container .log-loading {
  color: var(--cyan);
  font-style: italic;
}

/* Build phase (Claude Code) */
.modal-content.build-active {
  max-width: 1180px;
  width: 95vw;
}

.build-phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.build-phase-header h3 {
  color: var(--cyan);
  font-size: 1rem;
  margin: 0;
}

.build-phase-help {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(126, 231, 135, 0.22);
  border-radius: 8px;
  background: rgba(126, 231, 135, 0.08);
  color: #8ddca0;
  font-size: 0.82rem;
  line-height: 1.45;
}

#build-widget-container {
  min-height: 400px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
  .search-bar {
    flex-direction: column;
  }

  .search-input-wrap {
    max-width: 100%;
    width: 100%;
  }

  .project-row {
    padding: 10px 12px;
    gap: 10px;
  }

  .project-meta {
    display: none;
  }

  .project-actions {
    opacity: 1;
  }

  .agent-console-header {
    flex-direction: column;
  }

  .agent-console-actions {
    width: 100%;
  }

  .agent-console-cwd-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .agent-console-output {
    grid-template-columns: 1fr;
  }

  .agent-console-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .gateway-form-grid,
  .gateway-run-grid,
  .gateway-connection-summary {
    grid-template-columns: 1fr;
  }

  .gateway-field-wide {
    grid-column: auto;
  }

  .gateway-connection-header {
    flex-direction: column;
  }

  .build-log-tabs {
    gap: 6px;
  }
}

/* ── Agent Files Browser ──────────────────────────────────────── */

.agent-files-layout {
  display: flex;
  gap: 1px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  overflow: hidden;
  min-height: 500px;
}

.agent-files-sidebar {
  width: 280px;
  min-width: 220px;
  background: #0d1117;
  padding: 12px;
  overflow-y: auto;
  max-height: 70vh;
  border-right: 1px solid #30363d;
}

.agent-files-main {
  flex: 1;
  background: #0d1117;
  padding: 16px;
  overflow: auto;
  max-height: 70vh;
}

.agent-files-root-name {
  font-weight: 600;
  color: #58a6ff;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.agent-files-root-name:hover {
  background: #161b22;
}

.agent-files-children {
  padding-left: 12px;
  border-left: 1px solid #21262d;
  margin-left: 8px;
}

.agent-files-item {
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: #c9d1d9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-files-item:hover {
  background: #161b22;
}

.agent-files-item.is-dir {
  color: #58a6ff;
}

.agent-files-item.sensitive {
  opacity: 0.5;
}

.agent-files-icon {
  font-size: 12px;
  margin-right: 4px;
}

.agent-files-size {
  color: #8b949e;
  font-size: 11px;
}

.agent-files-file-header {
  font-size: 14px;
  font-weight: 600;
  color: #c9d1d9;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid #21262d;
}

.agent-files-content-pre {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.5;
  color: #c9d1d9;
  margin: 0;
  max-height: 60vh;
}

.agent-files-content-pre code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.agent-files-empty {
  color: #8b949e;
  padding: 20px;
  text-align: center;
}

.agent-files-loading {
  color: #8b949e;
  padding: 12px;
}

.agent-files-error {
  color: #f85149;
  padding: 8px;
  font-size: 13px;
}
