/* Shared, restrained visual language for agency workspaces. Chart category
   colours and circular state indicators intentionally keep their semantics. */
:root {
  --bg: #f4f6f8; --panel: #fff; --text: #252d38; --muted: #606c7c;
  --border: #d8dfe7; --accent: #254f78; --accent-hover: #193c5e;
  --accent-text: #fff; --button-text: #fff; --link: #245d92;
  --sidebar-bg: #edf1f5; --sidebar-text: #293749; --sidebar-muted: #5d6c7c;
  --sidebar-hover: #e1e8ef; --code-bg: #f0f3f6; --sys-bg: #eaf0f6; --sys-text: #405b76;
  --shadow-soft: 0 1px 3px #182b4008;
}
html[data-theme="dark"] {
  --bg: #17191d; --panel: #1e2126; --text: #e5e8ed; --muted: #a4adba;
  --border: #373d46; --accent: #3d6fb6; --accent-hover: #477dc6;
  --accent-text: #fff; --button-text: #fff; --link: #9bbce9;
  --sidebar-bg: #1b1e23; --sidebar-text: #e0e5ec; --sidebar-muted: #a4adba;
  --sidebar-hover: #2b323c; --code-bg: #252930; --sys-bg: #283342; --sys-text: #bdcce0;
  --shadow-soft: 0 1px 3px #0002;
  color-scheme: dark;
}
html[data-theme="light"] { color-scheme: light; }
body :is(button, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):not(.msg *) { border-radius: 4px !important; }
body :is(button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }
body :is(.login-card, .tpl-shell, .wfv2-shell, .bot-shell) { border-radius: 6px !important; }
.login-card { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.login-card :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select) { background: var(--bg); color: var(--text); border-color: var(--border) !important; }
.login-card input::placeholder, .login-card textarea::placeholder { color: var(--muted); opacity: 1; }
.login-card .icon-btn { background: transparent; color: var(--text); border: 1px solid var(--border); }
.topbar { border-top: 3px solid var(--accent); box-shadow: none; }
.brand-mark { filter: none; }
#rightbar { gap: 12px; }   /* 側欄的間距改在 .sb-scroll（外框三段之間不留空） */
#sidebar .side-actions button { background: var(--panel); border-color: var(--border); }
#sidebar .side-actions button:hover { background: var(--sys-bg); color: var(--text); border-color: var(--accent); transform: none; box-shadow: none; }
:is(.sb-group, .wf-group) { letter-spacing: .02em; }
:is(.loaded-item, .wf-group, .chat-skill-item, .msg, .avatar, .file-card, .video-plan-card, .think-body, .code-wrap, .dynamic-note, .wf-step, .wf-step-settings, .tpl-card, .tpl-advanced, .wfv2-node, .wfv2-properties, .adm-card, .adm-create) { border-radius: 4px !important; }
:is(.loaded-tag, .cite-chip, .focus-chip, .attach-chip, .wf-node, .wfv2-badge, .adm-tag, .art-badge) { border-radius: 3px !important; }
.msg.user { background: var(--sys-bg); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.msg.ai { box-shadow: none; }
.msg-row { margin-bottom: 22px; }
footer { box-shadow: none; }
#input { background: var(--panel); border-color: var(--border); }
#send { width: 38px; height: 38px; }
#adminBox, #settings { backdrop-filter: none; }
#adminBox .adm-heading h2 { font-size: 22px; }
#adminBox .adm-header { padding-top: 22px; padding-bottom: 20px; }
#adminBox :is(.adm-create, #admUserList, #admBulkActions, .adm-card) { border-radius: 4px; }
#adminBox .adm-tabs button { border-radius: 0 !important; }
#adminBox .adm-urow:first-child { border-radius: 4px 4px 0 0; }
#settings { --set-blue: #245d92; --set-selected: #e7eef6; }
html[data-theme="dark"] #settings { --set-blue: #a6c4ee; --set-selected: #293749; }
#settings #setForm .set-foot button[type="submit"] { background: var(--accent) !important; border-color: var(--accent); }
#settings .set-nav button.active { border-left: 3px solid var(--set-blue) !important; padding-left: 11px !important; }
#settings #setForm :is(input[type="range"], input[type="checkbox"]) { accent-color: var(--set-blue); }
:is(.tpl-header, .wfv2-header) { background: var(--panel); }
.wfv2-badge { background: var(--sys-bg); color: var(--link); border: 1px solid var(--border); }
:is(.tpl-card, .wfv2-node) { box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .side-actions button { transition: none; } }
/* Secondary sidebar controls stay on a muted surface. Avoid interpolating a
   light background while the theme's text colour has already changed. */
#sidebar .side-actions button {
  background: var(--sidebar-hover); color: var(--sidebar-text); border-color: var(--border);
  transition: border-color .15s ease;
}
#sidebar #modelRefresh {
  background: var(--sidebar-hover); color: var(--sidebar-text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
#sidebar .side-actions button:hover, #sidebar #modelRefresh:hover:not(:disabled) {
  background: var(--sys-bg); color: var(--text); border-color: var(--link);
}
/* Give project names a complete row instead of sharing it with four tools. */
#sidebar .kb-row { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#sidebar #kbSel { display: block; flex: none; width: 100%; min-width: 0; min-height: 38px; padding: 8px 28px 8px 10px; font-size: 13px; border: 1px solid var(--border); color: var(--sidebar-text); background: var(--sidebar-hover); text-overflow: ellipsis; }
#sidebar .kb-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 5px; }
#sidebar .kb-actions button { min-width: 0; padding: 7px 3px; font-size: 11px; white-space: nowrap; color: var(--sidebar-muted); background: transparent; border-color: var(--border); }
#sidebar .kb-actions button:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
#sidebar #kbDel:hover { color: #b83a43; }
html[data-theme="dark"] #sidebar #kbDel:hover { color: #ff9aa3; }
/* Gold grape emblem with a quiet, readable wordmark. */
.brand-wordmark {
  display: inline-flex; align-items: baseline; gap: 0; white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: -.035em;
  color: #1d2730;
}
.brand-wordmark .brand-rap { font-weight: 600; }
.brand-wordmark :is(.brand-g, .brand-x) { font-weight: 700; color: #af781f; }
html[data-theme="dark"] .brand-wordmark { color: #e5e8eb; }
html[data-theme="dark"] .brand-wordmark :is(.brand-g, .brand-x) { color: #ddb05a; }
.brand-grape-gold {
  display: inline-block; width: 24px; height: 28px; flex: none; background: #af781f;
  -webkit-mask: url('/static/grapx-grape-gold.svg?v=20261023d') center / contain no-repeat;
  mask: url('/static/grapx-grape-gold.svg?v=20261023d') center / contain no-repeat;
}
html[data-theme="dark"] .brand-grape-gold { background: #ddb05a; }
#sidebar .brand h1 { gap: 7px; }
#sidebar .brand > span { gap: 4px !important; }
#sidebar .brand .icon-btn { padding-left: 7px; padding-right: 7px; }
.topbar .brand-wordmark { font-size: 18px; }
#loginForm .brand-wordmark { font-size: 28px; }
#loginForm .brand-grape-gold { width: 30px; height: 35px; }
/* Narrow, user-resized sidebars keep the brand tools inside their bounds. */
#sidebar > .brand { flex-wrap: wrap; gap: 8px 6px; }
#sidebar > .brand > span { margin-left: auto; }
