:root {
  color-scheme: dark;
  --ink: #0b0614;
  --panel: #120a1e;
  --panel-2: #180e28;
  --card: #1a1030;
  --field: #0e0818;
  --paper: #f3eefc;
  --paper-dim: #d3c8ea;
  --muted: #9a8fb3;
  --violet: #a066ff;
  --violet-hi: #c79bff;
  --violet-deep: #6a2bd9;
  --pink: #e27bff;
  --green: #6ee7a0;
  --amber: #ffc861;
  --red: #ff6b8b;
  --line: rgba(199, 155, 255, .16);
  --mono: "DM Mono", monospace;
  --sans: "DM Sans", sans-serif;
  --display: "Space Grotesk", sans-serif;
  --side: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: radial-gradient(60% 50% at 80% 0%, rgba(106,43,217,.25), transparent 70%), var(--ink); color: var(--paper); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--display); letter-spacing: -.02em; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 10px; background: linear-gradient(135deg, var(--violet-deep), var(--violet) 60%, var(--pink)); color: white; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; box-shadow: 0 8px 22px -10px rgba(160,102,255,.9); transition: transform .2s, box-shadow .2s, opacity .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -10px rgba(199,155,255,.95); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: rgba(160,102,255,.08); border: 1px solid rgba(199,155,255,.3); box-shadow: none; }
.btn.ghost:hover { background: rgba(160,102,255,.18); }
.btn.danger { background: rgba(255,107,139,.12); border: 1px solid rgba(255,107,139,.4); color: #ffc2cf; box-shadow: none; }
.btn.small { padding: 7px 11px; font-size: 12px; border-radius: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transition: background .2s, color .2s, border-color .2s; }
.icon-btn:hover { background: rgba(160,102,255,.15); color: white; }
.icon-btn.danger:hover { background: rgba(255,107,139,.15); color: #ffc2cf; }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

input[type="text"], input[type="password"], input[type="date"], input[type="search"], textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); outline: none; transition: border-color .2s, box-shadow .2s; }
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(160,102,255,.2); }
input[type="date"] { color-scheme: dark; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--paper-dim); font-size: 12px; font-weight: 600; }
.hint { color: var(--muted); font-size: 12px; }
.error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }

@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Login / setup */
.screen-loading, .screen-auth { height: 100%; overflow: auto; }
.center-card { width: min(420px, calc(100% - 32px)); margin: 12vh auto 40px; padding: 36px 32px; border: 1px solid var(--line); border-radius: 24px; background: rgba(18,10,30,.85); backdrop-filter: blur(12px); box-shadow: 0 40px 90px -40px rgba(106,43,217,.9); text-align: center; animation: pop .4s ease; }
.auth-logo { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 0 20px rgba(160,102,255,.7)); animation: float 5s ease-in-out infinite; }
.center-card h1 { margin: 14px 0 6px; font-size: 26px; }
.center-card p { margin: 0 0 22px; color: var(--muted); }
.center-card form { display: grid; gap: 14px; text-align: left; }
.center-card .btn { width: 100%; padding: 13px; margin-top: 6px; }
.loading-card p { margin: 16px 0 0; }

