:root {
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f1effa;
  --text: #1b1b24;
  --muted: #6b6b7a;
  --line: #e6e4f0;
  --primary: #6d4aff;
  --primary-text: #ffffff;
  --danger: #d6293e;
  --warn: #b45309;
  --ok: #0f8a5f;
  --shadow: 0 1px 2px rgba(27, 27, 36, 0.06), 0 8px 24px rgba(27, 27, 36, 0.06);
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12111a;
    --surface: #1c1b27;
    --surface-2: #25243a;
    --text: #f0eff7;
    --muted: #9c9bb0;
    --line: #2f2e45;
    --primary: #8d70ff;
    --danger: #ff6b7d;
    --warn: #f5b25c;
    --ok: #3ccf91;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
.hidden { display: none; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; padding: 64px 16px; }
.center-text { text-align: center; }
.error { color: var(--danger); font-size: 14px; min-height: 0; }
.hint { color: var(--muted); font-size: 13px; }

/* Buttons and inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }

input[type='text'], input[type='email'], input[type='password'], input[type='date'], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #6d4aff, #e5389a); color: #fff; font-weight: 800; font-size: 28px;
}
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 16px; }
.top-actions { display: flex; gap: 8px; }

/* Board */
.board, .detail { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; min-height: 36px; cursor: pointer; font-size: 14px; }
.filter.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 14px; padding: 18px; padding-top: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; text-align: left; overflow: hidden; transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--accent, var(--primary)); }
.card:hover { transform: translateY(-2px); }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-title { flex: 1; min-width: 0; }
.card-title h2 { font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.tagline { color: var(--muted); font-size: 14px; }
.card-title .tagline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 380px) { .card-body { grid-template-columns: 1fr; } }
.mini { min-width: 0; }
.mini h3, .panel h3 { font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.count { font-weight: 500; letter-spacing: 0; text-transform: none; }
.empty { color: var(--muted); font-size: 13px; }
.more { color: var(--muted); font-size: 12px; margin-top: 2px; }
.mini-task { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; padding: 3px 0; cursor: pointer; }
.mini-task span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--accent, var(--primary)); flex: none; margin: 1px 0 0; cursor: pointer; }
.mini-row { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; }
.idea-latest { font-size: 14px; }
.avatars { display: flex; }
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; margin-right: -6px;
  background: color-mix(in srgb, var(--accent, var(--primary)) 22%, var(--surface)); color: var(--text); font-size: 11px; font-weight: 700; border: 2px solid var(--surface);
}
.row-item .avatar { margin-right: 0; width: 32px; height: 32px; border: none; }
.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto; }
.open-hint { color: var(--accent, var(--primary)); font-weight: 600; }
.add-card { align-items: center; justify-content: center; min-height: 220px; border-style: dashed; box-shadow: none; background: transparent; color: var(--muted); font-weight: 600; }
.add-card::before { display: none; }
.add-card .plus { font-size: 40px; line-height: 1; }

.logo {
  display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 12px; overflow: hidden;
  background: var(--accent, var(--primary)); color: #fff; font-weight: 800; font-size: 18px;
}
.logo.big { width: 72px; height: 72px; border-radius: 18px; font-size: 26px; }
.logo img { width: 100%; height: 100%; object-fit: contain; background: var(--surface); }

