:root {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --text: #1f2333;
  --muted: #6b7280;
  --border: #e3e5ec;
  --primary: #5b5bd6;
  --primary-dark: #4747b8;
  --danger: #dc2626;
  --green: #10b981;
  --red: #f43f5e;
  --purple: #a855f7;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 12px rgba(20, 24, 40, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}
h1, h2 { margin: 0; font-weight: 700; }
h1 { font-size: 1.4rem; }
p { margin: 0 0 .5rem; }
a { color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--border); margin: .5rem 0; }
.muted { color: var(--muted); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .5rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar__nav { display: flex; gap: .5rem; align-items: center; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 800; text-decoration: none; color: var(--text); font-size: 1.05rem; }
.brand--big { font-size: 1.5rem; margin-bottom: .5rem; }
.brand__logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; font-size: 1.1rem; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #f7f7fb; border-color: #cfd2dc; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: rgba(0,0,0,.05); border-color: transparent; }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn--sm { padding: .35rem .65rem; font-size: .82rem; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.button_to { display: inline; margin: 0; }

.input {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: .95rem; background: var(--surface); color: var(--text); resize: vertical;
}
.input:focus { outline: 2px solid rgba(91, 91, 214, .35); border-color: var(--primary); }
.input--sm { padding: .35rem .6rem; font-size: .85rem; width: auto; }
.input--xs { width: 4.2rem; padding: .25rem .4rem; font-size: .85rem; }
select.input { appearance: auto; }

.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; border: 0; padding: 0; margin: 0; }
.field--inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; }
.field legend { font-weight: 600; padding: 0; margin-bottom: .3rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .9rem; cursor: pointer; padding: .2rem 0; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.inline-form { display: inline; }
.linkish { background: none; border: 0; padding: 0; font: inherit; font-size: .78rem; color: var(--muted); cursor: pointer; text-decoration: underline; }
.linkish:hover { color: var(--danger); }

/* ---------- Layout pages ---------- */
.main { padding: 1.25rem; }
.page { max-width: 960px; margin: 0 auto; }
.page--narrow { max-width: 560px; background: var(--surface); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.page--narrow h1 { margin-bottom: .25rem; }
.page__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

.board-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.board-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; }
.board-item__link { display: flex; flex-direction: column; gap: .15rem; text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.board-item__name { font-weight: 700; font-size: 1.05rem; }
.board-item__meta { color: var(--muted); font-size: .85rem; }
.board-item__context { color: var(--muted); font-size: .9rem; }
.board-item__actions { display: flex; gap: .35rem; align-items: center; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; }
.auth-main { width: 100%; max-width: 400px; padding: 1rem; }
.auth-card { background: var(--surface); padding: 2rem; border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Flash ---------- */
.flash { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 50; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); background: #1f2333; color: #fff; font-size: .9rem; }
.flash--alert { background: var(--danger); }
.auth-body .flash { position: static; transform: none; margin: 1rem auto 0; max-width: 400px; }

/* ---------- Modal ---------- */
.modal { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.25); width: min(420px, 92vw); }
.modal::backdrop { background: rgba(20, 24, 40, .5); backdrop-filter: blur(2px); }
.modal__body { padding: 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.modal__title { font-size: 1.25rem; }
.modal__actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- Board ---------- */
.board-page .main { padding: 1rem 1.25rem; }
.board__header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.board__title { display: flex; align-items: flex-start; gap: .5rem; }
.board__title h1 { font-size: 1.35rem; }
.board__context { color: var(--muted); font-size: .9rem; white-space: pre-line; }
.board__tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.votes-left { font-size: .85rem; background: var(--surface); border: 1px solid var(--border); padding: .35rem .65rem; border-radius: 999px; }
.votes-left--empty { color: var(--danger); border-color: #fecaca; }
.filter { width: 11rem; }
.banner { background: #fef9c3; border: 1px solid #fde68a; color: #713f12; padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: .6rem; min-width: 240px; display: flex; flex-direction: column; gap: .2rem; }
.menu__body--row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; width: 15rem; min-width: 0; left: 0; right: auto; }
.menu__body--row .btn { width: 100%; }
.menu__item { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .45rem .5rem; border-radius: 6px; font: inherit; font-size: .9rem; color: var(--text); text-decoration: none; cursor: pointer; }
.menu__item:hover { background: #f3f4f8; }
.menu__item--danger { color: var(--danger); }
.menu form.button_to { display: block; }

/* Timer */
.timer { display: inline-flex; align-items: center; gap: .25rem; }
.timer__display { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1rem; padding: .25rem .6rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); min-width: 4.4rem; text-align: center; }
.timer--running .timer__display { color: var(--primary); border-color: var(--primary); }
.timer--done .timer__display { color: #fff; background: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* Columns */
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
@media (max-width: 860px) { .columns { grid-template-columns: 1fr; } }
.column { background: #eaecf2; border-radius: 12px; padding: .75rem; min-height: 60vh; display: flex; flex-direction: column; gap: .6rem; }
.column__header { display: flex; align-items: center; justify-content: space-between; padding: 0 .25rem; }
.column__header h2 { font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.column__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--col); }
.column__header-right { display: inline-flex; align-items: center; gap: .25rem; }
.column__eye { font-size: .95rem; padding: .1rem .35rem; }
.column__eye--hidden { background: #fef9c3; }
.column--hidden .column__header h2 { opacity: .8; }
.menu__label { font-size: .8rem; color: var(--muted); padding: .2rem .1rem 0; }
.column__count { font-size: .8rem; color: var(--muted); background: var(--surface); border-radius: 999px; padding: .1rem .5rem; }
.column--green { --col: var(--green); }
.column--red { --col: var(--red); }
.column--purple { --col: var(--purple); }
.column__cards { display: flex; flex-direction: column; gap: .6rem; min-height: 4rem; flex: 1; padding-bottom: 2rem; }

.new-card { background: var(--surface); border-radius: 10px; padding: .5rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .4rem; border-top: 3px solid var(--col); }
.new-card__input { border: 0; padding: .3rem .4rem; resize: none; min-height: 2.6rem; }
.new-card__input:focus { outline: none; }
.new-card__actions { display: flex; justify-content: flex-end; gap: .4rem; }

/* Cards */
.card { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); border-left: 4px solid var(--col); cursor: grab; transition: transform .12s, box-shadow .12s; }
.card:active { cursor: grabbing; }
.card--dragging { opacity: .4; }
.card--merge-target { outline: 3px dashed var(--primary); outline-offset: 2px; transform: scale(1.02); }
.card--merging { opacity: .6; }
.card--filtered-out { display: none; }
.card-placeholder { height: 3rem; border: 2px dashed var(--primary); border-radius: 10px; background: rgba(91,91,214,.08); }
.card__body { padding: .6rem .7rem .4rem; display: flex; flex-direction: column; gap: .4rem; }
.card__text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.card__blur { display: block; color: transparent; text-shadow: 0 0 9px rgba(31,35,51,.55); user-select: none; font-size: .95rem; }
.card--hidden { cursor: default; }
.card__child { margin-top: .5rem; padding-top: .5rem; border-top: 1px dashed var(--border); }
.card__child-meta { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; margin-top: .15rem; }
.card--merged { border-left-width: 6px; }
.card__edit .input { font-size: .95rem; }
.card__footer { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: .4rem; }
.card__author { font-weight: 600; }
.card__spacer { flex: 1; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .4rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted); list-style: none; }
.icon-btn:hover { background: #f3f4f8; color: var(--text); }
.icon-btn--danger:hover { color: var(--danger); }
.icon-btn::-webkit-details-marker { display: none; }

.vote-group { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.vote-group--mine { border-color: var(--primary); background: rgba(91,91,214,.06); }
.vote-btn { background: none; border: 0; padding: .2rem .55rem; font: inherit; font-size: .85rem; cursor: pointer; color: var(--text); display: inline-flex; gap: .25rem; align-items: center; }
.vote-btn:hover:not([disabled]) { background: rgba(91,91,214,.12); }
.vote-btn[disabled] { cursor: not-allowed; opacity: .6; }
.vote-btn--minus { border-right: 1px solid var(--border); color: var(--muted); }
.vote-count { font-weight: 700; }
.vote-mine { font-size: .75rem; color: var(--primary); }

/* Comments */
.comments-toggle[aria-expanded="true"] { color: var(--primary); background: rgba(91,91,214,.08); }
.comments { padding: .35rem 0 .3rem; display: flex; flex-direction: column; gap: .5rem; border-top: 1px dashed var(--border); }
.comments[hidden] { display: none; }
.comment { background: #f7f7fb; border-radius: 8px; padding: .4rem .6rem; }
.comment__meta { display: flex; gap: .4rem; align-items: center; font-size: .78rem; }
.comment__meta .linkish { margin-left: auto; text-decoration: none; font-size: .9rem; }
.comment__body { margin: .15rem 0 0; font-size: .88rem; color: var(--text); white-space: pre-wrap; }
.comment-form .input { resize: none; }
.card[draggable] .comments__body, .card[draggable] .card__edit { cursor: auto; }
