@layer views {
/* Ticket sheet: overlay, header, lineage, QA loop, fields, subtickets, links */
.sheet-wrap { position: fixed; inset: 0; z-index: var(--z-sheet); display: flex; align-items: center; justify-content: center; padding: 2.5vh max(16px, 2.5vw); }
.sheet { position: relative; width: 100%; max-width: 1380px; height: 100%; background: var(--bg-1); border: 1px solid var(--line-2); border-radius: var(--r-16); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 40px 120px -20px rgb(var(--black-rgb) / 0.9); animation: pop 220ms var(--ease-out); }
.sheet-h { height: 50px; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.idchip { font-family: var(--f-mono); font-size: var(--fs-12); color: var(--fg); background: var(--bg-4); border: 1px solid var(--line-2); border-radius: var(--r-7); padding: 3px 8px; display: inline-flex; align-items: center; gap: 6px; }
.idchip:hover { border-color: var(--fg-4); }
.watch { display: flex; align-items: center; gap: 8px; font-size: var(--fs-12); color: var(--fg-3); white-space: nowrap; }
.sheet-b { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 390px; }
.sheet-main { overflow: auto; padding: 22px 40px 60px; min-width: 0; }
.sheet-main > :not(.modal-wrap, .lightbox, focus-trap) { max-width: 900px; }
.sheet-loading { padding: 40px; color: var(--fg-3); }

.lineage { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--fg-3); flex-wrap: wrap; }
.lineage .sl { color: var(--fg-4); }
.lineage a, .lineage button { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--r-7); border: 1px solid var(--line); background: var(--bg-2); color: var(--fg-2); max-width: 280px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lineage a:hover, .lineage button:hover { border-color: var(--line-2); color: var(--fg); }

.tk-title { font-family: var(--f-display); font-weight: 700; font-size: var(--fs-32); line-height: 1.1; letter-spacing: -0.02em; margin: 12px 0 6px; text-wrap: balance; outline: none; border-radius: var(--r-6); width: 100%; background: none; border: 0; padding: 2px 4px; margin-left: -4px; color: var(--fg); resize: none; overflow: hidden; }
.tk-title:hover { background: var(--bg-2); }
.tk-title:focus { background: var(--bg-2); box-shadow: 0 0 0 1px var(--line-2); }
.tk-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--fg-3); font-size: var(--fs-12); align-items: center; }
.tk-sub b { color: var(--fg-2); font-weight: 500; }

