/* ── chat-window redesign v2 (full fidelity) ─────────────── */
:root {
  --chrome: #ecebe7;
  --chrome-line: #d8d6cf;
  --rail: #e5e3dd;
  --sidebar: #f0efeb;
  --sidebar-ink: #3c4045;
  --sidebar-muted: #757a82;
  --chrome-strong: #1a1c1e;
  --chrome-hover: rgba(0, 0, 0, 0.06);
  --win-border: rgba(255, 255, 255, 0.35);
  --pane: #fcfcfa;
  --pane-ink: #1a1c1e;
  --pane-body: #3c4045;
  --pane-muted: #65696f;
  --accent: #2f6ce0;
  --accent-soft: rgba(47, 108, 224, 0.1);
  --green: #3fb950;
  --card-line: #e4e2da;
  --card-bg: #f6f5f1;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --chrome: #17191d;
    --chrome-line: #26292f;
    --rail: #101215;
    --sidebar: #1b1e24;
    --sidebar-ink: #b9bcc2;
    --sidebar-muted: #7c828b;
    --chrome-strong: #e6e4df;
    --chrome-hover: rgba(255, 255, 255, 0.06);
    --win-border: rgba(255, 255, 255, 0.09);
    --pane: #1f2227;
    --pane-ink: #e9e7e2;
    --pane-body: #b9bcc1;
    --pane-muted: #8d929a;
    --accent: #7aa2f7;
    --accent-soft: rgba(122, 162, 247, 0.14);
    --card-line: #2e3238;
    --card-bg: #262a31;
  }
}
:root[data-theme="dark"] {
  --chrome: #17191d;
  --chrome-line: #26292f;
  --rail: #101215;
  --sidebar: #1b1e24;
  --sidebar-ink: #b9bcc2;
  --sidebar-muted: #7c828b;
  --chrome-strong: #e6e4df;
  --chrome-hover: rgba(255, 255, 255, 0.06);
  --win-border: rgba(255, 255, 255, 0.09);
  --pane: #1f2227;
  --pane-ink: #e9e7e2;
  --pane-body: #b9bcc1;
  --pane-muted: #8d929a;
  --accent: #7aa2f7;
  --accent-soft: rgba(122, 162, 247, 0.14);
  --card-line: #2e3238;
  --card-bg: #262a31;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.55;
  color: var(--pane-ink);
  background-color: #0b0e12;
  background-image:
    linear-gradient(rgba(8, 10, 14, 0.3), rgba(8, 10, 14, 0.12) 40%, rgba(8, 10, 14, 0.4)),
    url("img/backdrop.jpg");
  background-size: cover;
  background-position: center;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3.5vh 20px;
}

/* ── the window (fixed to viewport; chat scrolls inside) ── */
.window {
  width: min(1280px, 100%);
  height: min(93vh, 980px);
  min-height: 540px;
  background: var(--chrome);
  border: 1px solid var(--win-border);
  border-radius: 14px;
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.6), 0 6px 24px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--chrome-line);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.r { background: #f45952; }
.dot.y { background: #f5b942; }
.dot.g { background: #3fb950; }
.titlebar .title {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--sidebar-muted);
  margin-right: 24px;
}
.theme-toggle {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid var(--chrome-line);
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--chrome-hover); }

.app { display: flex; align-items: stretch; flex: 1; min-height: 0; }

/* ── leftmost icon rail ── */
.rail {
  width: 64px;
  flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--chrome-line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 4px;
}
.rail-logo {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
  text-decoration: none;
}
.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 9.5px;
  font-family: var(--sans);
  padding: 7px 0 6px;
  width: 52px;
  border-radius: 8px;
}
.rail-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.rail-item:hover { color: var(--chrome-strong); background: var(--chrome-hover); }
.rail-item.active { color: var(--chrome-strong); background: var(--chrome-hover); }
.rail-spacer { flex: 1; }
.rail-collapse {
  color: var(--sidebar-muted);
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
}
.rail-collapse:hover { color: var(--chrome-strong); background: var(--chrome-hover); }
.rail-collapse svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.window.sidebar-collapsed .sidebar { display: none; }

