/* First-party apps: the 1P Apps sheet as a compact tile table, with a comments rail that folds away.
   Tiles follow the ARM Linux study page (company-brain, product-research/first-party-apps-linux) at a
   smaller size: a 30px squircle with the logo inside and the name beside it, so the whole sheet fits
   one screen. */
:root {
  --squircle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M50 0C14 0 0 14 0 50s14 50 50 50 50-14 50-50S86 0 50 0z'/></svg>");
  --ground: #F2F4F7; --surface: #FFFFFF; --ink: #13161B; --muted: #596170; --faint: #858C98; --line: #D9DEE5;
  --tile-ring: rgba(19, 22, 27, .20); --tile-shadow: rgba(19, 22, 27, .12);
  --accent: #2563EB; --done: #17864C; --danger: #C8352A; --mark: #13161B;
  --sans: "Ubuntu Sans", "Ubuntu", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Ubuntu Sans Mono", "Ubuntu Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --rail: 340px; --bar: 46px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0D0F13; --surface: #151920; --ink: #E8EBF0; --muted: #9AA2AF; --faint: #6C7482; --line: #242932;
    --tile-ring: rgba(255, 255, 255, .12); --tile-shadow: rgba(0, 0, 0, .55);
    --accent: #60A5FA; --done: #62CF93; --danger: #F0705F; --mark: #E8EBF0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0D0F13; --surface: #151920; --ink: #E8EBF0; --muted: #9AA2AF; --faint: #6C7482; --line: #242932;
  --tile-ring: rgba(255, 255, 255, .12); --tile-shadow: rgba(0, 0, 0, .55);
  --accent: #60A5FA; --done: #62CF93; --danger: #F0705F; --mark: #E8EBF0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.35 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
img { max-width: 100%; }

/* sign-in */
#auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px 22px; width: min(100%, 380px); display: grid; gap: 12px; text-align: center; justify-items: center; }
.auth-card img { border-radius: 12px; }
.auth-card h1 { margin: 0; font-size: 22px; font-weight: 700; }
.auth-card p { margin: 0; color: var(--muted); font-size: 14px; }
.signin { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-weight: 600; background: var(--ground); }
.signin:hover { border-color: var(--faint); }
.g-mark, .gh-mark { width: 18px; height: 18px; display: inline-block; background-size: contain; background-repeat: no-repeat; }
.g-mark { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'><path fill='%23EA4335' d='M24 9.5c3.5 0 6.6 1.2 9.1 3.6l6.8-6.8C35.8 2.4 30.3 0 24 0 14.6 0 6.5 5.4 2.6 13.2l7.9 6.1C12.4 13.6 17.7 9.5 24 9.5z'/><path fill='%234285F4' d='M46.5 24.5c0-1.6-.1-3.1-.4-4.5H24v9h12.7c-.6 3-2.3 5.5-4.8 7.2l7.7 6c4.5-4.2 6.9-10.3 6.9-17.7z'/><path fill='%23FBBC05' d='M10.5 28.6c-.5-1.5-.8-3-.8-4.6s.3-3.1.8-4.6l-7.9-6.1C1 16.5 0 20.1 0 24s1 7.5 2.6 10.7l7.9-6.1z'/><path fill='%2334A853' d='M24 48c6.5 0 11.9-2.1 15.9-5.8l-7.7-6c-2.1 1.4-4.9 2.3-8.2 2.3-6.3 0-11.6-4.1-13.5-9.8l-7.9 6.1C6.5 42.6 14.6 48 24 48z'/></svg>"); }
.gh-mark { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23181717' d='M12 .3a12 12 0 0 0-3.8 23.4c.6.1.8-.3.8-.6v-2c-3.3.7-4-1.6-4-1.6-.6-1.4-1.4-1.8-1.4-1.8-1.1-.7.1-.7.1-.7 1.2.1 1.8 1.2 1.8 1.2 1.1 1.8 2.8 1.3 3.5 1 .1-.8.4-1.3.8-1.6-2.7-.3-5.5-1.3-5.5-5.9 0-1.3.5-2.4 1.2-3.2-.1-.3-.5-1.5.1-3.2 0 0 1-.3 3.3 1.2a11.5 11.5 0 0 1 6 0c2.3-1.5 3.3-1.2 3.3-1.2.7 1.7.3 2.9.1 3.2.8.8 1.2 1.9 1.2 3.2 0 4.6-2.8 5.6-5.5 5.9.4.4.8 1.1.8 2.2v3.3c0 .3.2.7.8.6A12 12 0 0 0 12 .3z'/></svg>"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .gh-mark { filter: invert(1); } }
:root[data-theme="dark"] .gh-mark { filter: invert(1); }
.auth-card .error { color: var(--danger); font-size: 13px; }
.auth-card .fine { color: var(--faint); font-size: 12px; }

/* top bar: title, legend, comments toggle, sheet link, me */
header { position: sticky; top: 0; z-index: 5; background: var(--ground); border-bottom: 1px solid var(--line); }
.bar { height: var(--bar); padding: 0 16px; display: flex; align-items: center; gap: 14px; }
.title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.title span { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.legend { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend .key.x { background: var(--mark); }
.legend .via-sample { font-family: var(--mono); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.tools { display: flex; gap: 8px; align-items: center; flex: none; }
.status { font-size: 12px; color: var(--faint); }
.status.err { color: var(--danger); }
.sheet, .toggle { font-size: 12px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sheet:hover, .toggle:hover { color: var(--ink); border-color: var(--faint); }
.toggle.on { background: var(--surface); color: var(--ink); border-color: var(--faint); }
.toggle .n { font-size: 11px; color: var(--muted); background: var(--line); border-radius: 9px; padding: 0 6px; font-weight: 600; }
.me { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; cursor: pointer; background: var(--line); }

/* layout: the table, and the comments rail when it is open */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
body.rail-open .layout { grid-template-columns: minmax(0, 1fr) var(--rail); }
main { padding: 8px 16px 30px; min-width: 0; }

/* the table */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.grid th { text-align: left; vertical-align: top; padding: 6px 10px 7px; border-bottom: 1.5px solid var(--line); background: var(--ground); position: sticky; top: var(--bar); z-index: 2; font-weight: 400; line-height: 1.25; }
.grid th .t { font-size: 13px; font-weight: 700; margin-right: 6px; }
.grid th .sub { font-size: 12px; color: var(--muted); }
.grid th .due { display: inline-block; margin-left: 6px; font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; vertical-align: 1px; }
.grid th.need { width: 128px; }
.grid th.p1 { width: 150px; }
.grid td { vertical-align: top; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.grid td.need { font-weight: 700; font-size: 13px; line-height: 1.25; padding-top: 11px; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.mark { padding-top: 10px; }
.mark .x { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--mark); color: var(--ground); font-weight: 800; font-size: 15px; line-height: 1; }
.mark .tbd { font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; display: inline-block; }

/* a cell that spans several needs: one box, the tile in its middle */
.grid td.span { vertical-align: middle; background: var(--surface); border: 1.5px solid var(--faint); border-radius: 12px; }
.grid td.span .apps { justify-content: center; }

/* tiles: a small squircle with the name beside it */
.apps { display: flex; flex-wrap: wrap; gap: 6px 14px; align-content: flex-start; }
.app { margin: 0; display: flex; align-items: center; gap: 7px; text-align: left; }
.tile-wrap { position: relative; width: 30px; height: 30px; flex: none; filter: drop-shadow(0 0 .5px var(--tile-ring)) drop-shadow(0 1px 3px var(--tile-shadow)); }
.tile { width: 100%; height: 100%; display: grid; place-items: center; background: var(--bg); -webkit-mask: var(--squircle) center / 100% 100% no-repeat; mask: var(--squircle) center / 100% 100% no-repeat; }
.tile > img { width: var(--s); height: var(--s); display: block; object-fit: contain; }
.tile .letter { color: #fff; font-weight: 800; font-size: 14px; }
figcaption { display: grid; gap: 0; }
.name { font-size: 13px; font-weight: 500; line-height: 1.2; overflow-wrap: anywhere; }
.via { font-family: var(--mono); font-size: 11px; line-height: 1.2; color: var(--muted); overflow-wrap: anywhere; }

/* comments rail */
.comments { position: sticky; top: var(--bar); height: calc(100dvh - var(--bar)); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
body:not(.rail-open) .comments { display: none; }
.rail-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); flex: none; }
.rail-title { font-size: 13px; font-weight: 700; }
.rail-title .n { font-size: 11px; color: var(--muted); background: var(--ground); border-radius: 9px; padding: 1px 7px; margin-left: 6px; font-weight: 600; }
.add { margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--faint); color: var(--muted); font-size: 18px; line-height: 1; display: grid; place-items: center; }
.add:hover, .add.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.rail-close { width: 26px; height: 26px; border-radius: 6px; color: var(--faint); font-size: 18px; display: grid; place-items: center; }
.rail-close:hover { background: var(--ground); color: var(--ink); }
.rail-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 24px; display: flex; flex-direction: column; gap: 8px; }
.thread { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px 8px; flex: none; background: var(--surface); }
.thread .top { display: flex; align-items: center; gap: 6px; }
.thread .top .resolve { margin-left: auto; flex: none; height: 22px; min-width: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; display: grid; place-items: center; }
.thread .top .resolve:hover { color: var(--done); border-color: var(--done); }
.thread .top .resolve svg { width: 12px; height: 12px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.c { display: flex; gap: 8px; }
.c + .c, .thread .top + .c { margin-top: 8px; }
.c.reply { margin-left: 18px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex: none; background: var(--line); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--muted); }
.c .body { flex: 1; min-width: 0; }
.c .who { display: flex; align-items: baseline; gap: 6px; font-size: 12px; font-weight: 600; }
.c .when { font-weight: 400; color: var(--faint); }
.c .del { margin-left: auto; color: var(--faint); font-size: 14px; opacity: 0; line-height: 1; }
.c:hover .del { opacity: 1; }
.c .del:hover { color: var(--danger); }
.c .txt { font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 1px; }
.thread.resolved .c .txt { color: var(--muted); }
.rail-body textarea { width: 100%; font: inherit; font-size: 13px; line-height: 1.4; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--ground); color: var(--ink); resize: none; display: block; overflow: hidden; }
.rail-body textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.thread textarea { margin-top: 8px; }
.composer { border: 1px solid var(--accent); border-radius: 10px; padding: 10px; flex: none; }
.composer .as { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.cbtns { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.cbtns button { font-size: 12px; padding: 4px 10px; border-radius: 7px; border: 1px solid var(--line); color: var(--muted); }
.cbtns button:hover { color: var(--ink); background: var(--ground); }
.cbtns .primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cbtns .primary:hover { color: #fff; }
.resolved-head { font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px 2px; flex: none; }
.resolved-head:hover { color: var(--ink); }
.nothing { color: var(--faint); font-size: 13px; text-align: center; padding: 40px 12px; line-height: 1.5; }

/* narrow screens: the rail drops under the table */
@media (max-width: 1000px) {
  body.rail-open .layout { grid-template-columns: 1fr; }
  .comments { position: static; height: auto; max-height: 70dvh; border-left: 0; border-top: 1px solid var(--line); }
  .legend { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