/* QA loop */
.flow { margin: 22px 0 8px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-14); padding: 14px 16px; }
.flow-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.flow-top .lab { font-size: var(--fs-10-5); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-4); font-weight: 600; }
.flow-top .auto { font-size: var(--fs-11-5); color: var(--fg-3); display: flex; align-items: center; gap: 5px; margin-left: auto; }
.flow-top .auto b { color: var(--merged); font-weight: 600; }
.steps { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); padding-top: 30px; }
.steps svg.arc { position: absolute; left: 0; top: 0; width: 100%; height: 34px; overflow: visible; }
.steps svg.arc path { fill: none; stroke: var(--st-reo); stroke-width: 1.6; stroke-dasharray: 4 3; }
.arc-label { position: absolute; top: -2px; left: 40%; transform: translateX(-50%); font-size: var(--fs-10-5); font-weight: 700; color: var(--st-reo); background: var(--bg-2); padding: 0 6px; letter-spacing: 0.02em; white-space: nowrap; }
.step { display: flex; flex-direction: column; align-items: center; gap: 7px; position: relative; font-size: var(--fs-11-5); color: var(--fg-3); text-align: center; }
.step::before { content: ""; position: absolute; top: 10px; left: -50%; right: 50%; height: 2px; background: var(--line-2); }
.step:first-of-type::before { display: none; }
.step.done::before, .step.cur::before { background: var(--loop); }
.step .node { width: 22px; height: 22px; border-radius: var(--r-round); border: 2px solid var(--line-2); background: var(--bg-2); position: relative; z-index: var(--z-local-1); display: grid; place-items: center; color: var(--fg-on-accent); }
.step.done .node { background: var(--accent); border-color: var(--accent); }
.step.cur .node { border-color: var(--accent); background: var(--bg-1); box-shadow: 0 0 0 5px var(--accent-soft); }
.step.cur .node::after { content: ""; width: 8px; height: 8px; border-radius: var(--r-round); background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
.step.cur { color: var(--fg); font-weight: 600; }
.step.done { color: var(--fg-2); }
.step .when { font-size: var(--fs-10-5); color: var(--fg-4); font-weight: 400; }
@keyframes pulse { 50% { transform: scale(0.6); opacity: 0.6; } }
.flow-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.flow-actions .lab { font-size: var(--fs-11-5); color: var(--fg-3); margin: 0 4px 0 8px; }
.retest { display: flex; align-items: center; gap: 6px; font-size: var(--fs-11-5); color: var(--fg-3); margin-left: auto; }
.retest i { width: 18px; height: 6px; border-radius: var(--r-3); background: var(--bg-5); }
.retest i.ok { background: var(--ok); }
.retest i.fail { background: var(--bad); }

/* Fields grid */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; margin: 18px 0 8px; }
/* The fold under the six main fields: a line across with a chevron in the middle (up while the rest show). */
.fields-more { grid-column: 1 / -1; position: relative; display: flex; justify-content: center; align-items: center; height: 30px; color: var(--fg-4); font-size: var(--fs-11-5); }
.fields-more::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.fields-more > * { position: relative; background: var(--bg-1); }
.fields-more .chev { padding: 0 4px 0 8px; box-sizing: content-box; transition: transform var(--t-fast); }
.fields-more > span { padding-right: 8px; }
.fields-more.open .chev { transform: rotate(180deg); }
.fields-more:hover { color: var(--fg-2); }
.f { display: grid; grid-template-columns: 118px minmax(0, 1fr); align-items: center; min-height: 36px; border-bottom: 1px solid var(--line); }
.f .k { color: var(--fg-3); font-size: var(--fs-12); display: flex; align-items: center; gap: 7px; }
.f .k .i { color: var(--fg-4); }
.f .v { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 6px; border-radius: var(--r-7); margin-left: -6px; min-height: 30px; cursor: pointer; min-width: 0; text-align: left; width: 100%; }
.f .v:hover { background: var(--bg-3); }
.f .v.readonly { cursor: default; }
.f .v.readonly:hover { background: none; }
.f .v .ver { font-family: var(--f-mono); font-size: var(--fs-11-5); color: var(--fg-2); }
.f .v .add { color: var(--fg-4); font-size: var(--fs-11-5); }
.f .hint { font-size: var(--fs-10-5); color: var(--fg-4); }
.f input.inline { background: var(--bg-1); border: 1px solid var(--accent-line); border-radius: var(--r-6); height: 26px; padding: 0 8px; outline: none; width: 100%; }

/* Subtickets */
.subs { border: 1px solid var(--line-2); border-radius: var(--r-12); overflow: hidden; max-width: 900px; }
.subs-h { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: var(--fs-12); color: var(--fg-3); }
.sub-r { display: grid; grid-template-columns: 22px 74px minmax(0, 1fr) auto auto 26px; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.sub-r:first-of-type { border-top: 0; }
.sub-r:hover { background: var(--bg-2); }
.sub-r .mono { font-size: var(--fs-11); color: var(--fg-3); }
.sub-r .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-r.done .tt { color: var(--fg-3); text-decoration: line-through; text-decoration-color: var(--fg-4); }
.sub-add { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-top: 1px solid var(--line); color: var(--fg-4); }
.sub-add input { flex: 1; background: none; border: 0; outline: none; height: 30px; font-size: var(--fs-12-5); color: var(--fg); }

/* Checklist */
.chk { display: flex; flex-direction: column; max-width: 900px; }
.ci { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-8); text-align: left; width: 100%; }
.ci:hover { background: var(--bg-2); }
.ci .lbl { flex: 1; min-width: 0; }
.ci.done .cb { background: var(--ok); border-color: var(--ok); color: var(--fg-on-accent); }
.ci.done .lbl { color: var(--fg-3); text-decoration: line-through; text-decoration-color: var(--fg-4); }
.ci .who { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: var(--fs-11); color: var(--fg-4); }
.ci .rm { opacity: 0; }
.ci:hover .rm { opacity: 1; }
.chk-prog { width: 90px; height: 5px; border-radius: var(--r-3); background: var(--bg-5); overflow: hidden; }
.chk-prog i { display: block; height: 100%; background: var(--ok); transition: width 300ms; }
.chk-add { display: flex; gap: 8px; padding: 4px 8px; color: var(--fg-4); align-items: center; }
.chk-add input { flex: 1; background: none; border: 0; outline: none; height: 30px; color: var(--fg); }

