:root {
  color-scheme: light dark;
  --ink: #1b1f1d;
  --soft: #4c5450;
  --muted: #8a918d;
  --paper: #fafaf8;
  --surface: #ffffff;
  --sunken: #f3f3f0;
  --line: #e6e7e3;
  --accent: #2f6b55;
  --accent-ink: #ffffff;
  --warn: #a8641a;
  --danger: #a3453c;
  --shadow: 0 24px 60px rgba(20, 30, 25, .12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Segoe UI", sans-serif;
  font-weight: 300;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eceeec;
    --soft: #b9bfbb;
    --muted: #7f8783;
    --paper: #131615;
    --surface: #1a1e1c;
    --sunken: #202523;
    --line: #2a302d;
    --accent: #7fc0a4;
    --accent-ink: #10201a;
    --warn: #d9a25f;
    --danger: #e08a80;
    --shadow: 0 24px 60px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
strong { font-weight: 400; }
code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Top bar */
.topbar {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { color: inherit; text-decoration: none; font-size: 15px; font-weight: 400; letter-spacing: .01em; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.local-badge { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.local-badge i, .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }

/* Buttons */
.button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px;
  background: transparent;
  font-weight: 400;
  font-size: 13px;
  transition: border-color .15s, opacity .15s;
}
.button:hover { border-color: var(--muted); }
.button:disabled { cursor: not-allowed; opacity: .4; }
.button.primary { color: var(--accent-ink); border-color: var(--accent); background: var(--accent); }
.button.primary:hover { opacity: .88; }
.button.quiet { border-color: transparent; color: var(--soft); padding-left: 8px; padding-right: 8px; }
.button.quiet:hover { color: var(--ink); }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 17px; font-weight: 300; padding: 2px 8px; border-radius: 8px; }
.icon-button:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.shell { min-height: calc(100vh - 56px); display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { padding: 22px 12px; border-right: 1px solid var(--line); min-width: 0; }
.sidebar-heading { display: flex; justify-content: space-between; align-items: center; padding: 0 10px 8px; color: var(--muted); font-size: 12px; }
.room-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.room-link { width: 100%; text-align: left; border: 0; border-radius: 10px; padding: 9px 10px; background: transparent; }
.room-link:hover, .room-link.active { background: var(--sunken); }
.room-link strong { display: block; font-size: 13px; font-weight: 300; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-link.active strong { font-weight: 400; }
.room-link span { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 11px; }
.dot.closed { background: var(--muted); opacity: .45; }
.dot.you { background: var(--warn); }
.dot.live { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } }
.workspace-summary { margin-top: 26px; padding: 0 10px; color: var(--muted); font-size: 11px; }
.workspace-summary h2 { font-size: 12px; font-weight: 300; margin-bottom: 6px; }
.workspace-item { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.room-view { padding: 48px 24px 96px; max-width: 760px; width: 100%; margin: 0 auto; }
.muted { color: var(--muted); font-size: 12px; }

/* Empty state */
.empty-state { min-height: 60vh; display: grid; place-content: center; justify-items: start; gap: 12px; }
.empty-state h1, .room-header h1, .team-head h1 { font-weight: 200; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.2; letter-spacing: -.01em; }
.empty-state p { color: var(--soft); margin-bottom: 10px; }

/* Room header */
.room-header { margin-bottom: 28px; }
.room-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.room-meta .state { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); }
.done-when { margin-top: 14px; color: var(--soft); white-space: pre-wrap; }
.done-when span { color: var(--muted); }

/* Next step */
.next { padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.next h2 { font-size: 19px; font-weight: 300; }
.next .hint { color: var(--muted); font-size: 13px; margin-top: 2px; }
.next .request { margin-top: 14px; padding-left: 14px; border-left: 2px solid var(--warn); color: var(--soft); font-size: 13px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 16px; }
.pick { display: grid; gap: 3px; color: var(--muted); font-size: 11px; }
.pick select { width: auto; min-width: 118px; padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.inline-form { display: grid; gap: 10px; margin-top: 14px; }
.inline-form .row { margin-top: 0; }
.next .more { margin-top: 16px; }

/* Sections */
.section { margin-top: 36px; }
.section > h2, .fold > summary { color: var(--muted); font-size: 12px; font-weight: 300; }
.section > h2 { margin-bottom: 14px; }
.folds { margin-top: 40px; }
.fold { border-top: 1px solid var(--line); padding: 12px 0; }
.fold:last-child { border-bottom: 1px solid var(--line); }
.fold > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "+"; font-size: 15px; }
.fold[open] > summary::after { content: "−"; }
.fold[open] > summary { margin-bottom: 12px; }
.fold > summary:hover { color: var(--ink); }

/* Timeline */
.timeline { display: grid; gap: 18px; border-left: 1px solid var(--line); padding-left: 18px; margin-left: 3px; }
.event { position: relative; }
.event::before { content: ""; position: absolute; left: -22px; top: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--paper); border: 1px solid var(--muted); }
.event.by-user::before { background: var(--muted); }
.event-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.event-head strong { font-size: 14px; }
.event-head span { color: var(--muted); font-size: 11px; }
.event-message { margin-top: 3px; color: var(--soft); font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.event details summary { cursor: pointer; list-style: none; }
.event details summary::-webkit-details-marker { display: none; }
.event details summary::after { content: " … more"; color: var(--muted); }
.event details[open] summary { display: none; }

/* Runs, prompt, lessons */
.run { padding: 5px 0; font-size: 13px; }
.run summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.run summary::-webkit-details-marker { display: none; }
.run summary span { color: var(--muted); font-size: 12px; }
.run summary .failed { color: var(--danger); }
pre { margin: 10px 0 0; padding: 14px; border-radius: 12px; background: var(--sunken); color: var(--soft); font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; }
.tabs { display: flex; align-items: baseline; gap: 14px; font-size: 13px; }
.tabs button { border: 0; background: transparent; padding: 0 0 2px; color: var(--muted); border-bottom: 1px solid transparent; }
.tabs button.active { color: var(--ink); border-color: var(--ink); }
.tabs .copy { margin-left: auto; }
.lessons { margin: 0; padding-left: 16px; color: var(--soft); font-size: 13px; display: grid; gap: 4px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 13px; color: var(--soft); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* Forms */
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 9px 11px; outline: none; font-size: 14px; font-weight: 300; }
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 9px; color: var(--soft); font-size: 13px; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.check small { color: var(--muted); font-size: 12px; }

/* Dialog */
dialog { width: min(520px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 18px; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 20, 18, .35); }
.dialog-form { padding: 24px; display: grid; gap: 14px; max-height: min(86vh, 760px); overflow: auto; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
.dialog-heading h1 { font-size: 20px; font-weight: 300; }
.more > summary { cursor: pointer; color: var(--muted); font-size: 12px; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover { color: var(--ink); }
.more[open] > summary { margin-bottom: 12px; }
.more > * + * { margin-top: 12px; }
.capability-options { display: grid; gap: 8px; }
.capability-options:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--danger); font-size: 12px; }
.form-error:empty { display: none; }

.toast { position: fixed; left: 50%; bottom: 24px; max-width: 360px; padding: 8px 16px; border-radius: 999px; color: var(--paper); background: var(--ink); font-size: 12px; opacity: 0; transform: translate(-50%, 6px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.error-card { color: var(--danger); font-size: 14px; }

@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .local-badge { display: none; }
  .shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .sidebar-heading, .workspace-summary { display: none; }
  .room-list { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; }
  .room-list::-webkit-scrollbar { display: none; }
  .room-link { min-width: 150px; max-width: 200px; }
  .room-view { padding: 28px 16px 72px; }
  .next { padding: 18px; }
  .pick { flex: 1; min-width: 0; }
  .pick select { width: 100%; min-width: 0; }
  input, textarea, select { font-size: 16px; }
}

/* Team rooms */
.sidebar-heading.second { margin-top: 26px; }
.hub .local-only, .signed-out .sidebar, .signed-out #new-team, [hidden] { display: none !important; }
.signed-out .shell { display: block; }
.signed-out #place { display: none; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
.local-badge.away i { background: var(--muted); opacity: .5; }
.sign-in { min-height: 60vh; display: grid; place-content: center; gap: 14px; width: min(320px, 100%); margin: 0 auto; }
.sign-in h1 { font-weight: 200; font-size: 28px; }
.sign-in .form-error { min-height: 18px; display: block; }
.chip.away:not([aria-pressed="true"]) { opacity: .55; }
a.room-link { display: block; text-decoration: none; color: inherit; }
.sidebar .muted { padding: 2px 10px; }
.team-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
.team-head .room-meta { margin-bottom: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; cursor: pointer; flex: none; padding-bottom: 6px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 28px; height: 16px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(12px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch.on { color: var(--soft); }

.thread { display: grid; gap: 26px; padding-bottom: 28px; }
.thread-empty { color: var(--muted); font-size: 13px; padding: 8px 0 28px; }
.group { display: grid; gap: 14px; }
.post-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 12px; color: var(--muted); }
.post-head strong { font-size: 13px; color: var(--ink); }
.post.mine .post-head strong { color: var(--accent); }
.asks { display: inline-flex; align-items: center; gap: 5px; }
.asks .dot { width: 5px; height: 5px; }
.asks .dot.hollow { background: transparent; border: 1px solid var(--muted); }
.asks.done { opacity: .6; }
.post-body { margin-top: 3px; color: var(--soft); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.post.mine .post-body { color: var(--ink); }
.post.error .post-body { color: var(--danger); }
.post-body pre { white-space: pre-wrap; margin: 8px 0; max-height: 360px; }
.post-body code { background: var(--sunken); border-radius: 5px; padding: 1px 5px; }
.post-body pre code { background: none; padding: 0; }
.post-body a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--line); }
.mention { color: var(--accent); }
.post-actions { display: flex; gap: 14px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.post:hover .post-actions, .post:focus-within .post-actions { opacity: 1; }
.post-actions button { border: 0; background: transparent; padding: 0; color: var(--muted); font-size: 12px; }
.post-actions button:hover { color: var(--ink); }
.replies { display: grid; gap: 14px; margin-left: 3px; padding-left: 18px; border-left: 1px solid var(--line); }
.post details summary { cursor: pointer; list-style: none; }
.post details summary::-webkit-details-marker { display: none; }
.post details summary::after { content: " … more"; color: var(--muted); }
.post details[open] summary { display: none; }

.composer { position: sticky; bottom: 0; padding: 12px 0 calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, transparent, var(--paper) 18px); }
.composer-box { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 10px 12px 10px 14px; transition: border-color .15s; }
.composer-box:focus-within { border-color: var(--muted); }
.composer textarea { border: 0; padding: 4px 0; background: transparent; resize: none; min-height: 26px; max-height: 220px; font-size: 15px; }
.replying { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; padding-bottom: 4px; }
.replying span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.replying[hidden] { display: none; }
.composer-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1; min-width: 0; color: var(--muted); font-size: 12px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; background: transparent; color: var(--soft); font-size: 12px; font-weight: 300; transition: border-color .15s, color .15s, background .15s; }
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); background: var(--accent); }
.chip.guest:not([aria-pressed="true"]) { border-style: dashed; }
.chip:disabled { opacity: .4; cursor: not-allowed; }

@media (hover: none) { .post-actions { opacity: 1; } }
@media (max-width: 760px) {
  .sidebar-heading.second { display: none; }
  .sidebar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .room-list { overflow: visible; flex: none; }
  .composer textarea { font-size: 16px; }
}