/* App layout */
.screen-app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); height: 100%; }
.sidebar { display: flex; flex-direction: column; gap: 4px; min-height: 0; padding: 20px 14px; border-right: 1px solid var(--line); background: rgba(12,7,22,.7); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(160,102,255,.6)); }
.brand strong { display: block; font: 700 14px var(--display); letter-spacing: .08em; }
.brand small { display: block; color: var(--pink); font: 10px var(--mono); letter-spacing: .2em; }
.side-label { display: flex; align-items: center; justify-content: space-between; margin: 10px 8px 6px; color: var(--pink); font: 10px var(--mono); letter-spacing: .18em; text-transform: uppercase; }
.side-label .icon-btn { width: 24px; height: 24px; }
.board-list { display: grid; gap: 3px; overflow-y: auto; min-height: 0; }
.board-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--paper-dim); text-align: left; cursor: pointer; transition: background .2s, color .2s; }
.board-link:hover { background: rgba(160,102,255,.1); color: white; }
.board-link.is-active { border-color: rgba(199,155,255,.35); background: linear-gradient(135deg, rgba(106,43,217,.45), rgba(160,102,255,.18)); color: white; }
.board-link .dot { flex: none; width: 10px; height: 10px; border-radius: 3px; box-shadow: 0 0 10px currentColor; }
.board-link span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-link small { color: var(--muted); font: 11px var(--mono); }
.side-bottom { display: grid; gap: 4px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.side-bottom .who { padding: 4px 10px 8px; color: var(--muted); font-size: 12px; }
.side-bottom .who strong { display: block; color: var(--paper); font-size: 13px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.topbar h1 { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: 22px; }
.topbar h1 .dot { width: 12px; height: 12px; border-radius: 4px; box-shadow: 0 0 14px currentColor; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tools input[type="search"] { width: 210px; padding: 8px 12px; }
.tools select { width: auto; padding: 8px 10px; }
.chip-toggle { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--paper-dim); font-size: 12px; font-weight: 600; cursor: pointer; }
.chip-toggle[aria-pressed="true"] { border-color: var(--violet); background: rgba(160,102,255,.2); color: white; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 11px var(--mono); }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.live.is-off::before { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* Board */
.board { display: flex; flex: 1; align-items: flex-start; gap: 14px; min-height: 0; padding: 20px 24px 24px; overflow: auto; }
.column { display: flex; flex: none; flex-direction: column; width: 290px; max-height: 100%; border: 1px solid var(--line); border-radius: 16px; background: rgba(18,10,30,.72); }
.column-head { display: flex; align-items: center; gap: 8px; padding: 12px 10px 8px 14px; }
.column-head h2 { flex: 1; min-width: 0; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.column-head .count { padding: 1px 8px; border-radius: 999px; background: rgba(160,102,255,.15); color: var(--violet-hi); font: 11px var(--mono); }
.column-menu { position: relative; }
.menu { position: absolute; top: 34px; right: 0; z-index: 20; display: grid; min-width: 180px; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); box-shadow: 0 20px 40px -12px rgba(0,0,0,.7); animation: pop .15s ease; }
.menu button { padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--paper-dim); text-align: left; cursor: pointer; }
.menu button:hover { background: rgba(160,102,255,.15); color: white; }
.menu button.danger { color: #ffc2cf; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; padding: 4px 10px 8px; overflow-y: auto; }
.add-card { margin: 0 10px 10px; }
.add-card button.open { width: 100%; padding: 9px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; transition: color .2s, border-color .2s, background .2s; }
.add-card button.open:hover { border-color: var(--violet); background: rgba(160,102,255,.08); color: white; }
.add-card form { display: grid; gap: 8px; }
.add-card textarea { min-height: 64px; }
.add-card .row { display: flex; gap: 8px; }
.new-column { flex: none; width: 260px; }
.new-column > button { width: 100%; padding: 14px; border: 1px dashed var(--line); border-radius: 16px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.new-column > button:hover { border-color: var(--violet); color: white; }

.card { position: relative; padding: 11px 12px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: border-color .2s, box-shadow .2s, transform .2s; }
.card:hover { border-color: rgba(199,155,255,.45); box-shadow: 0 12px 26px -16px rgba(106,43,217,.9); }
.card:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.card.prio-urgent { border-left: 3px solid var(--red); }
.card.prio-high { border-left: 3px solid var(--amber); }
.card h3 { margin: 0; font: 600 14px/1.4 var(--sans); letter-spacing: 0; overflow-wrap: anywhere; }
.labels { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.label { padding: 2px 8px; border-radius: 999px; background: hsla(var(--h), 85%, 65%, .16); color: hsl(var(--h), 90%, 80%); font: 600 10px var(--mono); letter-spacing: .04em; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.card-meta:empty { display: none; }
.meta { display: inline-flex; align-items: center; gap: 4px; }
.meta svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.meta.overdue { color: var(--red); font-weight: 700; }
.meta.soon { color: var(--amber); }
.meta.complete { color: var(--green); }
.prio { padding: 1px 7px; border-radius: 6px; font: 600 10px var(--mono); text-transform: uppercase; letter-spacing: .05em; }
.prio.urgent { background: rgba(255,107,139,.18); color: #ffb1c2; }
.prio.high { background: rgba(255,200,97,.16); color: var(--amber); }
.prio.low { background: rgba(154,143,179,.14); color: var(--muted); }
.avatars { display: flex; margin-left: auto; }
.avatar { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: -6px; border: 2px solid var(--card); border-radius: 50%; background: hsl(var(--h), 60%, 45%); color: white; font: 700 10px var(--sans); text-transform: uppercase; }
.avatar:first-child { margin-left: 0; }

/* Dragging */
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: rotate(2.5deg) scale(1.03); box-shadow: 0 30px 60px -20px rgba(0,0,0,.8), 0 0 0 1px var(--violet); cursor: grabbing; opacity: .95; }
.drop-slot { flex: none; border: 2px dashed rgba(199,155,255,.55); border-radius: 12px; background: rgba(160,102,255,.08); }
.card.is-dragging { display: none; }
body.dragging, body.dragging * { cursor: grabbing !important; }
.column.is-target { border-color: rgba(199,155,255,.5); background: rgba(40,20,70,.72); }

/* Dialogs */
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: 6vh 16px 30px; overflow-y: auto; background: rgba(6,3,12,.72); backdrop-filter: blur(4px); }
.dialog { width: min(760px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: 0 40px 90px -30px rgba(0,0,0,.9); animation: pop .2s ease; }
.dialog.narrow { width: min(460px, 100%); }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.dialog-head h2 { flex: 1; font-size: 20px; }
.dialog-head .title-input { flex: 1; padding: 6px 10px; border-color: transparent; background: transparent; font: 600 20px var(--display); }
.dialog-head .title-input:hover { border-color: var(--line); }
.dialog-body { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 22px; }
.dialog-main, .dialog-side { display: grid; align-content: start; gap: 16px; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-foot .btn.danger { margin-right: auto; }
.stack { display: grid; gap: 14px; }
.section-title { margin: 0; color: var(--paper-dim); font-size: 12px; font-weight: 700; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--paper-dim); font-size: 12px; cursor: pointer; }
.person .avatar { width: 22px; height: 22px; margin: 0; border: 0; }
.person[aria-pressed="true"] { border-color: var(--violet); background: rgba(160,102,255,.2); color: white; }
.label-editor { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.label-editor .label { display: inline-flex; align-items: center; gap: 4px; padding-right: 4px; }
.label-editor .label button { width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; line-height: 1; cursor: pointer; }
.label-editor input { flex: 1; min-width: 120px; padding: 7px 10px; }
.checklist { display: grid; gap: 6px; }
.progress { height: 6px; border-radius: 999px; background: rgba(160,102,255,.12); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--pink)); transition: width .3s; }
.check-item { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 8px; border-radius: 8px; }
.check-item:hover { background: rgba(160,102,255,.08); }
.check-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--violet); }
.check-item span { flex: 1; overflow-wrap: anywhere; }
.check-item.done span { color: var(--muted); text-decoration: line-through; }
.check-add { display: flex; gap: 8px; }
.check-add input { padding: 7px 10px; }
.comments { display: grid; gap: 10px; }
.comment { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; }
.comment-head .avatar { width: 20px; height: 20px; margin: 0; border: 0; font-size: 9px; }
.comment-head time { color: var(--muted); font: 11px var(--mono); }
.comment-head .icon-btn { width: 24px; height: 24px; margin-left: auto; }
.comment p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: grid; gap: 8px; }
.comment-form textarea { min-height: 64px; }
.comment-form .btn { justify-self: end; }
.stamp { color: var(--muted); font-size: 11px; line-height: 1.6; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 28px; height: 28px; border: 2px solid transparent; border-radius: 8px; cursor: pointer; }
.swatch[aria-pressed="true"] { border-color: white; box-shadow: 0 0 0 2px var(--violet); }

/* Tables (users, backups) */
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px var(--mono); letter-spacing: .12em; text-align: left; text-transform: uppercase; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td:last-child { text-align: right; white-space: nowrap; }
.role { padding: 2px 8px; border-radius: 999px; background: rgba(160,102,255,.15); color: var(--violet-hi); font: 10px var(--mono); text-transform: uppercase; }
.empty { padding: 28px 10px; color: var(--muted); text-align: center; }
.empty-board { margin: auto; padding: 40px; color: var(--muted); text-align: center; }

.toast { position: fixed; bottom: 22px; left: 50%; z-index: 200; max-width: calc(100% - 32px); padding: 11px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); box-shadow: 0 20px 40px -15px rgba(0,0,0,.8); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .25s, transform .25s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: rgba(255,107,139,.5); color: #ffc2cf; }

.mobile-boards { display: none; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .screen-app { display: block; height: auto; min-height: 100%; }
  .sidebar { display: none; }
  .main { min-height: 100vh; }
  .mobile-boards { display: flex; gap: 8px; align-items: center; width: 100%; }
  .mobile-boards select { flex: 1; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 18px; }
  .tools { width: 100%; }
  .tools input[type="search"] { flex: 1; width: auto; min-width: 140px; }
  .board { padding: 16px; scroll-padding: 0 16px; scroll-snap-type: x mandatory; }
  .column { width: min(300px, 84vw); max-height: none; scroll-snap-align: start; }
  .dialog-body { grid-template-columns: 1fr; }
  .dialog { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
