:root {
  --bg: #f6f7f9; --card: #fff; --fg: #1d2330; --muted: #6b7385; --line: #e2e5eb;
  --todo: #eef0f4; --todo-fg: #8a91a0;
  --active: #dbe8ff; --active-fg: #2457c5;
  --waiting: #fff0d1; --waiting-fg: #a3620a;
  --failed: #ffe0e0; --failed-fg: #b42323;
  --done: #dcf3e3; --done-fg: #1d7a3e;
  --skipped: #f1f1f1; --skipped-fg: #9a9a9a;
  --accent: #2457c5;
  --twin: #7f77dd;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --card: #1c2028; --fg: #e4e7ee; --muted: #959cab; --line: #2c323d;
    --todo: #242933; --todo-fg: #7f8796;
    --active: #1d2f52; --active-fg: #8db2ff;
    --waiting: #3d2e12; --waiting-fg: #f2bd5c;
    --failed: #4a1f22; --failed-fg: #ff9b9b;
    --done: #173826; --done-fg: #7fd99f;
    --skipped: #23262c; --skipped-fg: #6e737c;
    --accent: #8db2ff;
    --twin: #a9a3ee;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (prefers-color-scheme: dark) { button.primary { color: #10141b; } }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
a { color: var(--accent); }

.top { display: flex; gap: 12px; align-items: center; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.top h1 { font-size: 17px; margin: 0 12px 0 0; }
.top .toplink { margin-left: auto; font-size: 13px; text-decoration: none; }
.top .toplink:hover { text-decoration: underline; }
#search { flex: 1; min-width: 160px; max-width: 320px; }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--active); color: var(--active-fg); }

/* no overflow on main: it would become the scroll container and break the sticky table head */
main { padding: 16px 20px; }
.matrix { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 1300px; table-layout: fixed; }
.matrix th { font-weight: 600; color: var(--muted); font-size: 12px; text-align: left; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* --toph = height of the sticky top bar, set in app.js */
.matrix th { position: sticky; top: var(--toph, 57px); z-index: 4; background: var(--bg); padding: 6px; box-shadow: 0 -4px 0 var(--bg), 4px 0 0 var(--bg), -4px 0 0 var(--bg); }
.matrix td { background: var(--card); border-radius: 6px; padding: 6px 8px; vertical-align: middle; }
.matrix tr.row { cursor: pointer; }
.matrix tr.row:hover td { outline: 1px solid var(--muted); }
.matrix tr.sel td { outline: 2px solid var(--accent); }
.course .t { font-weight: 600; font-size: 15px; line-height: 1.3; display: flex; align-items: center; min-width: 0; }
.course .t .tt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.course .t button.rename { margin-left: 6px; padding: 2px 4px; border: 1px solid transparent; border-radius: 6px; background: transparent; vertical-align: 2px; opacity: .35; line-height: 0; }
.course .t button.rename { display: none; }  /* compact rows: only on hover, so it takes no title space */
.course:hover .t button.rename { display: inline-block; opacity: .8; }
.course .t button.rename:hover { opacity: 1; border-color: var(--accent); background: var(--active); }
.course .t button.rename img { width: 14px; height: 14px; }
@media (prefers-color-scheme: dark) { .course .t button.rename img { filter: invert(1); } }
/* language versions of one course (header twin:): one frame around both rows */
.matrix tbody.twin { outline: 2px solid var(--twin); outline-offset: 1px; border-radius: 8px; }
.course .t input.rename { width: 100%; box-sizing: border-box; font: inherit; }
.course .a { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* compact course cell, one row: title over author on the left, then flag + format,
   owner + tester and the system links side by side on the right */
.matrix td.course { padding: 5px 8px; }
.course .cg { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; column-gap: 10px; align-items: center; }
.course .ta { min-width: 0; }
.course .tags { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.course .links { display: flex; gap: 3px; align-items: center; }
.course .links a, .course .links button { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.course .links a:hover, .course .links button:hover { border-color: var(--accent); background: var(--active); }
.course .links img { width: 18px; height: 18px; }
@media (prefers-color-scheme: dark) { .course .links img { filter: invert(1); } }
.course .who { display: flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; }
.course .who button.tbtn { display: inline-flex; align-items: center; padding: 0 5px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; background: var(--card); cursor: pointer; }
.course .who button.tbtn:hover { border-color: var(--accent); background: var(--active); }
#testerDlg { width: min(720px, 94vw); }
#testerDlg h3 { margin: 0 0 2px; }
.tlist { width: 100%; border-collapse: collapse; margin: 10px 0; }
.tlist th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.tlist td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.tlist td.late { color: var(--failed-fg); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-align: left; }
/* last column: finish the whole course */
.matrix td.fin { padding: 4px; text-align: center; color: var(--done-fg); font-size: 20px; }
td.fin button.finish { width: auto; height: auto; padding: 0; border: 0; background: transparent; border-radius: 50%; line-height: 0; }
td.fin button.finish img { width: 26px; height: 26px; filter: grayscale(1); opacity: .3; }  /* grey until the row is hovered */
.matrix tr.row:hover td.fin button.finish img, td.fin button.finish:focus-visible img { filter: none; opacity: 1; }
/* summary line that folds the info area (Recently done, things to add) */
button.infofold { display: flex; gap: 16px; align-items: center; width: 100%; text-align: left; font-size: 12px; padding: 5px 10px; margin-bottom: 10px; border-radius: 8px; }
button.infofold .k { color: var(--muted); }
button.infofold b { font-weight: 600; }
button.infofold b.hot { color: var(--accent); }
button.infofold .tog { margin-left: auto; color: var(--accent); font-weight: 600; }
td.fin button.finish:hover { filter: brightness(1.1); box-shadow: 0 0 0 3px var(--done); }
.flag { width: 21px; height: 14px; vertical-align: -1px; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }
button.fmt { font-size: 12px; font-weight: 700; padding: 0 6px; border-radius: 8px; vertical-align: 1px; border: 1px solid transparent; line-height: 18px; }
button.fmt.f-60min { background: #ffe7c2; color: #9a5800; }
button.fmt.f-full { background: #e4dcff; color: #5a3fc0; }
button.fmt.auto { border: 1px dotted currentColor; opacity: .8; }
button.fmt.unset { background: transparent; border: 1px dashed var(--muted); color: var(--muted); font-weight: 500; }
@media (prefers-color-scheme: dark) {
  button.fmt.f-60min { background: #4a3210; color: #ffc46b; }
  button.fmt.f-full { background: #33295c; color: #c2b2ff; }
}
/* phase cell: one segment per step; a fully done phase is one solid green block */
td.pc { padding: 4px; background: transparent !important; }
.segs { display: flex; gap: 2px; height: 26px; border-radius: 6px; overflow: hidden; }
.segs i { flex: 1; min-width: 6px; background: var(--todo); display: flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 10px; font-weight: 700; color: #5a3a00; white-space: nowrap; overflow: hidden; }  /* text = waiting days */
/* matrix sections by current phase: a header row that folds its courses away */
.matrix tbody.grp td { background: transparent; padding: 10px 2px 0; }
.matrix tbody.grp button.grpbtn { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; width: 100%;
  text-align: left; padding: 2px 4px 4px; font-weight: 700; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.matrix tbody.grp button.grpbtn:hover { border-color: var(--muted); }
.grpbtn .car { color: var(--muted); font-size: 10px; width: 10px; }
.grpbtn .n { color: var(--muted); font-weight: 500; font-size: 12px; }
.segs i.s-done, .segs i.s-skipped { background: #4cb86e; }
.segs i.s-active { background: #7aa5f5; }
.segs i.s-waiting { background: #f2b544; }
.segs i.s-failed { background: #e05555; }
.segs.all i { background: #2f9e55; }
td.pc small { display: block; font-size: 11px; color: var(--muted); text-align: center; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell { text-align: center; font-size: 12px; min-width: 76px; }
.cell b { font-size: 13px; }
.cell small { display: block; opacity: .85; }
.todo { background: var(--todo) !important; color: var(--todo-fg); }
.active { background: var(--active) !important; color: var(--active-fg); }
.waiting { background: var(--waiting) !important; color: var(--waiting-fg); }
.failed { background: var(--failed) !important; color: var(--failed-fg); }
.done { background: var(--done) !important; color: var(--done-fg); }
.skipped { background: var(--skipped) !important; color: var(--skipped-fg); }
.next { font-size: 12px; color: var(--muted); }
.legend { color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 10px; vertical-align: -1px; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

#untracked .box, #cmsUntracked .box { background: var(--card); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
#untracked button, #cmsUntracked button { margin: 2px 4px; font-size: 12px; }

#panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--card); border-left: 1px solid var(--line); overflow-y: auto; z-index: 10; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
.ph { position: sticky; top: 0; background: var(--card); padding: 14px 18px 10px; border-bottom: 1px solid var(--line); z-index: 2; }
.ph h2 { margin: 0; font-size: 18px; }
.ph .sub { color: var(--muted); }
.ph .close { position: absolute; right: 14px; top: 12px; }
.ph .finish { position: absolute; right: 54px; top: 12px; background: var(--done); color: var(--done-fg); border-color: var(--done-fg); }
.pb { padding: 12px 18px 40px; }
.pb h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 0 6px; }
.chips span { display: inline-block; background: var(--active); color: var(--active-fg); border-radius: 10px; padding: 1px 8px; margin: 2px; font-size: 12px; }
details.phase { border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; }
details.phase > summary { padding: 7px 10px; cursor: pointer; font-weight: 600; display: flex; gap: 8px; align-items: center; }
details.phase > summary .pill { font-size: 11px; padding: 1px 7px; border-radius: 9px; font-weight: 500; }
.step { border-top: 1px solid var(--line); padding: 7px 10px; }
.step.drag { outline: 2px dashed var(--accent); }
.step .line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.step .sid { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); width: 32px; }
.step .title { flex: 1; min-width: 160px; }
.step .marks button { padding: 1px 7px; font-size: 12px; }
.step .marks button.on.todo, .step .marks button.on { font-weight: 600; }
.step .marks { display: inline-flex; gap: 6px; align-items: center; }
.step .marks button.tick { padding: 0; border: 0; background: transparent; border-radius: 50%; line-height: 0; }
.step .marks button.tick img { width: 32px; height: 32px; filter: grayscale(1); opacity: .3; }
.step .marks button.tick:hover img { opacity: .7; }
.step .marks button.tick.on img { filter: none; opacity: 1; }
.step input[type=date] { font-size: 12px; padding: 1px 4px; }
.meta { font-size: 12px; color: var(--muted); margin: 3px 0 0 40px; }
.meta .warn { color: var(--waiting-fg); }
.meta .auto { color: var(--active-fg); }
.subs { margin: 4px 0 0 40px; font-size: 13px; }
.subs label { display: block; }
.atts { margin: 4px 0 0 40px; font-size: 12px; }
.atts a { margin-right: 10px; }
.stepnotes { margin: 4px 0 0 40px; font-size: 12px; white-space: pre-wrap; }
.tools { margin-left: 40px; margin-top: 3px; }
.tools button { font-size: 11px; padding: 0 6px; color: var(--muted); }
table.masters { border-collapse: collapse; width: 100%; font-size: 13px; }
table.masters td, table.masters th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
.row-form { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.row-form input { flex: 1; min-width: 90px; }
.notes div { padding: 4px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; font-size: 13px; }
.notes .d { color: var(--muted); font-size: 12px; margin-right: 6px; }
textarea { width: 100%; min-height: 70px; }
.settings label { display: block; margin: 6px 0; font-size: 13px; }
.settings input { width: 100%; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); width: min(460px, 92vw); }
dialog label { display: block; margin: 8px 0; }
dialog input { width: 100%; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }
.cms { margin: 6px 0 10px; font-size: 13px; line-height: 1.9; }
.cms .meta { margin: 0 0 0 6px; display: inline; }
.cms .pill { margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 9px; }
.cmsu { display: inline-flex; align-items: center; gap: 2px; margin: 2px 6px 2px 0; }
.cmsu a { text-decoration: none; padding: 0 3px; }
.cmsu button.x { padding: 0 5px; font-size: 11px; color: var(--muted); }
.cmsu small { color: var(--muted); }
.pick { display: flex; gap: 6px; }
.pick input { flex: 1; min-width: 0; }
.pick button { white-space: nowrap; font-size: 12px; }
.stlabel { font-size: 11px; padding: 1px 7px; border-radius: 9px; }
.snote { display: block; width: calc(100% - 40px); margin: 4px 0 0 40px; font-size: 12px; padding: 2px 6px; }
.phasehead { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; }
.phasehead button { margin-left: auto; font-size: 12px; }
td.pc { cursor: zoom-in; }

/* sync chips in the top bar: green fresh, yellow old, red stale; click for the request to copy */
.syncs { display: inline-flex; gap: 4px; align-items: center; }
.syncs .chip { font-size: 12px; border-radius: 10px; padding: 1px 8px; border-color: transparent; white-space: nowrap; }
.syncs .chip.ok { background: var(--done); color: var(--done-fg); }
.syncs .chip.old { background: var(--waiting); color: var(--waiting-fg); }
.syncs .chip.stale { background: var(--failed); color: var(--failed-fg); }
.pop { position: fixed; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.18); padding: 12px 14px; z-index: 20; font-size: 13px; width: 340px; }
.pop h4 { margin: 0 0 6px; font-size: 14px; }
.pop code { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 8px 0; font-size: 12px; }
.pop .row { display: flex; gap: 6px; justify-content: flex-end; }
#ownerPop { width: auto; }
#ownerPop .row { justify-content: flex-start; }
#testerPop { width: 280px; }
#testerPop label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0; }
#testerPop input { width: 160px; }

/* "Recently done" strip and the testers box above the matrix */
.box.testers { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.testers > div { margin-top: 4px; }
.testers .tname { display: inline-block; min-width: 140px; font-weight: 600; }
.testers button { margin: 2px 4px 2px 0; }
.testers button.late, .late { color: var(--failed-fg); font-weight: 600; }
.tchip { font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.testerrow { display: flex; gap: 6px; align-items: center; margin: 8px 0; font-size: 13px; }
.testerrow input { flex: 1; min-width: 0; }
.nudge { margin: 4px 0 0 40px; padding: 4px 10px; border-radius: 6px; background: var(--waiting); color: var(--waiting-fg); font-size: 12px; display: flex; gap: 8px; align-items: center; }
.nudge button { font-size: 12px; padding: 0 8px; }
.shopcheck { margin: 4px 0 0 40px; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
.shopcheck .miss { color: var(--failed-fg); }
.shopcheck .ok { color: var(--done-fg); }
.shopcheck .hint { color: var(--muted); }
#mailDlg { width: min(620px, 94vw); }
#mailDlg textarea { min-height: 200px; }
.tlist .flag { margin-left: 5px; }

/* team: top bar links, phase G test block (release, due date, master upload) */
.team { display: inline-flex; gap: 12px; align-items: center; font-size: 13px; }
.team a { text-decoration: none; }
.team a:hover { text-decoration: underline; }
.testblock { margin: 6px 10px 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 8px; display: grid; gap: 8px; font-size: 13px; }
.testblock .ready { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; padding: 8px 10px; border-radius: 6px; background: var(--todo); }
.testblock .ready.on { background: var(--done); color: var(--done-fg); }
.testblock .mfiles { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.testblock .mfiles > span:first-child { color: var(--muted); margin-right: 4px; }
.testblock button.x { padding: 0 5px; font-size: 11px; }
.testblock .meta { margin: 0; }
.testblock .bar { height: 6px; background: var(--todo); border-radius: 3px; max-width: 320px; margin-bottom: 3px; }
.testblock .bar > div { height: 100%; background: var(--accent); border-radius: 3px; }

/* error bar: server not reachable or a request failed */
.errbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 100; display: flex; gap: 10px; align-items: center;
  max-width: min(720px, calc(100vw - 32px)); padding: 8px 12px; border-radius: 8px; background: #b42318; color: #fff; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.errbar button { font-size: 12px; padding: 2px 8px; }
.errbar button.x { background: transparent; color: #fff; border-color: transparent; }

/* sync popover: two numbered steps */
ol.syncsteps { margin: 4px 0 8px; padding-left: 18px; display: grid; gap: 8px; font-size: 12.5px; max-width: 340px; }
ol.syncsteps code { font-size: 11.5px; word-break: break-all; }

/* the hidden attribute always wins over display rules (e.g. labels in the New course dialog) */
[hidden] { display: none !important; }
