/* ==========================================================================
   工单 board (tickets.js) · the original board's 墨（Ink）design language, fitted into frapp.
   Tokens are the board's (DESIGN.md); where frapp has the same thing (ink, paper, lines, accent, shade) they are frapp's own
   variables, so the board follows the app's light and dark themes. Everything is scoped under .tk / .tk-*.
   ========================================================================== */

.tk {
  /* paper */
  --canvas: var(--bg);
  --well: color-mix(in srgb, var(--text) 6%, var(--bg));
  --surface: var(--bg);
  --raised: var(--bg);
  --tint: rgba(0, 0, 0, .05);
  --tint-2: rgba(0, 0, 0, .09);
  /* ink */
  --ink: var(--text);
  --ink-2: var(--text-2);
  --ink-3: var(--text-3);
  --ink-4: #b9b9b9;
  --line: var(--border);
  --line-soft: var(--border-light);
  /* meaning: colour only says something */
  --open: #d99a00;
  --progress: #3a83f7;
  --done: #10a37f;
  --closed: #9a9a9a;
  --danger: #e02e2a;
  /* shapes: rounded squares, the bigger the rounder */
  --r-xs: 6px;
  --r-s: 9px;
  --r-m: 12px;
  --r-l: 18px;
  --r-pill: 999px;
  /* layers: flat things use a hairline, floating things a shadow */
  --e1: 0 1px 2px rgba(0, 0, 0, .04), 0 0 0 1px var(--line-soft);
  --e2: 0 10px 30px -8px rgba(0, 0, 0, .16), 0 0 0 1px var(--line-soft);
  --e3: 0 30px 80px -16px rgba(0, 0, 0, .32), 0 0 0 1px var(--line-soft);
  /* motion */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.3, .64, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --t1: 120ms;
  --t2: 200ms;
  --t3: 320ms;
  --t4: 460ms;
  color: var(--ink);
  font: 14px/1.55 var(--font);
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: dark) {
  .tk {
    --well: color-mix(in srgb, var(--text) 5%, var(--bg));
    --surface: color-mix(in srgb, var(--text) 10%, var(--bg));
    --raised: var(--surface-2);
    --tint: rgba(255, 255, 255, .07);
    --tint-2: rgba(255, 255, 255, .12);
    --ink-4: #5e5e5e;
    --open: #f5c542;
    --progress: #5b9bfa;
    --done: #2fbf96;
    --closed: #8f8f8f;
    --danger: #ff5f57;
    --e1: 0 1px 2px rgba(0, 0, 0, .35), 0 0 0 1px var(--line-soft);
    --e2: 0 12px 32px -8px rgba(0, 0, 0, .6), 0 0 0 1px var(--line);
    --e3: 0 30px 90px -16px rgba(0, 0, 0, .75), 0 0 0 1px var(--line);
  }
}

/* Inverse areas (the toast): ink on light themes, paper on dark ones */
.tk-inverse {
  --raised: #0d0d0d; --surface: #1c1c1c; --well: #242424; --tint: rgba(255, 255, 255, .1); --tint-2: rgba(255, 255, 255, .16);
  --ink: #f4f4f4; --ink-2: #bdbdbd; --ink-3: #8f8f8f; --ink-4: #6b6b6b;
  --line: rgba(255, 255, 255, .14); --line-soft: rgba(255, 255, 255, .08);
  --accent: #ffffff; --accent-text: #0d0d0d; --accent-hover: #e2e2e2;
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  .tk-inverse {
    --raised: #f4f4f4; --surface: #ffffff; --well: #e9e9e9; --tint: rgba(0, 0, 0, .06); --tint-2: rgba(0, 0, 0, .1);
    --ink: #0d0d0d; --ink-2: #5d5d5d; --ink-3: #8f8f8f; --ink-4: #b5b5b5;
    --line: rgba(0, 0, 0, .12); --line-soft: rgba(0, 0, 0, .07);
    --accent: #0d0d0d; --accent-text: #ffffff; --accent-hover: #2f2f2f;
  }
}

/* The create bar: pale grey, the same family as the page */
.tk-dock {
  --raised: #ececec; --surface: #ffffff; --well: #e3e3e3; --tint: rgba(0, 0, 0, .06); --tint-2: rgba(0, 0, 0, .1);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  .tk-dock { --raised: #2e2e2e; --surface: #383838; --well: #353535; --tint: rgba(255, 255, 255, .08); --tint-2: rgba(255, 255, 255, .13); }
}

/* Status tones: put tk-tone-xxx on an element, read var(--c) inside */
.tk-tone-open { --c: var(--open); }
.tk-tone-in_progress { --c: var(--progress); }
.tk-tone-resolved { --c: var(--done); }
.tk-tone-closed { --c: var(--closed); }

