:root {
  --brand: #6d28d9;
  --brand-ink: #ffffff;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --success-bg: #dcfce7;
  --success-ink: #166534;
  --error-bg: #fee2e2;
  --error-ink: #991b1b;
  --radius: 12px;
  --focus: #1d4ed8;
}
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
}
.skip-link:focus {
  position: static; background: var(--brand); color: #fff;
  padding: .5rem 1rem; text-decoration: none;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .9rem 1.5rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar .brand { font-weight: 800; color: var(--brand); text-decoration: none; font-size: 1.1rem; }
.topbar nav { margin-left: auto; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.topbar .inline { display: inline; }
.topbar .who { color: var(--muted); font-size: .85rem; }
.topbar button {
  border: 1px solid var(--border); background: transparent; cursor: pointer;
  padding: .4rem .7rem; border-radius: 8px;
}

/* ---------- Layout ---------- */
main {
  max-width: 860px; margin: 2rem auto; padding: 0 1rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 .4rem; }
.lead { color: var(--muted); margin: .25rem 0 .5rem; }

/* ---------- Messages ---------- */
.messages { list-style: none; max-width: 860px; margin: 0 auto; padding: 0 1rem; }
.msg { padding: .6rem 1rem; border-radius: 8px; margin-bottom: .5rem; }
.msg-error   { background: var(--error-bg); color: var(--error-ink); border: 1px solid #f3b1b1; }
.msg-success { background: var(--success-bg); color: var(--success-ink); border: 1px solid #a7e0b4; }
.msg-warning { background: #fffbeb; color: #92400e; border: 1px solid #f0d58a; }

/* ---------- Cards & buttons ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.section { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.section h2 { font-size: 1.05rem; margin-top: 0; }

a.btn, button.btn {
  display: inline-block; background: var(--brand); color: #fff;
  border: none; cursor: pointer; padding: .55rem 1rem; border-radius: 9px;
  text-decoration: none; font-weight: 600;
}
a.btn:hover, button.btn:hover { background: #5a1fb0; }
a.btn.ghost, button.btn.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
a.btn.danger, button.btn.danger {
  background: transparent; color: var(--danger); border: 1px solid #f1c1c1;
}
a.btn.danger:hover, button.btn.danger:hover { background: var(--danger-bg); }
.btn + .btn { margin-left: .4rem; }
button[type="submit"].ghost, button.btn.ghost { background: transparent; }

/* ---------- Forms ---------- */
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .3rem; }
input[type=text], input[type=number], input[type=email], input[type=password], select, textarea {
  padding: .5rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
.form-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.field-error { color: var(--error-ink); font-size: .85rem; margin-top: .2rem; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); }
thead th { background: #f1f5f9; font-weight: 700; }
tbody tr:nth-child(even) { background: #f8fafc; }

/* ---------- Board cards (list) ---------- */
.board-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.board-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.board-card .bc-title { font-size: 1.1rem; font-weight: 700; margin: 0; }
.board-card .bc-meta { color: var(--muted); font-size: .85rem; }
.board-card .bc-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.badge {
  display: inline-block; padding: .1rem .55rem; border-radius: 99px;
  font-size: .78rem; font-weight: 600;
}
.badge.owner  { background: #fde68a; color: #78350f; }
.badge.editor { background: #bfdbfe; color: #1e3a8a; }
.badge.viewer { background: #e2e8f0; color: #334155; }
.badge.active { background: #bbf7d0; color: #14532d; }
.badge.off    { background: #fecaca; color: #7f1d1d; }
.badge.archived { background: #e2e8f0; color: #475569; }

.empty-state {
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); padding: 2rem 1.5rem; text-align: center;
}
.empty-state .es-title { font-weight: 700; margin: .25rem 0; }
.empty-state .es-text { color: var(--muted); }

.guestlink-box {
  display: flex; gap: .4rem; margin: .5rem 0;
}
input[readonly].guestlink-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f1f5f9; color: var(--text); width: 100%;
}
.copy-hint { font-size: .85rem; color: var(--success-ink); display: none; }
.copy-hint.show { display: inline; }

.info-callout {
  border-left: 4px solid #d97706; background: #fffbeb; padding: .8rem 1rem; border-radius: 8px;
}
.warn { border-left: 4px solid #d97706; background: #fffbeb; padding: .8rem 1rem; }
form.inline { display: inline; }

/* ---------- Responsive ---------- */
@media (min-width: 640px) {
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
@media (max-width: 520px) {
  main { padding: 0 .75rem; }
  .topbar { padding: .7rem .75rem; gap: .5rem; }
  .board-card { padding: .9rem; }
}