:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --bg-side: #f5f5f3;
  --bg-elev: #ffffff;
  --bg-hover: #eeeeec;
  --bg-selected: #e7e7e4;
  --bubble: #f2f2f0;
  --bubble-user: #e5e5e2;
  --bubble-user-ink: #1b1c1f;
  --solid: #17181b;
  --solid-ink: #ffffff;
  --ink: #1b1c1f;
  --ink-soft: #3d3f45;
  --muted: #676972;
  --line: #e8e8e4;
  --line-strong: #d6d6d1;
  --accent: #b8502f;
  --accent-soft: #f8e8e1;
  --success: #2f8b5b;
  --warn: #c7811a;
  --danger: #c93d37;
  --danger-soft: #fbe9e7;
  --shadow-sm: 0 1px 2px rgba(20, 21, 25, .06), 0 1px 1px rgba(20, 21, 25, .04);
  --shadow-md: 0 8px 28px rgba(20, 21, 25, .12), 0 2px 6px rgba(20, 21, 25, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --hue-0: 14; --hue-1: 36; --hue-2: 88; --hue-3: 160; --hue-4: 200; --hue-5: 230; --hue-6: 270; --hue-7: 330;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #191817; --bg-side: #201f1c; --bg-elev: #252421; --bg-hover: #2b2a26; --bg-selected: #33312c;
    --bubble: #2a2926; --bubble-user: #3a3831; --bubble-user-ink: #edece7; --solid: #ebebe6; --solid-ink: #17171a;
    --ink: #edece7; --ink-soft: #c9c6bd; --muted: #9d998e; --line: #302e29; --line-strong: #423f38;
    --accent: #e2916f; --accent-soft: #33201a; --success: #58b57f; --warn: #e2a24a; --danger: #ef7a72; --danger-soft: #3a2422;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191817; --bg-side: #201f1c; --bg-elev: #252421; --bg-hover: #2b2a26; --bg-selected: #33312c;
  --bubble: #2a2926; --bubble-user: #3a3831; --bubble-user-ink: #edece7; --solid: #ebebe6; --solid-ink: #17171a;
  --ink: #edece7; --ink-soft: #c9c6bd; --muted: #9d998e; --line: #302e29; --line-strong: #423f38;
  --accent: #e2916f; --accent-soft: #33201a; --success: #58b57f; --warn: #e2a24a; --danger: #ef7a72; --danger-soft: #3a2422;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-width: 320px; height: 100%; background: var(--bg); color: var(--ink); font: 14.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.012em; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: .92em; }
.app-shell { height: 100dvh; }

/* buttons */
.icon-button { width: 36px; height: 36px; min-width: 36px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-soft); display: inline-grid; place-items: center; transition: background .12s ease, color .12s ease; }
.icon-button:hover { background: var(--bg-hover); color: var(--ink); }
.icon-button.ghost { border-color: transparent; background: transparent; }
.icon-button.ghost:hover { background: var(--bg-hover); }
.icon-button.active { background: var(--bg-selected); color: var(--ink); }
.icon-button.small { width: 30px; height: 30px; min-width: 30px; }
.icon-button.small svg { width: 15px; height: 15px; }
.primary-button, .secondary-button, .danger-button { border-radius: 999px; min-height: 38px; padding: 0 16px; border: 1px solid transparent; font-weight: 600; font-size: 14px; transition: background .12s ease, transform .08s ease; }
.primary-button { background: var(--solid); color: var(--solid-ink); }
.primary-button:hover { filter: brightness(1.12); }
.secondary-button { color: var(--ink); background: var(--bg-elev); border-color: var(--line-strong); }
.secondary-button:hover { background: var(--bg-hover); }
.danger-button { color: #fff; background: var(--danger); }
.primary-button.small, .secondary-button.small, .danger-button.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.wide-button { width: 100%; }
.danger-text { color: var(--danger); }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.link-button.danger { color: var(--danger); }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg-side); }
.login-panel { width: min(100%, 420px); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow-md); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; font-size: 16px; }
.brand.large { font-size: 20px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: #b8502f; color: #faf8f5; font-size: 15px; font-weight: 700; }
.brand.large .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.login h1 { font-size: 28px; letter-spacing: -.03em; margin: 28px 0 8px; }
.login p { color: var(--muted); line-height: 1.55; }
.login form { display: grid; gap: 16px; margin-top: 24px; }
.setup-note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 14px; border-radius: 0 10px 10px 0; margin-top: 20px; color: var(--ink); }
code { font-family: var(--mono); font-size: .9em; }

