/* Colours. Dark mode is the default; <html data-theme="light"> switches
   to light mode. The server sets data-theme from the "theme" cookie,
   which the toggle in the header saves. */
:root {
  color-scheme: dark; /* dark form controls and scrollbars */
  --bg: #121212;
  --fg: #eeeeee;
  --muted: #aaaaaa;
  --accent: #58a6ff;
  --on-accent: #0d1117; /* text on accent-coloured buttons */
  --danger: #ff6b6b;
  --border: #333333;
  --surface: #1c1c1c;
  --error-bg: #3a1d1d;
  --success: #81c784;
  --success-bg: #1b2e1c;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #666666;
  --accent: #1f6feb;
  --on-accent: #ffffff;
  --danger: #c62828;
  --border: #dddddd;
  --surface: #f6f8fa;
  --error-bg: #fdecea;
  --success: #1b5e20;
  --success-bg: #e8f5e9;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
}

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

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px;
}

h1 { margin-top: 8px; }

.muted { color: var(--muted); }

.breadcrumb { margin: 0; font-size: 0.9em; }

.error {
  padding: 12px 16px;
  border-radius: 6px;
  background: var(--error-bg);
  color: var(--danger);
}

/* Buttons */

button, .button {
  display: inline-block;
  font: inherit;
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  cursor: pointer;
}

/* Light/dark toggle in the header: shows the sun in dark mode (click
   for light) and the moon in light mode (click for dark). */
button.theme-toggle {
  display: inline-flex;
  padding: 6px;
  background: none;
  color: var(--fg);
  border-radius: 999px;
}

button.theme-toggle:hover { background: var(--surface); }

.theme-toggle svg { width: 20px; height: 20px; }

.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 6px 12px;
}

button.link {
  background: none;
  color: var(--accent);
  padding: 0;
}

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

/* Forms */

form.inline { display: inline; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 500;
}

input, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}

td input { padding: 4px 8px; }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
}

/* Lists and tables */

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

.list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.list li form { margin-left: 8px; }

.tag {
  font-size: 0.8em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

/* Wide tables scroll sideways on phones instead of breaking the page. */
@media (max-width: 600px) {
  table { display: block; overflow-x: auto; }
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.card h2 { margin-top: 0; }

.actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.tag.danger {
  color: var(--danger);
  background: var(--error-bg);
}

.clock-result {
  padding: 16px;
  border-radius: 8px;
}

.clock-result.success {
  background: var(--success-bg);
  color: var(--success);
}

.clock-result h1 { margin: 0 0 8px; }

.display-link {
  word-break: break-all;
  padding: 12px;
  border-radius: 6px;
  background: var(--surface);
}

/* The QR screen at a Site: big, centred, nothing else. */

body.display {
  min-height: 100vh;
}

.display-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  max-width: none;
  text-align: center;
}

.display-main h1 { font-size: clamp(1.5rem, 5vw, 3rem); margin: 0; }

.display-hint { font-size: clamp(1rem, 2.5vw, 1.5rem); color: var(--muted); }

.display-clock { font-size: 1.25rem; color: var(--muted); }

/* Large enough to scan from arm's length, but fits any screen. */
.qr svg {
  display: block;
  width: min(70vh, 85vw);
  height: auto;
  border-radius: 8px;
}
