:root {
  color-scheme: light dark;
  --bg: light-dark(#fafafa, #16171a);
  --panel: light-dark(#fff, #1e2024);
  --text: light-dark(#1c1d21, #e6e7ea);
  --muted: light-dark(#6b6f7a, #9499a5);
  --line: light-dark(#e4e5e9, #2e3138);
  --accent: light-dark(#3b5bdb, #8ea2ff);
  --on-accent: light-dark(#fff, #10121a);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }

header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; flex-wrap: wrap; }
.brand { font-weight: 650; }
nav { display: flex; gap: 4px; }
nav a { padding: 4px 10px; border-radius: 6px; color: var(--muted); }
nav a.active { background: var(--bg); color: var(--text); }
.spacer { flex: 1; }
.me { color: var(--muted); }
.me:hover { color: var(--text); }
main { max-width: 1080px; margin: 0 auto; padding: 16px; }

input, select, textarea, button { font: inherit; color: inherit; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-width: 100%; }
textarea { width: 100%; resize: vertical; field-sizing: content; min-height: 5em; max-height: 60vh; }
button { cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bar input[type=search] { flex: 1; min-width: 160px; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 13px; margin: 20px 0 6px; color: var(--muted); font-weight: 600; }

.list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.row { display: grid; grid-template-columns: 84px 1fr 150px 110px 70px; gap: 12px; padding: 7px 12px;
  border-top: 1px solid var(--line); align-items: center; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--bg); }
.row > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .id, .row .meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.projects .row { grid-template-columns: 1fr 110px 130px 150px 90px; }
.users .row { grid-template-columns: 1fr 1fr 90px 110px; }
.bar.add { margin-top: 12px; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }

.detail { display: grid; grid-template-columns: 1fr 240px; gap: 24px; align-items: start; }
.title { width: 100%; font-size: 20px; font-weight: 600; border-color: transparent; background: transparent; padding: 4px 6px; }
.title:hover, .title:focus { border-color: var(--line); background: var(--panel); }
.side { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.side label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
.side select, .side input { width: 100%; color: var(--text); font-size: 14px; }
.comment { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.comment .who { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
button.link { border: 0; background: none; padding: 2px 4px; color: var(--accent); }
.side .open { color: var(--accent); overflow-wrap: anywhere; margin-top: -6px; }
.related { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; }
.rel { display: grid; grid-template-columns: 1fr auto; align-items: start; }
.rel a { display: grid; min-width: 0; }
.rel a > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel a .muted { font-size: 12px; }
.rel a:hover b { color: var(--accent); }
:disabled { opacity: .6; cursor: not-allowed; }

/* Rendered Markdown */
.md { overflow-wrap: anywhere; padding: 4px 6px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 15px; font-weight: 650; color: var(--text); margin: 1em 0 .4em; }
.md h1 { font-size: 17px; }
.md a { color: var(--accent); text-decoration: underline; }
.md code { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 13px; }
.md pre { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow-x: auto; }
.md pre code { border: 0; padding: 0; }
.md blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; }
.md img { max-width: 100%; }
.md ul, .md ol { padding-left: 22px; }
.comment .md { padding: 0; }
.actions { margin-top: 8px; }

/* EasyMDE, matched to the app theme */
.editor .editor-toolbar { border-color: var(--line); background: var(--panel); border-radius: 6px 6px 0 0; padding: 4px; }
.editor .editor-toolbar button { color: var(--text); border: 0; width: auto; padding: 0 8px; font-size: 13px; }
.editor .editor-toolbar button:hover, .editor .editor-toolbar button.active { background: var(--bg); border: 0; }
.editor .editor-toolbar i.separator { border-color: var(--line); }
.editor .CodeMirror { background: var(--panel); color: var(--text); border-color: var(--line); border-radius: 0 0 6px 6px; font: inherit; }
.editor .CodeMirror-cursor { border-color: var(--text); }
.editor .CodeMirror-selected { background: var(--line) !important; }
.editor .editor-preview { background: var(--panel); }
.editor .cm-comment { background: var(--bg) !important; }
.editor .CodeMirror .cm-header { font-size: 1.1em; line-height: inherit; }
.editor textarea { min-height: 0; border: 0; } /* CodeMirror's hidden input */
.activity { margin-top: 20px; }
.activity summary { color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.event { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 3px 0; font-size: 13px; overflow-wrap: anywhere; }
.crumb { color: var(--muted); margin-bottom: 4px; }
.crumb a:hover, .sub a:hover { color: var(--accent); }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
  padding: 16px; width: min(520px, 92vw); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 10px; }
dialog label { display: grid; gap: 3px; color: var(--muted); font-size: 12px; }
dialog label > * { color: var(--text); font-size: 14px; width: 100%; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 720px) {
  .detail { grid-template-columns: 1fr; }
  .row, .projects .row { grid-template-columns: 76px 1fr; }
  .row > :nth-child(n+3) { display: none; }
}
