/* Cravatar admin. Deliberately plain: this is a control room, not the product. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #17203a;
  --muted: #6b7590;
  --line: #e2e7f2;
  --brand: #1f6bff;
  --brand-ink: #ffffff;
  --danger: #d64545;
  --ok: #1f9d55;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06), 0 8px 24px rgba(23, 32, 58, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141f; --card: #171d2c; --ink: #e8ecf6; --muted: #9aa4bd;
    --line: #26304a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

/* .gate and .view set display, which would otherwise win over the hidden attribute. */
[hidden] { display: none !important; }

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

h1 { font-size: 17px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.who { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 12px; }

main { max-width: 1080px; margin: 0 auto; padding: 20px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 8px 16px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px;
}
.tab.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.view { display: none; }
.view.active { display: block; }

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

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.cards .card { margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 26px; font-variant-numeric: tabular-nums; }

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

.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.ranges { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--card); }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .empty { color: var(--muted); font-size: 13px; padding: 20px 0; text-align: center; }

/* ---- avatars */
.search {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 14px; min-width: 220px;
}
.avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.avatar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; text-align: center; position: relative;
}
.avatar.gone { opacity: .55; }
.avatar canvas { width: 100%; height: 190px; display: block; }
.avatar .name { font-weight: 600; margin-top: 6px; word-break: break-word; }
.avatar .meta { color: var(--muted); font-size: 12px; }
.avatar .actions { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.tag {
  position: absolute; top: 10px; left: 10px; font-size: 11px; border-radius: 999px;
  padding: 2px 8px; background: var(--line); color: var(--muted);
}
.tag.hidden { background: #ffe8b0; color: #7a5300; }
.tag.deleted { background: #ffd9d9; color: #8c1f1f; }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font: inherit; font-size: 13px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: default; }

/* ---- appearance */
.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.theme {
  border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; background: var(--card); padding: 0; text-align: left; font: inherit;
}
.theme.active { border-color: var(--brand); }
.theme .swatch { height: 96px; display: block; }
.theme .cap { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; }
.theme .live { color: var(--brand); font-size: 12px; font-weight: 600; }

/* ---- gate, toast, dialog */
.gate { display: grid; place-items: center; padding: 80px 20px; }
.gate-card { max-width: 420px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 20; font-size: 14px;
}

dialog {
  border: none; border-radius: var(--radius); padding: 0; background: var(--card);
  color: var(--ink); box-shadow: var(--shadow); max-width: 460px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(10, 14, 25, .45); }
.editor { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.editor label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.editor input[type=text], .editor input:not([type]) , .editor input[type=search] {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 15px;
}
.editor .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
.editor .preview { display: grid; place-items: center; background: var(--bg); border-radius: 10px; padding: 8px; }
.editor menu { display: flex; justify-content: flex-end; gap: 8px; margin: 0; padding: 0; }
.error { color: var(--danger); font-size: 13px; margin: 0; }
