:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #667085;
  --line: #e3e6ea;
  --accent: #17aa65;
  --accent-text: #ffffff;
  --error: #c62828;
  --error-bg: #fdecea;
  --note-bg: #e8f5ee;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1b1e23;
    --text: #e6e8eb;
    --muted: #98a2b3;
    --line: #2c3138;
    --error: #ff8a80;
    --error-bg: #3a1f1f;
    --note-bg: #183326;
  }
}

* { box-sizing: border-box; }

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

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

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

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

.top nav { display: flex; align-items: center; gap: 16px; }
.top nav form { margin: 0; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 0 0 12px; }

.row { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.row:has(.icon) { justify-content: flex-start; }

.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.narrow { max-width: 420px; margin: 48px auto; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 24px; }
.site { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; margin: 0; }
.site:hover { border-color: var(--accent); }
.site img, .icon { border-radius: 50%; flex: none; }

label { display: block; margin-bottom: 12px; }
label.check { display: flex; gap: 8px; align-items: center; }
small { display: block; color: var(--muted); font-size: 13px; }

input, textarea, button, .button {
  font: inherit;
  color: inherit;
}

input:not([type=checkbox]):not([type=color]):not([type=file]), textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

input[readonly] { color: var(--muted); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=color] { display: block; width: 64px; height: 40px; margin-top: 4px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
input[type=file] { display: block; margin-top: 4px; max-width: 100%; }

fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 16px; padding: 12px; }
legend { padding: 0 6px; color: var(--muted); }
.colors { display: flex; gap: 24px; }

button, .button {
  display: inline-block;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
  text-decoration: none;
}

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

form.inline { display: flex; gap: 8px; flex-wrap: wrap; }
form.inline input { flex: 1 1 200px; margin: 0; }

.note { padding: 12px 16px; border-radius: 8px; background: var(--note-bg); }
.note.error { background: var(--error-bg); color: var(--error); }
.error-text { color: var(--error); font-size: 13px; }
.muted { color: var(--muted); }
.mono, code, pre { font-family: ui-monospace, Consolas, monospace; }
code { font-size: 14px; word-break: break-all; }
.secret { letter-spacing: 1px; }
.hidden { display: none; }

table.list { width: 100%; border-collapse: collapse; }
table.list td { padding: 8px 4px; border-top: 1px solid var(--line); }
table.list tr:first-child td { border-top: 0; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: var(--line); }
.badge.success { background: #d3f3e1; color: #0f6b3f; }
.badge.failed { background: var(--error-bg); color: var(--error); }
.badge.running, .badge.queued { background: #fff3cd; color: #7a5a00; }

pre {
  background: #0d1117;
  color: #d1d7e0;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  max-height: 70vh;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.qr { background: #fff; padding: 8px; border-radius: 8px; width: max-content; margin: 8px 0; }
.qr svg { display: block; }

@media (max-width: 520px) {
  main { padding: 12px; }
  .top nav { gap: 12px; }
}

select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea.mono { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
fieldset > p.muted { margin-top: 0; font-size: 14px; }