/* layout */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: 100dvh; background: var(--bg); }
.layout[data-details="open"] { grid-template-columns: 300px minmax(0, 1fr) 320px; }
.sidebar { background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 16px; }
.brand-name { font-size: 15px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-left: 2px; }
.connection-dot.online { background: var(--success); }
.connection-dot.offline { background: var(--danger); animation: pulse 1.4s ease-in-out infinite; }
.search-wrap { margin: 2px 12px 8px; display: flex; align-items: center; gap: 8px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; color: var(--muted); }
.search-wrap:focus-within { border-color: var(--line-strong); }
.search-input { flex: 1; border: 0; background: transparent; padding: 8px 0; min-width: 0; font-size: 14px; }
.search-input:focus { outline: none; }
.search-input::-webkit-search-cancel-button { cursor: pointer; }
.bot-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px 8px 12px; flex: 1; }
.group-label { appearance: none; background: transparent; border: 0; color: var(--muted); width: 100%; padding: 10px 8px 3px; display: flex; gap: 6px; align-items: center; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.group-label svg { transition: transform .15s ease; color: color-mix(in srgb, var(--muted) 60%, transparent); }
.group-label[aria-expanded="false"] svg { transform: rotate(-90deg); }
.bot-row { position: relative; border-radius: 10px; transition: background .12s ease; }
.bot-row-main { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; border: 0; color: inherit; background: transparent; text-align: left; padding: 6px 8px; border-radius: 10px; }
.bot-row-main .avatar { width: 32px; height: 32px; font-size: 12px; }
.bot-row-main .avatar.has-mark { font-size: 17px; }
.bot-row:hover, .bot-row:focus-within { background: var(--bg-hover); }
.bot-row[aria-current="page"] { background: var(--bg-selected); }
.bot-row-menu { position: absolute; top: 7px; right: 6px; opacity: 0; background: var(--bg-elev); border: 1px solid var(--line); }
.bot-row:hover .bot-row-menu, .bot-row:focus-within .bot-row-menu, .bot-row-menu:focus-visible { opacity: 1; }
.bot-row:hover .bot-row-meta, .bot-row:focus-within .bot-row-meta { visibility: hidden; }
.bot-row:hover .bot-row-menu, .bot-row:focus-within .bot-row-menu { opacity: 0; }
@media (pointer: coarse) { .bot-row-menu { opacity: 1; } .bot-row:hover .bot-row-menu, .bot-row:focus-within .bot-row-menu { opacity: 1; } .bot-row .bot-row-meta { visibility: hidden; } }
@media (pointer: fine) { .bot-row:hover .bot-row-meta, .bot-row:focus-within .bot-row-meta { visibility: visible; } }
.context-menu { position: fixed; z-index: 30; min-width: 210px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); animation: rise .12s ease-out; }
.context-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 14px; color: var(--ink); }
.context-item svg { color: var(--muted); flex: 0 0 auto; }
.context-item:hover, .context-item:focus-visible { background: var(--bg-hover); outline: none; }
.context-item.danger, .context-item.danger svg { color: var(--danger); }
.context-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.context-item.has-submenu > svg:last-child { margin-left: auto; transform: rotate(-90deg); transition: transform .12s ease; color: var(--muted); }
.context-item.has-submenu.open > svg:last-child { transform: rotate(0); }
.context-submenu { display: grid; padding: 2px 0 4px 18px; }
.context-submenu .context-item { padding: 7px 10px; font-size: 13.5px; }
.context-submenu .context-item.checked { font-weight: 600; }
.context-spacer { width: 14px; height: 14px; flex: 0 0 auto; }
.group-label.static { cursor: default; gap: 6px; }
.bot-group { position: relative; }
.bot-group.dragging { opacity: .45; }
.group-label[draggable="true"] { cursor: grab; }
.bot-group.dragging .group-label { cursor: grabbing; }
.bot-group.drop-before::before, .bot-group.drop-after::after { content: ''; position: absolute; left: 4px; right: 4px; height: 2px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.bot-group.drop-before::before { top: 4px; }
.bot-group.drop-after::after { bottom: -1px; }
.bot-row-meta { display: inline-flex; align-items: center; gap: 4px; }
.bot-row-meta svg { color: var(--muted); }
.bot-row-avatar { position: relative; }
.presence { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg-side); background: var(--muted); }
.bot-row[aria-current="page"] .presence { border-color: var(--bg-selected); }
.presence.running, .presence.queued, .presence.waiting { background: var(--warn); }
.presence.running { animation: pulse 1.6s ease-in-out infinite; }
.presence.blocked, .presence.failed { background: var(--danger); }
.presence.awaiting-owner { background: var(--accent); }
.bot-row-copy { min-width: 0; display: grid; gap: 1px; }
.bot-row-line { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.bot-row-name { font-weight: 640; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-row-meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }
.bot-row-preview { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
.bot-row-preview.unread { color: var(--ink-soft); font-weight: 500; }
.unread-count { flex-shrink: 0; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--solid); color: var(--solid-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.search-results { display: grid; gap: 2px; padding-top: 6px; }
.search-hit { display: grid; gap: 3px; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 10px; }
.search-hit:hover { background: var(--bg-hover); }
.search-hit-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.search-hit-snippet { font-size: 12.5px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.message-item.flash .bubble { outline: 2px solid var(--accent); outline-offset: 2px; transition: outline-color .3s ease; }
.rules-card { padding: 0; }
.rules-label { display: grid; gap: 8px; padding: 10px 12px; }
.rules-label textarea { border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; background: var(--bg); font-size: 13.5px; line-height: 1.45; resize: vertical; min-height: 96px; width: 100%; }
.list-empty { padding: 40px 16px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.list-empty h2 { font-size: 17px; color: var(--ink); }
.sidebar-foot { padding: 8px 8px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; }
.foot-button { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; }
.foot-button:hover { background: var(--bg-hover); color: var(--ink); }

/* avatars */
.avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; overflow: hidden; color: hsl(var(--h) 45% 32%); background: hsl(var(--h) 70% 90%); border: 1px solid hsl(var(--h) 45% 82%); }
:root[data-theme="dark"] .avatar { color: hsl(var(--h) 60% 82%); background: hsl(var(--h) 35% 24%); border-color: hsl(var(--h) 30% 32%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: hsl(var(--h) 60% 82%); background: hsl(var(--h) 35% 24%); border-color: hsl(var(--h) 30% 32%); } }
.avatar.has-mark { font-size: 20px; font-weight: 400; }
.avatar.small { width: 30px; height: 30px; font-size: 11px; }
.avatar.small.has-mark { font-size: 16px; }
.avatar.large { width: 56px; height: 56px; font-size: 19px; }
.avatar.tiny { width: 18px; height: 18px; font-size: 8px; border-width: 1px; }
.avatar.tiny.has-mark { font-size: 11px; }
.peer-marker-row { display: flex; justify-content: center; padding: 6px 4px 2px; }
.routine-marker-row { display: flex; justify-content: center; padding: 6px 4px 2px; }
.routine-marker { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 8px; border-radius: 999px; max-width: 100%; }
.routine-marker .peer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.routine-marker:hover { background: var(--bg-hover); color: var(--ink-soft); }
.schedule-marker-row { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 4px 2px; }
.schedule-marker { display: inline-flex; align-items: center; gap: 6px; max-width: min(560px, 92%); border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted); font-size: 12px; padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.schedule-marker:hover { background: var(--bg-hover); color: var(--ink-soft); }
.schedule-marker svg:first-child { flex: none; }
.schedule-marker-label { flex: none; font-weight: 600; color: var(--ink-soft); }
.schedule-marker-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-marker svg:last-child { flex: none; transition: transform .12s ease; }
.schedule-marker.open svg:last-child { transform: rotate(180deg); }
.schedule-full { max-width: min(680px, 92%); align-self: center; }
.day-row { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; cursor: pointer; }
.day-chip input { margin: 0; accent-color: var(--ink); }
.day-chip:has(input:checked) { background: var(--bg-selected); border-color: var(--line-strong); }
.peer-marker { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 4px 8px; border-radius: 999px; }
.peer-marker:hover { background: var(--bg-hover); color: var(--ink-soft); }
.peer-name { color: var(--ink-soft); font-weight: 600; }
.bubble.peer { background: color-mix(in srgb, var(--bubble) 70%, var(--bg-elev)); border: 1px solid var(--line); }
.avatar.large.has-mark { font-size: 28px; }
.avatar.hue-0 { --h: var(--hue-0); } .avatar.hue-1 { --h: var(--hue-1); } .avatar.hue-2 { --h: var(--hue-2); } .avatar.hue-3 { --h: var(--hue-3); }
.avatar.hue-4 { --h: var(--hue-4); } .avatar.hue-5 { --h: var(--hue-5); } .avatar.hue-6 { --h: var(--hue-6); } .avatar.hue-7 { --h: var(--hue-7); }

/* conversation */
.conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--bg); }
.conv-head { min-height: 58px; padding: 8px 12px 8px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.back-button { display: none; }
.conv-title { display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: transparent; padding: 4px 8px 4px 4px; border-radius: 10px; text-align: left; }
.conv-title:hover { background: var(--bg-hover); }
.conv-copy { min-width: 0; }
.conv-head h1 { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-sub.running, .conv-sub.queued, .conv-sub.waiting { color: var(--warn); }
.conv-sub.blocked, .conv-sub.failed { color: var(--danger); }
.conv-sub.awaiting-owner { color: var(--accent); }
.head-spacer { flex: 1; }
.message-area { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 20px max(24px, calc((100% - 820px) / 2)) 12px; scroll-behavior: auto; }
.message-feed { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.message-feed > * { min-width: 0; max-width: 100%; }
.separator { align-self: center; color: var(--muted); font-size: 12px; padding: 14px 0 8px; }
.separator.new { width: 100%; display: flex; align-items: center; gap: 12px; color: var(--accent); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 8px 0; }
.separator.new::before, .separator.new::after { content: ""; flex: 1; height: 1px; background: color-mix(in srgb, var(--accent) 40%, transparent); }
.message-group { display: flex; align-items: flex-end; gap: 10px; min-width: 0; }
.group-items { display: grid; gap: 4px; min-width: 0; flex: 1; justify-items: start; }
.message-group.bot .message-item { max-width: min(100%, 680px); }
.message-group.user .group-items { justify-items: end; }
.message-group.user .message-item { max-width: min(70%, 560px); }
.message-group.user .message-item .bubble { margin-left: auto; }
.message-item { display: grid; gap: 6px; min-width: 0; }
.message-item > * { min-width: 0; }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.55; word-break: break-word; overflow-wrap: anywhere; position: relative; min-width: 0; max-width: 100%; }
.bubble.bot { background: var(--bubble); color: var(--ink); border-bottom-left-radius: 6px; }
.bubble.user { background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 6px; }
.bubble-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 4px; }
.message-copy { white-space: pre-wrap; }
.route-note { margin-bottom: 6px; font-size: 12.5px; }
.route-note > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 600; }
.route-note > summary::-webkit-details-marker { display: none; }
.route-note > summary::before { content: '\25B8'; font-size: 9px; }
.route-note[open] > summary::before { content: '\25BE'; }
.route-note-body { margin-top: 4px; white-space: pre-wrap; color: var(--ink-soft); line-height: 1.45; }
.md > * + * { margin-top: .6em; }
.md p { margin: 0; }
.md .md-heading { font-size: 1em; font-weight: 700; margin-top: 1em; letter-spacing: -.005em; }
.md h3.md-heading { font-size: 1.05em; }
.md > .md-heading:first-child { margin-top: 0; }
.md ul, .md ol { display: grid; gap: .25em; }
.md li > p { margin: 0; }
.md strong { font-weight: 650; }
.md ul, .md ol { margin: .4em 0 0; padding-left: 1.4em; }
.md li + li { margin-top: .2em; }
.md code { font-family: var(--mono); font-size: .88em; background: color-mix(in srgb, var(--ink) 8%, transparent); padding: .1em .35em; border-radius: 5px; }
.md pre { margin: .5em 0 0; padding: 12px 14px; border-radius: 10px; background: var(--bg-elev); border: 1px solid var(--line); overflow-x: auto; font-size: 13px; line-height: 1.5; }
.md pre code { background: transparent; padding: 0; font-size: inherit; }
.md blockquote { margin: .4em 0 0; padding: .1em 0 .1em 12px; border-left: 3px solid var(--line-strong); color: var(--ink-soft); }
.md hr { border: 0; border-top: 1px solid var(--line-strong); margin: .8em 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.bubble.user .md a, .bubble.user .md code { color: inherit; background: color-mix(in srgb, var(--bubble-user-ink) 10%, transparent); }
.md { min-width: 0; }
.md-table { overflow-x: auto; margin-top: .5em; max-width: 100%; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: separate; border-spacing: 0; font-size: 13.5px; width: max-content; min-width: 60%; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--bg-elev); }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; line-height: 1.4; word-break: normal; overflow-wrap: normal; }
.md th { white-space: nowrap; }
.md td:not(:has(code)) { max-width: 520px; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: color-mix(in srgb, var(--ink) 5%, transparent); font-weight: 650; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
.md td code { white-space: nowrap; }
.task-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 0 6px; }
.task-line-note { flex-basis: 100%; color: var(--ink-soft); }
.task-line.blocked, .task-line.failed { color: var(--danger); }
.task-line.blocked .task-line-note, .task-line.failed .task-line-note { color: var(--ink-soft); }
.task-line.awaiting-owner { color: var(--accent); }
.task-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.task-dot.running, .task-dot.queued, .task-dot.waiting { background: var(--warn); }
.task-dot.succeeded { background: var(--success); }
.task-dot.failed, .task-dot.blocked, .task-dot.cancelled { background: var(--danger); }
.task-dot.awaiting-owner { background: var(--accent); }
.task-dot.unconfirmed { background: var(--warn); }
.working-bubble { display: grid; gap: 8px; min-width: 140px; }
.working-head { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14px; }
.working-dots { display: inline-flex; gap: 3px; }
.working-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.working-dots i:nth-child(2) { animation-delay: .15s; }
.working-dots i:nth-child(3) { animation-delay: .3s; }
.working-preview { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.working-actions { display: flex; gap: 14px; }
.working-head.streaming { margin-top: 4px; min-height: 12px; }
.working-bubble .md { font-size: 15px; }
.empty-conversation { min-height: 100%; display: grid; place-items: center; text-align: center; padding: 40px 20px; }
.empty-conversation > div { max-width: 360px; display: grid; justify-items: center; gap: 10px; }
.empty-mark { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.empty-conversation h2 { font-size: 22px; letter-spacing: -.02em; }
.empty-conversation p { color: var(--muted); line-height: 1.55; }
.configuring-head { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14px; padding: 6px 14px; border-radius: 999px; background: var(--bubble); }
.feed-loading { display: grid; gap: 14px; padding: 12px 0; }
.skeleton { height: 44px; border-radius: 16px; background: linear-gradient(90deg, var(--bubble), var(--bg-hover), var(--bubble)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton.w60 { width: 60%; } .skeleton.w40 { width: 40%; } .skeleton.w70 { width: 70%; }
.skeleton.right { justify-self: end; }

/* question cards */
.question-stack { display: grid; gap: 8px; margin: 2px 0 6px 40px; max-width: min(100%, 640px); }
.question-card { background: var(--bubble); border-radius: 16px; padding: 14px 14px 12px; display: grid; gap: 10px; }
.question-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.question-head h3 { font-size: 14.5px; font-weight: 650; line-height: 1.4; }
.question-head p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.question-options { display: grid; gap: 6px; }
.question-option { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); font-size: 14px; transition: background .12s ease, border-color .12s ease; }
.question-option:hover { border-color: var(--line-strong); background: var(--bg-hover); }
.option-key { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--bg-selected); color: var(--muted); font-size: 11px; font-weight: 700; }
.question-free { display: flex; gap: 8px; }
.question-free input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: var(--bg-elev); font-size: 14px; }
.question-answer { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-soft); font-size: 14px; }
.question-answer svg { margin-left: auto; color: var(--success); }
.question-card.answered .question-head h3, .question-card.dismissed .question-head h3 { color: var(--ink-soft); }
.question-dismissed { color: var(--muted); font-size: 13px; }

/* composer */
.composer { padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); }
.composer-form { width: min(100%, 820px); margin: auto; display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--line-strong); background: var(--bg-elev); border-radius: 26px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow-sm); transition: border-color .12s ease, box-shadow .12s ease; }
.composer-form:focus-within { border-color: color-mix(in srgb, var(--ink) 35%, var(--line-strong)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 6%, transparent); }
.composer textarea { flex: 1; min-width: 0; resize: none; border: 0; background: transparent; padding: 9px 0; line-height: 1.45; font-size: 15px; max-height: 180px; overflow-y: auto; width: 100%; }
.composer-main { flex: 1; min-width: 0; display: grid; }
.composer .attach-button { align-self: end; margin-bottom: 1px; color: var(--muted); }
.composer.dragging .composer-form { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.attachment-tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 2px; }
.tray-item { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 4px 4px 8px; border-radius: 10px; background: var(--bg-hover); font-size: 12.5px; color: var(--ink-soft); }
.tray-item img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.tray-item.uploading { opacity: .7; }
.tray-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-status { color: var(--muted); font-size: 11.5px; }
.tray-remove { width: 24px; height: 24px; min-width: 24px; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.attachment-image img { display: block; max-width: min(100%, 320px); max-height: 260px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); }
.attachment-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); color: inherit; text-decoration: none; font-size: 13px; }
.attachment-file small { color: var(--muted); }
.bubble.user .attachment-file { background: color-mix(in srgb, var(--bubble-user-ink) 8%, transparent); border-color: color-mix(in srgb, var(--bubble-user-ink) 20%, transparent); }
.composer textarea:focus { outline: none; }
.composer-chips { width: min(100%, 820px); margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
.composer-folder { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-soft); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 500; cursor: pointer; max-width: 260px; transition: background .12s ease, border-color .12s ease; }
.composer-folder:hover { background: var(--bg-hover); }
.composer-folder.active { color: var(--ink); border-color: var(--line-strong); }
.composer-folder svg { flex: none; color: var(--muted); }
.composer-folder.active svg { color: var(--accent); }
.composer-folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-followup.active { color: var(--ink); border-color: var(--warn, var(--line-strong)); }
.composer-followup.active svg { color: var(--warn, var(--accent)); }
.interrupted-note { margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.downgrade-note { margin: 6px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.folder-picker { gap: 10px; }
.folder-recent-label, .folder-browser-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.folder-recent { display: flex; flex-wrap: wrap; gap: 6px; }
.folder-recent .chip-button { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; color: var(--ink-soft); }
.folder-recent .chip-button.active { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 10%, var(--bg-elev)); }
.folder-crumb { display: flex; align-items: center; gap: 6px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.folder-crumb-icon { display: inline-flex; color: var(--muted); }
.folder-crumb-path { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.folder-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); }
.folder-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; font-size: 13.5px; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); }
.folder-row:last-child { border-bottom: 0; }
.folder-row:hover { background: var(--bg-hover); }
.folder-row svg:first-child { flex: none; color: var(--accent); }
.folder-row-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-row svg:last-child { flex: none; color: var(--muted); }
.folder-list > .details-muted, .folder-list > .dialog-error { padding: 12px; margin: 0; }
.composer-tools { width: min(100%, 820px); margin: 6px auto 0; display: flex; justify-content: flex-end; padding: 0 6px; }
.composer-provider { border: 1px solid var(--line); background: var(--bg-elev); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: var(--ink-soft); max-width: 170px; cursor: pointer; }
.composer-provider:hover { background: var(--bg-hover); }
.mic-button { align-self: end; margin-bottom: 1px; color: var(--muted); }
.mic-button.listening { color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.bubble { position: relative; }
.bubble-copy { position: absolute; top: 4px; right: 4px; opacity: 0; width: 26px; height: 26px; min-width: 26px; background: var(--bg-elev); border: 1px solid var(--line); }
.bubble-copy svg { width: 13px; height: 13px; }
.bubble:hover .bubble-copy, .bubble-copy:focus-visible { opacity: 1; }
.bubble.user .bubble-copy { background: color-mix(in srgb, var(--bubble-user-ink) 10%, transparent); border-color: color-mix(in srgb, var(--bubble-user-ink) 22%, transparent); color: var(--bubble-user-ink); }
@media (pointer: coarse) { .bubble-copy { display: none; } }
.send-button { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--solid); color: var(--solid-ink); display: grid; place-items: center; transition: transform .08s ease, opacity .12s ease; }
.send-button:not(:disabled):hover { transform: translateY(-1px); }
.send-button:disabled { opacity: .35; }
.composer-note { width: min(100%, 820px); margin: 6px auto 0; color: var(--muted); font-size: 11.5px; text-align: center; }