/* Links */
.rels { display: flex; flex-direction: column; gap: 6px; max-width: 900px; }
.rel { display: grid; grid-template-columns: 110px 74px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-10); border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; }
.rel:hover { border-color: var(--line-2); }
.rel .kind { display: flex; align-items: center; gap: 7px; font-size: var(--fs-11-5); font-weight: 600; }
.rel .kind.block { color: var(--bad); }
.rel .kind.wait { color: var(--warn); }
.rel .kind.dup { color: var(--fg-3); }
.rel .kind.rel2 { color: var(--info); }
.rel .kind.gh { color: var(--merged); }
.rel .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel .merged-note { grid-column: 3 / -1; font-size: var(--fs-11); color: var(--fg-3); margin-top: -4px; }

/* GitHub card */
.gh { margin: 16px 0; border: 1px solid var(--line-2); border-radius: var(--r-12); overflow: hidden; }
.gh-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-width: 0; flex-wrap: wrap; }
.gh-row + .gh-row { border-top: 1px solid var(--line); }
.gh-row .prt { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 220px; }
.gh-row .prt span { color: var(--fg-3); font-weight: 400; }
.mrg { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-11); font-weight: 700; color: var(--merged); background: color-mix(in srgb, var(--merged) 13%, transparent); border-radius: var(--r-6); padding: 3px 8px; }
.mrg.open { color: var(--pr-open); background: color-mix(in srgb, var(--pr-open) 13%, transparent); }
.mrg.draft { color: var(--fg-3); background: var(--bg-4); }
.diff { font-family: var(--f-mono); font-size: var(--fs-11); white-space: nowrap; }
.diff .a { color: var(--ok); }
.diff .d { color: var(--bad); }
.checks { font-size: var(--fs-11-5); color: var(--ok); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.checks.failing { color: var(--bad); }
.checks.pending { color: var(--warn); }
.branch { font-family: var(--f-mono); font-size: var(--fs-11-5); color: var(--fg-2); background: var(--bg-3); border-radius: var(--r-6); padding: 2px 8px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.gh-row .when { margin-left: auto; font-size: var(--fs-11); color: var(--fg-4); white-space: nowrap; }

.hist { display: flex; align-items: center; gap: 8px; font-size: var(--fs-11-5); color: var(--fg-3); padding: 8px 10px; border-radius: var(--r-9); background: var(--bg-2); border: 1px solid var(--line); max-width: 720px; flex-wrap: wrap; }
.hist .vers { display: flex; gap: 3px; }
.hist .vers i { width: 8px; height: 8px; border-radius: var(--r-2); background: var(--bg-5); }
.hist .vers i.cur { background: var(--accent); }
.hist button { color: var(--accent); margin-left: auto; }

.desc-view { cursor: text; border-radius: var(--r-10); padding: 6px 8px; margin-left: -8px; }
.desc-view:hover { background: var(--bg-2); }
.desc-empty { color: var(--fg-4); font-size: var(--fs-13); }

.diffview { font-family: var(--f-mono); font-size: var(--fs-12); line-height: 1.6; border: 1px solid var(--line-2); border-radius: var(--r-10); overflow: auto; max-height: 50vh; }
.diffview .dl { padding: 0 10px; white-space: pre-wrap; }
.diffview .ins { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--fg); }
.diffview .del { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--fg-2); text-decoration: line-through; }