/* ---------- Basics (:where keeps the reset weaker than any class) ---------- */
:where(.tk, .tk *, .tk *::before, .tk *::after) { box-sizing: border-box; }
:where(.tk) button { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: inherit; cursor: pointer; }
:where(.tk) button:disabled { cursor: default; }
:where(.tk) a { color: inherit; text-decoration: none; }
:where(.tk) input, :where(.tk) textarea { font: inherit; color: inherit; }
.tk [hidden] { display: none !important; }

.tk-i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.tk-i.sm { width: 14px; height: 14px; }
.tk-num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tk-muted { color: var(--ink-3); font-size: inherit; }
.tk-grow { flex: 1; min-width: 0; }
.tk-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 16px; border-radius: var(--r-s);
  font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background-color var(--t2), color var(--t2), transform var(--t1) var(--ease-out), box-shadow var(--t2);
}
.tk-btn:active:not(:disabled) { transform: scale(.97); }
.tk-btn:disabled { opacity: .5; }
.tk-btn.primary { background: var(--accent); color: var(--accent-text); }
.tk-btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.tk-btn.ghost { color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.tk-btn.ghost:hover:not(:disabled) { background: var(--tint); color: var(--ink); }
.tk-btn.quiet { padding: 0 10px; color: var(--ink-2); }
.tk-btn.quiet:hover:not(:disabled) { background: var(--tint); color: var(--ink); }
.tk-btn.block { width: 100%; height: 42px; }
.tk-icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--r-s); color: var(--ink-3);
  transition: background-color var(--t2), color var(--t2), transform var(--t1) var(--ease-out);
}
.tk-icon-btn:hover { background: var(--tint); color: var(--ink); }
.tk-icon-btn:active { transform: scale(.92); }

.tk-input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 0; border-radius: var(--r-s); outline: none; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--t2);
}
.tk-input::placeholder, .tk-bare::placeholder { color: var(--ink-4); }
.tk-input:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 22%, transparent); }
.tk-input:focus { box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 4px color-mix(in srgb, var(--ink) 7%, transparent); }
.tk-input.sm { height: 34px; font-size: 13px; }
.tk-bare { width: 100%; padding: 0; border: 0; outline: none; background: transparent; resize: none; }
.tk-err { min-height: 18px; color: var(--danger); font-size: 12.5px; }

/* Avatars: rounded squares */
.tk-av {
  --s: 22px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--s); height: var(--s); border-radius: calc(var(--s) * .3);
  background: var(--c, #6f7782); color: #fff;
  font-size: calc(var(--s) * .48); font-weight: 600; line-height: 1;
  user-select: none;
}
.tk-stack { display: inline-flex; align-items: center; }
.tk-stack .tk-av { position: relative; box-shadow: 0 0 0 2px var(--surface); }
.tk-stack .tk-av + .tk-av { margin-left: -4px; }
.tk-stack .tk-more { margin-left: 5px; font-size: 11.5px; color: var(--ink-3); }

