:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --danger: #f87171;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 20px 12px;
}

.top h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

main { flex: 1; padding: 0 20px 8px; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 132px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: transform .12s ease, background .12s ease;
}

.card:active { transform: scale(.97); background: var(--surface-2); }

.card .dot {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: none;
}

.card .name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card .host {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.card .edit-tag {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  border: 2px dashed var(--muted);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: rgba(15, 23, 42, .72);
}

.empty {
  grid-column: 1 / -1;
  padding: 32px 8px;
  text-align: center;
  color: var(--muted);
}

.add {
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.add:active { background: var(--surface); }
.add-plus { font-size: 19px; line-height: 1; }

.foot { padding: 10px 20px 22px; }
.foot p { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }

/* buttons */
button { font: inherit; cursor: pointer; }

.ghost {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--text);
  font-weight: 550;
}

.ghost[aria-pressed="true"] { background: var(--surface-2); }

.primary {
  padding: 10px 18px;
  border-radius: 999px;
  border: 0;
  background: var(--text);
  color: var(--bg);
  font-weight: 650;
}

.danger {
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--danger);
  background: none;
  color: var(--danger);
  font-weight: 550;
}

/* dialog */
dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgba(2, 6, 23, .7); }

dialog h2 { margin: 0 0 16px; font-size: 19px; font-weight: 650; }

dialog label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

dialog input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

dialog input:focus-visible {
  outline: 2px solid var(--muted);
  outline-offset: 1px;
}

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 2px solid transparent;
  padding: 0;
}

.swatch[aria-checked="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}

dialog menu {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
}

.spacer { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
