:root {
  --bg: #f6f5f9; --panel: #ecebf2; --card: #ffffff; --line: #e2e0ea; --text: #1c1b22; --soft: #62607a; --faint: #9896ab;
  --accent: #5b5bd6; --accent-2: #4a4ac4; --accent-soft: #ececfb; --danger: #d6455b; --ok: #1f9d6b;
  --shadow: 0 1px 2px rgba(28, 27, 34, .06), 0 1px 1px rgba(28, 27, 34, .04); --shadow-lg: 0 18px 50px rgba(28, 27, 34, .22);
  --l-green: #3fb27f; --l-yellow: #e2b93b; --l-orange: #ef8b3a; --l-red: #e5596b; --l-purple: #9b6fe0; --l-blue: #4b94e6;
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #131218; --panel: #1c1b23; --card: #26252f; --line: #33313f; --text: #eeedf3; --soft: #a8a6ba; --faint: #73718a;
  --accent: #7c7cf0; --accent-2: #9090f5; --accent-soft: #2b2a48; --danger: #ef6b7f; --ok: #48c592;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6); color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #131218; --panel: #1c1b23; --card: #26252f; --line: #33313f; --text: #eeedf3; --soft: #a8a6ba; --faint: #73718a;
  --accent: #7c7cf0; --accent-2: #9090f5; --accent-soft: #2b2a48; --danger: #ef6b7f; --ok: #48c592;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { height: 100%; display: flex; flex-direction: column; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .12s, background .15s, border-color .15s, opacity .15s; white-space: nowrap; }
.btn:hover { border-color: var(--faint); } .btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: none; border-color: transparent; box-shadow: none; color: var(--soft); } .btn.ghost:hover { background: var(--panel); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.icon { width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--soft); transition: background .15s, color .15s; flex: none; }
.icon:hover { background: var(--panel); color: var(--text); }
.icon svg, .btn svg { width: 18px; height: 18px; flex: none; }
.input { width: 100%; height: 42px; padding: 0 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 13px; resize: none; display: block; line-height: 1.45; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }
select.input { height: 34px; padding: 0 8px; width: auto; font-size: 13px; }
.muted { color: var(--soft); } .tiny { font-size: 12.5px; color: var(--faint); }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: -.6px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.brand b { color: var(--accent); font-weight: 800; }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11.5px; font-weight: 700; flex: none; letter-spacing: 0; }
.avatar.s { width: 22px; height: 22px; font-size: 10px; }
.avatar.ghost { opacity: .6; }
.stack { display: inline-flex; } .stack .avatar { box-shadow: 0 0 0 2px var(--bg); margin-left: -6px; } .stack .avatar:first-child { margin-left: 0; }

/* ---------- sign-in */
.center { flex: 1; display: grid; place-items: center; padding: 24px 18px; }
.signin { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px 26px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.signin h1 { font-size: 22px; letter-spacing: -.4px; margin-top: 8px; }
.signin .btn { height: 44px; font-size: 15px; }
.code { text-align: center; font-size: 22px; letter-spacing: 8px; font-weight: 700; height: 52px; }
.err { color: var(--danger); font-size: 13.5px; min-height: 0; }

/* ---------- top bar */
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; min-height: 56px; flex: none; }
.top .grow { flex: 1; min-width: 0; }
.top .title { font-weight: 700; font-size: 17px; letter-spacing: -.3px; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 8px; margin-left: -4px; min-width: 60px; max-width: 100%; outline: none; text-overflow: ellipsis; }
.top .title:hover:not([readonly]) { background: var(--panel); } .top .title:focus { background: var(--card); border-color: var(--accent); }

/* ---------- home */
.home { flex: 1; overflow: auto; padding: 14px 16px 60px; }
.home .inner { max-width: 980px; margin: 0 auto; }
.home h2 { font-size: 22px; letter-spacing: -.4px; margin: 14px 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; text-align: left; min-height: 104px; padding: 15px 16px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s, border-color .15s, box-shadow .15s; color: var(--text); }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.tile .name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; overflow-wrap: anywhere; }
.tile.new { border-style: dashed; background: none; box-shadow: none; align-items: center; justify-content: center; color: var(--soft); font-weight: 600; flex-direction: row; gap: 8px; }
.tile.new:hover { color: var(--accent); }
.empty { text-align: center; color: var(--soft); padding: 40px 10px 24px; }