/* Chips */
.tk-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 500; white-space: nowrap;
  background: color-mix(in srgb, var(--c, var(--ink-3)) 13%, transparent);
  color: color-mix(in srgb, var(--c, var(--ink-3)) 72%, var(--ink));
}
.tk-sq { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2.5px; background: var(--c); }
.tk-tag { flex: none; padding: 1px 7px; border-radius: var(--r-xs); background: var(--tint); color: var(--ink-3); font-size: 11.5px; font-weight: 500; }
.tk-tag-chip {
  display: inline-block; min-width: 0; max-width: 140px; height: 18px; padding: 0 6px;
  border-radius: var(--r-xs); background: var(--tint); color: var(--ink-2);
  font-size: 11.5px; font-weight: 500; line-height: 18px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk-due {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: var(--r-pill); font-size: 11.5px; font-weight: 500; white-space: nowrap;
  color: var(--ink-2); background: var(--tint);
}
.tk-due .tk-i { width: 12px; height: 12px; }
.tk-due.over { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.tk-due.soon { color: color-mix(in srgb, var(--open) 70%, var(--ink)); background: color-mix(in srgb, var(--open) 15%, transparent); }
.tk-due.done { padding: 0; color: var(--ink-3); background: none; }

/* ---------- In the app shell: the sidebar row, the top bar, the main pane ---------- */
.nav-row.active { background: var(--active); }
.main.ticket-mode > :not(.topbar, .ticket-view, .notice) { display: none !important; }
.main.ticket-mode .title-wrap, .main.ticket-mode .topbar-actions > *, .main.ticket-mode .note-bar { display: none; }
.ticket-bar { display: none; flex: 1; align-items: center; gap: 12px; min-width: 0; }
.main.ticket-mode .ticket-bar { display: flex; }
.ticket-view {
  display: none; position: relative; flex: 1; flex-direction: column; min-height: 0;
  container-type: inline-size; isolation: isolate; background: var(--bg);
}
.main.ticket-mode .ticket-view { display: flex; }

.tk-views { display: flex; flex: none; gap: 2px; padding: 3px; border-radius: 11px; background: var(--well); }
.tk-views button {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500;
  transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
}
.tk-views button:hover { color: var(--ink); }
.tk-views button.on { background: var(--surface); color: var(--ink); box-shadow: var(--e1); }
.tk-views .count { font-size: 11.5px; color: var(--ink-3); }
.tk-tag-filter {
  display: inline-flex; flex: none; align-items: center; gap: 7px; height: 36px; max-width: 220px; padding: 0 12px;
  border-radius: 11px; background: var(--well); color: var(--ink-2); font-size: 13px; font-weight: 500;
  transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
}
.tk-tag-filter:hover { color: var(--ink); }
.tk-tag-filter.on { padding-right: 6px; background: var(--surface); color: var(--ink); box-shadow: var(--e1), inset 0 0 0 1.5px var(--ink); }
.tk-tag-filter .clear { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: var(--ink-3); }
.tk-tag-filter .clear:hover { background: var(--tint); color: var(--ink); }
.tk-tag-pop { width: 260px; }
.tk-pop-label { padding: 6px 10px 2px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.tk-search { position: relative; flex: none; width: 260px; }
.tk-search .tk-i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.tk-search .tk-input { height: 36px; padding: 0 12px 0 34px; }

/* ---------- Board ---------- */
.tk-col-tabs { display: none; }
.tk-board {
  display: grid; flex: 1; grid-auto-flow: column; grid-auto-columns: minmax(224px, 1fr); align-content: start;
  gap: 16px; align-items: start; min-height: 0;
  padding: 4px 24px 140px; overflow: auto; overscroll-behavior: contain;
}
.tk-board-note { display: grid; grid-column: 1 / -1; justify-items: center; gap: 10px; margin-top: 16vh; color: var(--ink-3); text-align: center; }
.tk-board-note b { color: var(--ink-2); font-weight: 600; }
.tk-col {
  border-radius: 16px; background: var(--well); padding: 6px 6px 8px;
  transition: background-color var(--t2), box-shadow var(--t2);
}
.tk-col-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 10px; font-size: 13px; font-weight: 600; }
.tk-col-head .count { color: var(--ink-3); font-size: 12px; font-weight: 500; }
.tk-col-body { display: grid; gap: 8px; min-height: 64px; }
.ticket-view.dragging .tk-col { box-shadow: inset 0 0 0 1px var(--line); }
.tk-col.drop { background: color-mix(in srgb, var(--c) 9%, var(--well)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, transparent); }
.tk-col-empty {
  display: grid; place-items: center; gap: 4px; min-height: 64px; padding: 14px;
  border: 1px dashed var(--line); border-radius: var(--r-m);
  color: var(--ink-4); font-size: 12.5px; text-align: center;
}
.tk-col-empty b { color: var(--ink-2); font-weight: 600; font-size: 13px; }

/* ---------- Cards ---------- */
.tk-card {
  position: relative; display: block; width: 100%;
  padding: 12px 14px 11px; border-radius: var(--r-m);
  background: var(--surface); box-shadow: var(--e1);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: transform var(--t2) var(--ease-out), box-shadow var(--t2) var(--ease-out), opacity var(--t2);
}
.tk-card:hover { transform: translateY(-2px); box-shadow: var(--e2); }
.tk-card:active { transform: scale(.985); }
.tk-card.lifted { opacity: .35; transform: none; box-shadow: var(--e1); }
.tk-card.ghosted { visibility: hidden; }
.tk-card.fresh { animation: tk-fresh 1.6s var(--ease-out); }
@keyframes tk-fresh {
  0% { transform: translateY(10px) scale(.96); opacity: 0; box-shadow: 0 0 0 2px var(--ink), var(--e2); }
  25% { transform: none; opacity: 1; box-shadow: 0 0 0 2px var(--ink), var(--e2); }
  100% { box-shadow: var(--e1); }
}
.tk-col[data-status=closed] .tk-card:not(:hover) { opacity: .66; }
.tk-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 20px; }
.tk-card-lead { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.tk-card-id { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-3); }
.tk-card-id .tk-lock { display: inline-flex; color: var(--ink-3); }
.tk-card-title {
  display: -webkit-box; margin-top: 3px; overflow: hidden; font-size: 14.5px; font-weight: 600; line-height: 1.45; word-break: break-word;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tk-card-excerpt {
  display: -webkit-box; margin-top: 4px; overflow: hidden; color: var(--ink-2); font-size: 13px; line-height: 1.55; word-break: break-word;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tk-card-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--ink-3); }
.tk-card-foot .tk-meta { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; }
.tk-card-foot .tk-meta.who { overflow: hidden; }
.tk-card-foot .tk-meta.who span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Pop-out card ---------- */
.tk-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 28px; }
.tk-layer.full { padding: 0; }
.tk-shade { position: absolute; inset: 0; background: var(--shade); }
.tk-sheet {
  position: relative; display: flex; flex-direction: column;
  width: min(1040px, 100%); height: min(88vh, 900px);
  border-radius: var(--r-l); background: var(--raised); box-shadow: var(--e3);
  overflow: hidden; transform-origin: 0 0; outline: none;
}
.tk-sheet.expanded { width: 100%; height: 100%; border-radius: 0; }
.tk-sheet-inner { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.tk-sheet-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  height: 56px; padding: 0 14px 0 26px; border-bottom: 1px solid var(--line-soft);
}
.tk-head-info { display: flex; align-items: center; gap: 10px; }
.tk-head-info .tk-num { font-size: 13px; color: var(--ink-3); }
.tk-save-state { font-size: 12px; color: var(--ink-3); }
.tk-sheet-body { display: grid; flex: 1; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.tk-sheet-main { min-height: 0; overflow-y: auto; padding: 24px 34px 64px; overscroll-behavior: contain; }
.tk-sheet-side { min-height: 0; overflow-y: auto; padding: 20px 20px 40px; border-left: 1px solid var(--line-soft); background: color-mix(in srgb, var(--well) 40%, var(--raised)); overscroll-behavior: contain; }
.tk-sheet.expanded .tk-sheet-body { grid-template-columns: minmax(0, 1fr); }
.tk-sheet.expanded .tk-sheet-side { display: none; }
.tk-sheet.expanded .tk-sheet-main { padding: 48px max(34px, calc((100% - 780px) / 2)) 96px; }

.tk-notice {
  display: flex; align-items: center; gap: 10px; margin: -4px 0 18px; padding: 10px 12px;
  border-radius: var(--r-m); background: var(--tint); color: var(--ink-2); font-size: 13px;
}
.tk-notice.warn { background: color-mix(in srgb, var(--open) 14%, transparent); color: var(--ink); }
.tk-notice .tk-btn { height: 30px; font-size: 12.5px; }

.tk-title-input {
  display: block; width: calc(100% + 16px); margin: 0 -8px; padding: 4px 8px;
  border-radius: 10px; font-size: 24px; font-weight: 700; line-height: 1.38; letter-spacing: -.01em; overflow: hidden;
  transition: background-color var(--t2), box-shadow var(--t2);
}
.tk-title-input:not([readonly]):hover { background: var(--tint); }
.tk-title-input:not([readonly]):focus { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--ink); }
.tk-byline { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
.tk-ed-wrap { margin-top: 22px; }

/* Properties */
.tk-prop { margin-bottom: 22px; }
.tk-prop-label { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.tk-prop-hint { margin: 6px 2px 0; font-size: 12px; color: var(--ink-4); }
.tk-status-list { display: grid; gap: 2px; }
.tk-status-opt {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r-s);
  color: var(--ink-2); font-size: 13.5px;
  transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
}
.tk-status-opt:hover:not(:disabled) { background: var(--tint); color: var(--ink); }
.tk-status-opt.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--e1); }
.tk-status-opt:disabled:not(.on) { opacity: .55; }
.tk-status-opt .tk-i { margin-left: auto; color: var(--ink); }
.tk-field-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 6px 10px;
  border-radius: var(--r-s); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 13.5px; transition: box-shadow var(--t2), background-color var(--t2);
}
.tk-field-btn:hover:not(:disabled) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent); }
.tk-field-btn:disabled { background: transparent; }
.tk-field-btn .placeholder { color: var(--ink-4); }
.tk-field-btn.over { color: var(--danger); }
.tk-person { display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 6px 0 8px; border-radius: var(--r-s); font-size: 13.5px; }
.tk-person:hover { background: var(--tint); }
.tk-person .x { width: 24px; height: 24px; opacity: 0; transition: opacity var(--t1); }
.tk-person:hover .x, .tk-person .x:focus-visible { opacity: 1; }
.tk-add-link { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-radius: var(--r-s); color: var(--ink-3); font-size: 13px; }
.tk-add-link:hover { background: var(--tint); color: var(--ink); }
.tk-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border-radius: 11px; background: var(--well); }
.tk-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px;
  border-radius: 8px; color: var(--ink-2); font-size: 12.5px; white-space: nowrap;
  transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
}
.tk-seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--e1); }
.tk-seg button:disabled:not(.on) { opacity: .55; }

