:root {
  --bg: #0a0c11; --panel: #10131a; --surface: #161a23; --surface-2: #1c212c; --line: #252b39; --line-soft: #1b202b;
  --text: #e6e9f0; --dim: #8d95a8; --faint: #5c6478; --accent: #7c8cff; --accent-soft: #7c8cff26; --ok: #34d399; --bad: #f87171;
  --agent: #c4b5fd; --r: 10px; --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.dim { color: var(--dim); } .faint { color: var(--faint); }
.error { color: var(--bad); min-height: 1.2em; margin: 0; }
.i { width: 16px; height: 16px; flex: none; stroke-width: 2; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

input, select, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  transition: border-color .15s, background-color .15s; min-width: 0; }
input:hover, select:hover, textarea:hover { border-color: #313849; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
select { appearance: none; padding-right: 28px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238d95a8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center; }
textarea { width: 100%; resize: vertical; min-height: 44px; line-height: 1.5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .1s, color .15s; }
.btn:hover { background: var(--surface-2); border-color: #313849; }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0d17; }
.btn.primary:hover { background: #95a2ff; border-color: #95a2ff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { padding: 7px; }
.btn.sm { padding: 4px; } .btn.sm .i { width: 14px; height: 14px; }
.btn.danger:hover { color: var(--bad); background: #f871711a; }

.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.01em; font-size: 15px; }
.mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: #fff;
  background: linear-gradient(135deg, #7c8cff, #a78bfa); box-shadow: 0 2px 12px #7c8cff44; }
.mark .i { width: 15px; height: 15px; }

/* auth */
.auth { max-width: 340px; margin: 16vh auto; display: flex; flex-direction: column; gap: 10px; padding: 28px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; animation: pop .3s var(--ease); }
.auth .brand { font-size: 20px; margin-bottom: 4px; }
.auth input { padding: 9px 12px; } .auth .btn { justify-content: center; padding: 9px; }
.auth p { margin: 0; }

/* layout */
#app { display: flex; flex-direction: column; height: 100%; }
header { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line-soft); background: var(--panel); flex-wrap: wrap; }
header .brand { margin-right: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 10px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 32px; width: 220px; }
#live { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin: 0 6px; }
#live.on { background: var(--ok); animation: pulse 2.4s infinite; }
main { flex: 1; display: flex; min-height: 0; position: relative; }

/* board */
#board { flex: 1; display: flex; gap: 12px; padding: 14px; overflow-x: auto; }
.col { flex: 0 0 300px; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 14px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; font-weight: 600; font-size: 13px; }
.count { font-size: 11.5px; font-weight: 500; color: var(--dim); background: var(--surface); border-radius: 99px; padding: 1px 8px; }
.cards { flex: 1; overflow-y: auto; padding: 2px 10px 10px; display: flex; flex-direction: column; gap: 8px; border-radius: 0 0 14px 14px; transition: background-color .15s; }
.cards.drop { background: var(--accent-soft); }
.cards:not(:has(.card))::before { content: "Nothing here"; color: var(--faint); font-size: 12.5px; text-align: center; padding: 18px 0; border: 1px dashed var(--line); border-radius: var(--r); }
.more { height: 1px; flex: none; }

.card { flex: none; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 10px 12px; cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s, border-color .15s; }
.card:hover { transform: translateY(-1px); border-color: var(--line); box-shadow: 0 6px 20px #0006; }
.card.flash { animation: enter .35s var(--ease), glow 1.6s ease-out; }
.card.dragging { opacity: .35; }
.card .title { margin: 5px 0 0; word-break: break-word; line-height: 1.4; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); min-width: 0; }
.card-foot { display: flex; margin-top: 8px; }
.id { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.flair { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 1px 8px 1px 7px; border-radius: 99px;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.flair::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.who { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 10.5px; font-weight: 650; color: #fff; flex: none; background: var(--h); }
.avatar.agent { border-radius: 6px; color: var(--agent); background: #c4b5fd1f; }
.avatar .i { width: 13px; height: 13px; }

/* activity */
#activity { width: 340px; border-left: 1px solid var(--line-soft); background: var(--panel); display: none; flex-direction: column; min-height: 0; }
#activity.open { display: flex; animation: slide .25s var(--ease); }
.aside-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 16px; }
#feed { list-style: none; padding: 0 8px 12px; margin: 0; overflow-y: auto; font-size: 13px; }
#feed li { padding: 8px; border-radius: 8px; cursor: pointer; display: grid; grid-template-columns: 20px 1fr; gap: 2px 10px; animation: enter .3s var(--ease); }
#feed li:hover { background: var(--surface); }
#feed .what { color: var(--dim); } #feed .what b { color: var(--text); font-weight: 500; }
#feed .snippet { grid-column: 2; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#feed time, .timeline time { color: var(--faint); font-size: 12px; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 0;
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 80px #000a; }
dialog[open] { animation: pop .22s var(--ease); }
dialog::backdrop { background: #05070bb3; backdrop-filter: blur(3px); animation: fade .2s; }
.dlg-top { display: flex; align-items: center; gap: 8px; padding: 12px 14px 0 20px; }
.dlg-body { padding: 8px 20px 20px; }
.ticket-grid { display: grid; grid-template-columns: 1fr 250px; gap: 24px; }
.ticket-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.title-input { margin-bottom: 8px; font-size: 20px; font-weight: 650; letter-spacing: -.01em; width: 100%; background: transparent; border-color: transparent; padding: 4px 8px; margin-left: -9px; }
.title-input:hover { background: var(--surface); }
.pill { font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--dim); }
.side { display: flex; flex-direction: column; gap: 14px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11.5px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.field select { width: 100%; }
.links { display: flex; flex-direction: column; gap: 2px; }
.link { display: flex; align-items: center; gap: 7px; padding: 4px 6px; margin: 0 -6px; border-radius: 6px; min-width: 0; }
.link:hover { background: var(--surface); }
.link a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link .i { color: var(--faint); }
.link .btn { opacity: 0; } .link:hover .btn { opacity: 1; }
.section-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.desc { background: var(--surface); border-radius: 12px; padding: 12px 14px; }

.md { word-break: break-word; line-height: 1.6; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 1em 0 .4em; } .md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.05em; }
.md img { max-height: 180px; max-width: 100%; border-radius: 8px; margin: 4px 6px 0 0; vertical-align: top; cursor: zoom-in; border: 1px solid var(--line);
  transition: transform .15s var(--ease); }
.md img:hover { transform: scale(1.02); }
.md pre { background: var(--bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; border: 1px solid var(--line-soft); }
.md code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: .9em; } .md pre code { padding: 0; }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--dim); }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.md a.file { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; margin: 2px 4px 2px 0; border-radius: 8px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.md a.file:hover { border-color: var(--accent); text-decoration: none; }

.timeline { display: flex; flex-direction: column; gap: 4px; }
.ev { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); padding: 3px 0; }
.ev > .i { color: var(--faint); width: 14px; height: 14px; margin: 0 3px; }
.ev b { color: var(--text); font-weight: 500; }
.comment { background: var(--surface); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.timeline .enter { animation: enter .35s var(--ease); }
.comment > .meta { margin-bottom: 6px; }

.composer { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer.over { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.composer textarea { border: 0; background: transparent; padding: 10px 12px; }
.composer textarea:focus { background: transparent; }
.composer .bar { display: flex; align-items: center; gap: 6px; padding: 6px; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.tray:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 3px 3px 4px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; max-width: 220px; animation: enter .2s var(--ease); }
.chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 5px; }
.chip > .i { margin: 0 4px; color: var(--dim); }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.loading { opacity: .6; } .chip.loading .name::after { content: " …"; }

/* settings */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border-radius: 10px; }
.tabs .btn { border: 0; padding: 5px 12px; background: transparent; color: var(--dim); }
.tabs .btn.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 3px #0005; }
.list { display: flex; flex-direction: column; margin: 14px 0; }
.item { display: flex; align-items: center; gap: 8px; padding: 6px 6px; border-radius: 8px; }
.item:hover { background: var(--surface); }
.item .ghost-input { background: transparent; border-color: transparent; }
.item .ghost-input:hover { border-color: var(--line); }
.item .actions { display: flex; gap: 2px; opacity: .5; transition: opacity .15s; } .item:hover .actions { opacity: 1; }
.swatch { width: 26px; height: 26px; padding: 0; border-radius: 50%; overflow: hidden; border: 2px solid var(--line); cursor: pointer; flex: none; }
.swatch::-webkit-color-swatch-wrapper { padding: 0; } .swatch::-webkit-color-swatch { border: 0; }
.add { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.add input { flex: 1; min-width: 140px; }
.keybox { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-top: 12px; background: #34d3991a; border: 1px solid #34d39955; border-radius: 10px; animation: enter .25s var(--ease); }
.keybox code { flex: 1; font-size: 12.5px; user-select: all; word-break: break-all; }

#lightbox { width: auto; max-width: 94vw; background: transparent; border: 0; box-shadow: none; cursor: zoom-out; }
#lightbox img { display: block; max-width: 94vw; max-height: 90vh; border-radius: 10px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 10; align-items: center; }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; box-shadow: 0 10px 30px #0008; animation: rise .25s var(--ease); }
.toast.bad { border-color: #f8717166; color: #fecaca; }

@keyframes enter { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes glow { from { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 24px #7c8cff33; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #34d39966; } 70%, 100% { box-shadow: 0 0 0 7px #34d39900; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 720px) {
  header { padding: 8px 10px; }
  header .brand .name, #btn-new span { display: none; }
  .search { order: 10; flex-basis: 100%; } .search input { width: 100%; }
  #f-project, #f-assignee { max-width: 34vw; }
  #board { padding: 10px; }
  .col { flex-basis: 84vw; }
  #activity.open { position: absolute; left: 0; right: 0; bottom: 0; height: 55%; width: auto; border-left: 0; border-top: 1px solid var(--line);
    box-shadow: 0 -12px 40px #000a; border-radius: 16px 16px 0 0; animation: rise .25s var(--ease); z-index: 2; }
  .ticket-grid { grid-template-columns: 1fr; }
  .side { order: -1; display: grid; grid-template-columns: 1fr 1fr; }
  .dlg-body { padding: 8px 14px 16px; }
}
.hint { font-size: 12px; }
.tabs.kind { margin: 4px 0 10px; }
.footnote { font-size: 12.5px; margin: 16px 0 0; }
#settings { width: min(640px, calc(100vw - 32px)); }