/* details panel */
.details-panel { border-left: 1px solid var(--line); background: var(--bg-side); display: flex; flex-direction: column; min-height: 0; }
.details-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 18px; min-height: 58px; border-bottom: 1px solid var(--line); }
.details-head h2 { font-size: 14px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; flex: 1; }
.details-panel.settings .details-head h2 { text-align: center; text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 15px; }
.settings-form { overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 0; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.settings-form > * { flex: 0 0 auto; }
.settings-avatar { display: grid; justify-items: center; gap: 12px; padding: 6px 0 4px; }
.avatar-preview .avatar { width: 72px; height: 72px; font-size: 24px; }
.avatar-preview .avatar.has-mark { font-size: 36px; }
.mark-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; width: 100%; }
.mark-option { height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); font-size: 20px; display: grid; place-items: center; transition: border-color .12s ease; }
.mark-option:first-child { font-size: 12px; font-weight: 700; color: var(--muted); }
.mark-option:hover { border-color: var(--line-strong); }
.mark-option.selected { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; padding: 0; background: hsl(var(--h) 65% 55%); }
.swatch.auto { width: auto; border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 600; background: var(--bg-selected); color: var(--ink-soft); }
.swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg-side); }
.swatch.hue-0 { --h: var(--hue-0); } .swatch.hue-1 { --h: var(--hue-1); } .swatch.hue-2 { --h: var(--hue-2); } .swatch.hue-3 { --h: var(--hue-3); }
.swatch.hue-4 { --h: var(--hue-4); } .swatch.hue-5 { --h: var(--hue-5); } .swatch.hue-6 { --h: var(--hue-6); } .swatch.hue-7 { --h: var(--hue-7); }
.settings-fields { display: grid; gap: 12px; }
.settings-fields .field-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.settings-fields input, .settings-fields textarea { border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 11px; background: var(--bg-elev); font-size: 14px; width: 100%; }
.settings-fields textarea { resize: vertical; line-height: 1.45; min-height: 120px; }
.settings-section { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: 6px; }
.setting-card { display: grid; grid-template-columns: minmax(0, 1fr); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; overflow: clip; min-height: max-content; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; cursor: pointer; min-width: 0; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-copy { display: grid; gap: 2px; min-width: 0; }
.setting-label { font-size: 14px; font-weight: 500; }
.setting-hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.setting-row select, .setting-row input:not(.switch) { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); font-size: 13px; flex: 0 1 46%; min-width: 0; width: 46%; }
.setting-row .switch { flex: 0 0 auto; margin: 0; }
.setting-row-stacked { flex-wrap: wrap; align-items: flex-start; }
.setting-row-stacked .setting-copy { flex: 1 1 100%; }
.setting-row select.setting-select-wide { flex: 1 1 100%; width: 100%; min-width: 0; margin-top: 8px; }
.settings-foot { position: sticky; bottom: 0; margin: 6px -18px 0; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--bg-side); border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.details-body { overflow-y: auto; overscroll-behavior: contain; padding: 16px 18px 24px; display: grid; gap: 22px; align-content: start; }
.details-identity { display: flex; align-items: center; gap: 12px; }
.details-name { font-weight: 650; font-size: 16px; }
.details-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.details-section { display: grid; gap: 8px; }
.details-section h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.details-section-head { display: flex; align-items: center; justify-content: space-between; }
.details-purpose { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.details-purpose.expanded { display: block; }
.details-muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.starter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.starter-label { color: var(--muted); font-size: 12.5px; margin-right: 2px; }
.chip-button { border: 1px solid var(--line); background: var(--bg-elev); cursor: pointer; }
.chip-button:hover { background: var(--bg-hover); }
.chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--bg-selected); color: var(--ink-soft); }
.screen-preview { display: block; width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev); aspect-ratio: 16 / 9; object-fit: contain; }
.screen-link { display: block; }
.details-kv { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 8px; font-size: 13px; color: var(--ink-soft); }
.details-kv small { grid-column: 2; color: var(--muted); font-family: var(--mono); font-size: 11.5px; word-break: break-all; }
.details-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.routines { display: grid; gap: 4px; }
.routine { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: start; padding: 8px 8px; margin: 0 -8px; border-radius: 12px; }
.routine-actions { grid-column: 2; margin-top: 2px; }
.routine:hover { background: var(--bg-hover); }
.routine-icon { color: var(--muted); padding-top: 2px; }
.routine-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.routine-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.routine-actions { display: flex; align-items: center; gap: 2px; }
.switch { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; margin: 0 6px 0 0; transition: background .15s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s ease; }
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(14px); }
.recent-list { display: grid; gap: 2px; }
.recent-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px; margin: 0 -8px; border-radius: 10px; width: calc(100% + 16px); }
.recent-item:hover:not(:disabled) { background: var(--bg-hover); }
.recent-copy { min-width: 0; display: grid; }
.recent-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-meta { font-size: 12px; color: var(--muted); }

