:root {
  --bg: #f4f4f1;
  --fg: #1b1b19;
  --muted: #6d6d68;
  --line: #dcdcd6;
  --card: #ffffff;
  --inset: #f7f7f5;
  --accent: #1f5f4f;
  --on-accent: #ffffff;
  --danger: #8c2f2f;
  --warn: #8a6d1f;
  --blue: #2f5f9e;
  --violet: #6a4c9c;
  --amber: #9a6a12;
  --slate: #5b6470;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 2px 8px rgb(0 0 0 / .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11110d;
    --fg: #e8e6e0;
    --muted: #9a978f;
    --line: #2e2e28;
    --card: #1a1a15;
    --inset: #14140f;
    --accent: #6fbfa5;
    --on-accent: #10140f;
    --danger: #d98b8b;
    --warn: #d9c07f;
    --blue: #8ab4f0;
    --violet: #b9a0e8;
    --amber: #e0b860;
    --slate: #a3abb6;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .88em; }

.muted { color: var(--muted); }
.ok    { color: var(--accent); }
.warn  { color: var(--warn); }
.error { color: var(--danger); }

/* ------------------------------------------------------------------ icons */

.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -.18em;
}

/* A tinted square holding an icon. The tint classes only set --c, so one
   rule covers every colour and both themes. */
.ico {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.ico .icon { width: 1.15rem; height: 1.15rem; }
.ico.lg { width: 2.9rem; height: 2.9rem; border-radius: 12px; }
.ico.lg .icon { width: 1.5rem; height: 1.5rem; }

.t-accent { --c: var(--accent); }
.t-blue   { --c: var(--blue); }
.t-violet { --c: var(--violet); }
.t-amber  { --c: var(--amber); }
.t-red    { --c: var(--danger); }
.t-slate  { --c: var(--slate); }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* ----------------------------------------------------------------- layout */

header.top {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--fg);
  text-decoration: none;
  min-width: 0;
}
.brand .ico { width: 1.9rem; height: 1.9rem; }
.brand .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

header.top .right { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.who { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .9rem; }

main { max-width: 84rem; margin: 0 auto; padding: 1.4rem 1.4rem 4rem; }

.page-head { margin: .4rem 0 1.3rem; }
.page-head .back {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .88rem;
  text-decoration: none;
  margin-bottom: .7rem;
}
.page-title { display: flex; align-items: center; gap: .9rem; }
.page-title > div { min-width: 0; }
.page-title h1 { margin: 0; font-size: 1.55rem; line-height: 1.25; overflow-wrap: anywhere; }
.page-title p { margin: .3rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }

.count {
  display: inline-block;
  font-size: .9rem;
  font-weight: 600;
  padding: .05rem .55rem;
  border-radius: 999px;
  vertical-align: .2em;
  color: var(--muted);
  background: var(--inset);
  border: 1px solid var(--line);
}

/* The grid. Columns appear as the width allows -- one on a phone, up to four
   on a wide monitor -- and dense packing back-fills the holes a two-column
   card would otherwise leave. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  grid-auto-flow: row dense;
  gap: 1rem;
  align-items: stretch;
}

@media (min-width: 50rem) {
  .grid > .span2 { grid-column: span 2; }
}
.grid > .wide { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ boxes */

.box {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.box.danger { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }

.box-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.box-head h2 {
  margin: 0;
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .01em;
  overflow-wrap: anywhere;
}
.box-head h2 a { color: var(--fg); text-decoration: none; }
.box-head h2 a:hover { color: var(--accent); }

.box-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  padding: 1rem 1.1rem 1.1rem;
  min-width: 0;
}
/* The control a card exists for sits on its bottom edge, so buttons line up
   across a row of cards whatever the length of the text above them. */
.box-body > :last-child { margin-top: auto; }
.box-body > p { margin: 0; }

.box.flush .box-body { padding: 0; gap: 0; }
.box.flush table { border: none; border-radius: 0 0 12px 12px; }

.desc { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.desc.caution { color: var(--warn); }

.box.message, .box.auth {
  max-width: 44rem;
  margin: 2rem auto;
  padding: 1.6rem 1.6rem 1.4rem;
  align-items: stretch;
  gap: .8rem;
}
.box.auth { max-width: 24rem; }
.message-ico { align-self: center; }
.box.message h1, .box.auth h1 { margin: 0; text-align: center; font-size: 1.35rem; }
.box.message > p { margin: 0; }
.box.message .links { display: flex; flex-wrap: wrap; gap: 1.2rem; justify-content: center; }
.box.message .links a { display: inline-flex; align-items: center; gap: .35rem; }

/* Dashboard site cards */
.box.site.off { opacity: .75; }
.meta { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .88rem; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }
.manage { align-self: flex-start; }
.new-site { border-style: dashed; }

.subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: .8rem;
}
.sub {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--inset);
  padding: .9rem 1rem;
}
.file-line { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: 0; }

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .12rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 28%, transparent);
  white-space: nowrap;
}
.badge .icon { width: .85rem; height: .85rem; }