/* ── sidebar ── */
.sidebar {
  width: 226px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--chrome-line);
  padding: 14px 10px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 6px 12px;
}
.side-name { color: var(--chrome-strong); font-family: var(--display); font-weight: 600; font-size: 15px; }
.side-plus {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--chrome-hover);
  color: var(--sidebar-ink);
  font-size: 14px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.side-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px;
  color: var(--sidebar-muted);
  padding: 12px 6px 5px;
}
.side-label .tri { font-size: 8px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4.5px 8px;
  border-radius: 6px;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  text-decoration: none;
}
.side-link:hover { background: var(--chrome-hover); }
.side-link.active { background: var(--accent-soft); color: var(--chrome-strong); }
.side-link .hash { color: var(--sidebar-muted); font-family: var(--mono); }
.side-link.active .hash { color: var(--accent); }
.side-link .mini-avatar {
  width: 20px; height: 20px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.presence {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--sidebar);
  position: absolute;
  right: -3px; bottom: -3px;
}
.side-link .app-ico { width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.app-ico.gh { background: #24292f url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23fff' d='M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12'/></svg>") center / 11px no-repeat; color: #fff; }
.app-ico.li { background: #0a66c2; color: #fff; font-weight: 700; font-family: var(--sans); }
.app-ico.gm { background: #fff url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='52 42 88 66'><path fill='%234285f4' d='M58 108h14V74L52 59v43c0 3.32 2.69 6 6 6'/><path fill='%2334a853' d='M120 108h14c3.32 0 6-2.69 6-6V59l-20 15'/><path fill='%23fbbc04' d='M120 48v26l20-15v-8c0-7.42-8.47-11.65-14.4-7.2'/><path fill='%23ea4335' d='M72 74V48l24 18 24-18v26L96 92'/><path fill='%23c5221f' d='M52 51v8l20 15V48l-5.6-4.2c-5.94-4.45-14.4-.22-14.4 7.2'/></svg>") center / 11px no-repeat; border: 1px solid #ddd; }
.side-foot {
  margin-top: auto;
  padding: 14px 6px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--sidebar-muted);
  line-height: 1.6;
}

/* ── chat pane ── */
.pane { flex: 1; min-width: 0; background: var(--pane); display: flex; flex-direction: column; }
.pane-head {
  padding: 12px 22px 0;
  border-bottom: 1px solid var(--card-line);
}
.pane-who { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pane-avatar {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: visible;
}
.pane-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.pane-avatar .presence { border-color: var(--pane); }
.pane-title { font-family: var(--display); font-weight: 600; font-size: 15.5px; }
.pane-sub { font-size: 12px; color: var(--pane-muted); }
.tabs { display: flex; gap: 20px; }
.tab {
  font-size: 13px;
  color: var(--pane-muted);
  text-decoration: none;
  padding: 0 2px 9px;
  border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 6px;
}
.tab svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tab.active { color: var(--pane-ink); border-bottom-color: var(--pane-ink); font-weight: 500; }

.chat { padding: 20px 24px 30px; flex: 1; overflow-y: auto; min-height: 0; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--card-line); }
.divider span {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pane-muted);
  border: 1px solid var(--card-line);
  border-radius: 999px;
  padding: 2px 11px;
}

.msg { display: grid; grid-template-columns: 40px 1fr; gap: 13px; margin-bottom: 20px; }
.msg-avatar {
  width: 40px; height: 40px;
  border-radius: 9px;
  font-family: var(--mono);
  font-size: 13px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: visible;
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
.msg-avatar.sam { background: var(--accent); }
.msg-avatar.bot { background: #4c566d; }
.msg-avatar .presence { border-color: var(--pane); }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.msg-name { font-family: var(--display); font-weight: 600; font-size: 14px; }
.msg-tag {
  font-family: var(--mono);
  font-size: 9.5px;
  background: var(--accent);
  color: #fff;
  border-radius: 3px;
  padding: 1px 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.msg-time { font-family: var(--mono); font-size: 11px; color: var(--pane-muted); }
.msg-body { min-width: 0; }
.msg-body p { margin: 0 0 10px; max-width: 70ch; color: var(--pane-body); font-size: 14.5px; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body a { color: var(--accent); text-underline-offset: 3px; }
.msg-body ul { margin: 4px 0 10px; padding-left: 4px; list-style: none; max-width: 70ch; }
.msg-body ul li { position: relative; padding-left: 16px; color: var(--pane-body); font-size: 14.5px; margin-bottom: 4px; }
.msg-body ul li::before { content: "•"; position: absolute; left: 2px; color: var(--pane-muted); }

/* hashtag pills inside messages */
.tagpill {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  text-decoration: none;
  white-space: nowrap;
}
a.tagpill:hover { text-decoration: underline; }

/* attachments with filename captions */
.file-cap {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pane-muted);
  margin: 12px 0 5px;
}
.attach-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 8px; }
.attach-row.single { grid-template-columns: 1fr; max-width: 560px; }
.attach {
  border: 1px solid var(--card-line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 13px 15px 11px;
  position: relative;
}
.attach .expand {
  position: absolute;
  top: 9px; right: 9px;
  width: 20px; height: 20px;
  border-radius: 5px;
  border: 1px solid var(--card-line);
  color: var(--pane-muted);
  font-size: 13px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.attach h3 { font-family: var(--display); font-size: 14.5px; font-weight: 600; margin: 0 0 2px; padding-right: 24px; }
.attach h3 a { color: inherit; text-decoration: none; }
.attach h3 a:hover { color: var(--accent); }
.attach .meta { font-family: var(--mono); font-size: 10.5px; color: var(--pane-muted); margin-bottom: 6px; }
.attach p { font-size: 13px; color: var(--pane-body); margin: 0 0 9px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--pane-muted);
  border: 1px solid var(--card-line);
  border-radius: 4px;
  padding: 1.5px 6px;
}
.attach .live { font-family: var(--mono); font-size: 11.5px; margin-top: 9px; display: inline-block; color: var(--accent); }

/* visual thumbnails (project tiles) */
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 8px; }
.thumb { text-decoration: none; color: inherit; display: block; }
.thumb-art {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--card-line);
  background:
    radial-gradient(120% 100% at 15% 0%, rgba(255, 255, 255, 0.14), transparent 55%),
    linear-gradient(135deg, var(--th-a, #2c3550), var(--th-b, #141a2c));
  background-image: var(--th-img), linear-gradient(135deg, var(--th-a, #2c3550), var(--th-b, #141a2c));
  background-size: cover;
  background-position: center;
}
.thumb-art::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(120% 90% at 30% 10%, #000 20%, transparent 75%);
}
.thumb-art .glyph {
  position: absolute;
  right: 10px; top: 6px;
  font-size: 46px;
  opacity: 0.35;
  filter: saturate(0.8);
}
.thumb-art .t-title {
  position: absolute;
  left: 12px; right: 12px; bottom: 10px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.25;
  color: #f2f1ed;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.thumb-art .expand {
  position: absolute;
  top: 8px; left: 8px;
  width: 20px; height: 20px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.thumb .t-meta { font-family: var(--mono); font-size: 10.5px; color: var(--pane-muted); margin: 7px 0 2px; }
.thumb .t-line { font-size: 12.5px; color: var(--pane-body); line-height: 1.45; margin: 0 0 6px; }
.thumb .chip-row { gap: 5px; }
.thumb:hover .thumb-art { border-color: var(--accent); }

/* per-project hues */
.th-pipeline { --th-a: #3b4a7a; --th-b: #141a2e; --th-img: url("img/tiles/pipeline.svg"); }
.th-fallback { --th-a: #235a63; --th-b: #0e1e22; --th-img: url("img/tiles/fallback.svg"); }
.th-deploy   { --th-a: #2d5d43; --th-b: #0f1f17; --th-img: url("img/tiles/deploy.svg"); }
.th-credits  { --th-a: #5d4a26; --th-b: #211a0e; --th-img: url("img/tiles/credits.svg"); }
.th-voices   { --th-a: #5a3860; --th-b: #1e1222; --th-img: url("img/tiles/voices.svg"); }
.th-gpu      { --th-a: #613a3a; --th-b: #221212; --th-img: url("img/tiles/gpu.svg"); }
.th-engine   { --th-a: #43406b; --th-b: #161527; --th-img: url("img/tiles/engine.svg"); }
.th-discord  { --th-a: #3a4a6b; --th-b: #121827; --th-img: url("img/tiles/discord.svg"); }
.th-infra    { --th-a: #2e5556; --th-b: #101e1e; --th-img: url("img/tiles/infra.svg"); }
.th-content  { --th-a: #56552e; --th-b: #1e1e10; --th-img: url("img/tiles/content.svg"); }
.th-runner   { --th-a: #63472a; --th-b: #231810; --th-img: url("img/tiles/runner.svg"); }
.th-playshop { --th-a: #2e5d6b; --th-b: #0f2026; --th-img: url("img/tiles/playshop.svg"); }
.th-xr       { --th-a: #2a4d63; --th-b: #0f1b23; --th-img: url("img/tiles/xr.svg"); }
.th-kids     { --th-a: #5d2e4a; --th-b: #200f1a; --th-img: url("img/tiles/kids.svg"); }

/* pdf attachment */
.pdf-attach {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--card-line);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 12px 14px;
  max-width: 430px;
  margin-top: 8px;
  text-decoration: none;
}
.pdf-ico {
  width: 38px; height: 44px;
  border-radius: 5px;
  background: #d13438;
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pdf-name { font-size: 13.5px; font-weight: 500; color: var(--pane-ink); }
.pdf-sub { font-family: var(--mono); font-size: 11px; color: var(--pane-muted); }

/* pills + reactions */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--pane-ink);
  border: 1px solid var(--card-line);
  background: var(--card-bg);
  border-radius: 999px;
  padding: 5px 13px;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.primary:hover { color: #fff; opacity: 0.9; }
.react-row { display: flex; gap: 6px; margin-top: 10px; }
.react {
  font-size: 12px;
  font-family: var(--mono);
  border: 1px solid var(--card-line);
  background: var(--card-bg);
  border-radius: 999px;
  padding: 2.5px 9px;
  color: var(--pane-muted);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  user-select: none;
}
.react:hover { border-color: var(--pane-muted); }
.react.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.react.pop { animation: react-pop 0.28s ease; }
@keyframes react-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.showmore {
  display: block;
  width: fit-content;
  margin: 4px auto 0;
  font-size: 12.5px;
  font-family: var(--sans);
  color: var(--pane-muted);
  border: 1px solid var(--card-line);
  background: var(--card-bg);
  border-radius: 999px;
  padding: 5px 15px;
  text-decoration: none;
}
.showmore:hover { color: var(--pane-ink); border-color: var(--pane-muted); }

/* level-ups + achievements (journey) */
.levelup {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 65%), var(--card-bg);
  padding: 14px 16px 13px;
  margin-top: 6px;
  max-width: 640px;
}
.lu-cap {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}
.lu-title { font-family: var(--display); font-weight: 600; font-size: 16.5px; margin-bottom: 3px; }
.lu-sub { font-size: 13px; color: var(--pane-body); max-width: 60ch; }
.xp { margin-top: 12px; }
.xp-label {
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--pane-muted);
  margin-bottom: 4px;
}
.xp-track {
  height: 10px;
  background: var(--card-line);
  overflow: hidden;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 13px, transparent 13px 17px);
  mask: repeating-linear-gradient(90deg, #000 0 13px, transparent 13px 17px);
}
.xp-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #fff));
  transition: width 1.1s steps(12, end);
}
/* grouped follow-up messages (no avatar repeat) */
.msg.compact { margin-bottom: 5px; }
.msg.compact .msg-gutter { width: 40px; }
.msg + .msg.compact { margin-top: -12px; }
.msg.compact + .msg.compact { margin-top: 0; }

/* slack-style threads */
.thread-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  margin-top: 5px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: var(--sans);
  text-align: left;
}
.thread-btn:hover { border-color: var(--card-line); background: var(--card-bg); }
.thread-btn .tb-av { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.thread-btn .tb-count { color: var(--accent); font-size: 12.5px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.thread-btn .tb-last {
  color: var(--pane-muted);
  font-size: 12.5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-btn .tb-view { color: var(--pane-muted); font-size: 12px; margin-left: auto; opacity: 0; white-space: nowrap; flex-shrink: 0; }
.thread-btn:hover .tb-view { opacity: 1; }

.thread-pane {
  display: none;
  flex-direction: column;
  width: 0;
  flex-shrink: 0;
  background: var(--pane);
  border-left: 1px solid var(--card-line);
  min-height: 0;
}
.window.thread-open .thread-pane { display: flex; width: 380px; }
.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--card-line);
}
.thread-head .th-title { font-family: var(--display); font-weight: 600; font-size: 14.5px; }
.thread-head .th-sub { font-family: var(--mono); font-size: 11px; color: var(--pane-muted); }
.thread-close {
  border: none;
  background: transparent;
  color: var(--pane-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
}
.thread-close:hover { background: var(--card-bg); color: var(--pane-ink); }
.thread-body { flex: 1; overflow-y: auto; padding: 16px 16px 22px; }
.thread-body .msg { margin-bottom: 14px; }
.thread-data { display: none; }

/* typing */
.typing { display: flex; align-items: center; gap: 10px; color: var(--pane-muted); font-size: 12.5px; font-family: var(--mono); margin-top: 6px; }
.typing .dots span {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--pane-muted); margin-right: 3px;
  animation: blink 1.3s infinite;
}
.typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.typing .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* floating contact pill */
.contact-float {
  position: fixed;
  right: 26px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--chrome);
  border: 1px solid var(--win-border);
  border-radius: 999px;
  padding: 7px 8px 7px 7px;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.contact-float .mini-avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 11px; position: relative; flex-shrink: 0; }
.contact-float .mini-avatar img { border-radius: 9px; }
.contact-float .mini-avatar::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 9px;
  box-shadow:
    inset 0 1.5px 1px rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.contact-float .cf-text { line-height: 1.25; padding-right: 2px; }
.contact-float .cf-title { color: var(--chrome-strong); font-size: 13px; font-weight: 500; }
.contact-float .cf-sub { color: var(--sidebar-muted); font-family: var(--mono); font-size: 10.5px; }
.contact-float .cf-plus {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* canvas (pinned project doc, Slack-canvas style) */
.canvas {
  border: 1px solid var(--card-line);
  border-radius: 10px;
  background: var(--card-bg);
  overflow: hidden;
  max-width: 720px;
  margin-top: 8px;
}
.canvas-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--card-line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--pane-muted);
}
.canvas-head .doc-ico {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.canvas-body { padding: 15px 18px 17px; }
.canvas-body .c-title { font-family: var(--display); font-size: 18px; font-weight: 600; margin: 0 0 3px; }
.canvas-body .c-sub { color: var(--pane-body); font-size: 13.5px; margin: 0; max-width: 64ch; }
.canvas-sec { margin-top: 15px; }
.canvas-sec .c-lbl {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--accent); margin-bottom: 6px;
}
.canvas-sec ul { margin: 0; padding-left: 17px; }
.canvas-sec li { font-size: 13.5px; color: var(--pane-body); margin-bottom: 4px; }
.canvas-sec li strong { color: var(--pane-ink); font-weight: 600; }
.canvas-sec p { font-size: 13.5px; color: var(--pane-body); margin: 0; }
.flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flow .step {
  font-family: var(--mono); font-size: 11.5px;
  border: 1px solid var(--card-line); border-radius: 5px;
  padding: 3px 9px; color: var(--pane-body); background: var(--pane);
}
.flow .arw { color: var(--pane-muted); font-size: 11px; }

/* th hue for lab tiles */
.th-loop { --th-a: #2f4a7a; --th-b: #121a2e; --th-img: url("img/tiles/loop.svg"); }

/* ── responsive (reference breakpoints: 991 / 767 / 479) ── */
.m-nav { display: none; }

@media (max-width: 991px) {
  body { padding: 2vh 12px; }
  .rail { display: none; }
  .thumb-grid { grid-template-columns: repeat(2, 1fr); }
  .attach-row { grid-template-columns: 1fr; }
  .window.thread-open .pane { display: none; }
  .window.thread-open .thread-pane { width: 100%; flex: 1; }
}

@media (max-width: 767px) {
  body { padding: 2vh 10px; }
  .window { min-height: 0; }
  .sidebar { display: none; }
  .m-nav {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--chrome-line);
    overflow-x: auto;
  }
  .m-nav a {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--sidebar-ink);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
  }
  .m-nav a.active { background: var(--accent-soft); color: var(--chrome-strong); }
  .chat { padding: 16px 14px 22px; }
  .pane-head { padding: 10px 14px 0; }
  .msg { grid-template-columns: 34px 1fr; gap: 10px; }
  .msg-avatar { width: 34px; height: 34px; }
  .msg.compact .msg-gutter { width: 34px; }
  .contact-float { right: 12px; bottom: 12px; }
}

@media (max-width: 479px) {
  body { padding: 1.5vh 6px; }
  .thumb-grid { grid-template-columns: 1fr; }
  .titlebar { padding: 10px 12px; }
  .titlebar .title { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat { padding: 12px 10px 18px; }
  .pane-sub { display: none; }
  .tabs { gap: 14px; }
  .msg-body p { font-size: 14px; }
  .thread-btn .tb-last { display: none; }
  .levelup { padding: 12px 13px 11px; }
  .contact-float .cf-text { display: none; }
  .contact-float { padding: 6px; gap: 0; }
  .contact-float .cf-plus { margin-left: 6px; }
}
