:root {
  --bg: #0b0d10;
  --surface: #12161b;
  --surface-2: #171c22;
  --line: #232a33;
  --line-soft: #1b2229;
  --text: #e9eef4;
  --muted: #8d9aa8;
  --blue: #3b82f6;
  --blue-deep: #1d4ed8;
  --blue-glow: rgba(59, 130, 246, 0.28);
  --green: #3ddc84;
  --radius: 16px;
  --max: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* A class-based display (e.g. .preview{display:flex}) beats the hidden attribute,
   which has no specificity. Make [hidden] always win. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* subtle blue wash so the board doesn't read as flat black */
  background-image:
    radial-gradient(900px 420px at 12% -8%, rgba(59, 130, 246, 0.13), transparent 62%),
    radial-gradient(760px 380px at 100% 0%, rgba(29, 78, 216, 0.10), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 22px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11, 13, 16, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16), 0 0 14px var(--blue-glow);
}
.brand-name { font-weight: 650; letter-spacing: -0.015em; font-size: 1.05rem; }
.brand-accent { color: var(--blue); }
.nav { display: flex; align-items: center; gap: 20px; font-size: 0.92rem; }
.nav a { color: var(--muted); text-decoration: none; transition: color 0.15s ease; }
.nav a:hover { color: var(--text); }
.lock { font-size: 0.85rem; opacity: 0.6; }

/* ---------- hero ---------- */
.hero { padding: 68px 0 34px; }
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(1.85rem, 4.6vw, 2.85rem);
  line-height: 1.12;
  letter-spacing: -0.03em;
  font-weight: 660;
}
.sub { margin: 0 0 26px; max-width: 54ch; color: var(--muted); font-size: 1.02rem; }
.br-desk { display: none; }
@media (min-width: 720px) { .br-desk { display: inline; } }

.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  display: inline-flex; align-items: baseline; gap: 7px;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 7px 15px; font-size: 0.85rem; color: var(--muted);
}
.stat b { color: var(--text); font-weight: 620; font-variant-numeric: tabular-nums; }
.stat.is-blue b { color: var(--blue); }

/* ---------- form panel ---------- */
.add { padding: 14px 0 44px; }
.panel {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 26px 24px 24px;
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.9);
}
.panel h2 { margin: 0 0 18px; font-size: 1.12rem; font-weight: 620; letter-spacing: -0.01em; }

