:root {
  --bg: #f6f6f4; --fg: #1d1d1b; --muted: #6b6b66; --line: #dcdcd6; --accent: #1d1d1b;
  --card: #ffffff; --error: #a3261b; --header-h: 44px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); }
a { color: inherit; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; }
button { font: inherit; cursor: pointer; }
button.link { background: none; border: 0; text-decoration: underline; color: var(--muted); padding: 0 0 0 8px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 600; text-decoration: none; }
.content { max-width: 880px; margin: 32px auto; padding: 0 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.narrow { max-width: 380px; margin: 48px auto; }
label { display: block; margin: 12px 0; }
input[type=email], input[type=password] { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
form button[type=submit]:not(.link) { margin-top: 8px; padding: 8px 16px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; }
.error { color: var(--error); margin: 8px 0; }
.projects { list-style: none; padding: 0; }
.projects li { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--line); }

/* Shell */
body.shell { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.shell-header { height: var(--header-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.shell-header .spacer { flex: 1; }
.shell-header select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); max-width: 46vw; }
.shell-header .hint { font-size: 13px; color: var(--muted); }
.shell-header .icon { background: none; border: 0; color: var(--muted); font-size: 16px; padding: 4px 8px; }
.prototype { flex: 1; width: 100%; border: 0; background: #fff; }
.pill { display: none; position: fixed; top: 8px; right: 8px; z-index: 10; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 12px; opacity: .85; }
body.collapsed .shell-header, body.chrome-off .shell-header { display: none; }
body.collapsed .pill { display: block; }
@media (max-width: 600px) { .shell-header .user { display: inline-block; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; } }

/* Sidebar (M2) */
.stage { flex: 1; display: flex; min-height: 0; }
.tab-toggle { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; color: var(--fg); }
.tab-toggle .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--bg); font-size: 12px; }
.sidebar { width: 360px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--card); overflow: hidden; }
.sidebar[hidden] { display: none; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 6px 8px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--fg); }
.new-thread, .reply { padding: 10px 12px; }
.new-thread { border-bottom: 1px solid var(--line); }
.sidebar textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; resize: vertical; }
.sidebar .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.sidebar button[type=submit] { padding: 5px 12px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; }
.sidebar button:disabled { opacity: .5; }
.filter { margin: 0; font-size: 13px; color: var(--muted); }
.thread-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.thread { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.thread.focused { background: #fffbe6; }
.thread.status-resolved, .thread.status-answered { opacity: .8; }
.thread-head { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.permalink { margin-left: auto; text-decoration: none; }
.message { margin: 6px 0; }
.message.answer { border-left: 3px solid #2f7d4f; padding-left: 8px; }
.message .meta { display: flex; gap: 6px; align-items: baseline; font-size: 13px; flex-wrap: wrap; }
.message .body { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.replies { margin-left: 12px; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.badge.team { background: #e8eefc; color: #2b4a9b; }
.badge.answered, .status-answered .badge.status { background: #e3f3e8; color: #2f7d4f; }
.status-resolved .badge.status { background: #eee; }
.small { font-size: 13px; }
.empty { padding: 12px; }
@media (max-width: 700px) {
  .sidebar { position: fixed; inset: var(--header-h) 0 0 0; width: auto; z-index: 20; }
  .tab-toggle { padding: 3px 6px; }
}

/* Pins and comment mode (M3) */
.mode { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.mode button { background: none; border: 0; padding: 3px 10px; color: var(--muted); }
.mode button[aria-pressed="true"] { background: var(--fg); color: #fff; }
body.picking .prototype { outline: 3px solid #2b4a9b; outline-offset: -3px; }
.pin-note { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.pin-badge { min-width: 22px; height: 20px; padding: 0 6px; border: 0; border-radius: 10px 10px 10px 2px; color: #fff; font-size: 12px; font-weight: 600; }
.pin-badge.comment { background: #2b4a9b; } .pin-badge.question { background: #c46a12; } .pin-badge.closed { background: #8b8b85; }
.message.clickable { cursor: pointer; }
@media (max-width: 700px) { .mode button { padding: 3px 6px; } }

/* User menu and invite dialog (M4) */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; font-size: 14px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu { position: absolute; right: 0; top: 28px; z-index: 30; min-width: 180px; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.user-menu .menu a { text-decoration: none; }
.user-menu .menu button.link { padding: 0; text-align: left; }
.invite { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.invite::backdrop { background: rgba(0,0,0,.25); }
.invite h2 { margin-top: 0; font-size: 18px; }
.invite input[type=email], .invite input[type=text] { display: block; width: 100%; margin-top: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.invite .row { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.invite button[type=submit], .invite #invite-copy { padding: 6px 14px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; }
.copy-row { display: flex; gap: 6px; }
.copy-row input { flex: 1; }
.member-list { padding-left: 18px; font-size: 14px; color: var(--muted); }
.invite-result { background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.or { margin: 20px 0 8px; font-size: 13px; }
.button-secondary { display: block; text-align: center; padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: var(--card); }

/* Phone widths: the header scrolls sideways instead of overflowing; the panel is full screen. */
@media (max-width: 700px) {
  .shell-header { gap: 6px; padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
  .shell-header::-webkit-scrollbar { display: none; }
  .shell-header > * { flex: none; }
  .shell-header .brand { max-width: 28vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .shell-header select { max-width: 30vw; }
  .shell-header .hint, .shell-header .spacer { display: none; }
  .user-menu .menu { position: fixed; top: calc(var(--header-h) + 4px); right: 8px; }
  .content { margin: 16px auto; }
  .narrow { margin: 24px auto; }
}
