:root {
  color-scheme: light dark;
  --bg: #fbfbfa; --panel: #f3f2ef; --line: #e4e2dd; --text: #1c1b19; --muted: #7a776f;
  --accent: #d9480f; --accent-soft: #fdeee6; --ok: #2f9e44; --warn: #e67700; --bad: #c92a2a; --hover: #eae8e3;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141413; --panel: #1b1b19; --line: #2b2a27; --text: #ecebe7; --muted: #8d8a82;
    --accent: #ff8a4c; --accent-soft: #2e1d14; --ok: #51cf66; --warn: #ffa94d; --bad: #ff6b6b; --hover: #25241f; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--text); color: var(--bg); font-weight: 550; }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--muted); padding: 6px 10px; font-weight: 450; }
button.ghost:hover { background: var(--hover); color: var(--text); }
input, textarea, select { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--muted); }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.5em; font-size: 13px; }
.mark { color: var(--accent); }

#login { height: 100%; display: grid; place-items: center; padding: 24px; }
#login form { width: min(340px, 100%); display: grid; gap: 12px; text-align: center; }
#login .mark { font-size: 40px; line-height: 1; }
#login h1 { font-size: 22px; letter-spacing: -.01em; }
#login p { color: var(--muted); }

#app { height: 100%; display: grid; grid-template-columns: 260px 1fr; }
aside { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
aside > header { padding: 16px 18px 8px; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.conn { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: auto; }
.conn.live { background: var(--ok); }
nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
nav h2 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 14px 10px 4px; }
nav ul { list-style: none; margin: 0; padding: 0; }
.row { width: 100%; display: flex; align-items: center; gap: 8px; text-align: left; background: transparent; color: var(--text); font-weight: 450; padding: 5px 10px; border-radius: 7px; }
.row:hover { background: var(--hover); }
.row.active { background: var(--text); color: var(--bg); }
.row.active .sub, .row.active .glyph { color: inherit; opacity: .7; }
.row .glyph { color: var(--muted); width: 14px; text-align: center; flex: none; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.row .count { margin-left: auto; font-size: 11px; font-weight: 650; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; line-height: 17px; }
.row .count:empty { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; margin: 0 3px; }
.dot.on { background: var(--ok); border-color: var(--ok); }
aside footer { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 4px; font-size: 13px; }
aside footer #me { padding: 2px 10px 6px; color: var(--muted); }
aside footer button { text-align: left; }

section { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100vh; height: 100dvh; }
section > header { display: flex; gap: 10px; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--line); }
section > header h1 { font-size: 16px; letter-spacing: -.01em; }
section > header p { color: var(--muted); font-size: 13px; }
#menu, #menu2 { display: none; }

#messages, #handoff-list { flex: 1; overflow-y: auto; padding: 16px 24px 8px; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; }
.day { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 8px; }
.msg { display: grid; grid-template-columns: 34px 1fr; gap: 0 12px; padding: 3px 0; }
.msg.lead { margin-top: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 650; font-size: 14px; color: #fff; text-transform: uppercase; }
.msg .head { display: flex; gap: 8px; align-items: baseline; }
.msg .who { font-weight: 650; }
.msg .time { color: var(--muted); font-size: 12px; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; grid-column: 2; }
.msg .body a { color: var(--accent); }
.mention { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 3px; font-weight: 550; }
.msg.system { grid-template-columns: 1fr; color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0; }
.msg.system .body { grid-column: 1; }
.tag { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; border-radius: 5px; padding: 1px 6px; border: 1px solid var(--line); color: var(--muted); }
.card { grid-column: 2; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; margin: 4px 0; max-width: 720px; background: var(--panel); }
.card.alert { border-left-color: var(--warn); }
.card .title { font-weight: 650; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .note { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; }
.card details { margin-top: 6px; }
.card summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.card pre { font: 12px/1.45 var(--mono); overflow-x: auto; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pill { display: inline-block; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; border-radius: 10px; padding: 1px 8px; background: var(--hover); color: var(--muted); }
.pill.offered { background: var(--accent-soft); color: var(--accent); }
.pill.accepted, .pill.working { color: var(--warn); }
.pill.done { color: var(--ok); }
.pill.failed, .pill.declined, .pill.cancelled { color: var(--bad); }
.woke { color: var(--muted); font-size: 12px; grid-column: 2; }
code, .id { font-family: var(--mono); font-size: 12.5px; }

#composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 24px 18px; }
#composer textarea { resize: none; max-height: 40vh; line-height: 1.45; }
#readonly { padding: 14px 24px 20px; font-size: 13px; }

#handoff-list .card { grid-column: 1; margin: 0 0 12px; }
#handoff-list .card header { display: flex; gap: 10px; align-items: center; justify-content: space-between; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { font-size: 17px; margin-bottom: 14px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 8px 0 0; }
dialog .secret { font: 12.5px/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; user-select: all; white-space: pre-wrap; margin: 8px 0 12px; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  aside { position: fixed; inset: 0 20% 0 0; z-index: 5; transform: translateX(-100%); transition: transform .15s; }
  #app.menu aside { transform: none; box-shadow: 0 0 0 100vw rgba(0, 0, 0, .3); }
  #menu, #menu2 { display: block; }
  section > header, #messages, #handoff-list, #composer { padding-left: 14px; padding-right: 14px; }
}