/* Activity */
.tk-feed-sec { padding-top: 6px; border-top: 1px solid var(--line-soft); }
.tk-feed-sec .tk-prop-label { margin-top: 16px; }
.tk-feed { margin: 0; padding: 0; list-style: none; }
.tk-feed li { position: relative; display: flex; gap: 10px; padding-bottom: 14px; color: var(--ink-2); font-size: 12.5px; line-height: 1.6; }
.tk-feed li:not(:last-child)::before { content: ''; position: absolute; left: 10.5px; top: 26px; bottom: 4px; width: 1px; background: var(--line); }
.tk-feed .what { flex: 1; min-width: 0; padding-top: 1px; word-break: break-word; }
.tk-feed .what b { color: var(--ink); font-weight: 600; }
.tk-feed .what .tk-i { vertical-align: -2px; }
.tk-feed .what .tk-pill { height: 19px; margin: 0 3px; font-size: 11.5px; vertical-align: 1px; }
.tk-feed .when { color: var(--ink-3); font-size: 11.5px; }
.tk-feed .quote { color: var(--ink); }
.tk-feed .change { display: inline-flex; align-items: center; gap: 2px; vertical-align: 1px; }
.tk-feed .change .tk-pill { margin: 0; }
.tk-feed .arrow { margin: 0 3px; color: var(--ink-3); }

