:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --surface-hover: #222228;
  --border: #2a2a32;
  --text: #e8e8ec;
  --text-muted: #8888a0;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

main {
  flex: 1;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

footer a:first-child {
  color: var(--text);
  font-weight: 600;
}

.footer-logout {
  font-size: 0.85rem;
  color: var(--text-muted) !important;
}

.footer-logout:hover {
  color: var(--danger) !important;
}

/* ─── Category sections ─── */
.category-section {
  margin-bottom: 1rem;
}

.category-heading {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* ─── Site grid & cards ─── */
.sites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
}

.site-card {
  position: relative;
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  transition: border-color 0.2s, background 0.15s, box-shadow 0.2s, transform 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
}

.site-card:hover {
  border-color: var(--card-border, var(--accent));
  background: var(--surface-hover);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(-2px);
}

/* Local badge */
.local-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
  pointer-events: none;
}

/* ─── Site icons ─── */
.site-icon-wrap {
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-icon-emoji {
  font-size: 2.2rem;
  line-height: 1;
  display: block;
}

.site-icon-fa {
  font-size: 2.2rem;
  color: var(--card-border, var(--accent));
  display: block;
  line-height: 1;
}

.site-icon-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
}

.site-card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
  line-height: 1.3;
}

.site-card .description {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  min-height: 2em;
  flex: 1;
}

.site-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: auto;
}

.site-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  transition: border-color 0.15s, background 0.15s;
}

.site-links a[aria-disabled="true"] {
  opacity: 0.6;
  pointer-events: none;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}

.status-dot.checking {
  background: var(--text-muted);
  opacity: 0.7;
}

.status-dot.reachable {
  background: var(--success);
}

.status-dot.unreachable {
  background: var(--danger);
}

.site-links a:hover {
  border-color: var(--card-border, var(--accent));
  background: rgba(99, 102, 241, 0.08);
}

.site-links a.https {
  border-color: var(--success);
  color: var(--success);
}

.site-links a.https:hover {
  background: rgba(34, 197, 94, 0.1);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state p {
  margin: 0 0 1rem;
}

/* ─── Admin ─── */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.settings-section-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.text-muted-cell {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface-hover);
}

td .url-cell {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.color-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 4px;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* ─── Forms ─── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 480px;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.form-hint code {
  font-family: var(--font-mono);
  background: var(--border);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* Icon input with live preview */
.icon-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-input-row input {
  flex: 1;
}

.icon-preview {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  flex-shrink: 0;
}

/* Color picker row */
.color-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.color-input-row input[type="color"] {
  width: 44px;
  height: 38px;
  padding: 2px 4px;
  flex-shrink: 0;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.color-input-row input[type="text"] {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.validation-summary {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.validation-summary ul {
  margin: 0;
  padding-left: 1.25rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--accent);
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.message.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--success);
  color: var(--success);
}

.message.danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
}

/* ─── Login page ─── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.login-card {
  width: 100%;
  max-width: 360px !important;
}

.login-heading {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  text-align: center;
}