.status { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; }

p.error, p.ok, p.warn, p.note {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: .6rem .8rem;
  background: var(--card);
  margin: 0 0 1rem;
}
.box p.error, .box p.ok, .box p.warn { margin: 0; }
p.error .icon, p.ok .icon, p.warn .icon, p.note .icon { margin-top: .15em; }
p.note { color: var(--muted); }

/* ----------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}
th, td { text-align: left; padding: .55rem 1.1rem; border-bottom: 1px solid var(--line); }
thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
tbody tr:last-child td, table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

table.kv th { width: 11rem; color: var(--muted); font-weight: 500; }
table.kv td { overflow-wrap: anywhere; }

table.files td { white-space: nowrap; }
table.files a.entry { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
table.files a.entry:hover { text-decoration: underline; }
.i-dir  { color: var(--amber); }
.i-link { color: var(--violet); }
.i-file { color: var(--muted); }

@media (max-width: 34rem) {
  table.kv th, table.kv td { display: block; width: auto; border: none; padding: .15rem 1.1rem; }
  table.kv th { padding-top: .65rem; font-size: .8rem; }
  table.kv tr { display: block; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
  table.kv tr:last-child { border-bottom: none; }
}

/* -------------------------------------------------------------------- pre */

pre {
  margin: 0;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .8rem;
  overflow-x: auto;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .8rem;
  white-space: pre-wrap;
  word-break: break-word;
}
pre.log { max-height: 22rem; overflow-y: auto; }

/* ------------------------------------------------------------------ forms */

form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: .7rem; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; }
.row .grow { flex: 1 1 10rem; }
.row .port { flex: 0 1 6.5rem; }

label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; }
label.check { flex-direction: row; align-items: flex-start; gap: .45rem; }
label.check input { margin: .2rem 0 0; flex: none; }

input[type=text], input[type=password], input:not([type]), textarea {
  padding: .5rem .65rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--inset);
  color: var(--fg);
  font: inherit;
  width: 100%;
  min-width: 0;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type=file] { font: inherit; font-size: .85rem; max-width: 100%; }
input[type=checkbox] { accent-color: var(--accent); }

textarea.editor {
  font-family: ui-monospace, Menlo, monospace;
  font-size: .82rem;
  line-height: 1.45;
  padding: .7rem;
  background: var(--inset);
  resize: vertical;
}

button, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  align-self: flex-start;
  padding: .48rem .9rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: .9rem;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
button:hover, a.button:hover { border-color: var(--muted); }
button .icon, a.button .icon { width: 1rem; height: 1rem; }

button.primary, a.button:not(.ghost) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
button.primary:hover, a.button:not(.ghost):hover { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }

button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }

button.ghost, a.button.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
button.block { align-self: stretch; }

.actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

@media (max-width: 34rem) {
  main { padding: 1rem 1rem 3rem; }
  header.top { padding: .6rem 1rem; }
  .brand .muted, .who { display: none; }
  .page-title h1 { font-size: 1.3rem; }
}