/* modals */
.modal-layer { position: fixed; inset: 0; z-index: 20; background: rgba(15, 16, 20, .45); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { background: var(--bg-elev); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-md); border-radius: 18px; width: min(100%, 520px); max-height: min(92dvh, 860px); overflow: auto; padding: 22px 24px 20px; animation: rise .16s ease-out; }
.modal-card.wide { width: min(100%, 680px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 4px; }
.modal-head h2 { font-size: 19px; letter-spacing: -.02em; }
.modal-head p { color: var(--muted); margin-top: 4px; line-height: 1.5; font-size: 13.5px; }
.modal-form { display: grid; gap: 16px; margin-top: 14px; }
.stack { display: grid; gap: 16px; }
.form-section { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-section h3 { font-size: 13px; font-weight: 650; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field label, .field-label { font-weight: 600; font-size: 13px; }
.field input, .field textarea, .field select, .config-editor { border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: var(--bg); padding: 9px 11px; width: 100%; font-size: 14px; }
.field input:focus, .field textarea:focus, .field select:focus, .config-editor:focus { outline: none; border-color: var(--ink-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 8%, transparent); }
.field textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.field small { color: var(--muted); line-height: 1.4; font-size: 12.5px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.option-list { display: grid; gap: 4px; }
.option-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.4; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }
.option-row:hover { background: var(--bg-hover); }
.option-row.disabled { cursor: default; opacity: .65; }
.option-row input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); flex-shrink: 0; }
.option-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.option-footnote { color: var(--muted); font-size: 12px; padding: 4px 2px 0; }
.status-list { display: grid; gap: 6px; }
.status-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.4; }
.status-row small { display: block; color: var(--muted); font-size: 12.5px; }
.status-badge { flex-shrink: 0; margin-top: 1px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg-selected); color: var(--muted); }
.status-badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.status-badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-error { color: var(--danger); font-size: 13px; }
.dialog-note { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.callout { background: var(--bubble); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); white-space: pre-wrap; }
.callout.warn { background: var(--danger-soft); color: var(--ink); }
.disclosure summary { cursor: pointer; font-weight: 600; font-size: 13.5px; padding: 6px 0; color: var(--ink-soft); }
.disclosure[open] summary { margin-bottom: 8px; }
.disclosure > :not(summary) { margin-top: 8px; }
.menu-list { display: grid; gap: 2px; }
.menu-item { text-align: left; border: 0; background: transparent; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; }
.menu-item:hover { background: var(--bg-hover); }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.list-row:last-child { border-bottom: 0; }
.list-row-copy { flex: 1; min-width: 0; display: grid; }
.list-row-copy small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.plain-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 8px 12px; color: var(--muted); background: transparent; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.tab[aria-selected="true"] { color: var(--ink); border-color: var(--ink); }
.config-editor { font-family: var(--mono); font-size: 13px; line-height: 1.5; min-height: 240px; resize: vertical; }
.task-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.task-prompt { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; max-height: 160px; overflow: auto; }
.task-result { font-size: 14px; }
.log { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 11.5px; background: var(--bg-side); border: 1px solid var(--line); padding: 10px; border-radius: 8px; max-height: 200px; overflow: auto; color: var(--ink-soft); margin: 0; }
.worker-feed { max-height: 340px; font-size: 12px; color: var(--ink); }
.diff { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; background: var(--bg-side); border: 1px solid var(--line); padding: 10px; border-radius: 8px; max-height: 420px; overflow: auto; margin: 0; line-height: 1.5; }
.diff-add { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); display: block; }
.diff-del { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); display: block; }
.diff-same { color: var(--muted); display: block; }
.artifacts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.artifact-image { display: grid; gap: 4px; text-decoration: none; color: var(--ink-soft); font-size: 12px; }
.artifact-image img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-side); }
.artifact-file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 13px; }
.artifact-file small { color: var(--muted); margin-left: auto; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 8px; max-width: min(92vw, 520px); background: var(--solid); color: var(--solid-ink); padding: 10px 8px 10px 16px; border-radius: 999px; box-shadow: var(--shadow-md); font-size: 13.5px; animation: rise .18s ease-out; }
.toast.error { background: var(--danger); color: #fff; }
.toast-close { width: 28px; height: 28px; min-width: 28px; border: 0; background: rgba(255, 255, 255, .12); color: inherit; }
.toast-close svg { width: 14px; height: 14px; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-3px); opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .working-dots i { opacity: .8; }
}

