:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e0e0e6;
  --text-muted: #8b8fa3;
  --accent: #6c8aff;
  --accent-dim: #3d4f8a;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
  --blue: #60a5fa;
  --code-bg: #141620;
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 32px 0 28px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  margin-top: 2px;
  font-size: 14px;
}

/* Token bar */
.token-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 280px;
}

.token-bar label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.token-input-wrap {
  display: flex;
  gap: 0;
}

.token-input-wrap input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  outline: none;
}

.token-input-wrap input:focus {
  border-color: var(--accent-dim);
}

.token-input-wrap button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 10px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.token-input-wrap button:hover {
  color: var(--text);
}

.token-status {
  font-size: 11px;
  color: var(--text-muted);
}

.token-status.active {
  color: var(--green);
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: #5a7aef;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

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

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.1);
}

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

.btn-run {
  background: rgba(108, 138, 255, 0.1);
  color: var(--accent);
  border-color: rgba(108, 138, 255, 0.3);
  margin-left: auto;
}

.btn-run:hover:not(:disabled) {
  background: rgba(108, 138, 255, 0.2);
}

/* Create form */
.create-form {
  margin-bottom: 16px;
}

.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.form-row input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.form-row input:focus {
  border-color: var(--accent-dim);
}

.form-row input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Actions bar */
.actions-bar {
  display: flex;
  gap: 8px;
}

/* Projects list */
.projects-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.empty-state.error {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Project card */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

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

.project-id {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-running {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}

.status-stopped {
  background: rgba(139, 143, 163, 0.15);
  color: var(--text-muted);
}

.status-error {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

.project-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.project-url {
  margin-bottom: 12px;
}

.project-url a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  font-family: "SF Mono", "Fira Code", monospace;
}

.project-url a:hover {
  text-decoration: underline;
}

.project-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Sections */
section {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
}

section:last-child {
  border-bottom: none;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: -0.3px;
}

p {
  margin-bottom: 12px;
  color: var(--text-muted);
}

p:last-child {
  margin-bottom: 0;
}

code {
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--accent);
}

/* Code blocks */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 0;
  overflow-x: auto;
}

.code-block pre { margin: 0; }

.code-block code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}

/* Endpoints */
.endpoint {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.endpoint > p {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 0;
  font-size: 13px;
}

.method {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.method.get { background: rgba(96, 165, 250, 0.15); color: var(--blue); }
.method.post { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.method.delete { background: rgba(248, 113, 113, 0.15); color: var(--red); }

.endpoint > code {
  font-size: 13px;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-weight: 500;
}

.badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge.auth { background: rgba(251, 146, 60, 0.15); color: var(--orange); }
.badge.public { background: rgba(52, 211, 153, 0.15); color: var(--green); }

/* Run result */
.run-result {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
  overflow: hidden;
}

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

.run-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
}

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

.run-result pre {
  padding: 16px;
  margin: 0;
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
}

.run-result code {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}

/* Lifecycle */
.lifecycle {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.state {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.state h3 {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--accent);
}

.state p { font-size: 12px; margin: 0; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: none; }

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 16px;
}

footer p { font-size: 13px; color: var(--text-muted); }

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

footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 600px) {
  header { padding: 20px 0 16px; }
  .header-row { flex-direction: column; }
  .token-bar { min-width: unset; }
  header h1 { font-size: 20px; }
  section { padding: 24px 0; }
  .endpoint { padding: 12px; }
  .lifecycle { grid-template-columns: 1fr; }
  .project-actions { flex-direction: column; }
}
