:root {
  --ink: #0a0a0b;
  --text: #18181b;
  --muted: #6b6b76;
  --accent: #3f369b;
  --lavender: #cbc4ff;
  --lavender-soft: #efecff;
  --border: #e4e4ec;
  --surface: #f6f6f8;
  --card: #fff;
  --danger: #e5484d;
  --radius: 16px;
  --font: "Inter", "Geist", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 520px at 8% -8%, #e4defd 0%, transparent 60%),
    radial-gradient(700px 480px at 92% 4%, #ece9ff 0%, transparent 60%),
    #fbfbfe;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-weight: 500; letter-spacing: -0.035em; color: var(--ink); margin: 0; }
h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); line-height: 1.02; }
h2 { font-size: 1.75rem; line-height: 1.15; }

.accent { color: var(--accent); }
.dim { color: #8a8a93; }
.muted { color: var(--muted); margin: 6px 0 0; }
.lead { color: var(--muted); font-size: 1.125rem; max-width: 560px; margin: 20px 0 0; }

/* --- Buttons, inputs, tags --------------------------------------------- */

input, button { font: inherit; }

button {
  border: 0;
  border-radius: 12px;
  padding: 14px 22px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: default; }

button.link {
  background: none;
  color: var(--accent);
  padding: 0;
  font-weight: 500;
  border-radius: 0;
}

button.link:hover:not(:disabled) { transform: none; text-decoration: underline; }
button.link.danger { color: var(--danger); }

input {
  width: 100%;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #d9d9e3;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
}

input::placeholder { color: #9d9da8; }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--lavender-soft); }

input[type=file] { padding: 8px; border-style: dashed; color: var(--muted); font-size: 0.9rem; }

input[type=file]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 600 0.85rem var(--font);
  cursor: pointer;
}

.tag {
  display: inline-block;
  padding: 5px 10px;
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  font: 500 0.75rem/1.2 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}

.tag.soft { border-color: transparent; background: var(--lavender-soft); color: var(--accent); }
.tag.dark { border-color: #3a3a40; color: #b9b9c2; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 5px;
  border-radius: 12px;
  background: var(--lavender);
  color: var(--ink);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.badge-key { padding: 4px 8px; border-radius: 8px; background: #fff; font-weight: 500; }

.error {
  margin: 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fdecec;
  color: #b4232a;
  font-size: 0.925rem;
}

/* --- Layout -------------------------------------------------------------- */

.topbar, .hero, main { max-width: 1040px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.mark {
  width: 28px;
  height: 20px;
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 6px -6px 0 -3px var(--accent);
}

.who { display: flex; gap: 10px; align-items: center; }
.who form { margin: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.925rem;
}

.chip strong { color: var(--ink); font-weight: 600; }
.chip { padding: 8px 16px 8px 8px; line-height: 1.3; }
.chip .bubble { width: 40px; height: 40px; margin: 0; font-size: 0.95rem; }
.chip .link { font-size: 0.8rem; }

/* --- Avatar bubbles ------------------------------------------------------- */

.voters { display: flex; flex-wrap: wrap; align-items: center; margin-top: 10px; padding-left: 6px; }

.bubble {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  margin-left: -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: hsl(var(--h, 250) 55% 88%);
  color: hsl(var(--h, 250) 45% 28%);
  font: 600 0.75rem/1 var(--font);
  cursor: default;
  transition: transform 0.12s ease;
}

.bubble img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.bubble:hover, .bubble:focus-visible { z-index: 2; transform: translateY(-2px); outline: none; }
.bubble:focus-visible { box-shadow: 0 0 0 3px var(--lavender); }

.bubble::after {
  content: attr(data-name);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 240px;
  width: max-content;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font: 500 0.8rem/1.3 var(--font);
  white-space: normal;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.bubble:hover::after, .bubble:focus-visible::after { opacity: 1; }

.no-votes { display: inline-block; margin-top: 8px; color: var(--muted); font-size: 0.875rem; }

.optional { color: var(--muted); font-size: 0.85rem; }

.hero { padding-top: 72px; padding-bottom: 48px; }
.hero h1 { margin-top: 28px; }

main { display: grid; gap: 24px; padding-bottom: 80px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 1px 2px rgba(16, 16, 40, 0.04), 0 12px 40px -24px rgba(63, 54, 155, 0.25);
}

.section-head { display: grid; gap: 12px; justify-items: start; margin-bottom: 24px; }

/* --- Leaders (dark stats block) ------------------------------------------ */

.leaders {
  background: #000;
  color: #fff;
  border-radius: 24px;
  padding: 32px;
}

.leaders h2 { color: #fff; }
.leaders .dim { color: #8a8a93; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 24px; }

.stat { background: #151517; border-radius: 18px; padding: 24px; }

.big {
  margin: 14px 0 4px;
  font-size: clamp(3.5rem, 9vw, 5.5rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(180deg, #fff 35%, #c4b8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.big sup { font-size: 0.3em; letter-spacing: 0; margin-left: 6px; vertical-align: top; position: relative; top: 0.5em; }
.stat-label { color: #a5a5ae; font-size: 1.05rem; }

/* --- Add forms ------------------------------------------------------------ */

.add { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.add input[name=title] { flex: 1 1 220px; }
.add input[name=description] { flex: 2 1 300px; }
.add input[type=date] { flex: 0 1 240px; }
.add .file { flex: 1 1 320px; display: grid; gap: 4px; color: var(--muted); font-size: 0.85rem; }

/* --- Lists ---------------------------------------------------------------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.list li:hover { border-color: #cfcadf; box-shadow: 0 8px 24px -16px rgba(63, 54, 155, 0.35); }
.list li.empty { justify-content: center; color: var(--muted); background: var(--surface); border-style: dashed; }
.list li.past { opacity: 0.55; }

.vote {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 92px;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: 500 0.72rem/1.2 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.vote .count { font: 500 1.6rem/1 var(--font); letter-spacing: -0.03em; }
.vote.on { background: var(--ink); color: #fff; }

.photo { flex: 0 0 auto; }
.photo img { display: block; width: 132px; height: 96px; object-fit: cover; border-radius: 12px; }

.body { flex: 1; min-width: 0; }
.title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--ink); font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.details { margin-top: 4px; color: var(--text); overflow-wrap: anywhere; }
.meta { margin-top: 8px; color: var(--muted); font-size: 0.875rem; }

.actions { display: grid; gap: 6px; justify-items: end; font-size: 0.875rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

/* --- Sign-in page ----------------------------------------------------------- */

body.login { min-height: 100vh; padding: 24px; display: grid; place-items: center; }

.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 1160px;
  min-height: min(760px, calc(100vh - 48px));
  border-radius: 28px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 24px 80px -32px rgba(30, 24, 90, 0.35);
}

.login-intro { display: flex; flex-direction: column; gap: 28px; padding: 48px 56px; }
.login-intro h1 { font-size: clamp(2.2rem, 4.5vw, 3.6rem); }
.login-intro .lead { margin: 0; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }

.checks li {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.checks li::before { content: "✓"; color: var(--accent); font-weight: 600; }

.note { display: grid; gap: 14px; justify-items: start; margin-top: auto; padding: 28px; border-radius: 20px; background: var(--surface); }
.note p { margin: 0; color: var(--muted); }

.login-panel {
  display: grid;
  place-items: center;
  padding: 48px;
  background: linear-gradient(180deg, #0c0d2e 0%, #2b2b7a 45%, #6e5fb8 75%, #b49bd6 100%);
}

.login-card {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 440px;
  padding: 40px;
  border-radius: 24px;
  background: #fff;
}

.login-card label { display: grid; gap: 10px; color: var(--ink); font-size: 1rem; }
.login-card button { width: 100%; margin-top: 6px; padding: 16px; }

/* --- Admin ---------------------------------------------------------------------- */

a.btn-outline, .btn-outline {
  display: inline-block;
  border: 1.5px solid var(--ink);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.btn-small { padding: 8px 14px; border-radius: 10px; font-size: 0.875rem; }
.btn-danger { background: var(--danger); }

.notice { margin: 0; padding: 12px 16px; border-radius: 12px; background: #e8f8ef; color: #12663f; }

.admin-login { max-width: 400px; box-shadow: 0 24px 80px -32px rgba(30, 24, 90, 0.35); }
.admin-login .brand { font-size: 1.25rem; }

.admin-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-row + .admin-row { margin-top: 12px; }
.admin-row.compact { grid-template-columns: 1fr auto; }
.admin-row form { margin: 0; }
.admin-row .meta { margin-top: 2px; }

.admin-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.admin-tools form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-tools input { width: auto; padding: 8px 12px; border-radius: 10px; font-size: 0.9rem; }
.admin-tools input[name=new_name] { width: 180px; }

.bubble.big-bubble { width: 48px; height: 48px; margin: 0; font-size: 1rem; }

.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.check input { width: auto; }

.danger-zone { border-color: #f1c0c3; }

/* --- Small screens ------------------------------------------------------------ */

@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro, .login-panel { padding: 32px 24px; }
  .note { display: none; }
}

@media (max-width: 600px) {
  .card, .leaders { padding: 22px; border-radius: 20px; }
  .hero { padding-top: 40px; }
  .list li { flex-wrap: wrap; }
  .photo { order: -1; flex-basis: 100%; }
  .photo img { width: 100%; height: 180px; }
  .actions { flex-basis: 100%; display: flex; justify-content: flex-end; gap: 16px; }
}