@media (max-width: 1100px) { .sheet-b { grid-template-columns: minmax(0, 1fr) 330px; } .sheet-main { padding: 20px 24px 50px; } .fields { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .sheet-wrap { padding: 0; } .sheet { border-radius: 0; }
  .sheet-b { display: block; overflow: auto; } .sheet-main { overflow: visible; padding: 18px 16px 30px; }
  .watch { display: none; } .tk-title { font-size: var(--fs-26); }
  .rel { grid-template-columns: 1fr auto; }
}

/* Additions for the live sheet */
.tk-sub .c-reo { color: var(--st-reo); }
.tk-sub .c-over { color: var(--warn); }
.tk-sub .c-gh { color: var(--merged); display: inline-flex; align-items: center; gap: 4px; }
input.tk-title { width: 100%; background: none; border: 0; outline: none; padding: 0; border-bottom: 1px solid var(--accent-line); border-radius: 0; }
.step .node .i.thick { stroke-width: 2.4; }
.desc-view.editable { cursor: text; }
.edit-desc { margin-top: 6px; font-size: var(--fs-11-5); color: var(--fg-3); display: inline-flex; align-items: center; gap: 5px; }
.edit-desc:hover { color: var(--fg); }
button.desc-empty { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 720px; padding: 14px; border: 1px dashed var(--line-2); border-radius: var(--r-12); text-align: left; }
button.desc-empty:hover { border-color: var(--fg-4); color: var(--fg-2); }
.ci .cb { flex: none; }
.ci .cb:disabled { cursor: default; }
.rel .ibtn.sm { opacity: 0; }
.rel:hover .ibtn.sm, .rel .ibtn.sm:focus-visible { opacity: 1; }

/* Description history dialog */
.hist-body { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; }
.hist-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow: auto; }
.hist-list button { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; padding: 7px 9px; border-radius: var(--r-7); text-align: left; font-size: var(--fs-11-5); color: var(--fg-2); }
.hist-list button .muted { grid-column: 2; font-size: var(--fs-11); }
.hist-list button:hover { background: var(--bg-3); }
.hist-list button.on { background: var(--sel); color: var(--fg); }

/* Link dialog */
.pick-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; min-height: 40px; max-height: 300px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: var(--r-7); text-align: left; font-size: var(--fs-11-5); }
.pick:hover { background: var(--bg-3); }
.pick .mono { color: var(--fg-3); font-size: var(--fs-11); }
.pick .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow .kids-done { margin: 0 0 10px; }
.pick.on { background: var(--sel); }
.dialog .seg { width: 100%; }
.dialog .seg button { flex: 1; justify-content: center; }

/* GitHub card: pull requests and commits that name the ticket */
.gh-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-12); background: var(--bg-2); overflow: hidden; }
.ghpr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "pr tt checks diff" "flow flow who who"; gap: 4px 10px; align-items: center; padding: 10px 12px; color: inherit; }
.ghc, .ghnote + .ghrow { border-top: 1px solid var(--line); }
.ghpr:hover, .ghc:hover { background: var(--bg-3); }
.ghpr .prl { grid-area: pr; }
.ghpr .tt { grid-area: tt; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghpr .checks { grid-area: checks; display: inline-flex; gap: 4px; align-items: center; font-size: var(--fs-10-5); color: var(--fg-3); }
.ghpr .checks.ok { color: var(--ok); }
.ghpr .checks.bad { color: var(--bad); }
.ghpr .diff { grid-area: diff; font-family: var(--f-mono); font-size: var(--fs-10-5); }
.ghpr .diff .add { color: var(--ok); }
.ghpr .diff .del { color: var(--bad); }
.ghpr .flow { grid-area: flow; font-size: var(--fs-11); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghpr .who, .ghc .who { grid-area: who; font-size: var(--fs-11); color: var(--fg-4); text-align: right; white-space: nowrap; }
.ghnote { display: flex; gap: 6px; align-items: center; padding: 6px 12px 10px; font-size: var(--fs-12); color: var(--fg-3); }
.ghc { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 12px; color: inherit; font-size: var(--fs-12-5); }
.ghc .sha { color: var(--accent); font-size: var(--fs-11); }
.ghc .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--fg-2); }
.ghmore { padding: 7px 12px; text-align: left; font-size: var(--fs-12); color: var(--accent); border-top: 1px solid var(--line); }

/* Linking a pull request by hand: the header button, the inline form, the unlink cross on each row. */
.h2 .h2-act { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: var(--r-7); font-family: var(--f-ui); font-size: var(--fs-11-5); font-weight: 500; color: var(--fg-3); }
.h2 .h2-act:hover { background: var(--bg-4); color: var(--fg); }
.ghlink { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.ghlink .err, .ghlink .hint { grid-column: 1 / -1; font-size: var(--fs-11-5); }
.ghlink .hint { color: var(--fg-4); }
.ghrow { position: relative; }
.ghrow:has(.ghx) .ghpr { padding-right: 40px; }
.ghrow + .ghrow { border-top: 1px solid var(--line); }
.ghrow .ghx { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-7); color: var(--fg-3); background: var(--bg-3); opacity: 0; transition: opacity var(--t-fast); }
.ghrow:hover .ghx, .ghrow .ghx:focus-visible { opacity: 1; }
.ghrow .ghx:hover { color: var(--bad); background: var(--bg-4); }
.ghempty { padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--r-12); font-size: var(--fs-12); color: var(--fg-3); }
}