.chip { display: inline-block; flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-decoration: none; }
.chip.status-building { background: color-mix(in srgb, #6d4aff 16%, transparent); color: var(--primary); }
.chip.status-testing { background: color-mix(in srgb, #0ea5e9 18%, transparent); color: #0284c7; }
@media (prefers-color-scheme: dark) { .chip.status-testing { color: #5cc4f5; } }
.chip.status-live { background: color-mix(in srgb, #10b981 18%, transparent); color: var(--ok); }
.chip.status-idea { background: color-mix(in srgb, #f59e0b 20%, transparent); color: var(--warn); }
.chip.prio { background: color-mix(in srgb, #ef4444 16%, transparent); color: var(--danger); }
.chip.link { color: var(--primary); }
.due { flex: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.due.soon { background: color-mix(in srgb, #f59e0b 22%, transparent); color: var(--warn); }
.due.overdue { background: color-mix(in srgb, #ef4444 18%, transparent); color: var(--danger); }

.empty-state { text-align: center; padding: 64px 16px; display: grid; gap: 12px; justify-items: center; }
.empty-state h2 { font-size: 22px; }
.empty-state p { max-width: 460px; }

/* Detail */
.back { display: inline-block; margin-bottom: 12px; text-decoration: none; font-weight: 600; min-height: 32px; }
.detail-head {
  position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 16px; padding: 20px; padding-top: 26px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.detail-head::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--accent); }
.detail-title { flex: 1; min-width: 180px; }
.detail-title h1 { font-size: 26px; line-height: 1.15; overflow-wrap: anywhere; }
.head-actions { display: flex; gap: 8px; width: 100%; }
@media (min-width: 720px) { .head-actions { width: auto; } }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; display: grid; text-align: left; background: none; border: none; padding: 4px 0; cursor: pointer; min-height: 36px; }
.row-title { overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: 13px; }
.row-sub.clamp { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row-item.done .row-title { text-decoration: line-through; color: var(--muted); }
.quick { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.quick input[type='text'] { flex: 1 1 140px; }
.quick input[type='date'] { flex: 0 1 150px; }
.panel > .empty { margin: 4px 0 0; }

/* Dialogs and forms */
.dlg {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.dlg::backdrop { background: rgba(10, 10, 20, 0.55); }
.form { display: grid; gap: 14px; padding: 20px; }
.form h2 { font-size: 20px; }
.form h3 { font-size: 15px; margin-top: 8px; }
.field { display: grid; gap: 6px; font-size: 14px; }
.field > span { font-weight: 600; }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.actions.left { justify-content: flex-start; }
.actions.center { justify-content: center; }
.actions.spread { align-items: center; }
.logo-row { display: flex; align-items: center; gap: 16px; }
.logo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; background: var(--c); cursor: pointer; padding: 0; }
.swatch.on { border-color: var(--text); }
input[type='color'] { width: 40px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 0; }
.inline-form { display: flex; gap: 8px; }
.people-list .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); word-break: break-all; }
.setup { display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.tick { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none; font-weight: 700; font-size: 13px; }
.check.ok .tick { background: color-mix(in srgb, #10b981 22%, transparent); color: var(--ok); }
.check.bad .tick { background: color-mix(in srgb, #ef4444 20%, transparent); color: var(--danger); }
.check.warn .tick { background: var(--surface-2); color: var(--muted); }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); display: grid; gap: 14px; justify-items: center; }
.login-card h1 { font-size: 24px; }
.login-form { display: grid; gap: 12px; width: 100%; }
.backup { width: 100%; font-size: 14px; color: var(--muted); }
.backup summary { cursor: pointer; text-align: center; min-height: 32px; }
.backup .login-form { margin-top: 10px; }

#toast {
  white-space: pre-line;
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: min(92vw, 440px); font-size: 14px; z-index: 100;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* Feedback, files and sharing */
.chip.fb-bug { background: color-mix(in srgb, #ef4444 16%, transparent); color: var(--danger); }
.chip.fb-suggestion { background: color-mix(in srgb, #6d4aff 16%, transparent); color: var(--primary); }
.chip.fb-question { background: color-mix(in srgb, #f59e0b 20%, transparent); color: var(--warn); }
.chip.fb-praise { background: color-mix(in srgb, #10b981 18%, transparent); color: var(--ok); }
.quick-select { flex: 0 1 140px; width: auto; }
.shared-with { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.shared-with .avatars .avatar { border-color: var(--surface); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 8px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb a { display: block; aspect-ratio: 1; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-name { display: block; padding: 4px 6px; font-size: 11px; color: var(--muted); }
.icon-btn { flex: none; width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }
.thumb .icon-btn { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; font-size: 18px; background: rgba(0, 0, 0, 0.55); color: #fff; }
.file-ext { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 700; }
.file-link { text-decoration: none; color: inherit; }
.panel-files.drop { outline: 2px dashed var(--primary); outline-offset: -4px; background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.panel-files .hint { margin-top: 8px; }

/* ---------- workspace look ---------- */
:root { --bg: #f5f6f8; --line: #e4e6eb; --radius: 14px; --shadow: 0 1px 2px rgba(20, 21, 26, 0.04); --surface-2: #f0f1f5; }
@media (prefers-color-scheme: dark) { :root { --bg: #101116; --surface: #181a21; --surface-2: #22242d; --line: #2a2d38; } }
body { letter-spacing: -0.005em; }
h1, h2, h3 { letter-spacing: -0.02em; }

/* header */
.detail-head { padding: 22px 24px; margin-bottom: 20px; box-shadow: var(--shadow); gap: 18px; }
.detail-head::before { display: none; }
.detail-title h1 { font-size: 28px; font-weight: 700; }
.tagline { color: var(--muted); margin-top: 2px; }
.logo.big { width: 64px; height: 64px; border-radius: 16px; }

/* two column workspace: work on the left, context on the right */
.panels { grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.col { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (max-width: 860px) { .panels { grid-template-columns: 1fr; } }

/* panels */
.panel { padding: 18px 20px 14px; box-shadow: var(--shadow); }
.panel h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 650; text-transform: none; letter-spacing: -0.01em; color: var(--text); }
.panel h3 .count { margin-left: 0; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.panel h3 .count:empty { display: none; }
.panel > .empty { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.row-item { padding: 8px 6px; margin: 0 -6px; border-radius: 10px; border-bottom: none; }
.row-item + .row-item { border-top: 1px solid var(--line); border-top-left-radius: 0; border-top-right-radius: 0; }
.row-item:hover { background: var(--surface-2); }
.row-item + .row-item:hover { border-radius: 10px; }
.row-title { font-weight: 550; }

/* add rows: hidden until wanted */
.quick[hidden], .add-ghost[hidden] { display: none; }
.add-ghost {
  display: flex; align-items: center; width: 100%; margin-top: 6px; padding: 9px 8px; margin-left: -2px; border: none; border-radius: 10px;
  background: none; color: var(--muted); font-size: 14px; font-weight: 550; text-align: left; cursor: pointer;
}
.add-ghost:hover, .add-ghost:focus-visible { color: var(--primary); background: var(--surface-2); }

/* add forms */
.quick { margin-top: 10px; }
.quick-multi { flex-direction: column; align-items: stretch; gap: 8px; }
.quick-multi textarea { width: 100%; height: 84px; min-height: 84px; padding: 11px 14px; line-height: 1.45; }
.panel-notes .quick-multi textarea, .panel-feedback .quick-multi textarea { height: 120px; }
.quick-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.quick-row .grow { flex: 1 1 0; }
.quick-row .quick-select { flex: none; width: auto; min-height: 36px; padding: 6px 28px 6px 10px; font-size: 14px; }
.quick-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.quick-label select, .quick-label input { min-height: 36px; padding: 6px 10px; font-size: 14px; width: auto; max-width: 150px; }

/* assignees and people */
.avatar.assignee { margin-right: 0; width: 26px; height: 26px; border: none; }
.mini-task span.mini-who { display: inline-grid; -webkit-line-clamp: unset; overflow: visible; }
.mini-who { margin-left: auto; flex: none; font-size: 10px; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; place-items: center; background: color-mix(in srgb, var(--accent, var(--primary)) 22%, var(--surface)); }
.row-main.static { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: default; }
.row-sub.clamp { -webkit-line-clamp: 4; }
.panel-notes .row-sub.clamp, .panel-feedback .row-sub.clamp { -webkit-line-clamp: 6; }
.panel-people .quick { align-items: center; }

/* dashboard cards */
.card { box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent, var(--primary)); transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover { transition: none; transform: none; } }

/* reorder cards */
.board-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.board-bar .filters { margin: 0; }
.card.reordering { cursor: grab; border-style: dashed; }
.card.reordering:hover { transform: none; }
.card.dragging { opacity: .45; }
.card.drop-target { border-color: var(--primary); border-style: solid; background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.reorder-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.reorder-bar .hint { margin: 0; font-size: 12px; text-align: center; }
.reorder-bar .btn[disabled] { opacity: .35; cursor: default; }

/* greeting */
.greeting { margin-left: auto; margin-right: 14px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; text-align: right; }
.greet-main { font-size: 14px; font-weight: 650; }
.greet-sub { font-size: 12px; color: var(--primary); font-weight: 600; }
@media (max-width: 700px) { .greet-sub { display: none; } .greet-main { font-size: 13px; } }
@media (max-width: 480px) { .greeting { display: none; } }

/* board sections */
.group { margin-bottom: 28px; }
.group-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.group-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.group-head .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.group-tools { margin-left: auto; display: flex; gap: 4px; }
.group-tools .btn[disabled] { opacity: .35; }

/* open tasks overview on the board */
.overview { margin-bottom: 24px; }
.overview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; margin-bottom: 8px; }
.overview-head h3 { margin: 0; }
.overview-head .filters { margin: 0; }
.card-tag { display: inline-flex; align-items: center; gap: 6px; max-width: 150px; flex: none; font-size: 12px; font-weight: 600; color: var(--text); text-decoration: none; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--surface-2); }
.card-tag .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, var(--primary)); flex: none; }
.card-tag:hover { background: color-mix(in srgb, var(--accent, var(--primary)) 14%, var(--surface)); }
@media (max-width: 560px) { .card-tag { max-width: 96px; } }
