:root {
  --bg: #f7f6f3; --panel: #ffffff; --card: #ffffff; --text: #1f2328; --muted: #6b7078;
  --line: #e3e1dc; --accent: #5b5bd6; --accent-text: #ffffff; --hover: #efede8; --create: #5b5bd6;
  --waiting: #a3670a; --danger: #b4403a; --agent: #f1f0fb; --code: #f0eee9;
  --s-backlog: #7a7f87; --s-todo: #3d6fb8; --s-doing: #9a6b00; --s-review: #7b4fc2; --s-done: #2f8a57; --s-cancelled: #8f8f8f;
  --radius: 6px; --radius-sm: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --panel: #1e2024; --card: #24262b; --text: #e6e6e3; --muted: #959aa3;
    --line: #2f3238; --accent: #8b8bf0; --accent-text: #111; --hover: #2a2d33; --create: #5b5bd6;
    --waiting: #e0a740; --danger: #ef7d76; --agent: #23233a; --code: #2a2c31;
    --s-backlog: #9aa0a8; --s-todo: #7aa7ec; --s-doing: #e3b341; --s-review: #b593f0; --s-done: #6cc58f; --s-cancelled: #8a8a8a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 1.6em 0 .6em; font-weight: 600; }
h3 { font-size: .9rem; margin: 1.2em 0 .4em; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, pre, .mono, .key { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
code { background: var(--code); padding: .1em .35em; border-radius: var(--radius-sm); font-size: .9em; }
pre { background: var(--code); padding: .7em .9em; border-radius: var(--radius); overflow-x: auto; }
pre code { padding: 0; background: none; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.key { color: var(--muted); font-size: .85em; white-space: nowrap; }

/* The header is the page's one row of controls: where you are, the
   List/Board toggle, search (Ctrl+K) with the list's filters, New ticket,
   who you are, and the settings menu. Everything below it is content. */
header.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; padding: .5rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; color: var(--text); }
.crumb { color: var(--text); font-weight: 600; white-space: nowrap; }
.crumb:hover { text-decoration: none; color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg a { padding: .22rem .7rem; color: var(--muted); font-size: .9rem; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a:hover { text-decoration: none; color: var(--text); background: var(--hover); }
.seg a.on { background: var(--hover); color: var(--text); }
/* The middle of the header: search and Create, centred in the space left. */
.center { flex: 1; display: flex; align-items: center; justify-content: center; gap: .5rem; min-width: 0; }
form.search { display: flex; align-items: center; gap: .4rem; flex: 1; min-width: 12rem; max-width: 34rem; margin: 0; }
.button.create { display: inline-flex; align-items: center; gap: .35rem; flex: none; background: var(--create); color: #fff; font-weight: 600; padding: .38rem .85rem; white-space: nowrap; }
.button.create > span { font-size: 1.25rem; line-height: 1; font-weight: 500; margin-top: -.1rem; }
.profile { display: inline-flex; cursor: pointer; border-radius: 50%; }
.profile .avatar { width: 1.9rem; height: 1.9rem; }
.profile:hover .avatar, details[open] > .profile .avatar { box-shadow: 0 0 0 2px var(--accent); }
.avatar.initial { display: inline-flex; align-items: center; justify-content: center; background: var(--hover); color: var(--text); font-weight: 700; font-size: .85rem; text-transform: uppercase; }
form.search .field { position: relative; flex: 1; display: flex; align-items: center; }
form.search input[type=search] { flex: 1; padding-right: 4.2rem; }
form.search .hint-key { position: absolute; right: .6rem; pointer-events: none; color: var(--muted); opacity: .6; margin: 0; }
form.search .field:focus-within .hint-key { display: none; }
.me { display: flex; align-items: center; gap: .5rem; }
.me form { margin: 0; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; }
.iconbtn:hover, details[open] > .iconbtn { background: var(--hover); color: var(--text); }
.pop.right { left: auto; right: 0; }
.menu-items { display: flex; flex-direction: column; width: 15rem; padding: .35rem; }
.menu-items a, .menuitem { display: block; width: 100%; text-align: left; padding: .4rem .55rem; border-radius: var(--radius-sm); color: var(--text); background: none; font-size: .92rem; }
.menu-items a:hover, .menuitem:hover { background: var(--hover); text-decoration: none; filter: none; }
.menu-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: .5rem .55rem .15rem; }
.menu-items form { border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .3rem; }
.empty { margin: 2rem 0; text-align: center; }
.avatar { width: 20px; height: 20px; border-radius: 50%; vertical-align: middle; }
main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
main.wide { max-width: none; padding: 1.2rem 24px 3rem; }

/* The ticket drawer: the list's click opens it on the right, under the
   header, and the list moves left to make room. */
:root { --drawer-w: min(48rem, 52vw); }
.drawer { display: none; position: fixed; z-index: 15; top: var(--head-h, 3rem); right: 0; bottom: 0; width: var(--drawer-w); overflow-y: auto; background: var(--bg); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgb(0 0 0 / .18); padding: .6rem 1.2rem 3rem; }
body.drawer-open .drawer { display: block; }
body.drawer-open main { max-width: none; margin: 0; padding-right: calc(var(--drawer-w) + 16px); }
.tline.current { background: var(--hover); box-shadow: inset 3px 0 0 var(--accent); }
.panel-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.panel-bar .iconbtn { background: none; padding: 0; }
.drawer .flash, .ticket-modal .flash { width: auto; margin: 0 0 .6rem; }
dialog.ticket-modal { width: min(64rem, calc(100% - 32px)); max-height: calc(100vh - 4rem); overflow-y: auto; padding: .7rem 1.3rem 1.5rem; background: var(--bg); }
.board .card { user-select: none; }
.flash { max-width: 1200px; margin: .8rem auto 0; padding: .5rem 1rem; background: var(--agent); border-radius: var(--radius); width: calc(100% - 32px); }

input, select, textarea, button, .button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .55rem; min-width: 0; }
textarea { width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--radius-sm); padding: .42rem .9rem; cursor: pointer; display: inline-block; }
button:hover, .button:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary { background: var(--hover); color: var(--text); }
button.link { background: none; color: var(--muted); padding: 0; }
button.link:hover { color: var(--text); text-decoration: underline; }
button.danger, .danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
.short { width: 8rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.stack label { display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; color: var(--muted); }
.stack label > * { color: var(--text); }
.inline { display: flex; gap: .4rem; margin-top: .5rem; }
.inline input { flex: 1; }
.buttons { display: flex; gap: .5rem; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1.2rem 0; }
.panel > h2:first-child { margin-top: 0; }
details.panel > summary { cursor: pointer; font-weight: 600; }
details.panel[open] > summary { margin-bottom: .8rem; }
.narrow { max-width: 30rem; margin: 3rem auto; }
.login { text-align: center; }
.login h1 { display: flex; justify-content: center; align-items: center; gap: .5rem; }
.login form { margin-top: .8rem; }
table { border-collapse: collapse; width: 100%; margin-bottom: .6rem; }
th, td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
th { color: var(--muted); font-weight: 500; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.projects { list-style: none; padding: 0; margin: .4rem 0; display: flex; flex-direction: column; gap: .5rem; }
.project { display: flex; align-items: center; gap: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.project:hover { border-color: var(--accent); }
.project-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .15rem; padding: .75rem 1rem; color: var(--text); }
.project-main:hover { text-decoration: none; }
.project-name .key { margin-right: .3rem; }
.project-desc { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta { flex: none; display: flex; gap: 1rem; align-items: center; padding-right: 1rem; }
#new-project h2 { margin-top: 0; }
/* Import from Linear: a drop zone on the projects page (app.js), a file
   picker without script; then the review page. */
.dropzone { margin-top: 1.2rem; padding: 1rem 1.1rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--text); text-align: center; }
.dropzone p { margin: 0; }
.dropzone.over, body.dragging-file .dropzone { border-color: var(--accent); background: var(--hover); }
.dropzone.busy { opacity: .6; pointer-events: none; }
.filepick { color: var(--accent); cursor: pointer; text-decoration: underline; }
.filepick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filepick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.import-people { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.import-people legend { font-weight: 600; margin-bottom: .2rem; }
.import-person { display: flex; align-items: center; gap: .8rem; justify-content: space-between; }
.import-person input[name=login] { width: 14rem; }
.inline-flash { width: auto; margin: 0 0 .8rem; }
#new-project .actions, .panel .actions { display: flex; justify-content: flex-end; gap: .5rem; }



.quickadd { display: flex; gap: .4rem; margin: .8rem 0; }
.quickadd input[name=title] { flex: 1; }
/* Shortcut hints whisper: small, muted, no box. */
kbd { font: 500 .72em system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .02em; opacity: .5; margin-left: .35em; }
.button kbd, button kbd { opacity: .65; }


details.popover { position: relative; }
details.popover > summary { list-style: none; user-select: none; }
details.popover > summary::-webkit-details-marker { display: none; }
details.popover[open] > summary { filter: brightness(1.08); }
.count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .25em; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .78em; text-align: center; }
.pop { position: absolute; z-index: 10; top: calc(100% + .35rem); left: 0; width: 17rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .25); padding: .7rem .8rem; }
.pop fieldset { border: 0; padding: 0; margin: 0 0 .7rem; display: flex; flex-direction: column; gap: .15rem; }
.pop legend { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
.pop label { display: flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; }
.pop label .status, .pop label .prio { width: auto; text-align: left; }

/* The list is the hierarchy: subtickets nest under their parent with a guide line. */
.tree { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { margin-left: 1.35rem; border-left: 1px solid var(--line); }
.tree li { border-top: 1px solid var(--line); }
.tree > ul > li:first-child { border-top: 0; }
.tree .node { display: flex; }
.tree .node.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.tree li.dragging { opacity: .45; }
.tree-root { margin: .4rem; padding: .5rem; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: var(--radius-sm); font-size: .85rem; }
.tree-root.over { border-color: var(--accent); color: var(--accent); }
.hint { margin-top: .5rem; }

dialog.modal { width: min(36rem, calc(100% - 32px)); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: 0 16px 48px rgb(0 0 0 / .35); }
dialog.modal::backdrop { background: rgb(0 0 0 / .5); }
.newticket { display: flex; flex-direction: column; gap: .6rem; }
.newticket .title-input { font-size: 1.1rem; font-weight: 600; border-color: transparent; background: transparent; padding-left: .2rem; }
.newticket .title-input:focus { outline: none; border-bottom-color: var(--line); }
.newticket textarea { border-color: transparent; background: transparent; padding-left: .2rem; }
.newticket textarea:focus { outline: none; }
.newticket .actions { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.narrowish { max-width: 40rem; }
.tline { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; flex: 1; min-width: 0; color: var(--text); }
.tline:hover { background: var(--hover); text-decoration: none; }
.tline .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tline.closed .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.tline .meta { display: flex; gap: .6rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.prio { display: inline-block; width: 1.6rem; font-weight: 700; font-size: .8rem; color: var(--muted); text-align: center; flex: none; }
.prio-urgent { color: var(--danger); }
.prio-high { color: var(--waiting); }
.waiting { color: var(--waiting); }
.assignee { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--hover); color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; overflow: hidden; }
.assignee img { width: 100%; height: 100%; }
.assignee.none { background: none; }
.card-top .assignee { margin-left: .3rem; width: 1.2rem; height: 1.2rem; }
.status { font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; width: 5.6rem; text-align: right; flex: none; }
.status-backlog { color: var(--s-backlog); } .status-todo { color: var(--s-todo); } .status-doing { color: var(--s-doing); }
.status-review { color: var(--s-review); } .status-done { color: var(--s-done); } .status-cancelled { color: var(--s-cancelled); }
h2 .status { width: auto; text-align: left; font-size: .8rem; }

.board { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .6rem; width: 100%; align-items: stretch; }
.lane { flex: 1 1 13rem; min-width: 13rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; min-height: 8rem; display: flex; flex-direction: column; }
.lane h2 { margin: .2rem .2rem .6rem; display: flex; gap: .5rem; align-items: baseline; }
.lane-toggle { margin-left: auto; padding: 0 .35rem; background: none; border: none; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.lane-toggle:hover { color: var(--accent); }
/* A collapsed lane (app.js, remembered per browser) is a narrow strip with its
   name running down it; it is still a drop target, and a click opens it. */
.lane.collapsed { flex: 0 0 2.4rem; min-width: 0; padding: .5rem 0; cursor: pointer; align-items: center; }
.lane.collapsed h2 { writing-mode: vertical-rl; margin: .2rem 0; flex-direction: row-reverse; justify-content: flex-end; }
.lane.collapsed .lane-toggle { margin: 0 0 .3rem; transform: rotate(180deg); writing-mode: horizontal-tb; }
.lane.collapsed .cards, .lane.collapsed .lane-add { display: none; }
.lane.over { outline: 2px dashed var(--accent); }
.cards { display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .45rem .55rem; color: var(--text); cursor: grab; }
.card:hover { text-decoration: none; border-color: var(--accent); }
.card.closed .card-title { color: var(--muted); }
.card-top { display: flex; gap: .4rem; align-items: center; font-size: .8rem; }
.card-top .prio { width: auto; }
.card-top .kids, .card-top .waiting { margin-left: auto; font-size: .78rem; color: var(--muted); }
.card-top .waiting { color: var(--waiting); }
.assignee { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--hover); color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; overflow: hidden; }
.assignee img { width: 100%; height: 100%; }
.assignee.none { background: none; }
.card-top .assignee { margin-left: .3rem; width: 1.2rem; height: 1.2rem; }
.card-title { font-size: .92rem; margin-top: .15rem; }
.lane-add input { width: 100%; margin-top: .4rem; background: transparent; border-style: dashed; }

.ticket { max-width: 52rem; }
.ticket-title { font-size: 1.45rem; }
.ticket-title .key { font-size: .8em; margin-right: .3rem; }
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose img { max-width: 100%; }
.prose table { width: auto; }

/* Title and description edit in place: under html.js (early.js) the form
   shows only while .editing (a double click); without script, both show. */
.js .inline-edit:not(.editing) > form, .js .inline-edit.editing > .shown { display: none; }
[data-dbledit] { cursor: text; }
.title-edit { display: flex; gap: .5rem; align-items: center; margin: .67em 0; }
.title-edit input { flex: 1; font-size: 1.3rem; font-weight: 600; }
.desc { margin: .4rem 0 1rem; min-height: 1.5rem; border-radius: var(--radius-sm); }
.desc:hover, .comment-edit > .prose:hover { background: var(--hover); }
.inline-edit .buttons { display: flex; gap: .4rem; }
/* The ticket's fields: one row of dropdowns under the title. */
.fieldrow { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: -.2rem 0 .6rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: 0 0 0 .6rem; border: 1px solid var(--line); border-radius: 999px; font-size: .75rem; color: var(--muted); }
.chip:hover, .chip:focus-within { border-color: var(--accent); }
.chip select { appearance: none; background: none; border: 0; box-shadow: none; color: var(--text); font-size: .82rem; padding: .2rem .7rem .2rem .1rem; max-width: 15rem; text-overflow: ellipsis; cursor: pointer; }
.chip select:focus { outline: none; }
.chip select option { background: var(--panel); color: var(--text); }
.chip.status-backlog select { color: var(--s-backlog); } .chip.status-todo select { color: var(--s-todo); } .chip.status-doing select { color: var(--s-doing); }
.chip.status-review select { color: var(--s-review); } .chip.status-done select { color: var(--s-done); } .chip.status-cancelled select { color: var(--s-cancelled); }
.fieldrow .opened { margin-left: auto; }
.links { margin-top: 1rem; }
.linkrow { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: .3rem; }
.linkrow form { padding: 0 .6rem; }
.linkrow .tline { padding: .35rem .5rem; gap: .4rem; }
.linkrow .status { width: auto; }
.linkrow .prio { width: auto; }
.danger-zone { margin-top: 2rem; }

.timeline { margin-top: 1rem; }
.comment { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin: .6rem 0; }
.comment.agent { background: var(--agent); }
.comment-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .35rem; flex-wrap: wrap; }
.comment-edit form { margin-top: .5rem; }
.badge { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; background: var(--hover); color: var(--muted); }
.event { padding: .25rem .9rem; }
.comment-new { margin-top: 1rem; }
.newtoken { border-color: var(--accent); }

@media (max-width: 800px) {
  :root { --drawer-w: 100vw; }
  body.drawer-open main { padding-right: 16px; }
  .tline { flex-wrap: wrap; }
  .tline .title { flex-basis: 100%; order: -1; white-space: normal; }
  .status { width: auto; margin-left: auto; }
  .center { order: 10; flex-basis: 100%; }
  form.search { max-width: none; }
  .me { margin-left: auto; }
  .pop { width: min(17rem, calc(100vw - 32px)); }
}

.people { list-style: none; padding: 0; margin: 0 0 .6rem; }
.people li { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people li:last-child { border-bottom: 0; }
.people form { margin-left: auto; }
.avatar.blank { display: inline-block; background: var(--hover); }