/* responsive */
@media (max-width: 1100px) {
  .layout[data-details="open"] { grid-template-columns: 300px minmax(0, 1fr); }
  .layout[data-details="open"] .details-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 100vw); z-index: 15; box-shadow: var(--shadow-md); border-left: 1px solid var(--line); }
}
@media (max-width: 740px) {
  .layout, .layout[data-details="open"] { display: block; height: 100dvh; }
  .sidebar, .conversation { height: 100dvh; }
  .layout[data-view="conversation"] .sidebar { display: none; }
  .layout[data-view="list"] .conversation { display: none; }
  .layout[data-details="open"] .details-panel { width: 100vw; }
  .back-button { display: inline-grid; }
  .sidebar-head { padding: 12px 10px 6px 14px; }
  .bot-list { padding: 4px 8px 12px; }
  .bot-row { padding: 10px 10px; }
  .conv-head { padding: 6px 8px 6px 6px; min-height: 56px; }
  .conv-title { padding-left: 2px; }
  .message-area { padding: 14px 12px 8px; }
  .message-group.user .message-item { max-width: 88%; }
  .message-group.bot .message-item { max-width: 100%; }
  .question-stack { margin-left: 0; }
  .composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; }
  .composer-note { display: none; }
  .modal-layer { padding: 0; align-items: end; }
  .modal-card, .modal-card.wide { width: 100%; max-height: 94dvh; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
  .field-row { grid-template-columns: 1fr; }
  .field input, .field textarea, .field select, .question-free input { font-size: 16px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* Create-bot interview: reuses the conversation question card, plus a greeting bubble and step footer. */
.question-option:has(.question-option-copy) { align-items: flex-start; }
.question-option-copy { display: grid; gap: 2px; min-width: 0; }
.question-option-copy small { color: var(--muted); font-size: 12.5px; }
.interview-greeting p { display: inline-block; background: var(--bubble); border-radius: 16px; padding: 10px 14px; font-size: 14.5px; }
.interview-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.interview-foot .link-button { margin-right: auto; }
