:root {
  --ink: #171a20;
  --panel: #1e2229;
  --panel-raised: #262b33;
  --hairline: #343a44;
  --text: #e8e6dd;
  --text-muted: #8b92a0;
  --amber: #c98a3b;
  --amber-dim: #8a5f28;
  --brick: #b3452e;
  --teal: #5c7a8a;
  --radius: 3px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2 {
  font-family: "IBM Plex Serif", serif;
  font-weight: 600;
  margin: 0;
}

code,
.mono {
  font-family: "IBM Plex Mono", monospace;
}

button {
  font-family: inherit;
}

.button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.button:hover {
  border-color: var(--teal);
}

.button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.button-small {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.button-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #1a1206;
  font-weight: 500;
}

.button-primary:hover {
  background: #d99a4d;
  border-color: #d99a4d;
}

.button-danger {
  border-color: var(--brick);
  color: var(--brick);
}

.button-danger:hover {
  background: var(--brick);
  color: var(--text);
}

.button-ghost {
  border-color: transparent;
  color: var(--text-muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
}

.wordmark {
  font-family: "IBM Plex Serif", serif;
  font-weight: 600;
  font-size: 1.1rem;
}

.account-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.account-email {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--brick);
  color: var(--text);
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--ink);
}

.button[disabled] {
  opacity: 0.6;
  cursor: default;
}

.button[disabled]:hover {
  border-color: var(--hairline);
}

.auth-view {
  display: flex;
  justify-content: center;
  padding: 4rem 1.5rem;
}

.auth-panel {
  max-width: 420px;
  width: 100%;
}

.auth-panel h1 {
  font-size: 1.6rem;
  line-height: 1.3;
  max-width: 32ch;
}

.auth-sub {
  color: var(--text-muted);
  margin: 0.75rem 0 1.75rem;
  max-width: 48ch;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 1.25rem;
}

.auth-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 0;
  margin-right: 1.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.auth-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--amber);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.field input,
.field select {
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

.field-hint {
  margin: -0.5rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.app-view {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  border-right: 1px solid var(--hairline);
  padding: 1.25rem;
}

.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.sidebar-head h2 {
  font-size: 1rem;
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-list li {
  padding: 0.6rem 0.5rem;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.project-list li:hover {
  color: var(--text);
}

.project-list li.is-selected {
  border-left-color: var(--amber);
  color: var(--text);
  background: var(--panel);
}

.inline-form {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.inline-form input {
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
}

.inline-form-actions {
  display: flex;
  gap: 0.5rem;
}

.register {
  padding: 1.5rem 2rem;
}

.register-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--hairline);
}

.register-head h2 {
  font-size: 1.3rem;
}

.empty-state {
  color: var(--text-muted);
  padding: 2rem 0;
}

.route-form {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.route-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-wide {
  grid-column: 1 / -1;
}

.token-reveal {
  border: 1px solid var(--amber);
  background: var(--panel-raised);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  animation: reveal 0.3s ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.token-reveal-label {
  margin: 0;
  color: var(--amber);
  font-size: 0.8rem;
  flex-basis: 100%;
}

.token-reveal-value {
  word-break: break-all;
  flex: 1;
  min-width: 200px;
}

.route-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.route-row {
  border-bottom: 1px solid var(--hairline);
  padding: 0.9rem 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 1rem;
}

.route-row-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  flex-shrink: 0;
}

.status-dot.is-paused {
  background: var(--text-muted);
}

.route-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.route-label {
  font-weight: 500;
}

.route-url {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.route-row-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: "IBM Plex Mono", monospace;
}

.route-row-actions {
  display: flex;
  gap: 0.5rem;
}

.token-sublist {
  grid-column: 1 / -1;
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px dashed var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
}

.token-status {
  font-family: "IBM Plex Mono", monospace;
  color: var(--text-muted);
}

.token-created {
  color: var(--text-muted);
  flex: 1;
}

@media (max-width: 760px) {
  .app-view {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--hairline);
  }
  .route-form-grid {
    grid-template-columns: 1fr;
  }
  .route-row {
    grid-template-columns: 1fr;
    row-gap: 0.5rem;
  }
  .route-row-meta {
    align-items: flex-start;
    flex-direction: row;
    gap: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .token-reveal {
    animation: none;
  }
}