.tk-sk { display: block; height: 12px; margin: 10px 0; border-radius: 6px; background: linear-gradient(90deg, var(--well) 25%, var(--tint) 50%, var(--well) 75%); background-size: 300% 100%; animation: tk-shimmer 1.3s linear infinite; }
@keyframes tk-shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }

/* ---------- The editor (the notes editor, with attachments) ---------- */
.tk-ed.note-editor { min-height: 180px; margin-top: 0; font-size: 15px; line-height: 1.75; caret-color: var(--ink); }
.tk-ed.note-editor[data-placeholder].is-empty::before { inset: 0 0 auto 0; color: var(--ink-4); content: attr(data-placeholder); }
.tk-ed.drop { border-radius: var(--r-s); box-shadow: 0 0 0 2px var(--ink); }
.tk-ed.note-editor > p, .tk-ed.note-editor > [data-b] { margin: 2px 0; }
.tk-ed.note-editor > h1, .tk-ed.note-editor > h2, .tk-ed.note-editor > h3, .tk-ed.note-editor > h4, .tk-ed.note-editor > h5, .tk-ed.note-editor > h6 { margin: 20px 0 4px; font-weight: 700; line-height: 1.4; }
.tk-ed.note-editor > :first-child { margin-top: 0; }
.tk-ed.note-editor > blockquote { margin: 6px 0; padding: 0 0 0 14px; border-left: 3px solid var(--line); color: var(--ink-2); }
.tk-ed.note-editor > hr { height: 1px; margin: 16px 0; border: 0; background: var(--line); }
.tk-ed.note-editor > pre { margin: 8px 0; padding: 12px 14px; border: 0; border-radius: var(--r-m); background: var(--well); font: 13px/1.6 var(--mono); }
.tk-ed.note-editor > [data-b="todo"]::before { top: .42em; border-color: var(--ink-3); }
.tk-ed.note-editor > [data-b="todo"][data-checked]::before { border-color: var(--ink); background: var(--ink); color: var(--canvas); }
.tk-ed.note-editor[data-readonly] > [data-b="todo"]::before { cursor: default; }
.tk-ed.note-editor a { text-decoration-color: var(--ink-3); }
.tk-ed.note-editor:not([data-readonly]) a { cursor: text; }
.tk-ed.note-editor code { padding: .15em .35em; border-radius: 6px; background: var(--well); font: 500 .875em var(--mono); }
.tk-ed.note-editor strong { font-weight: 700; }

