:root {
  color-scheme: light;
  --paper: #f3f5f7;
  --white: #fff;
  --text: #18252b;
  --muted: #52636e;
  --border: #dbe2e7;
  --accent: #12624f;
  --accent-soft: #e5f4ec;
  --danger: #a8303c;
  --rail: #172932;
  --rail-muted: #b7cbd3;
  font: 14px/1.48 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--paper);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #287e69; outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
.app { display: grid; grid-template-columns: var(--rail-width, 234px) minmax(0, 1fr); min-height: 100dvh; }
.app[data-rail-collapsed] { grid-template-columns: minmax(0, 1fr); }
.rail { position: sticky; top: 0; z-index: 2; height: 100dvh; min-width: 0; container-type: inline-size; background: var(--rail); color: #f4f9f9; padding: 17px 11px 11px; display: flex; flex-direction: column; }
#rail-divider { position: absolute; inset-block: 0; inset-inline-end: -5px; width: 10px; z-index: 5; cursor: col-resize; touch-action: none; }
#rail-divider::after { content: ''; position: absolute; inset-block: 0; left: 4px; width: 2px; background: transparent; }
#rail-divider:hover::after, #rail-divider:focus-visible::after, .resizing-rail #rail-divider::after { background: #73c4ae; }
#rail-divider:focus-visible { outline: none; }
.resizing-rail { cursor: col-resize; user-select: none; }
.resizing-rail iframe { pointer-events: none; }
.brand { display: flex; align-items: center; gap: 9px; padding: 1px 5px 17px; }
.brand-mark { flex: none; display: block; }
.brand b { display: block; font-size: 16px; letter-spacing: -.03em; }
.brand small, .rail-count { display: block; color: var(--rail-muted); font-size: 11px; }
.rail-head { padding: 0 3px 3px; min-height: 34px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.rail-title { display: flex; align-items: center; gap: 3px; }
.rail-head h2 { color: var(--rail-muted); font-size: 12px; white-space: nowrap; }
.rail-tools { display: flex; gap: 2px; align-items: center; }
.rail-tool { display: inline-flex; justify-content: center; align-items: center; gap: 4px; min-width: 26px; min-height: 28px; padding: 3px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #d9ede9; white-space: nowrap; }
.rail-tool:enabled:hover { border-color: #527079; background: #2b464e; }
.rail-tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.rail-tool span { display: none; font-size: 11px; }
@container (min-width: 318px) {
  .rail-tool { padding-inline: 6px; }
  .rail-tool span { display: inline; }
}
.rail-button { border: 0; border-radius: 7px; background: transparent; padding: 6px 8px; color: #e3edf0; text-align: left; overflow-wrap: anywhere; }
.rail-button:hover, .rail-button[aria-current] { background: #2b464e; }
.rail-button:focus-visible, .rail-role:focus-visible, .rail-branch:focus-visible, .rail-tool:focus-visible, .node:focus-visible, #org-chart:focus-visible { outline: 2px solid #9be1c0; outline-offset: -2px; }
#org-directory { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.directory-scroll { flex: 1; min-height: 0; overflow: auto; scrollbar-color: #5c7780 transparent; }
#org-list, #org-flat { padding: 2px 2px 8px; }
.directory-scroll ul { list-style: none; margin: 0; padding: 0; }
.rail-subtree { margin-left: 8px; padding-left: 4px; border-left: 1px solid #405a64; }
.rail-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 1px; border-radius: 7px; margin: 2px 0; }
.rail-row.current { background: #2c494d; box-shadow: inset 2px 0 #a7e5c6; }
.rail-row.retained { background: #223940; }
.rail-row:hover:not(.current) { background: #28434b; }
.rail-branch { background: none; border: 0; color: var(--rail-muted); width: 18px; height: 30px; padding: 0; }
.rail-role { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; padding: 5px 5px 5px 0; border: 0; border-radius: 6px; text-align: left; background: transparent; }
.rail-role-content, .node-content { flex: 1; min-width: 0; }
.role-avatar { display: grid; place-items: center; flex: none; width: var(--avatar-size, 24px); height: var(--avatar-size, 24px); border-radius: 25%; background: var(--avatar-fill); overflow: hidden; }
.role-avatar img { display: block; width: 100%; height: 100%; }
#selected-avatar { --avatar-size: 40px; }
#org-flat .rail-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
#org-flat .rail-role { padding-inline-start: 7px; }
.reorder-grip { cursor: grab; touch-action: none; align-self: stretch; color: var(--rail-muted); }
.reorder-grip:active { cursor: grabbing; }
.reorder-grip svg { stroke-width: 2; }
.flat-entry { position: relative; }
.flat-entry.reorder-source { opacity: .45; }
.flat-entry[data-drop]::after { position: absolute; content: ''; inset-inline: 2px; height: 2px; background: #9be1c0; pointer-events: none; border-radius: 2px; }
.flat-entry[data-drop="before"]::after { top: -1px; }
.flat-entry[data-drop="after"]::after { bottom: -1px; }
.rail-role-title, .rail-role-meta { display: flex; align-items: center; gap: 5px; min-width: 0; }
.rail-role-title strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rail-role-meta { flex-wrap: wrap; color: var(--rail-muted); font-size: 11px; line-height: 1.3; overflow-wrap: anywhere; }
.rail-plan { display: none; }
@container (min-width: 252px) {
  .rail-plan { display: inline; }
  .rail-role-title strong { white-space: normal; overflow-wrap: anywhere; }
}
@container (max-width: 175px) {
  .rail-head { gap: 3px; padding-inline: 0; }
  .rail-head .rail-tools { gap: 1px; }
  .rail-head .rail-tool { min-width: 21px; padding-inline: 2px; }
  .rail-subtree { margin-left: 5px; padding-left: 3px; }
  .rail-row { grid-template-columns: 15px minmax(0, 1fr); }
  .rail-branch { width: 15px; }
}
.rail-branch-note { color: #d3e6e8; }
.rail-queue { margin-left: auto; flex: none; padding: 0 5px; border-radius: 10px; color: #ffdda2; background: #594c36; font-size: 10px; font-weight: 700; }
.rail-unread { margin-left: auto; flex: none; min-width: 17px; padding: 0 5px; border-radius: 10px; color: #173555; background: #c6e0fa; text-align: center; font-size: 10px; line-height: 16px; font-weight: 750; }
.status-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: #a0b0b7; }
.status-dot[data-state="idle"], .status-dot[data-state="reminder"] { background: #79d6ae; }
.status-dot[data-state="busy"], .status-dot[data-state="unready"] { background: #edbc62; }
.status-dot[data-state="offline"] { background: #e6a1ae; }
.status-dot[data-state="retreat"] { background: #c6afe9; }
.rail-empty { color: var(--rail-muted); padding: 7px; font-size: 12px; }
.rail-bottom { position: relative; display: flex; align-items: center; justify-content: space-between; flex: none; gap: 3px; padding: 5px 0 0; border-top: 1px solid #3b555d; }
.rail-settings { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 32px; font-size: 12px; white-space: nowrap; }
.rail-founder { display: flex; align-items: center; gap: 4px; margin-block-end: 4px; }
.rail-all-messages { flex: 1; font-size: 12px; font-weight: 650; }
#founder-records[aria-current] { background: #2b464e; }
.rail-channels { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.rail-channel { position: relative; flex: none; display: grid; place-items: center; width: 34px; height: 32px; padding: 0; font-size: 12px; }
.rail-channel img { display: block; width: 22px; height: 22px; }
@container (max-width: 195px) {
  .rail-channels { gap: 0; }
  .rail-channel { width: 27px; }
}
.rail-indicator { position: absolute; inset-inline-end: 3px; inset-block-end: 4px; width: 9px; height: 9px; border: 1px solid var(--rail); border-radius: 50%; background: #a0b0b7; }
.rail-indicator[data-state="idle"], .rail-indicator[data-state="connected"] { background: #79d6ae; }
.rail-indicator[data-state="unready"], .rail-indicator[data-state="configuring"] { background: #edbc62; }
.rail-indicator[data-state="offline"], .rail-indicator[data-state="disconnected"] { background: #e6a1ae; }
.rail-channel[aria-expanded="true"] { background: #2b464e; }
.rail-popup { position: absolute; bottom: calc(100% + 6px); inset-inline: 0; z-index: 4; padding: 8px; border: 1px solid #527079; border-radius: 9px; background: #203740; box-shadow: 0 5px 18px #10202955; max-height: min(310px, 60dvh); overflow: auto; }
#mobile-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; }
#mobile-popup { width: min(280px, calc(100vw - 24px)); inset-inline-start: auto; inset-inline-end: 0; }
@container (max-width: 195px) {
  #mobile-popup { inset-inline-start: 0; inset-inline-end: auto; }
}
#mobile-popup header p, #mobile-popup > p { margin: 4px 0; color: var(--rail-muted); font-size: 12px; }
#status-popup { width: max(100%, 196px); inset-inline-start: auto; }
@container (max-width: 195px) {
  #status-popup { inset-inline-start: 0; inset-inline-end: auto; }
}
.rail-popup h2 { font-size: 13px; }
.rail-popup #connection { margin: 5px 0 8px; color: var(--rail-muted); font-size: 12px; }
.rail-status-footer { margin-top: 8px; display: flex; align-items: center; gap: 6px; justify-content: space-between; flex-wrap: wrap; }
.rail-status-footer .button { color: var(--text); }
.org-control-panel { display: grid; gap: 4px; }
.org-control-row { border-top: 1px solid #3b555d; padding-block: 4px; }
.org-control-line, .org-control-picker-actions { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.org-control-line > span { font-size: 12px; font-weight: 600; white-space: nowrap; }
.org-control-modes { display: flex; gap: 2px; padding: 2px; border-radius: 5px; background: #162b33; }
.org-control-modes button { padding: 4px 5px; border: none; border-radius: 4px; background: transparent; color: var(--rail-muted); font-size: 12px; white-space: nowrap; }
.org-control-modes button[aria-pressed="true"] { background: #bfe6d5; color: #164337; }
.org-control-row p { margin: 3px 0; color: var(--rail-muted); font-size: 11px; }
.org-control-role-list { display: grid; gap: 3px; max-height: 132px; overflow: auto; padding: 3px 0; }
.org-control-role-list label { font-size: 12px; overflow-wrap: anywhere; }
.org-control-role-list input { accent-color: #85d9ba; }
.org-control-picker-actions { justify-content: flex-end; }
.org-control-picker-actions .button:not(.primary) { color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Keep screen-reader labels inside their badges' scroll containers. */
.rail-queue, .rail-unread, .context-unread { position: relative; }
main { min-width: 0; }
h1 { font-size: 21px; line-height: 1.28; overflow-wrap: anywhere; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.panel-header p, .muted { color: var(--muted); font-size: 12px; }
.actions, .chips { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.switches { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 3px; padding: 3px 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--white); }
.switches > span { color: var(--muted); font-size: 11px; padding-inline: 5px 2px; }
.switches button { padding: 3px 6px; border: 0; border-radius: 6px; background: #fff1d4; color: #734700; font-size: 12px; white-space: nowrap; }
.switches button[data-enabled="true"] { background: var(--accent-soft); color: var(--accent); }
.button { border: 1px solid var(--border); border-radius: 8px; background: var(--white); font-weight: 600; padding: 7px 11px; white-space: nowrap; }
.button:hover { background: #f1f6f5; }
.button.primary { background: var(--accent); border-color: var(--accent); color: white; }
.button.primary:hover { background: #0f4f40; }
.button.compact { font-size: 12px; padding: 5px 8px; }
.button.danger { color: var(--danger); }
.workbench { padding: 14px 16px 16px; }
.panel { border-radius: 13px; border: 1px solid var(--border); background: var(--white); overflow: hidden; min-width: 0; }
.panel-header { padding: 12px 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.panel-header p { margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 20px; background: #edf1f4; color: #435763; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.idle, .chip.reminder { color: #145b43; background: #e4f4e9; }
.chip.busy, .chip.pending { color: #734700; background: #fff1d4; }
.chip.offline { color: #74364a; background: #f7e8ee; }
.chip.retreat { color: #50378b; background: #efe8fa; }
.chip.unconfigured { color: #53616b; background: #edf0f2; }
.chip.sent, .chip.cc { color: #145b43; background: #e4f4e9; }
.chip.withdrawn { color: #53616b; background: #edf0f2; }
#org-chart { border: 1px solid #38525c; border-radius: 8px; margin-bottom: 8px; background: #14252d radial-gradient(#344b54 1px, transparent 1px) 0 0 / 16px 16px; }
.graph { position: relative; }
.graph svg { position: absolute; inset: 0; pointer-events: none; }
.graph svg path { fill: none; stroke: #628087; stroke-width: 1.25; }
.node { --avatar-size: 26px; position: absolute; width: 136px; height: 56px; padding: 6px 8px; background: #203740; border: 1px solid #4d6972; border-radius: 8px; color: #f4f9f9; text-align: left; display: flex; align-items: center; gap: 6px; }
.node:hover { background: #2b464e; }
.node.selected { border-color: #75b7a3; background: #28464a; }
.node[aria-current] { box-shadow: inset 2px 0 #a7e5c6; }
.node b, .node-meta > span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-title { display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.node b { display: block; font-size: 13px; }
.node-meta { display: flex; align-items: center; gap: 4px; color: var(--rail-muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 9px 15px; border-bottom: 1px solid var(--border); }
.inspector { padding: 13px 15px 15px; min-height: 132px; }
.inspector > * + * { margin-top: 8px; }
.split { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.role-meta { overflow-wrap: anywhere; }
.tabs { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); padding: 0 14px; flex-wrap: wrap; }
.tab { border: 0; border-bottom: 2px solid transparent; background: none; padding: 7px 0; color: var(--muted); white-space: nowrap; }
.tab[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.tab small { margin-left: 3px; font-size: 11px; }
.traffic-body { padding: 0 14px 13px; min-height: 310px; max-height: 610px; overflow: auto; }
.record { display: block; border: 0; border-bottom: 1px solid #e7ecef; background: transparent; text-align: left; width: 100%; padding: 10px 0; overflow-wrap: anywhere; }
.record:hover { background: #f4f8f6; }
.record strong { display: block; margin: 4px 0 1px; font-size: 13px; }
.record p, .message p { white-space: pre-wrap; overflow-wrap: anywhere; }
.record p { color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.list-empty { padding: 20px 0; color: var(--muted); }
.detail { padding: 11px 0 0; display: grid; gap: 9px; }
.message { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafb; }
.message p { margin: 5px 0; }
.text-button { border: 0; background: transparent; color: var(--accent); font-weight: 650; padding: 2px 0; text-align: left; }
.text-button:hover { text-decoration: underline; }
dialog { width: min(560px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); border: 1px solid var(--border); border-radius: 14px; padding: 0; color: var(--text); box-shadow: 0 20px 75px #142a3f48; }
dialog::backdrop { background: #182d3966; }
.dialog-head { padding: 15px 18px 12px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 14px 18px 16px; display: grid; gap: 10px; }
.dialog-body > .actions:last-child { justify-content: flex-end; margin-top: 4px; }
form label { display: grid; gap: 3px; font-size: 13px; font-weight: 600; min-width: 0; }
form input:not([type=checkbox]), form select, form textarea { width: 100%; border: 1px solid #bacbd2; border-radius: 7px; padding: 7px 8px; background: #fff; min-width: 0; }
form input:disabled, form select:disabled { background: #f0f3f5; color: var(--muted); }
form textarea { min-height: 72px; resize: vertical; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
form label.check { display: flex; align-items: flex-start; gap: 7px; }
form label.check input { margin: 4px 0 0; }
.avatar-picker { min-width: 0; border: 1px solid var(--border); border-radius: 8px; }
.avatar-picker summary { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 7px 8px; font-weight: 600; }
.avatar-picker summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.avatar-picker[open] summary::after { content: '▴'; }
.avatar-picker summary small { margin-inline-start: 5px; color: var(--muted); font-weight: 400; }
.avatar-preview { --avatar-size: 32px; flex: none; }
.avatar-placeholder { display: grid; place-items: center; width: 32px; height: 32px; border: 1px dashed #9baeb7; border-radius: 8px; color: var(--muted); }
.avatar-options { padding: 8px; border-top: 1px solid var(--border); display: grid; gap: 8px; justify-items: start; }
.avatar-choices, .avatar-colors { display: flex; flex-wrap: wrap; gap: 4px; }
.avatar-choices button, .avatar-colors button { border: 1px solid transparent; background: transparent; border-radius: 7px; min-width: 44px; min-height: 44px; padding: 3px; }
.avatar-choices button { --avatar-size: 28px; display: grid; justify-items: center; align-items: center; gap: 2px; font-size: 11px; }
.avatar-colors button { display: grid; place-items: center; }
.avatar-colors button span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--avatar-fill); color: transparent; }
.avatar-colors button[aria-pressed="true"] span { color: var(--text); }
.avatar-choices button:hover, .avatar-colors button:hover { background: #f1f6f5; }
.avatar-choices button[aria-pressed="true"], .avatar-colors button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.binding-field { display: grid; gap: 3px; min-width: 0; }
.binding-results { border: 1px solid #bacbd2; border-radius: 7px; min-width: 0; }
.binding-results summary { padding: 7px 8px; cursor: pointer; overflow-wrap: anywhere; }
.binding-results summary:focus-visible { outline: 2px solid #287e69; outline-offset: 2px; }
.binding-results ul { list-style: none; margin: 0; padding: 3px; border-top: 1px solid var(--border); max-height: min(280px, 36dvh); overflow-y: auto; }
.binding-results li + li { border-top: 1px solid var(--border); }
.binding-results button { display: grid; gap: 2px; width: 100%; min-width: 0; border: 0; border-radius: 4px; padding: 7px; text-align: left; background: var(--white); overflow-wrap: anywhere; }
.binding-results button:enabled:hover, .binding-results button:focus-visible { background: var(--accent-soft); }
.binding-results button:focus-visible { outline-offset: -2px; }
.binding-results button:disabled { opacity: 1; color: var(--muted); }
.candidate-meta, .candidate-state { display: flex; gap: 3px 8px; align-items: center; flex-wrap: wrap; }
.candidate-meta, .candidate-path, .candidate-state .session-model { color: var(--muted); font-size: 12px; }
.candidate-state { margin-top: 2px; }
.friend { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.friend p { white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { padding: 8px 10px; background: #eef4f6; border-radius: 7px; color: #34525f; font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }
.toast { position: fixed; z-index: 5; bottom: 16px; right: 16px; max-width: min(430px, calc(100vw - 32px)); padding: 9px 12px; background: #19352f; color: white; border-radius: 9px; box-shadow: 0 3px 14px #203e3350; pointer-events: none; }
.plan-tools { display: flex; align-items: center; justify-content: space-between; gap: 9px; flex-wrap: wrap; padding: 10px 15px; border-bottom: 1px solid var(--border); }
.plan-caption { display: flex; align-items: center; gap: 5px 9px; flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.plan-caption code, .plan-caption small { color: var(--muted); font-size: 12px; }
#plan-content iframe { display: block; width: 100%; height: 100%; border: 0; }
#role-panel { display: flex; flex-direction: column; min-width: 0; background: var(--white); }
#message-role-tools { display: flex; min-height: 0; min-width: 0; flex: 1; flex-direction: column; }
#message-role-tools > .panel-header { flex: none; }
#message-role-tools .panel-header p { font-size: 12px; }
#message-role-tools #inspector, #message-role-tools #plan-content { min-height: 0; flex: 1; overflow: auto; }
#role-plan { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#messages-panel { display: grid; grid-template-columns: minmax(170px, min(38%, 300px)) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: clip; }
.message-directory, .message-content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.message-directory { background: #edf0f4; border-inline-end: 1px solid var(--border); }
.message-directory-head { display: grid; gap: 9px; padding: 13px 11px 10px; border-bottom: 1px solid var(--border); }
.message-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.message-actions { margin-inline-start: auto; flex-wrap: nowrap; gap: 4px; }
.plan-shortcut { display: grid; padding: 3px; place-items: center; min-width: 27px; }
.plan-shortcut img { display: block; }
.message-setup { justify-self: start; font-size: 12px; }
.message-filter-bar, .message-filters { display: flex; align-items: center; gap: 4px; }
.message-filter-bar button { min-height: 27px; padding: 3px 5px; border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
#message-sidebar-toggle { display: grid; place-items: center; width: 27px; padding: 0; }
#message-sidebar-toggle:hover { background: #e4e9ef; }
#message-sidebar-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.4; }
#message-sidebar-toggle[aria-expanded="true"] svg path { stroke-width: 3; }
#message-scope { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-filters button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: #a7cdbd; }
.message-create { position: relative; }
.message-create summary { cursor: pointer; list-style: none; min-width: 27px; padding-inline: 5px; text-align: center; line-height: 1.2; }
.message-create summary::-webkit-details-marker { display: none; }
.message-create-menu { position: absolute; z-index: 3; top: calc(100% + 5px); inset-inline-end: 0; min-width: 114px; padding: 4px; border: 1px solid var(--border); border-radius: 7px; background: var(--white); box-shadow: 0 4px 12px #203e3320; }
.message-create-menu button { display: block; width: 100%; border: 0; border-radius: 4px; background: transparent; text-align: start; padding: 5px 8px; white-space: nowrap; }
.message-create-menu button:hover { background: var(--accent-soft); }
#message-list { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 4px; }
.message-row { display: flex; width: 100%; align-items: center; gap: 8px; min-height: 56px; padding: 7px; border: 0; border-radius: 7px; background: transparent; text-align: start; }
.message-row:hover { background: #e4e9ef; }
.message-row[aria-current="true"] { background: #e0e1f6; color: #393f81; }
.message-row-copy { display: grid; flex: 1; min-width: 0; gap: 2px; }
.message-row-copy > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-row-icon { display: grid; place-items: center; border-radius: 8px; background: #e1e9ed; color: #365763; width: 28px; height: 28px; flex: none; }
.message-row time { flex: none; font-size: 11px; color: var(--muted); }
#message-list > .list-empty, #message-conversation > .list-empty { padding: 16px 9px; }
#message-conversation-head p { font-size: 12px; }
#message-conversation { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.context-unread { flex: none; min-width: 18px; padding-inline: 5px; border-radius: 10px; color: #383883; background: #d9daf6; text-align: center; font-size: 10px; line-height: 17px; font-weight: 750; }
.conversation-stream { flex: 1; min-height: 245px; max-height: calc(100dvh - 220px); overflow: auto; padding: 10px 15px; overflow-wrap: anywhere; }
.chat-message { display: flex; gap: 9px; padding: 8px 3px; }
.chat-message + .chat-message { border-top: 1px solid #edf0f2; }
.chat-message:focus { outline: 2px solid #8684c3; outline-offset: -2px; border-radius: 5px; background: #f6f5ff; }
.chat-message > div { min-width: 0; flex: 1; }
.chat-message .role-avatar { --avatar-size: 29px; margin-top: 3px; }
.chat-message p { margin: 4px 0; white-space: pre-wrap; }
.chat-message blockquote, .compose-quote { border-inline-start: 2px solid #a6a5d3; color: var(--muted); padding-inline-start: 7px; margin: 0 0 3px; font-size: 12px; }
.composer-slot { padding: 8px 13px 12px; min-width: 0; }
.inline-compose { position: relative; border: 1px solid var(--border); border-radius: 9px; padding: 8px; background: var(--white); }
.inline-compose:focus-within { border-color: #9b9ad3; }
.compose-editor { position: relative; padding: 6px 2px; min-height: 48px; max-height: 30dvh; overflow: auto; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; line-height: 1.55; }
.compose-editor[data-empty="true"]::before { content: attr(data-placeholder); position: absolute; inset: 6px auto auto 2px; color: var(--muted); pointer-events: none; }
.compose-editor[aria-readonly="true"] { cursor: default; opacity: .7; }
.compose-address { display: inline; padding: 1px 4px; margin-inline: 2px; border-radius: 4px; background: #e9e9fa; color: #43438b; word-break: keep-all; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.compose-address[data-compose-address="cc"] { background: #eef1f5; color: #4d5b71; font-size: .92em; }
.inline-compose .compose-quote { display: flex; justify-content: space-between; gap: 5px; align-items: start; overflow-wrap: anywhere; }
.compose-identity { color: var(--muted); font-size: 12px; }
.compose-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.compose-meta .compose-identity { margin-inline-end: auto; }
.compose-meta label { font-size: 12px; }
.compose-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.compose-send { display: flex; align-items: stretch; margin-inline-start: auto; gap: 2px; }
.compose-type { display: grid; position: relative; place-items: center; width: 26px; border-radius: 6px; color: var(--muted); }
.compose-type:hover, .compose-icon:hover { background: #eef2f5; color: var(--text); }
.compose-type:focus-within { outline: 2px solid #287e69; outline-offset: 1px; }
.compose-type select { position: absolute; inset: 0; padding: 0; opacity: 0; cursor: pointer; }
.compose-icon { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.compose-type svg, .compose-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.compose-input { position: relative; }
.compose-cc-field input { box-sizing: border-box; padding: 5px 7px; font-size: 12px; }
.compose-cc-field .compose-picker { width: min(280px, 72vw); inset-inline-start: 8px; }
.compose-picker { position: absolute; z-index: 4; inset-inline-start: 0; bottom: calc(100% + 3px); width: min(100%, 310px); box-sizing: border-box; padding: 7px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 5px 18px #26375225; }
.compose-picker ul { list-style: none; padding: 0; margin: 4px 0 0; max-height: min(185px, 35dvh); overflow: auto; }
.compose-picker-title { display: block; padding: 2px 5px; color: var(--muted); }
.compose-picker li button { text-align: start; width: 100%; border: 0; border-radius: 5px; background: transparent; padding: 6px; cursor: pointer; }
.compose-picker li[aria-selected="true"] button, .compose-picker li button:hover { background: #e1e2fa; color: #373775; }
.compose-picker p { padding: 4px; margin: 0; }
.compose-hint { white-space: nowrap; }
.message-cc { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; font-size: 12px; color: var(--muted); }
.message-cc [role="status"] { overflow-wrap: anywhere; }
@media (max-width: 720px) { .compose-hint { display: none; } }
.workspace-empty { margin: 15px; padding: 16px; border: 1px dashed var(--border); border-radius: 8px; background: #fafbfc; }
.workspace-empty p { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
#inspector { container-type: inline-size; background: #f8fafb; }
.role-detail-grid { display: grid; gap: 10px; }
@container (min-width: 800px) {
  .role-detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
}
.role-section { min-width: 0; display: grid; gap: 9px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--white); overflow-wrap: anywhere; }
.role-section-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-height: 28px; }
.role-section-head h3 { font-size: 14px; }
.role-description { white-space: pre-wrap; }
.role-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(112px, 100%), 1fr)); gap: 9px 12px; }
.role-fields dt { color: var(--muted); font-size: 11px; }
.role-fields dd { margin: 1px 0 0; min-width: 0; white-space: pre-wrap; }
.role-fields code, .role-section > p code, .role-command code { font-size: 12px; }
.role-pickup { padding-top: 6px; border-top: 1px solid #e8edf0; }
.role-diagnostics summary { width: fit-content; cursor: pointer; color: var(--accent); font-size: 12px; font-weight: 650; }
.role-diagnostics summary:focus-visible { outline: 2px solid #287e69; outline-offset: 2px; }
.role-diagnostics .role-fields { margin-top: 8px; grid-template-columns: minmax(0, 1fr); }
.role-command { display: grid; justify-items: start; gap: 5px; margin-top: 8px; padding: 8px; border-radius: 6px; background: #eef4f6; }
#groups-panel .panel-header { padding-inline: 0; }
.group-main > * + * { margin-top: 8px; }
#queue-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 9px 14px; color: var(--muted); font-size: 12px; }
#queue-role { max-width: 100%; }
@media (max-width: 940px) {
  .workbench { padding-inline: 12px; }
  .traffic-body { min-height: 230px; }
}
@media (max-width: 740px) {
  .rail { padding-inline: 6px; }
}
@media (max-width: 560px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: relative; height: auto; max-height: 52dvh; padding: 8px 10px; }
  #rail-divider { display: none; }
  .brand { padding-bottom: 5px; }
  .rail-head { padding-bottom: 3px; }
  #org-list, #org-flat { max-height: 145px; }
  .rail-popup { top: calc(100% + 3px); bottom: auto; }
  #status-popup { width: min(240px, 100%); }
  .fields { grid-template-columns: 1fr; }
  .workbench { padding: 9px; }
  #plan-content iframe { height: 65dvh; }
}

#phone-notice { position: fixed; inset: 6px 12px auto; z-index: 5; display: flex; justify-content: space-between;
  gap: 6px; padding-inline: 12px 4px; background: var(--accent-soft); border: 1px solid #a7cdbd;
  border-radius: 9px; box-shadow: 0 2px 7px #26375225; }
#phone-notice button { min-height: 48px; }
#phone-notice button:last-child { min-width: 48px; padding: 0; text-align: center; font-size: 20px; }
#phone-directory, #phone-conversation-head { display: none; }
#app[data-phone-layout] ~ .toast { top: calc(env(safe-area-inset-top, 0px) + 60px); bottom: auto; }
.app[data-phone-layout][data-phone-page] { min-height: 100dvh; height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.app[data-phone-layout][data-phone-page] > .rail, .app[data-phone-layout][data-phone-page="directory"] > main { display: none; }
.app[data-phone-layout][data-message-workspace]:not([data-rail-collapsed]) { grid-template-rows: auto minmax(0, 1fr); }
.app[data-phone-layout][data-message-workspace] > .rail:not([hidden]) { display: flex; }
.app[data-phone-layout][data-message-workspace] #phone-conversation-head { display: none; }
.app[data-phone-layout][data-message-workspace] .workbench { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); }
.app[data-phone-layout][data-phone-page="directory"] #phone-directory {
  display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; background: var(--white);
}
.app[data-phone-layout] .phone-directory-head, .app[data-phone-layout] #phone-conversation-head { display: flex; align-items: center; gap: 10px; }
.phone-directory-head { justify-content: space-between; }
.phone-tools, .phone-filters { display: flex; align-items: center; gap: 4px; }
.phone-tool, .phone-filters button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 48px; min-height: 48px; padding: 0 8px; border: 0; border-radius: 9px;
  background: transparent; font: inherit; color: var(--muted);
}
.phone-tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.phone-scope { min-width: 0; justify-content: start; color: inherit; font-size: 1.125rem; font-weight: 700; }
.phone-scope:disabled { opacity: 1; }
.phone-scope span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-tool[aria-expanded="true"], .phone-filters button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.phone-filters button { padding-inline: 12px; }
.phone-connection { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.phone-connection button { min-height: 48px; }
#phone-role-name { margin: 0; font-size: 1.125rem; line-height: 1.35; overflow-wrap: anywhere; }
#phone-role-search { flex: none; min-height: 48px; font-size: 16px; }
#phone-roles { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
#phone-roles .message-row { min-height: 62px; border-radius: 0; border-bottom: 1px solid var(--border); }
#phone-roles .message-row small { font-size: .8125rem; }
.phone-role { display: flex; align-items: center; gap: 10px; text-align: left;
  width: 100%; min-height: 56px; background: none; border: 0; border-bottom: 1px solid var(--border);
  padding: 8px 6px; font: inherit; color: inherit; }
.phone-role[aria-current] { background: var(--accent-soft); }
.phone-role small, #phone-role-state { display: block; color: var(--muted); }
.phone-role-copy { min-width: 0; overflow-wrap: anywhere; }
.phone-empty .text-button { display: block; margin: 0 auto; min-height: 48px; }
.app[data-phone-layout][data-phone-page="content"] > main { min-height: 0; display: flex; flex-direction: column; }
.app[data-phone-layout][data-phone-page="content"] #phone-conversation-head {
  flex: none; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--white);
}
#phone-conversation-head button { flex: none; min-height: 48px; }
.app[data-phone-layout][data-phone-conversation="true"] .workbench { flex: 1; min-height: 0; padding: 0; display: grid; }
.app[data-phone-layout][data-phone-conversation="true"] #role-panel { height: 100%; min-height: 0; }
.app[data-phone-layout][data-phone-conversation="true"] .conversation-stream { flex: 1 1 0; min-height: 0; max-height: none; overflow: auto; }
.app[data-phone-layout][data-phone-conversation="true"] .composer-slot { flex: none; }
.app[data-phone-layout][data-phone-conversation="true"] .compose-editor { font-size: 16px; max-height: min(28dvh, 10rem); }
.app[data-phone-layout][data-phone-conversation="true"] .chat-message > div { min-width: 0; }
.app[data-phone-layout][data-phone-conversation="true"] .chat-message .text-button { min-height: 48px; }
.app[data-phone-layout][data-phone-conversation="true"] .compose-send > *, .app[data-phone-layout] .compose-picker li button { min-height: 48px; }
.app[data-phone-layout][data-phone-conversation="true"] .compose-type { width: 48px; }
.phone-latest-slot { position: relative; height: 0; z-index: 2; }
#phone-latest { position: absolute; inset: auto 12px 6px auto; min-height: 48px; box-shadow: 0 2px 7px #26375225; }
@media (min-width: 561px) {
  /* Size the shell once; each pane scrolls inside the space left by its controls. */
  .app { height: 100dvh; grid-template-rows: minmax(0, 1fr); overflow: clip; }
  .rail { position: relative; height: auto; }
  main { min-height: 0; }
  .workbench { height: 100%; display: grid; grid-template-rows: minmax(0, 1fr); }
  .workbench > section { min-height: 0; }
  .workbench .panel-header, .composer-slot, #traffic-tabs, #queue-filter, #inbox-filter, #plan-tools { flex: none; }
  .conversation-stream, .traffic-body, .group-main, .settings-layout {
    min-height: 0; flex: 1 1 0; overflow: auto; overscroll-behavior: contain;
  }
  .settings-layout { align-content: start; }
  .conversation-stream, .traffic-body { max-height: none; }
  #traffic-panel, #groups-panel, #settings-panel { display: flex; flex-direction: column; }
}
@media (min-width: 561px) and (max-height: 550px) {
  .workbench { padding-block: 8px; }
  .workbench .panel-header { padding-block: 8px; }
  .composer-slot { padding-block: 4px 8px; }
  .compose-editor { min-height: 36px; max-height: 22dvh; }
  .compose-quote > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
}
.compose-tools .compose-final { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; white-space: nowrap; }
.compose-tools .compose-final[hidden] { display: none; }
.compose-final input { width: auto; margin: 0; }

.mobile-device { padding: 10px 0; border-top: 1px solid var(--border); gap: 8px; }
#mobile-link img { display: block; margin-bottom: 8px; image-rendering: pixelated; }
.mobile-pair-page { min-height: 100dvh; padding: 24px 16px; display: grid; place-items: start center; }
.mobile-pair-page .panel { width: min(100%, 420px); padding: 22px; }
.mobile-pair-page h1 { margin: 12px 0; }
.mobile-pair-page label { display: grid; gap: 6px; }
.mobile-pair-page input { min-height: 44px; font-size: 16px; }
.mobile-pair-page .button { min-height: 44px; margin-top: 12px; }
#pair-confirmation { font-size: 26px; letter-spacing: .16em; }

.mobile-reminder-picker { display: grid; gap: 7px; max-height: 44dvh; overflow: auto; }
.mobile-reminder-picker label { display: flex; flex-direction: row; align-items: start; gap: 6px; }
.mobile-reminder-picker input { flex: none; }
