/* Tasks */
.app-tasks { --tk: #6366f1; --tk-rgb: 99, 102, 241; position: relative; container-type: inline-size; container-name: tasks; }
[data-theme="light"] .app-tasks { --tk: #4f46e5; --tk-rgb: 79, 70, 229; }
.app-tasks .btn-primary { background: var(--tk); }
.app-tasks .chip.on { background: var(--tk); color: #fff; }
.win .tk-modeseg button.on .ic { color: #818cf8; }
.win .tk-search { width: 200px; }
.win .tk-search .input { height: 30px; background: var(--tile); box-shadow: none; }
.win .tk-search .input:focus { box-shadow: inset 0 0 0 2px #818cf8; }

/* sidebar */
.app-tasks .tk-side { width: 228px; }
.app-tasks.tk-no-side .tk-side { display: none; }
.app-tasks .tk-side .side-item .ic { color: var(--tk); }
.app-tasks .tk-side .side-item.on { background: rgba(var(--tk-rgb), .16); }
.app-tasks .tk-side .count.tk-over { color: #ef4444; font-weight: 700; }
.app-tasks .tk-side .tk-drop-on { box-shadow: inset 0 0 0 2px var(--tk); background: rgba(var(--tk-rgb), .12); }
.app-tasks .tk-glabel { display: flex; align-items: center; justify-content: space-between; padding-right: 2px; }
.app-tasks .tk-addlist { width: 24px; height: 24px; border-radius: 7px; color: var(--text-2); }
.app-tasks .tk-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; display: inline-block; margin: 0 3px; }
.app-tasks .tk-dot.sm { width: 7px; height: 7px; margin: 0 2px 0 0; }
.app-tasks .tk-tags { display: flex; flex-wrap: wrap; gap: 5px; padding: 2px 8px 10px; }
.app-tasks .tk-tags .chip { height: 24px; font-size: 12px; padding: 0 9px; }

/* main */
.app-tasks .tk-main { position: relative; }
.app-tasks .tk-head { display: flex; align-items: center; gap: 8px; padding: 18px 22px 8px; flex: 0 0 auto; }
.app-tasks .tk-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.app-tasks .tk-title h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-tasks .tk-title-ic { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(160deg, #818cf8, #4338ca); flex: 0 0 auto; }
.app-tasks .tk-sub { font-size: 12.5px; margin-top: 1px; }
.app-tasks .tk-quickwrap { padding: 4px 22px 8px; flex: 0 0 auto; }
.app-tasks .tk-quick { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow .12s; }
.app-tasks .tk-quick:focus-within { box-shadow: inset 0 0 0 2px var(--tk); }
.app-tasks .tk-quick-ic { color: var(--tk); display: grid; }
.app-tasks .tk-quick-in { flex: 1; min-width: 0; height: 100%; border: 0; background: none; outline: none; font-size: 14px; color: var(--text); }
.app-tasks .tk-quick-in::placeholder { color: var(--text-3); }
.app-tasks .tk-quick-kbd { opacity: 0; transition: opacity .12s; }
.app-tasks .tk-quick.has .tk-quick-kbd { opacity: 1; }
.app-tasks .tk-quick-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 4px 0; min-height: 0; font-size: 12px; }
.app-tasks .tk-quick-chips:empty { display: none; }
.app-tasks .tk-ptitle { font-weight: 600; color: var(--text-2); margin-right: 4px; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tasks .tk-pchip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; background: rgba(var(--tk-rgb), .14); color: var(--tk); font-weight: 600; }
.app-tasks .tk-pchip.p3 { background: rgba(239, 68, 68, .14); color: #ef4444; }
.app-tasks .tk-pchip.p2 { background: rgba(245, 158, 11, .16); color: #d48806; }
.app-tasks .tk-content { flex: 1; padding: 4px 14px 30px; }

/* rows */
.app-tasks .tk-list { display: flex; flex-direction: column; max-width: 860px; }
.app-tasks .tk-group { display: flex; align-items: baseline; gap: 8px; padding: 16px 10px 6px; font-size: 13px; border-bottom: 1px solid var(--line); }
.app-tasks .tk-group b { font-size: 14px; }
.app-tasks .tk-group span { color: var(--text-3); font-size: 12.5px; }
.app-tasks .tk-group.over b { color: #ef4444; }
.app-tasks .tk-group .link { margin-left: auto; font-size: 12.5px; color: var(--tk); }
.app-tasks .tk-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 10px; border-radius: 10px; position: relative; outline: none; cursor: default; touch-action: pan-y; }
.app-tasks .tk-row::after { content: ''; position: absolute; left: 44px; right: 10px; bottom: 0; height: 1px; background: var(--line); }
.app-tasks .tk-row:hover { background: var(--hover); }
.app-tasks .tk-row.sel { background: rgba(var(--tk-rgb), .14); }
.app-tasks .tk-row:focus-visible { box-shadow: inset 0 0 0 2px var(--tk); }
.app-tasks .tk-row-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.app-tasks .tk-row-title { font-size: 14px; line-height: 1.35; word-break: break-word; }
.app-tasks .tk-row.done .tk-row-title, .app-tasks .tk-card.done .tk-card-title { color: var(--text-3); text-decoration: line-through; }
.app-tasks .tk-row-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-2); }
.app-tasks .tk-m { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.app-tasks .tk-m.over { color: #ef4444; font-weight: 600; }
.app-tasks .tk-m.today { color: var(--tk); font-weight: 600; }
.app-tasks .tk-m.tag { color: var(--tk); }
.app-tasks .tk-m.doing { color: #d48806; font-weight: 600; }
.app-tasks .tk-m.p3 { color: #ef4444; } .app-tasks .tk-m.p2 { color: #d48806; } .app-tasks .tk-m.p1 { color: #3b82f6; }
.app-tasks .tk-flag { display: grid; padding-top: 2px; }
.app-tasks .tk-flag.p3 { color: #ef4444; } .app-tasks .tk-flag.p2 { color: #f59e0b; } .app-tasks .tk-flag.p1 { color: #3b82f6; }
.app-tasks .tk-check { --c: var(--text-3); width: 20px; height: 20px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--c); background: none; padding: 0; display: grid; place-items: center; color: transparent; margin-top: 1px; transition: background .15s, color .15s; }
.app-tasks .tk-check.p1 { --c: #3b82f6; } .app-tasks .tk-check.p2 { --c: #f59e0b; } .app-tasks .tk-check.p3 { --c: #ef4444; }
.app-tasks .tk-check.p1, .app-tasks .tk-check.p2, .app-tasks .tk-check.p3 { background: color-mix(in srgb, var(--c) 12%, transparent); }
.app-tasks .tk-check:hover { color: var(--c); }
.app-tasks .tk-check[aria-checked="true"], .app-tasks .tk-completing .tk-check { background: var(--tk); border-color: var(--tk); color: #fff; }
.app-tasks .tk-check.sm { width: 17px; height: 17px; border-width: 1.6px; }
.app-tasks .tk-check.lg { width: 24px; height: 24px; margin-top: 4px; }
.app-tasks .tk-completing { opacity: .4; transition: opacity .35s; }
.app-tasks .tk-completing .tk-row-title { text-decoration: line-through; }
.app-tasks .tk-flash { animation: tk-flash 1.2s ease; }
@keyframes tk-flash { 0% { background: rgba(var(--tk-rgb), .3); } }
.app-tasks .tk-done-toggle { display: flex; align-items: center; gap: 6px; margin: 14px 0 4px; padding: 6px 10px; border: 0; background: none; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 700; align-self: flex-start; }
.app-tasks .tk-done-toggle:hover { background: var(--hover); }
.app-tasks .tk-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 50px 20px; color: var(--text-2); }
.app-tasks .tk-empty-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: rgba(var(--tk-rgb), .12); color: var(--tk); margin-bottom: 4px; }
.app-tasks .tk-empty h3 { margin: 0; font-size: 16px; color: var(--text); }
.app-tasks .tk-empty p { margin: 0; font-size: 13px; max-width: 320px; }

/* board */
.app-tasks.tk-board-mode .tk-content { padding: 4px 16px 16px; display: flex; }
.app-tasks .tk-board { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 12px; flex: 1; min-height: 0; overflow-x: auto; align-items: start; }
.app-tasks .tk-col { background: var(--surface-2); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; min-height: 120px; max-height: 100%; transition: box-shadow .12s, background .12s; }
.app-tasks .tk-col.tk-drop-on { box-shadow: inset 0 0 0 2px var(--tk); background: rgba(var(--tk-rgb), .06); }
.app-tasks .tk-col-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 14px; font-size: 13px; }
.app-tasks .tk-col-head .icon-btn { width: 26px; height: 26px; }
.app-tasks .tk-col-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.app-tasks .tk-col.k-doing .tk-col-dot { background: #f59e0b; }
.app-tasks .tk-col.k-done .tk-col-dot { background: #22c55e; }
.app-tasks .tk-col-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 10px; overflow-y: auto; min-height: 60px; }
.app-tasks .tk-col-empty { font-size: 12px; text-align: center; padding: 16px 8px; border: 1.5px dashed var(--line-2); border-radius: 10px; }
.app-tasks .tk-card { background: var(--surface); border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0, 0, 0, .12), inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 7px; cursor: grab; touch-action: none; outline: none; }
[data-theme="dark"] .app-tasks .tk-card { background: var(--surface-3); }
.app-tasks .tk-card:hover { box-shadow: 0 3px 10px rgba(0, 0, 0, .16), inset 0 0 0 1px var(--line-2); }
.app-tasks .tk-card.sel { box-shadow: inset 0 0 0 2px var(--tk); }
.app-tasks .tk-card:focus-visible { box-shadow: inset 0 0 0 2px var(--tk); }
.app-tasks .tk-card-top { display: flex; gap: 10px; align-items: flex-start; }
.app-tasks .tk-card-title { font-size: 13.5px; line-height: 1.35; flex: 1; min-width: 0; word-break: break-word; }
.app-tasks .tk-card .tk-row-meta { padding-left: 30px; }
.app-tasks .tk-card .tk-row-meta:empty { display: none; }
.app-tasks .tk-prog { margin-left: 30px; height: 3px; }
.app-tasks .tk-prog > i { background: var(--tk); }
.app-tasks .tk-dragging { opacity: .35; }
.app-tasks .tk-ghost { position: absolute; left: 0; top: 0; z-index: 100; pointer-events: none; opacity: .95; box-shadow: 0 16px 34px -10px rgba(0, 0, 0, .45) !important; background: var(--surface); border-radius: 10px; }
.app-tasks.tk-is-dragging, .app-tasks.tk-is-dragging * { cursor: grabbing !important; user-select: none; }
.app-tasks .tk-drop-marker { height: 3px; border-radius: 2px; background: var(--tk); margin: -2px 4px; flex: 0 0 auto; }

/* detail */
.app-tasks .tk-detail { width: 0; flex: 0 0 auto; overflow: hidden; border-left: 1px solid transparent; background: var(--surface); display: flex; flex-direction: column; transition: width .18s var(--ease); }
.app-tasks.tk-has-detail .tk-detail { width: 340px; border-left-color: var(--line); }
.app-tasks .tk-d-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 8px 16px; flex: 0 0 auto; width: 340px; }
.app-tasks .tk-d-title { flex: 1; min-width: 0; border: 0; background: none; outline: none; resize: none; font-size: 18px; font-weight: 700; line-height: 1.35; color: var(--text); padding: 2px 0; overflow: hidden; font-family: inherit; }
.app-tasks .tk-d-body { flex: 1; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 14px; width: 340px; }
.app-tasks .tk-d-field { display: flex; flex-direction: column; gap: 6px; }
.app-tasks .tk-d-field > label { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.app-tasks .tk-d-row { display: flex; gap: 8px; }
.app-tasks .tk-d-row .input { flex: 1; min-width: 0; }
.app-tasks .tk-d-row .input[type="time"] { flex: 0 0 124px; }
.app-tasks .tk-d-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.app-tasks .tk-d-chips .chip { height: 24px; font-size: 12px; padding: 0 10px; }
.app-tasks .tk-d-prio { display: flex; }
.app-tasks .tk-d-prio button { flex: 1; justify-content: center; padding: 0 6px; gap: 4px; }
.app-tasks .tk-d-prio button.p3 .ic { color: #ef4444; } .app-tasks .tk-d-prio button.p2 .ic { color: #f59e0b; } .app-tasks .tk-d-prio button.p1 .ic { color: #3b82f6; }
.app-tasks .tk-d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.app-tasks .tk-d-grid .select, .app-tasks .tk-d-field > .select { width: 100%; }
.app-tasks .tk-d-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 5px; border-radius: var(--r-ctl); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); min-height: 34px; }
.app-tasks .tk-tagchip { height: 24px; font-size: 12px; padding: 0 4px 0 9px; background: rgba(var(--tk-rgb), .14); color: var(--tk); gap: 2px; }
.app-tasks .tk-tagchip button { border: 0; background: none; color: inherit; padding: 2px; border-radius: 50%; display: grid; }
.app-tasks .tk-tagchip button:hover { background: rgba(var(--tk-rgb), .2); }
.app-tasks .tk-tag-in { flex: 1; min-width: 80px; border: 0; background: none; outline: none; font-size: 13px; color: var(--text); height: 24px; padding: 0 4px; }
.app-tasks .tk-subs { display: flex; flex-direction: column; }
.app-tasks .tk-subrow { display: flex; align-items: center; gap: 8px; min-height: 32px; border-bottom: 1px solid var(--line); }
.app-tasks .tk-subrow.done .tk-sub-in { color: var(--text-3); text-decoration: line-through; }
.app-tasks .tk-sub-in { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 13.5px; color: var(--text); height: 30px; }
.app-tasks .tk-sub-plus { color: var(--tk); display: grid; width: 17px; place-items: center; }
.app-tasks .tk-sub-x { width: 24px; height: 24px; opacity: 0; }
.app-tasks .tk-subrow:hover .tk-sub-x, .app-tasks .tk-sub-x:focus-visible { opacity: .7; }
.app-tasks .tk-d-notes { width: 100%; min-height: 90px; }
.app-tasks .tk-d-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding-top: 6px; border-top: 1px solid var(--line); }

/* sheets */
.app-tasks .tk-sheet-layer { position: absolute; inset: 0; z-index: 40; background: rgba(0, 0, 0, .28); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 16px; }
.app-tasks .tk-sheet { width: min(380px, 100%); padding: 16px; border-radius: 16px; background: var(--glass-strong); display: flex; flex-direction: column; gap: 12px; }
.app-tasks .tk-sheet h3 { margin: 0; font-size: 16px; }
.app-tasks .tk-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.app-tasks .tk-swatch { width: 28px; height: 28px; border-radius: 50%; border: 0; padding: 0; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .2); }
.app-tasks .tk-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.app-tasks .tk-sheet-actions { display: flex; gap: 8px; }
.app-tasks .tk-scrim { display: none; }

/* narrow windows + phone */
@container tasks (max-width: 1000px) {
  .app-tasks.tk-has-detail .tk-side { display: none; }
}
@media (max-width: 759px) {
  .win .tk-search { width: 120px; }
  .win .tk-modeseg button span { display: none; }
  .app-tasks .tk-side { position: absolute; left: 0; top: 0; bottom: 0; z-index: 30; width: min(280px, 82vw); box-shadow: var(--shadow-pop); background: var(--surface); }
  .app-tasks.tk-has-detail .tk-side { display: flex; }
  .app-tasks.tk-no-side .tk-side { display: none; }
  .app-tasks.tk-side-open .tk-scrim, .app-tasks.tk-has-detail .tk-scrim { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(0, 0, 0, .35); }
  .app-tasks .tk-detail { position: absolute; left: 0; right: 0; bottom: 0; top: 12%; z-index: 35; width: auto !important; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-pop); transform: translateY(105%); transition: transform .22s var(--ease); border: 0 !important; }
  .app-tasks.tk-has-detail .tk-detail { transform: none; }
  .app-tasks .tk-d-head, .app-tasks .tk-d-body { width: auto; }
  .app-tasks .tk-head { padding: 14px 14px 6px; }
  .app-tasks .tk-title h1 { font-size: 21px; }
  .app-tasks .tk-quickwrap { padding: 4px 14px 8px; }
  .app-tasks .tk-content { padding: 4px 6px 30px; }
  .app-tasks .tk-board { grid-template-columns: repeat(3, 78vw); scroll-snap-type: x mandatory; }
  .app-tasks .tk-col { scroll-snap-align: start; }
}