/* Attachments: image blocks, inline thumbnails, file chips */
.note-editor .att { position: relative; user-select: none; -webkit-user-select: none; }
.note-editor .att-icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.note-editor > figure.att {
  display: block; width: fit-content; max-width: 100%; min-width: 120px; min-height: 72px; margin: 12px 0;
  border-radius: 12px; overflow: hidden; background: var(--well, var(--surface-2)); box-shadow: var(--e1, 0 0 0 1px var(--border-light)); cursor: zoom-in;
}
.note-editor > figure.att img { display: block; max-width: 100%; max-height: 520px; opacity: 0; transition: opacity .32s; }
.note-editor > figure.att.ok img { opacity: 1; }
.note-editor > figure.att.broken::after { content: '图片无法显示'; display: grid; place-items: center; height: 72px; padding: 0 16px; color: var(--text-3); font-size: 13px; }
.note-editor .att-thumb { display: inline-block; margin: 0 2px; border-radius: 6px; overflow: hidden; vertical-align: middle; cursor: zoom-in; }
.note-editor .att-thumb img { display: block; height: 64px; }
.note-editor .att-file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; margin: 0 2px; padding: 0 10px;
  border-radius: 9px; background: var(--well, var(--surface-2)); box-shadow: inset 0 0 0 1px var(--border-light);
  vertical-align: middle; font-size: 13px; line-height: 1; cursor: pointer; transition: background-color .2s;
}
.note-editor .att-file:hover { background: var(--active); }
.note-editor .att-file .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-editor .att-file .att-size { color: var(--text-3); font-size: 12px; }
.note-editor .att-x {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 7px; background: rgba(0, 0, 0, .55); color: #fff; opacity: 0; transition: opacity .12s; cursor: pointer;
}
.note-editor .att-file .att-x { position: static; width: 18px; height: 18px; margin-right: -4px; background: none; color: var(--text-3); }
.note-editor .att:hover .att-x { opacity: 1; }
.note-editor .att-x .att-icon { width: 14px; height: 14px; }
.note-editor .att-pending { cursor: progress; }
.note-editor > figure.att-pending { display: grid; place-items: center; width: 240px; height: 120px; color: var(--text-3); font-size: 12.5px; }
.note-editor .att-pending .att-name { padding: 0 14px; text-align: center; }
.note-editor .att-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--text); transition: width .2s; }

