:root {
  color-scheme: dark;

  --bg: #14171d;
  --panel: #1b1f27;
  --panel-hover: #212632;
  --border: #2a2f3a;
  --text: #e7e9ed;
  --text-dim: #838d9c;
  --accent: #4fd1c5;
  --accent-ink: #0a1f1d;

  --status-running: #5ec26a;
  --status-stopped: #838d9c;
  --status-pending: #f2b84b;
  --status-error: #ef5b5b;
  --status-suspended: #b177e0;

  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  max-width: 44rem;
  margin: 3rem auto;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
}

h1, h2 {
  font-family: var(--font-mono);
  font-weight: 600;
  margin: 0;
}

h1 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

a {
  color: var(--accent);
}

header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

#nav button {
  white-space: nowrap;
}

.wordmark .tagline {
  margin: 0.15rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* --- forms & controls --- */

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

input, textarea, button {
  font: inherit;
  font-size: 0.9rem;
}

input, textarea {
  padding: 0.55rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  font-size: 0.8rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  padding: 0;
}

input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  padding: 0.55rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button:hover {
  border-color: var(--text-dim);
  background: var(--panel-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
  border-color: var(--accent);
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 22rem;
  margin-bottom: 2rem;
}

.panel {
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#auth-section {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

#auth-form {
  width: 100%;
  margin-bottom: 0;
}

.auth-switch {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* --- standalone utility pages (tos.html, report.html, admin.html) --- */

.page-intro {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0 0 1.5rem;
}

.panel h2:not(:first-child) {
  margin-top: 1.5rem;
}

main > section + section {
  margin-top: 2rem;
}

.site-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* .back-link on its own, outside the flex layout Settings uses it in
   (which supplies spacing via its own gap) -- give it room of its own. */
.back-link--page {
  display: inline-block;
  margin-bottom: 1.5rem;
}

#create-wiki-form {
  flex-direction: row;
  max-width: none;
  gap: 0.6rem;
  margin-top: 1.25rem;
  margin-bottom: 0;
}

#create-wiki-form input {
  flex: 1;
}

/* --- wiki list --- */

#wiki-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#wiki-list > li {
  position: relative;
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

#wiki-list > li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--status-pending);
}

#wiki-list > li[data-status="running"]::before { background: var(--status-running); }
#wiki-list > li[data-status="stopped"]::before { background: var(--status-stopped); }
#wiki-list > li[data-status="pending"]::before { background: var(--status-pending); }
#wiki-list > li[data-status="error"]::before { background: var(--status-error); }
#wiki-list > li[data-status="suspended"]::before { background: var(--status-suspended); }
#wiki-list > li[data-status="starting"]::before { background: var(--accent); }

.wiki-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.wiki-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.wiki-actions button {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.wiki-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.wiki-info a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
}

.wiki-info a:hover {
  text-decoration: underline;
}

/* --- generic card list (admin queue: reports, suspended wikis) ---
   Same visual grammar as #wiki-list: a bordered panel-card with a
   colored spine, just generalized past the dashboard's own ID scope and
   keyed by data-kind instead of a wiki's status. */

.card-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.card-list > li {
  position: relative;
  padding: 0.85rem 1rem 0.85rem 1.15rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.card-list > li::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3px;
  background: var(--border);
}

.card-list > li[data-kind="report"]::before { background: var(--status-error); }
.card-list > li[data-kind="suspended"]::before { background: var(--status-suspended); }

.entity-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.entity-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.entity-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.empty-state {
  padding: 0.85rem 1.15rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.status--pending { color: var(--status-pending); }
.status--running { color: var(--status-running); }
.status--stopped { color: var(--status-stopped); }
.status--error { color: var(--status-error); }
.status--suspended { color: var(--status-suspended); }
.status--starting { color: var(--accent); }

.setup-cta {
  margin-top: 0.85rem;
  padding: 0.75rem 0.85rem;
  background: color-mix(in srgb, var(--status-pending) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-pending) 35%, transparent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.setup-cta .btn-primary {
  margin-left: auto;
}

.backups-panel,
.usage-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.backups-panel button {
  align-self: flex-start;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.backup-list,
.usage-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.backup-list li,
.usage-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

#settings-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.back-link {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.back-link:hover {
  background: none;
  border-color: transparent;
  color: var(--accent);
}

.danger-zone {
  max-width: none;
  margin-bottom: 0;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--status-error) 8%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--status-error) 35%, transparent);
  border-radius: 6px;
}

.danger-zone p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.btn-danger {
  align-self: flex-start;
  border-color: var(--status-error);
  color: var(--status-error);
}

.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--status-error) 15%, transparent);
  border-color: var(--status-error);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#message {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 26rem;
  margin: 0 auto 1.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
  opacity: 1;
  transition: opacity 0.4s ease;
}

#message::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

#message.message--error {
  color: var(--status-error);
  background: color-mix(in srgb, var(--status-error) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-error) 35%, transparent);
}

#message.message--success {
  color: var(--status-running);
  background: color-mix(in srgb, var(--status-running) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-running) 35%, transparent);
}

#message.fade-out {
  opacity: 0;
}

#message:empty {
  display: none;
}
