body.tk { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.tk-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.tk-top nav { display: flex; gap: 8px; }

.tk-wrap { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px; display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; min-height: 0; }
.tk-side, .tk-main { border: 1px solid var(--line); border-radius: 20px; background: rgba(17, 17, 19, .7); min-height: 0; }
.tk-side { display: flex; flex-direction: column; overflow: hidden; height: calc(100vh - 120px); }
.tk-side-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.tk-side-head h1 { font-family: var(--display); font-size: 22px; letter-spacing: -.02em; }
.tk-list { overflow-y: auto; padding: 8px; display: grid; gap: 4px; align-content: start; }
.tk-empty { color: var(--dim); font-size: 14px; padding: 16px 10px; }
.tk-item { display: grid; gap: 3px; width: 100%; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid transparent; background: none; cursor: pointer; transition: background .15s; }
.tk-item:hover { background: var(--panel-2); }
.tk-item.on { background: var(--accent-soft); border-color: rgba(var(--accent-rgb), .35); }
.tk-item-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-item-top b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tk-item small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); flex: none; }
.tk-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; flex: none; }
.tk-pill.open { background: rgba(34, 197, 94, .14); color: #86efac; }
.tk-pill.closed { background: rgba(255, 255, 255, .07); color: var(--muted); }

.tk-main { display: flex; flex-direction: column; height: calc(100vh - 120px); overflow: hidden; }
.tk-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tk-pane[hidden] { display: none; }
.tk-hello { margin: auto; max-width: 420px; text-align: center; padding: 30px 20px; }
.tk-hello-ic { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; display: grid; place-items: center; background: var(--accent-soft); }
.tk-hello-ic svg { width: 26px; height: 26px; fill: var(--accent-text); }
.tk-hello h2 { font-family: var(--display); font-size: 26px; letter-spacing: -.02em; margin-bottom: 8px; }
.tk-hello p { color: var(--muted); margin-bottom: 20px; }
.tk-hello .tk-small { font-size: 13px; margin: 16px 0 0; }
.tk-hello .tk-small a { color: var(--accent-text); }

.tk-form { padding: 24px; overflow-y: auto; max-width: 640px; }
.tk-form h2 { font-family: var(--display); font-size: 22px; margin-bottom: 18px; }
.tk-form .btn-primary { align-self: flex-start; }
.tk-back { display: none; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0; margin-bottom: 12px; text-align: left; }

.tk-thread-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.tk-thread-head .tk-back { margin: 0; }
.tk-thread-title { flex: 1; min-width: 0; }
.tk-thread-title h2 { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 2px; }

.tk-msgs { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.tk-msg { max-width: min(560px, 86%); display: grid; gap: 4px; }
.tk-msg.user { align-self: flex-end; }
.tk-msg .who { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.tk-msg.user .who { justify-content: flex-end; }
.tk-msg .who b { color: var(--text); font-weight: 600; }
.tk-msg.staff .who b { color: var(--accent-text); }
.tk-staff-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); }
.tk-bubble { padding: 11px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.5; }
.tk-msg.user .tk-bubble { background: #26262a; color: var(--text); border-bottom-right-radius: 6px; }
.tk-msg.staff .tk-bubble { background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.tk-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tk-files a { font-size: 12.5px; padding: 4px 9px; border-radius: 8px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); color: var(--accent-text); }
.tk-files img { max-width: 240px; max-height: 200px; border-radius: 10px; border: 1px solid var(--line); }
.tk-sys { align-self: center; font-size: 12.5px; color: var(--dim); padding: 4px 12px; border-radius: 99px; background: var(--panel); }

.tk-reply { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; border-top: 1px solid var(--line); }
.tk-reply textarea { min-height: 44px; max-height: 180px; resize: none; padding-top: 11px; }
.tk-closed-note { padding: 16px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center; }
.tk-closed-note[hidden] { display: none; }

.tk-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 12px; background: #19191c; border: 1px solid var(--line-2); font-size: 14px; transition: .2s; z-index: 50; }
.tk-toast.show { opacity: 1; transform: translate(-50%, 0); }
.tk-toast.err { border-color: rgba(244, 63, 94, .5); color: #fda4af; }

@media (max-width: 820px) {
  .tk-wrap { grid-template-columns: minmax(0, 1fr); padding: 14px 16px; }
  .tk-side, .tk-main { height: calc(100vh - 100px); }
  body.tk.viewing .tk-side { display: none; }
  body.tk:not(.viewing) .tk-main { display: none; }
  .tk-back { display: inline-block; }
}
@media (max-width: 820px) {
  .tk-thread-head { padding: 12px 14px; gap: 10px; }
  .tk-meta > span:not(.tk-pill) { display: none; }
}

/* staff view */
.tk-staffbar { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.tk-staffbar[hidden], .tk-filters[hidden] { display: none; }
.tk-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.tk-seg button { height: 32px; border: none; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tk-seg button.on { background: var(--accent-soft); color: var(--accent-text); }
.tk-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; }
.tk-count[hidden] { display: none; }
.tk-filters { display: flex; gap: 8px; }
.tk-filters select { height: 34px; font-size: 13px; padding: 0 10px; flex: 1; }
.tk-item .tk-user { color: var(--accent-text); }
.tk-msg.note .tk-bubble { background: rgba(245, 158, 11, .1); border: 1px dashed rgba(245, 158, 11, .45); color: #fde68a; }
.tk-note-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; background: rgba(245, 158, 11, .15); color: #fcd34d; }
.tk-reply-box { flex: 1; display: grid; gap: 6px; min-width: 0; }
.tk-note-toggle { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.tk-note-toggle[hidden] { display: none; }
.tk-reply.note textarea { border-color: rgba(245, 158, 11, .6); box-shadow: 0 0 0 4px rgba(245, 158, 11, .12); }
.tk-help { color: var(--muted); font-size: 14px; margin: -8px 0 16px; }
.tk-help.small { font-size: 13px; margin: -4px 0 14px; }
.tk-help b { color: var(--text); }
.tk-status { font-size: 13.5px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 16px; }
.tk-status.ok { border-color: rgba(34, 197, 94, .35); color: #86efac; }
.tk-status.warn { border-color: rgba(245, 158, 11, .35); color: #fcd34d; }
body.tk [hidden] { display: none !important; }

/* open / archive groups */
.tk-group-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); padding: 8px 10px 4px; }
.tk-empty.small { font-size: 13px; padding: 6px 10px 10px; }
.tk-cat { display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 10px; padding: 8px 10px; border: none; background: none; color: var(--dim); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; border-radius: 8px; text-align: left; }
.tk-cat:hover { color: var(--text); background: var(--panel); }
.tk-cat svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.tk-cat.open svg { transform: rotate(90deg); }
.tk-cat-count { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); letter-spacing: 0; }
.tk-archive { display: grid; gap: 4px; padding-left: 8px; margin-left: 8px; border-left: 1px solid var(--line); }
.tk-item.closed b { color: var(--muted); font-weight: 500; }
.tk-filter-note { flex: 1; align-self: center; font-size: 12px; color: var(--dim); }
