:root {
  --paper: #f7f8f9;
  --surface: #ffffff;
  --ink: #172b4d;
  --muted: #505f79;
  --line: #dcdfe4;
  --accent: #0c66e4;
  --accent-soft: #e9f2ff;
  --todo: #44546f;
  --todo-bg: #e4e6ea;
  --doing: #0055cc;
  --doing-bg: #cce0ff;
  --done: #216e4e;
  --done-bg: #dcfff1;
  --danger: #ae2e24;
  --peek-w: 460px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1d2125;
    --surface: #22272b;
    --ink: #dee4ea;
    --muted: #9fadbc;
    --line: #38414a;
    --accent: #579dff;
    --accent-soft: #1c2b41;
    --todo: #b6c2cf;
    --todo-bg: #2c333a;
    --doing: #85b8ff;
    --doing-bg: #09326c;
    --done: #7ee2b8;
    --done-bg: #1c3329;
    --danger: #fd9891;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 "Hanken Grotesk", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }

.btn {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); font-weight: 600; padding: 10px 18px; }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); }

/* Centered in the viewport. A top margin here would collapse through <body> and make the page scroll. */
#signin { max-width: 420px; height: 100%; margin: 0 auto; padding: 0 20px 8vh; display: flex; flex-direction: column; justify-content: center; }
#signin .btn { align-self: flex-start; }
#signin h1 { font-size: 40px; letter-spacing: -0.02em; margin: 0 0 8px; }
#signin p { color: var(--muted); margin: 0 0 24px; font-size: 16px; }
#signin p.tagline { color: var(--accent); font-size: 20px; font-style: italic; margin-bottom: 12px; }

#app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 48px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #8270db); }
.topbar nav { display: flex; gap: 20px; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 14px 0; }
.topbar nav a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px var(--accent); }
#jump { margin-left: auto; }
#jump input {
  width: 230px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
}
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.who img, .avatar { border-radius: 50%; }

.work { flex: 1; display: flex; min-height: 0; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 28px; border-bottom: 1px solid var(--line); }
.filter { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.filter .picker { min-width: 150px; }
.filter .picker-pop { min-width: 260px; right: auto; }
.filter .chip { background: var(--doing-bg); color: var(--doing); border-color: transparent; font-weight: 600; }
.filter .chip button { color: inherit; }
#main { flex: 1; min-height: 0; overflow: auto; padding: 24px 28px 60px; outline: none; }
#peek {
  width: var(--peek-w); flex: none; overflow: auto; background: var(--surface);
  border-left: 1px solid var(--line); padding: 16px 20px 40px;
}
@media (max-width: 900px) {
  #peek { position: fixed; inset: 48px 0 0 0; width: auto; border-left: 0; }
  .who span, #nav-mine { display: none; } /* the brand already goes to "Assigned to me" */
  #jump input { width: 150px; }
  #main { padding: 16px 12px 60px; }
  #filters { padding: 10px 12px; }
}
@media (max-width: 480px) {
  .topbar { gap: 12px; padding: 0 12px; }
  #jump input { width: 100px; }
}

.pagehead { display: flex; align-items: baseline; gap: 14px; margin: 0 0 14px; flex-wrap: wrap; }
.pagehead h1 { font-size: 22px; letter-spacing: -0.01em; margin: 0; }
.pagehead .count { color: var(--muted); }
.pagehead label { margin-left: auto; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.note { color: var(--muted); padding: 28px 0; }
.error { color: var(--danger); }

/* The ticket this page is about */
.focus {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 18px; margin-bottom: 22px; cursor: pointer;
}
.focus.selected { border-color: var(--accent); box-shadow: inset 3px 0 var(--accent); }
.focus .crumb { color: var(--muted); font-size: 13px; }
.focus h1 { font-size: 22px; margin: 4px 0 10px; letter-spacing: -0.01em; }
.focus .facts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--muted); }
.progress { height: 4px; background: var(--todo-bg); border-radius: 2px; margin-top: 14px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--done); }