.field { margin-bottom: 16px; flex: 1 1 220px; min-width: 0; }
.field label {
  display: block; margin-bottom: 7px;
  font-size: 0.8rem; font-weight: 560; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--muted);
}
.req { color: var(--blue); }
.opt { color: #5f6b78; font-weight: 500; text-transform: none; letter-spacing: 0; }

input[type="text"], select {
  width: 100%;
  background: #0d1116;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.98rem;
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}
input[type="text"]::placeholder { color: #55616e; }
input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.hint { margin: 7px 0 0; font-size: 0.79rem; color: #6c7885; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.field.who { flex: 0 1 220px; }

.money { position: relative; display: flex; align-items: center; }
.money span {
  position: absolute; left: 14px; color: var(--muted);
  font-size: 0.98rem; pointer-events: none;
}
.money input { padding-left: 28px; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-block;
  background: linear-gradient(180deg, #4a8df8, var(--blue-deep));
  color: #fff;
  border: 1px solid #2f6fe0;
  border-radius: 11px;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 590;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 10px 26px -14px var(--blue-glow);
  transition: transform 0.13s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: default; filter: none; }

.form-msg { margin: 14px 0 0; font-size: 0.88rem; }
.form-msg.is-err { color: #ff8f8f; }
.form-msg.is-ok { color: #6ee7a8; }

/* ---------- preview ---------- */
.preview {
  display: flex; gap: 16px;
  background: #0d1116;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 4px 0 18px;
}
.preview-img {
  flex: 0 0 168px; height: 118px;
  border-radius: 10px; overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: center;
}
.preview-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-img.noimg::after { content: attr(data-label); font-size: 0.72rem; color: #4d5865; }
.preview-body { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.preview-site { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--blue); }
.preview-title { font-weight: 590; font-size: 1rem; line-height: 1.3; }
.preview-desc {
  font-size: 0.84rem; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.preview.loading { opacity: 0.6; }

/* ---------- board ---------- */
.board { padding: 4px 0 60px; }
.board-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.board-head h2 { margin: 0; font-size: 1.14rem; font-weight: 620; letter-spacing: -0.01em; }
.sort { display: flex; align-items: center; gap: 9px; font-size: 0.82rem; color: var(--muted); }
.sort select { width: auto; padding: 8px 12px; font-size: 0.85rem; }

.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.card:hover { border-color: #2f3b48; transform: translateY(-2px); }

.card-img { height: 172px; background: var(--surface-2); overflow: hidden; display: block; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-img.placeholder {
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(135deg, rgba(59, 130, 246, 0.10), transparent 58%),
    var(--surface-2);
  color: #46525f; font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase;
}

.card-body { padding: 15px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-total {
  font-size: 1.28rem; font-weight: 660; letter-spacing: -0.025em;
  color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.card-total small { font-size: 0.7rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.card-beds {
  font-size: 0.74rem; color: #9fb0c0;
  background: #0f141a; border: 1px solid var(--line-soft);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.card-title { margin: 2px 0 0; font-size: 0.98rem; font-weight: 590; line-height: 1.32; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--blue); }
.card-site {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.055em; color: var(--blue);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-addr { font-size: 0.83rem; color: var(--muted); }
.card-note {
  font-size: 0.84rem; color: #b3c0cd;
  border-left: 2px solid rgba(59, 130, 246, 0.5);
  padding-left: 9px; margin-top: 2px;
}
.card-foot {
  margin-top: auto; padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line-soft); font-size: 0.74rem; color: #66727f;
}

/* ---------- voting ---------- */
.votes {
  margin: 12px 0 10px;
  padding: 11px 12px;
  background: #0d1116;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.vote-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.vote-tally {
  font-size: 0.84rem; font-weight: 650; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.vote-tally.is-prio { color: var(--green); }
.vote-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: #5f6b78; }

.seats { display: flex; gap: 6px; margin-bottom: 10px; }
.seat {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.71rem; font-weight: 650; line-height: 1;
}
.seat-empty { border: 1.5px dashed #333e4a; background: transparent; }
.seat-yes { background: rgba(40, 199, 120, 0.16); border: 1.5px solid rgba(40, 199, 120, 0.55); color: var(--green); }
.seat-no { background: rgba(255, 96, 96, 0.14); border: 1.5px solid rgba(255, 96, 96, 0.5); color: #ff8f8f; }
.seat-mine { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35); }

.vote-actions { display: flex; gap: 7px; }
.vote-btn {
  flex: 1;
  background: #131a21;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #b3c0cd;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 570;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.vote-btn:hover:not(:disabled) { border-color: #3a4757; color: var(--text); }
.vote-btn:disabled { opacity: 0.42; cursor: default; }
.vote-yes.is-active {
  background: rgba(40, 199, 120, 0.16);
  border-color: rgba(40, 199, 120, 0.6);
  color: var(--green);
}
.vote-no.is-active {
  background: rgba(255, 96, 96, 0.14);
  border-color: rgba(255, 96, 96, 0.55);
  color: #ff8f8f;
}
.vote-note { margin-top: 8px; font-size: 0.72rem; color: #5f6b78; }

/* ---------- priority treatment ---------- */
.card.is-priority {
  border-color: rgba(40, 199, 120, 0.42);
  box-shadow: 0 0 0 1px rgba(40, 199, 120, 0.12), 0 20px 50px -34px rgba(40, 199, 120, 0.5);
}
.card { transition: border-color 0.16s ease, transform 0.16s ease, box-shadow 0.2s ease, opacity 0.2s ease; }
.card-leaving { opacity: 0; transform: scale(0.97); }

.prio-ribbon {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(10, 30, 20, 0.88);
  border: 1px solid rgba(40, 199, 120, 0.55);
  color: var(--green);
  font-size: 0.67rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.prio-ribbon::before { content: "\2713"; font-size: 0.72rem; }

.nav-priority { position: relative; display: inline-flex; align-items: center; gap: 5px; }
.prio-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green); display: inline-block;
  box-shadow: 0 0 6px rgba(40, 199, 120, 0.6);
}
.nav-priority.is-active { color: var(--text); }

.hero-priority { padding-bottom: 26px; }
.prio-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(40, 199, 120, 0.12);
  border: 1px solid rgba(40, 199, 120, 0.42);
  color: var(--green);
  font-size: 0.72rem; font-weight: 620;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 999px; margin-bottom: 14px;
}
.hero-priority h1 { margin-bottom: 10px; }

.card-desc {
  margin: 2px 0 0; font-size: 0.84rem; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-open { color: var(--blue); text-decoration: none; font-weight: 560; }
.card-open:hover { text-decoration: underline; }
.card-del {
  background: none; border: 0; color: #66727f; cursor: pointer;
  font-family: inherit; font-size: 0.74rem; padding: 2px 4px; border-radius: 6px;
}
.card-del:hover { color: #ff8f8f; background: rgba(255, 90, 90, 0.08); }

.empty { color: var(--muted); font-size: 0.92rem; padding: 26px 0; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line-soft); padding: 22px 0 30px; }
.foot .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.foot { font-size: 0.78rem; color: #5f6b78; }
.foot-note { color: #4a5563; }

/* ---------- 404 ---------- */
.err { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.err-code { font-size: clamp(4rem, 18vw, 8rem); font-weight: 700; letter-spacing: -0.05em; color: #1e2733; line-height: 1; }
.err h1 { margin: 8px 0 6px; font-size: 1.3rem; font-weight: 620; }
.err p { margin: 0 0 22px; color: var(--muted); font-size: 0.92rem; }

@media (max-width: 560px) {
  .hero { padding: 44px 0 24px; }
  .panel { padding: 20px 16px; }
  .preview { flex-direction: column; gap: 12px; }
  .preview-img { flex: 0 0 auto; width: 100%; height: 148px; }
  .board-head { flex-direction: column; align-items: flex-start; }
}
