:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --text: #2b2724;
  --muted: #6f6760;
  --line: #e6dfd5;
  --accent: #b5532c;
  --accent-text: #ffffff;
  --soft: #f3ece2;
  --problem: #9b2c1f;
  --ok: #2f6b3a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a18;
    --card: #282421;
    --text: #eee8e1;
    --muted: #a99f95;
    --line: #3b3531;
    --accent: #e0835a;
    --accent-text: #1d1a18;
    --soft: #322c28;
    --problem: #f08a7a;
    --ok: #8fd19e;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

body.wide main { max-width: 64rem; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 2rem 0 0.5rem; }

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

label { display: block; font-weight: 600; margin: 1rem 0 0.3rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--text);
}

input[type="checkbox"], input[type="radio"] { width: auto; margin-right: 0.4rem; }
label.check { font-weight: normal; display: flex; align-items: center; margin: 0.3rem 0; }

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border: 0;
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  cursor: pointer;
}

button.quiet {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
  font-weight: normal;
  padding: 0.3rem 0.8rem;
  margin: 0;
}

form.inline { display: inline; }

.hint { color: var(--muted); }
.small { color: var(--muted); font-size: 0.85rem; display: block; }
.problem { color: var(--problem); }
.ok { color: var(--ok); }

.box {
  background: var(--soft);
  border-radius: 0.7rem;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
.box p { margin: 0; }
.box .button { margin-top: 0.6rem; }

ul.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
ul.chips li, .chip {
  display: inline-block;
  background: var(--soft);
  border-radius: 1rem;
  padding: 0.15rem 0.7rem;
  font-size: 0.9rem;
}
.chip.pending { border: 1px dashed var(--muted); background: transparent; }

ul.devices { list-style: none; padding: 0; }
ul.devices li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.qr { background: #fff; padding: 0.5rem; border-radius: 0.5rem; width: min(18rem, 100%); margin: 1rem 0; }
.qr svg { display: block; width: 100%; height: auto; }
.link code { word-break: break-all; font-size: 0.85rem; }
.link + button.copy { margin: 0 0 1.5rem; }

/* The admin page */

nav { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin-bottom: 1.5rem; font-weight: 600; }
nav a { text-decoration: none; }
nav a.here { color: var(--text); }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
td form { display: inline; }
td button.quiet { font-size: 0.85rem; }

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.row > * { flex: 1 1 12rem; }
.row > button { flex: 0 0 auto; }

.muted { color: var(--muted); }
.ended { color: var(--muted); text-decoration: line-through; }

/* An owner's page: actions beside a name, and the rename fold-out */

ul.devices li > span:last-child { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: flex-end; align-items: center; }
summary { cursor: pointer; color: var(--accent); margin: 0.8rem 0 0.3rem; }
ul.devices li { flex-wrap: wrap; }
details.rename { flex-basis: 100%; }
details.rename summary { margin: 0; font-size: 0.85rem; }
details.rename form { margin-top: 0.2rem; }
details.rename button { margin-top: 0; }
