:root {
  --accent: #6965db;
  --accent-hover: #5753c9;
  --accent-soft: #eeedff;
  --text: #1b1b1f;
  --muted: #6b6b76;
  --bg: #f6f6f9;
  --card: #ffffff;
  --border: #e6e6ec;
  --danger: #e03131;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.btn:hover { background: #f1f1f5; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 15px;
}

.input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.error { min-height: 20px; margin: 8px 0 0; color: var(--danger); font-size: 14px; }

/* ---------- вход ---------- */

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.auth-card {
  width: min(380px, 100%);
  padding: 32px 28px 28px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
}

.logo img { width: 32px; height: 32px; }

.auth-card h1 { margin: 24px 0 4px; font-size: 18px; }
.auth-card .hint { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-card label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 20px; height: 42px; }

/* ---------- список досок ---------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
}

.user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin: 8px 0 20px;
}

.toolbar .input { max-width: 360px; }

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

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

.card:hover { border-color: #c9c7f5; box-shadow: 0 4px 16px rgba(105, 101, 219, .12); }

.card .name {
  margin-right: 60px;
  font-weight: 600;
  font-size: 15px;
  word-break: break-word;
}

.card .meta {
  margin-top: auto;
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.card .online { color: #2f9e44; }

.card .actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s;
}

.card:hover .actions, .card:focus-within .actions { opacity: 1; }

.card .actions button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.card .actions button:hover { background: #f1f1f5; color: var(--text); }

.card.new {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.empty { color: var(--muted); }

.panel {
  margin-top: 40px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.panel h2 { margin: 0 0 16px; font-size: 16px; }

.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users td { padding: 8px 4px; border-top: 1px solid var(--border); }
.users td:last-child { text-align: right; white-space: nowrap; }
.users .badge { margin-left: 6px; padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.users .badge.owner { background: #fff3bf; color: #b08000; }
.users .you { color: var(--muted); font-size: 13px; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.form-row .input { flex: 1 1 160px; width: auto; }
.form-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; }

dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}

dialog::backdrop { background: rgba(0, 0, 0, .3); }
dialog h2 { margin: 0 0 16px; font-size: 18px; }
dialog label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