/* ---------- Popovers ---------- */
.tk-pop {
  position: fixed; z-index: 80; min-width: 230px; max-width: calc(100vw - 16px); padding: 6px;
  border-radius: 14px; background: var(--raised); box-shadow: var(--e2);
  animation: tk-pop-in var(--t2) var(--ease-out);
}
.tk-pop.up { transform-origin: bottom left; }
.tk-pop-shade { position: fixed; inset: 0; z-index: 79; background: var(--shade); animation: tk-fade var(--t2); }
.tk-pop.as-sheet {
  top: auto; left: 0; right: 0; bottom: 0; width: auto; min-width: 0; max-width: none; max-height: 78dvh; overflow-y: auto;
  padding: 18px 12px calc(16px + env(safe-area-inset-bottom)); border-radius: var(--r-l) var(--r-l) 0 0;
  animation: tk-sheet-up var(--t3) var(--ease-out);
}
.tk-pop.as-sheet::before { content: ''; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); }
.tk-pop.as-sheet .tk-pop-item { min-height: 46px; font-size: 15px; }
.tk-pop.as-sheet .tk-pop-list { max-height: none; }
.tk-pop.as-sheet .tk-share-pop { width: auto; }
@keyframes tk-sheet-up { from { transform: translateY(100%); } }
@keyframes tk-pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.tk-pop-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 10px;
  border-radius: var(--r-s); color: var(--ink); font-size: 13.5px;
}
.tk-pop-item:hover:not(:disabled), .tk-pop-item:focus-visible { background: var(--tint); outline: none; }
.tk-pop-item .hint { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.tk-pop-item.danger { color: var(--danger); }
.tk-pop-item:disabled { opacity: .75; }
.tk-pop-sep { height: 1px; margin: 6px 4px; background: var(--line-soft); }
.tk-pop-list { max-height: 280px; margin-top: 6px; overflow-y: auto; }
.tk-pop .tk-input.sm { margin-bottom: 2px; }
.tk-pop .tk-date-row { display: flex; gap: 6px; padding: 4px 4px 2px; }
.tk-share-pop { width: 340px; padding: 8px 8px 4px; }
.tk-pop-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.tk-pop-desc { margin: 6px 0 12px; color: var(--ink-3); font-size: 12.5px; line-height: 1.6; }
.tk-share-row { display: flex; gap: 6px; margin-bottom: 6px; }
.tk-share-row .tk-input { font-family: var(--mono); font-size: 12px; }
.tk-share-pop .tk-btn.block { height: 38px; margin-bottom: 6px; }
.tk-share-pop .tk-pop-item { margin-top: 2px; }

/* ---------- Create bar: a small bar that grows into a card; hover only lifts it a hair ---------- */
.tk-dock {
  --w-closed: 126px;
  --w-open: min(680px, calc(100vw - 24px));
  position: absolute; left: 50%; bottom: 24px; z-index: 40;
  width: var(--w-closed); height: 48px;
  transform: translateX(-50%);
  border-radius: 14px; background: var(--raised); box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .2), 0 0 0 1px var(--line-soft);
  overflow: hidden;
  transition:
    width var(--t4) var(--ease-spring),
    height var(--t3) var(--ease-out),
    border-radius var(--t3) var(--ease-out),
    background-color var(--t2),
    box-shadow var(--t3),
    opacity var(--t2),
    transform var(--t3) var(--ease-out);
}
.tk-dock.has-draft { --w-closed: 158px; }
.tk-dock.big { --w-open: min(920px, calc(100vw - 24px)); }
/* The bar sits in the main pane, which is narrower than the window when the sidebar is open */
@supports (width: 1cqw) { .tk-dock { --w-open: min(680px, calc(100cqw - 24px)); } .tk-dock.big { --w-open: min(920px, calc(100cqw - 24px)); } }
.tk-dock:not(.open):hover { transform: translate(-50%, -1px); box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .26), 0 0 0 1px var(--line); }
.tk-dock:not(.open):active { transform: translateX(-50%) scale(.98); }
.tk-dock.open { width: var(--w-open); border-radius: var(--r-l); box-shadow: var(--e3); }
.ticket-view.sheet-open .tk-dock { opacity: 0; pointer-events: none; transform: translate(-50%, 16px); }
.tk-dock-pill {
  position: absolute; inset: 0 auto auto 0; display: flex; align-items: center; gap: 10px;
  width: max-content; height: 48px; padding: 0 18px; color: var(--ink);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: opacity var(--t2), transform var(--t3) var(--ease-out);
}
.tk-dock-plus { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--accent); color: var(--accent-text); }
.tk-dock-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--open); }
.tk-dock.open .tk-dock-pill { opacity: 0; pointer-events: none; transform: translateY(-6px); }
.tk-dock-form {
  position: absolute; inset: 0 auto auto 0; width: var(--w-open);
  padding: 16px 20px 14px; opacity: 0; pointer-events: none;
  transition: opacity var(--t2);
}
.tk-dock.open .tk-dock-form { opacity: 1; pointer-events: auto; transition-delay: 110ms; }
.tk-dock-top { display: flex; align-items: center; gap: 2px; }
.tk-dock-top .tk-dock-title { margin-right: 6px; }
.tk-dock-title { font-size: 18px; font-weight: 700; line-height: 1.4; }
.tk-dock-ed { max-height: 40vh; margin-top: 8px; overflow-y: auto; border-radius: var(--r-s); transition: max-height var(--t3) var(--ease-out); }
.tk-dock-ed .tk-ed.note-editor { min-height: 150px; font-size: 14px; transition: min-height var(--t3) var(--ease-out); }
.tk-dock.big .tk-dock-ed { max-height: calc(100dvh - 250px); }
.tk-dock.big .tk-dock-ed .tk-ed.note-editor { min-height: min(52vh, 520px); }
.tk-dock-attrs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tk-attr {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); font-size: 12.5px;
  transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
}
.tk-attr:hover { background: var(--tint); color: var(--ink); }
.tk-attr.set { background: var(--tint); box-shadow: none; color: var(--ink); }
.tk-attr .tk-stack .tk-av { box-shadow: 0 0 0 2px var(--raised); }
.tk-attr .tk-ellipsis { max-width: 160px; }
.tk-dock-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.tk-dock .tk-err { min-height: 0; margin-top: 6px; }
.tk-shake { animation: tk-shake .36s var(--ease-out); }
@keyframes tk-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* ---------- Toast and lightbox ---------- */
.tk-toast {
  position: fixed; left: 50%; top: 64px; z-index: 95;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px; border-radius: var(--r-m);
  background: var(--raised); box-shadow: var(--e2); font-size: 13px;
  transform: translateX(-50%);
  animation: tk-toast-in var(--t3) var(--ease-spring);
}
.tk-toast.out { opacity: 0; transform: translate(-50%, -8px); transition: opacity var(--t2), transform var(--t2) var(--ease-in); }
.tk-toast .tk-btn { height: 28px; padding: 0 10px; font-size: 12.5px; }
@keyframes tk-toast-in { from { opacity: 0; transform: translate(-50%, -14px) scale(.96); } }
.tk-lightbox { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 48px 24px; background: rgba(0, 0, 0, .82); animation: tk-fade var(--t2); cursor: zoom-out; }
.tk-lightbox img { max-width: 100%; max-height: calc(100vh - 140px); border-radius: var(--r-m); box-shadow: var(--e3); animation: tk-zoom-in var(--t3) var(--ease-out); }
.tk-lightbox .tk-cap { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; align-items: center; justify-content: center; gap: 12px; color: #fff; font-size: 13px; }
.tk-lightbox .tk-cap .tk-btn { color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
@keyframes tk-fade { from { opacity: 0; } }
@keyframes tk-zoom-in { from { opacity: 0; transform: scale(.94); } }

/* ---------- Phone: one column, status tabs, a bottom-sheet card ---------- */
@media (max-width: 760px) {
  .ticket-bar { gap: 8px; }
  .tk-views .label { display: none; }
  /* Icon only; a tag filter in use gets a darker outline, clearing is in the menu */
  .tk-tag-filter, .tk-tag-filter.on { padding: 0 10px; }
  .tk-tag-filter .label, .tk-tag-filter .clear { display: none; }
  .tk-search { flex: 1; width: auto; }
  /* The search field fills the bar while it is being typed in */
  .tk-search:focus-within { position: absolute; left: 8px; right: 8px; z-index: 2; }
  /* iOS zooms into inputs under 16px */
  .tk-input, .tk-ed.note-editor, .tk-dock-ed .tk-ed.note-editor, .tk-title-input { font-size: 16px; }
  .tk-col-tabs {
    display: flex; flex: none; gap: 6px; padding: 2px 14px 10px; overflow-x: auto; scrollbar-width: none;
  }
  .tk-col-tabs::-webkit-scrollbar { display: none; }
  .tk-col-tabs button {
    display: inline-flex; flex: none; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
    border-radius: var(--r-s); background: var(--well); color: var(--ink-2); font-size: 13.5px; font-weight: 500;
    transition: background-color var(--t2), color var(--t2), box-shadow var(--t2);
  }
  .tk-col-tabs button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--e1); }
  .tk-col-tabs .count { color: var(--ink-3); font-size: 12px; }
  .tk-board {
    grid-auto-columns: calc(100vw - 40px); gap: 12px; padding: 0 14px calc(120px + env(safe-area-inset-bottom));
    scroll-snap-type: x mandatory; scroll-padding: 14px; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  @supports (width: 1cqw) { .tk-board { grid-auto-columns: calc(100cqw - 40px); } }
  .tk-board::-webkit-scrollbar { display: none; }
  .tk-col { padding-top: 8px; scroll-snap-align: start; scroll-snap-stop: always; }
  .tk-col-head { display: none; }
  .tk-expand-btn { display: none; }
  .tk-sheet-head { position: relative; }
  .tk-sheet-head::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line); }
  .tk-layer { padding: 0; place-items: end stretch; }
  .tk-sheet { width: 100%; height: 94dvh; border-radius: var(--r-l) var(--r-l) 0 0; }
  .tk-sheet.expanded { height: 100dvh; border-radius: 0; }
  .tk-sheet-body { display: block; overflow-y: auto; }
  .tk-sheet-main { padding: 18px 20px calc(48px + env(safe-area-inset-bottom)); overflow: visible; }
  .tk-sheet-main > .tk-props { display: flow-root; margin-top: 18px; padding: 14px 14px 0; border-radius: var(--r-m); background: color-mix(in srgb, var(--well) 55%, var(--raised)); }
  .tk-sheet-main > .tk-props .tk-status-list { grid-template-columns: 1fr 1fr; }
  .tk-sheet-main > .tk-feed-sec { margin-top: 32px; }
  /* The create bar does not animate its width: opening it shows the big editor straight away */
  .tk-dock { bottom: calc(16px + env(safe-area-inset-bottom)); --w-open: calc(100vw - 24px); }
  @supports (width: 1cqw) { .tk-dock, .tk-dock.big { --w-open: calc(100cqw - 24px); } }
  .tk-dock, .tk-dock * { transition: none !important; }
  .tk-dock:not(.open):hover { transform: translateX(-50%); }
  .tk-dock-big { display: none; }
  .tk-toast { top: 60px; }
}

/* A touch screen has no hover: what only appeared on hover stays shown, and cards do not lift */
@media (hover: none) {
  .note-editor .att-x, .tk-person .x { opacity: 1; }
  .tk-card:hover { transform: none; box-shadow: var(--e1); }
}

@media (prefers-reduced-motion: reduce) {
  .tk, .tk *, .tk *::before, .tk *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; transition-delay: 0ms !important; }
}
