:root {
  --ink: #1d1c1d;
  --muted: #616061;
  --faint: #9aa3ae;
  --line: #e8e8ea;
  --band: #f4f2f7;
  --accent: #4a154b;
  --blue: #1264a3;
  --not_started: #9aa3ae;
  --in_progress: #1d9bd1;
  --blocked: #e01e5a;
  --complete: #2eb67d;
  --left: 340px;
  --row: 34px;
  --axis: 62px;
  font-family: Lato, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; background: #fff; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: #fff; }
.title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
#projectPicker { font-size: 20px; font-weight: 800; border: 0; background: transparent; padding: 2px 4px; max-width: 46vw; cursor: pointer; border-radius: 6px; }
#projectPicker:hover { background: #f4f4f5; }
.channel { color: var(--muted); text-decoration: none; white-space: nowrap; }
.channel:hover { color: var(--blue); text-decoration: underline; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#search { border: 1px solid #ccc; border-radius: 6px; padding: 5px 9px; width: 170px; }
.seg { display: inline-flex; border: 1px solid #ccc; border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 5px 10px; cursor: pointer; border-left: 1px solid #e3e3e3; }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: #f4f4f5; }
.seg button.on { background: var(--accent); color: #fff; }
.btn { border: 1px solid #ccc; background: #fff; border-radius: 6px; padding: 5px 12px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f4f4f5; }
.btn.primary { background: #007a5a; border-color: #007a5a; color: #fff; }
.btn.primary:hover { background: #148567; }
.btn.danger { color: #c4153c; border-color: #e5a3b4; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.me { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.summary { padding: 6px 16px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); }
.summary b { color: var(--ink); }
.summary .warn { color: #c4153c; font-weight: 700; }

/* ---- the chart */
.scroller { flex: 1; overflow: auto; position: relative; outline: none; }
.canvas { position: relative; }
.axis { position: sticky; top: 0; z-index: 5; height: var(--axis); display: flex; background: #fff; border-bottom: 1px solid #d1d1d3; }
.axis .corner { position: sticky; left: 0; z-index: 6; width: var(--left); flex: none; background: #fff; border-right: 1px solid #d1d1d3; display: flex; align-items: flex-end; padding: 0 12px 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.axis .scale { position: relative; flex: none; }
.axis .tick { position: absolute; bottom: 5px; font-size: 11px; color: var(--muted); white-space: nowrap; transform: translateX(3px); }
.axis .tick.center { transform: translateX(-50%); }
.axis .today { position: absolute; top: 23px; transform: translateX(-50%); background: #e01e5a; color: #fff; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; white-space: nowrap; }
.axis .month { position: absolute; top: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; padding-left: 3px; }
.grid { position: absolute; left: var(--left); top: var(--axis); pointer-events: none; z-index: 0; }
.row { position: relative; display: flex; height: var(--row); z-index: 1; }
.row:hover .cell { background: #f8f8fa; }
.row.focus .cell, .row.focus { background: #fff6d8 !important; }
.row.focus .cell { background: #fff6d8; }
.cell { position: sticky; left: 0; z-index: 3; width: var(--left); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; background: #fff; border-right: 1px solid #d1d1d3; border-bottom: 1px solid #f2f2f3; cursor: pointer; min-width: 0; }
.cell.indent { padding-left: 22px; }
.cell .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell .name.done { color: var(--muted); text-decoration: line-through; }
.cell .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cell .when.late { color: #c4153c; font-weight: 700; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid; cursor: pointer; padding: 0; background: #fff; }
.dot.not_started { border-color: var(--not_started); }
.dot.in_progress { border-color: var(--in_progress); background: radial-gradient(circle, var(--in_progress) 0 3px, #fff 3.5px); }
.dot.blocked { border-color: var(--blocked); background: var(--blocked); }
.dot.complete { border-color: var(--complete); background: var(--complete); }
.avatar { width: 22px; height: 22px; border-radius: 5px; flex: none; object-fit: cover; background: #ddd; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; }
.track { position: relative; flex: none; border-bottom: 1px solid #f2f2f3; }
.section-row { height: 30px; }
.section-row .cell { background: var(--band); font-weight: 800; color: var(--accent); cursor: default; }
.section-row .track { background: var(--band); }
.section-row:hover .cell { background: var(--band); }

.bar { position: absolute; top: 7px; height: calc(var(--row) - 14px); border-radius: 4px; cursor: grab; display: flex; align-items: center; padding: 0 6px; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: visible; touch-action: none; user-select: none; }
.bar.not_started { background: var(--not_started); }
.bar.in_progress { background: var(--in_progress); }
.bar.blocked { background: var(--blocked); }
.bar.complete { background: var(--complete); }
.bar.late { box-shadow: 0 0 0 2px #c4153c; }
.bar .inside { overflow: hidden; text-overflow: ellipsis; }
.bar .after { position: absolute; left: calc(100% + 6px); color: var(--muted); font-weight: 400; }
.bar .grip { position: absolute; top: 0; bottom: 0; width: 7px; cursor: ew-resize; }
.bar .grip.l { left: -2px; }
.bar .grip.r { right: -2px; }
.bar:hover, .bar.hl { filter: brightness(1.06); outline: 2px solid rgba(29, 28, 29, 0.35); outline-offset: 1px; }
.bar.dragging { cursor: grabbing; opacity: 0.85; }
.milestone { position: absolute; top: 50%; width: 14px; height: 14px; transform: translate(-50%, -50%) rotate(45deg); border-radius: 2px; cursor: grab; touch-action: none; }
.milestone .after { position: absolute; left: 16px; top: -3px; transform: rotate(-45deg); transform-origin: left top; white-space: nowrap; color: var(--muted); font-size: 12px; }
.nodates { position: absolute; top: 9px; left: 8px; font-size: 12px; color: var(--faint); font-style: italic; }
.dep { fill: none; stroke: #8a8f98; stroke-width: 1.3; }
.dep.hl { stroke: #1d1c1d; stroke-width: 2; }
.empty { padding: 40px 20px; color: var(--muted); text-align: center; }
.dragtip { position: fixed; z-index: 50; background: #1d1c1d; color: #fff; font-size: 12px; padding: 3px 7px; border-radius: 4px; pointer-events: none; }

/* ---- task panel */
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: #fff; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12); z-index: 20; display: flex; flex-direction: column; }
.panel header { display: flex; align-items: flex-start; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.panel header h2 { margin: 0; font-size: 18px; flex: 1; line-height: 1.3; word-break: break-word; }
.panel .close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.panel .body { flex: 1; overflow: auto; padding: 12px 16px 16px; }
.panel .statuses { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.panel .statuses button { border: 1px solid #ccc; background: #fff; border-radius: 14px; padding: 3px 10px; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.panel .statuses button.on { color: #fff; border-color: transparent; }
.panel .statuses button.on.not_started { background: var(--not_started); }
.panel .statuses button.on.in_progress { background: var(--in_progress); }
.panel .statuses button.on.blocked { background: var(--blocked); }
.panel .statuses button.on.complete { background: var(--complete); }
.facts { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #d6d6d8; border-radius: 12px; padding: 2px 9px 2px 6px; font-size: 12px; cursor: pointer; background: #fff; display: inline-flex; align-items: center; gap: 5px; }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip .dot { width: 10px; height: 10px; border-width: 2px; }
.notes { white-space: pre-wrap; background: #f8f8fa; border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-bottom: 12px; }
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: center; }
.panel h3 a { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--blue); }
.comment { display: flex; gap: 8px; margin-bottom: 10px; }
.comment .who { font-weight: 700; font-size: 13px; }
.comment .when { color: var(--faint); font-size: 11px; margin-left: 6px; font-weight: 400; }
.comment .text { font-size: 14px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.comment.app .text { color: var(--muted); font-size: 13px; }
.mention { background: #e8f5fa; color: #1264a3; border-radius: 3px; padding: 0 2px; }
.composer { position: relative; margin-top: 8px; }
.composer textarea { width: 100%; min-height: 64px; border: 1px solid #ccc; border-radius: 8px; padding: 8px 10px; resize: vertical; }
.composer .row2 { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; color: var(--faint); font-size: 12px; }
.suggest { position: absolute; left: 8px; bottom: calc(100% - 4px); background: #fff; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); max-height: 220px; overflow: auto; z-index: 30; min-width: 240px; }
.suggest div { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.suggest div.on, .suggest div:hover { background: var(--blue); color: #fff; }
.suggest small { opacity: 0.7; }

/* ---- edit form */
.form label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.form input[type="text"], .form input[type="date"], .form select, .form textarea { width: 100%; border: 1px solid #ccc; border-radius: 6px; padding: 6px 8px; }
.form textarea { min-height: 70px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .err { color: #c4153c; font-size: 12px; margin-top: 3px; }
.form .actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.form .actions .spacer { flex: 1; }
.picklist { border: 1px solid #ccc; border-radius: 6px; max-height: 170px; overflow: auto; }
.picklist input[type="search"] { width: 100%; border: 0; border-bottom: 1px solid #eee; padding: 6px 8px; position: sticky; top: 0; background: #fff; }
.picklist label { display: flex; gap: 8px; align-items: center; margin: 0; padding: 4px 8px; font-weight: 400; color: var(--ink); font-size: 13px; cursor: pointer; }
.picklist label:hover { background: #f6f6f7; }

.menu { position: fixed; z-index: 40; background: #fff; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14); padding: 4px 0; min-width: 160px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 12px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--blue); color: #fff; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d1c1d; color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 60; font-size: 13px; }
.toast.bad { background: #c4153c; }

.message-page main { max-width: 520px; margin: 12vh auto; padding: 0 20px; line-height: 1.5; }

@media (max-width: 700px) {
  :root { --left: 180px; }
  .cell .when, .cell .avatar { display: none; }
  #search { width: 120px; }
}
