: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; }
.check--fixed { color: var(--muted); cursor: default; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .5rem; }
.inline-form { display: inline; }
.password-row { display: flex; gap: .5rem; }
.password-row .input { flex: 1; min-width: 0; }
.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); }

.team-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.25rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: inherit; text-decoration: none; font-size: .85rem; font-weight: 600; }
.chip:hover { border-color: #cfd2dc; }
.chip--active, .chip--active:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.board-group + .board-group { margin-top: 1.75rem; }
.board-group__title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .6rem; }

.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__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; }
.inline-title__button { background: none; border: 0; padding: 0 .2rem; margin: 0 -.2rem; border-radius: 6px; font: inherit; color: inherit; text-align: left; cursor: text; }
.inline-title__button:hover { background: rgba(0,0,0,.06); }
.inline-title > [hidden] { display: none; }
.inline-title__input { font-weight: 700; }
.inline-title__input--board { font-size: 1.2rem; padding: .2rem .5rem; min-width: 18rem; }
.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; }
.banner { position: relative; background: #fef9c3; border: 1px solid #fde68a; color: #713f12; padding: .5rem 2.25rem .5rem .9rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.banner__close { position: absolute; top: .3rem; right: .45rem; background: none; border: 0; padding: .1rem .35rem; font-size: 1.15rem; line-height: 1; color: inherit; cursor: pointer; opacity: .6; border-radius: 4px; }
.banner__close:hover { opacity: 1; background: #fde68a; }

.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: flex; gap: 1rem; align-items: flex-start; overflow-x: auto; padding-bottom: .75rem; scroll-snap-type: x proximity; }
.column { flex: 1 1 0; min-width: 240px; scroll-snap-align: start; }
@media (max-width: 640px) { .columns { flex-direction: column; overflow-x: visible; } .column { min-width: 0; width: 100%; } }
.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; gap: .25rem; padding: 0 .25rem; }
.column__header h2 { font-size: 1rem; display: flex; align-items: center; gap: .4rem; min-width: 0; white-space: nowrap; }
.column__heading { flex: 1 1 auto; min-width: 0; }
.column__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.column__heading .inline-title__input { width: 100%; }
.column__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--col); flex-shrink: 0; }
.column__header-right { display: inline-flex; align-items: center; gap: .1rem; flex-shrink: 0; }
.column__count { font-size: .8rem; color: var(--muted); background: var(--surface); border-radius: 999px; padding: .1rem .45rem; }
.column__eye { font-size: .95rem; padding: .1rem .2rem; }
.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--teal { --col: #14b8a6; }
.column--blue { --col: #3b82f6; }
.column--orange { --col: #f59e0b; }
.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: 2.5rem; flex: 1; }

.add-card__trigger { width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: .5rem .6rem; font: inherit; font-size: .9rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.add-card__row { display: flex; align-items: center; gap: .25rem; }
.add-card__row[hidden] { display: none; }
.add-card__row > .add-card__trigger { flex: 1; }
.add-card__import { width: auto; white-space: nowrap; list-style: none; }
.import-menu__body { width: 320px; max-width: calc(100vw - 2rem); }
.import-picker__source { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .5rem; }
.import-picker { display: flex; flex-direction: column; gap: .5rem; }
.import-picker__group { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; max-height: 30vh; overflow-y: auto; }
.import-picker__card { align-items: flex-start; white-space: pre-line; }
.import-picker__card input { margin-top: .2rem; flex-shrink: 0; }
.import-picker__empty { font-size: .85rem; padding: .2rem 0; }
.add-card__trigger:hover { background: rgba(0,0,0,.05); color: var(--text); }
.new-card { background: var(--surface); border-radius: 10px; padding: .5rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .4rem; border-left: 4px solid var(--col); }
.new-card[hidden] { display: none; }
.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-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: .25rem; flex-wrap: nowrap; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: .4rem; }
.card__author { font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__spacer { flex: 1 1 0; min-width: 0; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 6px; padding: .2rem .3rem; white-space: nowrap; flex-shrink: 0; 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; flex-shrink: 0; 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); }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: .3rem; }
.reaction { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--border); background: #f7f7fb; font: inherit; font-size: .85rem; cursor: pointer; color: var(--text); }
.reaction:hover { border-color: #cfd2dc; background: #eef0f6; }
.reaction--mine { border-color: var(--primary); background: rgba(91,91,214,.1); }
.reaction__count { font-size: .78rem; font-weight: 600; color: var(--muted); }
.reaction-picker { display: inline-block; }
.reaction-picker__body { left: auto; right: 0; width: 15.5rem; grid-template-columns: repeat(5, 1fr); }
.reaction-picker__emoji { background: none; border: 0; border-radius: 8px; padding: .3rem; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.reaction-picker__emoji:hover { background: #f3f4f8; }
.card[draggable] .card__edit { cursor: auto; }