/* ---------- board */
.board { flex: 1; display: flex; align-items: flex-start; gap: 12px; overflow-x: auto; overflow-y: hidden; padding: 4px 16px 16px; scroll-padding: 0 16px; }
.list { flex: none; width: 284px; max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 14px; }
.list-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 6px 14px; cursor: grab; }
.list-head .name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 5px; margin-left: -6px; outline: none; }
.list-head .name:focus { background: var(--card); border-color: var(--accent); cursor: text; }
.list-head .name[readonly] { cursor: inherit; }
.list-head .count { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.list-head .icon { width: 28px; height: 28px; }
.cards { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 8px 2px; min-height: 40px; display: flex; flex-direction: column; gap: 7px; scrollbar-width: thin; }
.card { background: var(--card); border-radius: 10px; padding: 9px 11px 9px; box-shadow: var(--shadow); border: 1px solid transparent; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: border-color .12s, box-shadow .12s; flex: none; }
.card:hover { border-color: var(--accent); }
.card .t { overflow-wrap: anywhere; font-size: 14.5px; }
.card .labels { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.card .labels i { width: 34px; height: 6px; border-radius: 3px; }
.card .meta { display: flex; align-items: center; gap: 10px; margin-top: 7px; color: var(--faint); font-size: 12px; min-height: 22px; }
.card .meta span { display: inline-flex; align-items: center; gap: 3px; }
.card .meta svg { width: 13px; height: 13px; }
.card .meta .due.late { color: var(--danger); font-weight: 600; }
.card .meta .stack { margin-left: auto; } .card .meta .stack .avatar { box-shadow: 0 0 0 2px var(--card); }
.more { margin: 2px 0 4px; font-size: 13px; color: var(--soft); padding: 7px; border-radius: 8px; text-align: center; } .more:hover { background: var(--card); }
.list-foot { padding: 6px 8px 8px; }
.add { width: 100%; text-align: left; padding: 8px 9px; border-radius: 9px; color: var(--soft); font-size: 14px; display: flex; gap: 6px; align-items: center; transition: background .15s, color .15s; }
.add:hover { background: var(--card); color: var(--text); } .add svg { width: 16px; height: 16px; }
.addbox { display: grid; gap: 7px; } .addbox .row { display: flex; gap: 6px; align-items: center; }
.list.new { background: none; } .list.new .add { background: var(--panel); padding: 12px 14px; border-radius: 14px; } .list.new .addbox { background: var(--panel); padding: 8px; border-radius: 14px; }
.sortable-ghost { opacity: .35; }
.card.sortable-ghost { background: var(--accent-soft); box-shadow: none; } .card.sortable-ghost > * { visibility: hidden; }
.sortable-drag { transform: rotate(2.5deg); box-shadow: var(--shadow-lg) !important; opacity: 1 !important; cursor: grabbing; }
.card.sortable-chosen { border-color: var(--accent); }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* ---------- layers: dialog, sheet, menu */
#layer:empty { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(20, 19, 28, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px 14px; overflow-y: auto; z-index: 20; animation: fade .16s; backdrop-filter: blur(2px); }
.dialog { width: 100%; max-width: 440px; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px; animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); position: relative; }
.dialog.wide { max-width: 720px; }
.dialog h3 { font-size: 18px; letter-spacing: -.3px; margin-bottom: 14px; padding-right: 36px; }
.dialog .x { position: absolute; top: 12px; right: 12px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; } .field > span { font-size: 13px; font-weight: 600; color: var(--soft); }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; font-size: 14px; } .check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.menu { position: fixed; z-index: 40; min-width: 200px; max-width: min(300px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s; max-height: 70vh; overflow: auto; }
.menu button, .menu a { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 8px; text-align: left; font-size: 14px; color: var(--text); }
.menu button:hover, .menu a:hover { background: var(--panel); text-decoration: none; }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .head { padding: 6px 10px 4px; font-size: 12.5px; color: var(--faint); }
.menu .tick { margin-left: auto; color: var(--accent); }
.menu svg { width: 16px; height: 16px; color: var(--soft); flex: none; }
.menu .sw { width: 28px; height: 14px; border-radius: 4px; flex: none; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 9px 15px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- card detail */
.cd-title { width: 100%; font-size: 20px; font-weight: 700; letter-spacing: -.3px; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 8px; margin: -4px 0 0 -8px; resize: none; outline: none; display: block; line-height: 1.3; overflow: hidden; }
.cd-title:focus { background: var(--card); border-color: var(--accent); }
.cd-in { font-size: 13px; color: var(--soft); margin: 2px 0 14px; padding-right: 40px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 9px; background: var(--panel); font-size: 13px; font-weight: 600; color: var(--soft); transition: background .15s, color .15s; position: relative; }
.chip:hover { color: var(--text); } .chip svg { width: 15px; height: 15px; }
.chip.label { color: #fff; } .chip.label:hover { color: #fff; filter: brightness(1.06); }
.chip input[type="date"] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.chip.on { color: var(--text); } .chip.late { color: var(--danger); }
.sec { margin-top: 18px; } .sec > h4 { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--soft); display: flex; align-items: center; gap: 8px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; min-height: 44px; cursor: text; font-size: 14.5px; }
.desc.empty { color: var(--faint); }
.rowi { display: flex; align-items: center; gap: 9px; padding: 6px 4px 6px 8px; border-radius: 8px; min-height: 38px; }
.rowi:hover { background: var(--panel); } .rowi .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.rowi .icon { width: 28px; height: 28px; opacity: 0; } .rowi:hover .icon, .rowi:focus-within .icon { opacity: 1; }
@media (hover: none) { .rowi .icon { opacity: .6; } }
.rowi input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; margin: 0; }
.rowi.done .grow { text-decoration: line-through; color: var(--faint); }
.rowi .lk { display: flex; align-items: center; gap: 9px; color: var(--text); min-width: 0; flex: 1; } .rowi .lk span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowi .lk small { color: var(--faint); } .rowi .lk svg { width: 18px; height: 18px; flex: none; }
.bar { height: 5px; border-radius: 3px; background: var(--panel); overflow: hidden; flex: 1; max-width: 120px; } .bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .25s; }
.comment { display: flex; gap: 10px; margin-top: 12px; } .comment .b { flex: 1; min-width: 0; }
.comment .who { font-size: 13px; font-weight: 700; } .comment .who span { font-weight: 400; color: var(--faint); margin-left: 6px; }
.comment .txt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; margin-top: 1px; }
.comment .del { font-size: 12px; color: var(--faint); } .comment .del:hover { color: var(--danger); }
.act { font-size: 12.5px; color: var(--faint); padding: 3px 0; } .act b { color: var(--soft); font-weight: 600; }
.cd-foot { display: flex; justify-content: space-between; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- share + stats */
.copy { display: flex; gap: 8px; } .copy .input { font-size: 13px; color: var(--soft); }
.person { display: flex; align-items: center; gap: 10px; padding: 7px 0; } .person .grow { flex: 1; min-width: 0; } .person .n { font-weight: 600; font-size: 14px; } .person .e { font-size: 12.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; } .stats th { text-align: right; font-size: 12px; color: var(--faint); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.stats th:first-child, .stats td:first-child { text-align: left; padding-left: 0; } .stats td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.stats td.big { font-weight: 800; font-size: 17px; } .stats .who { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.seg { display: inline-flex; background: var(--panel); border-radius: 9px; padding: 3px; margin-bottom: 14px; } .seg button { padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--soft); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------- phone */
@media (max-width: 640px) {
  .top { padding: 8px 10px; gap: 6px; }
  .board { padding: 2px 10px 10px; gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 10px; }
  .list { width: 86vw; scroll-snap-align: start; }
  body.dragging .board { scroll-snap-type: none; }
  .scrim { padding: 0; align-items: flex-end; }
  .dialog, .dialog.wide { max-width: none; border-radius: 20px 20px 0 0; border-bottom: 0; max-height: 94dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .22s cubic-bezier(.2, .9, .3, 1); }
  .dialog.full { min-height: 94dvh; }
  .input, .cd-title, .desc, .card .t { font-size: 16px; }   /* 16px: phones do not zoom in when typing */
  .hide-s { display: none !important; }
  .grid { grid-template-columns: 1fr 1fr; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