table.tickets { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.tickets th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tickets th button.sort {
  all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: -2px -4px;
}
.tickets th button.sort:hover { color: var(--ink); }
.tickets th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tickets th button.sort .arrow { font-size: 10px; opacity: 0.45; }
.tickets th[aria-sort="ascending"] button.sort,
.tickets th[aria-sort="descending"] button.sort { color: var(--ink); }
.tickets th[aria-sort="ascending"] .arrow,
.tickets th[aria-sort="descending"] .arrow { opacity: 1; color: var(--accent); }
.tickets td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tickets tr:last-child td { border-bottom: 0; }
.tickets tbody tr { cursor: pointer; }
.tickets tbody tr:hover { background: var(--paper); }
.tickets tbody tr.selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.tickets .key { white-space: nowrap; }
.twist {
  display: inline-block; width: 24px; height: 24px; margin: -2px 2px -2px -4px; padding: 0; vertical-align: middle;
  border: 0; border-radius: 5px; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
button.twist:hover { background: var(--line); color: var(--ink); }
.star {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px;
  margin-left: 2px; padding: 0; vertical-align: middle; border: 0; border-radius: 5px; background: none;
  color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.star:hover { background: var(--line); color: var(--ink); }
.star[aria-pressed="true"] { color: var(--accent); }
.tickets tr.noterow { cursor: default; }
.tickets tr.noterow:hover { background: none; }
.dragging tbody tr { cursor: grabbing; }
.tickets tbody tr.drop, .focus.drop { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.tickets tbody tr.drop-before td { box-shadow: inset 0 3px 0 var(--accent); }
.tickets tbody tr.drop-after td { box-shadow: inset 0 -3px 0 var(--accent); }
.toast {
  position: fixed; left: 20px; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 8px; background: var(--ink); color: var(--paper);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); max-width: min(560px, calc(100vw - 40px));
}
.toast .btn { color: var(--ink); padding: 3px 10px; }
.toast .btn.quiet { color: var(--paper); }
.toast.error { background: var(--danger); }
.tickets .key a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.tickets .key a:hover { text-decoration: underline; }
.tickets .summary { min-width: 220px; }
.tickets .type { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 5px; white-space: pre-wrap; }
.tickets .person { white-space: nowrap; }
.empty { color: var(--muted); }
.person { display: inline-flex; align-items: center; gap: 6px; }
.avatar.initial {
  display: inline-grid; place-items: center; width: 20px; height: 20px; flex: none;
  font-size: 11px; font-weight: 700; color: #172b4d;
}
.ttag { display: inline-flex; align-items: center; gap: 5px; }
.ttag i { width: 12px; height: 12px; border-radius: 3px; flex: none; background: var(--muted); }
.ttag i.epic { background: #8f7ee7; }
.ttag i.story { background: #22a06b; }
.ttag i.task { background: #388bff; }
.ttag i.sub { background: #2898bd; }
.ttag i.bug { background: #e2483d; }
.prio { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.prio i { font-style: normal; font-size: 10px; }
.prio i.hi { color: #e2483d; }
.prio i.mid { color: #d97008; }
.prio i.lo { color: #388bff; }
.chip.version { border-color: transparent; background: var(--doing-bg); color: var(--doing); font-weight: 600; }
.peeking .col-priority, .peeking .col-components { display: none; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--todo); background: var(--todo-bg);
}
.pill.indeterminate { color: var(--doing); background: var(--doing-bg); }
.pill.done { color: var(--done); background: var(--done-bg); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 7px; margin: 1px 4px 1px 0;
  border: 1px solid var(--line); border-radius: 4px; font-size: 12.5px; white-space: nowrap; background: var(--surface);
}
.chip button { border: 0; background: none; padding: 0 2px; cursor: pointer; color: var(--muted); }

/* Side panel */
.peekhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.peekhead .key { font-weight: 700; text-decoration: none; }
.peekhead .key:hover { text-decoration: underline; }
.peekhead .type { color: var(--muted); }
.peekhead .state { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.peekhead .ext { color: var(--muted); font-size: 12.5px; }
.peek-error { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; }
textarea.title {
  width: 100%; border: 1px solid transparent; border-radius: 6px; background: none; resize: none;
  font-size: 19px; font-weight: 600; line-height: 1.3; padding: 4px 6px; margin: 0 -6px 10px; overflow: hidden;
}
textarea.title:hover, textarea.title:focus { border-color: var(--line); background: var(--paper); }
.fields { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; align-items: start; }
.fields > label, .fields > .label { color: var(--muted); padding-top: 6px; font-size: 13px; }
.fields select, .fields input[type=text], .fields input[type=number], .fields input[type=date], .fields input[type=url] {
  width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.fields .static { padding-top: 6px; }
details.more { margin-top: 14px; }
details.more summary { cursor: pointer; color: var(--muted); margin-bottom: 10px; }
.section { margin: 22px 0 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.adf { overflow-wrap: anywhere; }
.adf p { margin: 0 0 10px; }
.adf h1, .adf h2, .adf h3, .adf h4 { font-size: 15px; margin: 16px 0 6px; }
.adf pre { background: var(--paper); padding: 10px; border-radius: 6px; overflow: auto; font-size: 12.5px; }
.adf code { background: var(--paper); padding: 0 4px; border-radius: 3px; font-size: 12.5px; }
.adf blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.adf table { border-collapse: collapse; margin-bottom: 10px; }
.adf td, .adf th { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
.adf a { color: var(--accent); }

/* Picker */
.picker { position: relative; }
.picker-control {
  width: 100%; min-height: 32px; text-align: left; padding: 3px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--surface); cursor: pointer; display: flex; flex-wrap: wrap; align-items: center;
}
.picker-control .placeholder { color: var(--muted); }
.picker-control img { margin-right: 6px; }
.picker-pop {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); padding: 6px;
}
.picker-pop input { width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); margin-bottom: 4px; }
.picker-pop ul { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.picker-pop li { padding: 5px 8px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.picker-pop li.active { background: var(--accent-soft); }
.picker-pop li[aria-selected=true]::after { content: "✓"; margin-left: auto; color: var(--accent); }
.picker-pop.checks li[aria-selected=true]::after { content: none; }
.picker-pop li input { width: 16px; height: 16px; margin: 0 2px 0 0; accent-color: var(--accent); cursor: pointer; }
.tickets td.editing { padding: 4px 6px; }
.tickets td.editing input.inline, .tickets td.editing select {
  width: 100%; padding: 5px 8px; border: 1px solid var(--accent); border-radius: 6px; background: var(--surface);
}
.tickets td.editing .picker { min-width: 200px; }
.tickets tbody tr.dim td { color: var(--muted); }
.tickets tbody tr.dim .pill, .tickets tbody tr.dim .chip, .tickets tbody tr.dim .avatar { opacity: 0.6; }
.picker-pop li .hint { color: var(--muted); font-size: 12.5px; }
.picker-pop .none { color: var(--muted); padding: 5px 8px; }

@media (prefers-reduced-motion: no-preference) {
  #peek { animation: slide 0.14s ease-out; }
  @keyframes slide { from { transform: translateX(16px); opacity: 0; } }
}
