:root {
  --bg: #f7f6f3;
  --panel: #efede8;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #dedbd4;
  --accent: #256d5a;
  --accent-text: #ffffff;
  --accent-soft: #e2efe9;
  --user: #e9e6df;
  --hover: #e6e3dc;
  --code: #f2f0eb;
  --danger: #b4382c;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161716;
    --panel: #1c1e1d;
    --surface: #232625;
    --text: #e8e6e1;
    --muted: #9a9790;
    --line: #323634;
    --accent: #4fb393;
    --accent-text: #0e1513;
    --accent-soft: #1d332d;
    --user: #2a2e2c;
    --hover: #2b2f2d;
    --code: #1a1c1b;
    --danger: #e26b5e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }
.ico.sm { width: 14px; height: 14px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#app { display: grid; grid-template-columns: 280px 1fr; height: 100dvh; }

/* sidebar */
#side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; }
.brand { font-size: 15px; color: var(--muted); }
.brand b { color: var(--text); font-weight: 600; }
.search { display: flex; align-items: center; gap: 8px; margin: 4px 12px 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; outline: none; color: var(--text); }
#list { overflow-y: auto; flex: 1; padding: 0 6px 8px; }
.row-conv { position: relative; border-radius: 8px; }
.row-conv:hover { background: var(--hover); }
.row-conv.active { background: var(--accent-soft); }
.conv { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 36px 8px 10px; border-radius: 8px; }
.pin-btn { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 28px; height: 28px; opacity: 0; }
.row-conv:hover .pin-btn, .pin-btn:focus-visible { opacity: 1; }
.row-conv.pinned .pin-btn { opacity: .55; }
.row-conv.pinned:hover .pin-btn { opacity: 1; }
#pin.on { color: var(--accent); }
.conv .t { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .m { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 16px; font-size: 12px; color: var(--muted); }

/* main */
main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
header h1 { font-size: 16px; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project { display: flex; align-items: center; gap: 6px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 0 4px 0 10px; background: var(--surface); max-width: 40%; }
.project select { border: 0; background: none; padding: 6px 4px; outline: none; color: var(--text); min-width: 0; max-width: 100%; }
.icon { display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; width: 34px; height: 34px; border-radius: 9px; color: var(--muted); flex: none; }
.icon:hover { background: var(--hover); color: var(--text); }
#menu { display: none; }

#msgs { flex: 1; overflow-y: auto; padding: 24px 16px 8px; }
.msg { max-width: 820px; margin: 0 auto 24px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { background: var(--user); border-radius: var(--radius); padding: 10px 14px; width: fit-content; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; align-items: flex-start; }
.msg .atts img { max-height: 180px; max-width: 260px; border-radius: 10px; border: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 5px 8px 5px 10px; text-decoration: none; color: inherit; max-width: 280px; }
.chip > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip small { color: var(--muted); white-space: nowrap; }
.chip button { display: inline-flex; border: 0; background: none; padding: 2px; border-radius: 6px; color: var(--muted); }
.chip button:hover { background: var(--hover); color: var(--text); }
.chip.thumb { padding: 4px 6px 4px 4px; }
.chip.thumb img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.chip.err { border-color: var(--danger); color: var(--danger); }

.answer { word-wrap: break-word; }
.answer > :first-child { margin-top: 0; }
.answer p, .answer ul, .answer ol { margin: 0 0 .8em; }
.answer a { color: var(--accent); }
.answer pre { position: relative; background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font: 13px/1.5 var(--mono); }
.answer pre code.hljs { background: none; padding: 0; }
.answer code { font: 13px var(--mono); background: var(--code); padding: 1px 5px; border-radius: 5px; }
.answer pre code { padding: 0; background: none; }
.answer table { border-collapse: collapse; margin: 0 0 .8em; display: block; overflow-x: auto; }
.answer th, .answer td { border: 1px solid var(--line); padding: 5px 10px; }
.answer blockquote { margin: 0 0 .8em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.copy { position: absolute; top: 6px; right: 6px; display: inline-flex; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 4px; color: var(--muted); opacity: 0; }
.answer pre:hover .copy, .copy:focus-visible { opacity: 1; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 1em; vertical-align: -2px; background: var(--accent); margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

details.think { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
details.think summary { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: 6px; list-style: none; }
details.think summary::-webkit-details-marker { display: none; }
details.think summary .ico { transition: transform .15s; }
details.think[open] summary .chev { transform: rotate(90deg); }
details.think .r { white-space: pre-wrap; border-left: 2px solid var(--line); padding: 6px 0 6px 12px; margin-top: 6px; max-height: 320px; overflow-y: auto; }
.steps { list-style: none; padding: 0; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 6px; padding: 2px 0; min-width: 0; }
.steps li b { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.steps li .sum { white-space: nowrap; }
.error { display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: 14px; }
.msg-actions { margin-top: 4px; display: flex; gap: 2px; }
.msg-actions button { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border: 0; background: none; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.msg-actions button:hover { background: var(--hover); color: var(--text); }

.empty { max-width: 560px; margin: 14vh auto 0; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); font-weight: 600; margin: 0 0 8px; font-size: 22px; }

/* composer */
#composer { max-width: 852px; width: 100%; margin: 0 auto; padding: 8px 16px 16px; }
#composer .box { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s; }
#composer .box:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
#chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 10px 0; }
#chips:empty { display: none; }
#input { display: block; width: 100%; resize: none; overflow-y: hidden; max-height: 40vh; border: 0; background: none; padding: 12px 14px 6px; outline: none; line-height: 1.5; }
#input.scroll { overflow-y: auto; }
#composer .row { display: flex; align-items: center; gap: 6px; padding: 4px 8px 8px; }
.attach { cursor: pointer; }
.tog { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; padding: 5px 10px 5px 8px; border-radius: 999px; border: 1px solid var(--line); }
.tog .ico { width: 15px; height: 15px; }
.tog input { display: none; }
.tog:hover { color: var(--text); }
.tog:has(input:checked) { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.grow { flex: 1; }
.hint { font-size: 12px; color: var(--muted); margin-right: 4px; }
.send { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-text); }
.send:disabled { opacity: .45; cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }

/* drop overlay */
#drop { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); pointer-events: none; }
#drop[hidden] { display: none; }
#drop > div { border: 2px dashed var(--accent); border-radius: 18px; padding: 36px 56px; text-align: center; background: var(--surface); color: var(--muted); display: grid; justify-items: center; gap: 4px; }
#drop .ico { width: 28px; height: 28px; color: var(--accent); }
#drop p { margin: 6px 0 0; color: var(--text); font-weight: 600; }
#drop span { font-size: 13px; }

/* mobile */
#scrim { display: none; }
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #side { position: fixed; inset: 0 auto 0 0; width: 84%; max-width: 320px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  #app.open #side { transform: none; }
  #app.open #scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 10; }
  #menu { display: inline-flex; }
  #msgs { padding: 16px 12px 8px; }
  #composer { padding: 6px 10px 10px; }
  header { padding: 8px 10px; }
  .project { max-width: 38%; }
  .hint { display: none; }
  .msg.user .bubble { max-width: 92%; }
}

/* ---------- v3: header grid, pickers, menus ---------- */
header { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.h-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.h-mid { display: flex; justify-content: center; }
.h-right { display: flex; justify-content: flex-end; gap: 2px; }
.picker { display: inline-flex; align-items: center; gap: 8px; max-width: 280px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; color: var(--text); }
.picker:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.picker > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker .ico:first-child { color: var(--muted); }
.picker .ico:last-child { width: 15px; height: 15px; color: var(--muted); }
.picker.set .ico:first-child { color: var(--accent); }

.menu { position: fixed; z-index: 60; min-width: 220px; max-width: 340px; max-height: 320px; overflow-y: auto; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgb(0 0 0 / .28); }
.menu .opt { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.menu .opt .ico { color: var(--muted); }
.menu .opt.sel .ico.check { color: var(--accent); }
.menu .opt:hover, .menu .opt.hi { background: var(--hover); }
.menu .opt > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .opt small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu .label { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }
#slash { position: absolute; bottom: calc(100% - 4px); left: 16px; right: auto; width: min(520px, calc(100% - 32px)); max-width: none; }
#composer { position: relative; }

/* ---------- context ring ---------- */
.ctx { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-right: 4px; cursor: default; }
.ctx svg { width: 16px; height: 16px; transform: rotate(-90deg); }
.ctx circle { fill: none; stroke-width: 3; }
.ctx .track { stroke: var(--line); }
.ctx .fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 50.27; stroke-dashoffset: 50.27; transition: stroke-dashoffset .3s; }
.ctx.warn .fill { stroke: #d39b2a; }
.ctx.full .fill { stroke: var(--danger); }

/* ---------- messages: actions, edit ---------- */
.msg.user .msg-actions { justify-content: flex-end; opacity: 0; transition: opacity .15s; }
.msg.user:hover .msg-actions, .msg.user .msg-actions:focus-within { opacity: 1; }
.msg.assistant .msg-actions .regen { display: none; }
.msg.assistant.last .msg-actions .regen { display: inline-flex; }
.edit-box { width: min(100%, 640px); background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); padding: 8px; }
.edit-box textarea { width: 100%; resize: vertical; min-height: 70px; border: 0; background: none; outline: none; padding: 4px 6px; }
.edit-box .acts { display: flex; justify-content: flex-end; gap: 6px; }
.note { max-width: 820px; margin: 0 auto 18px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.note::before, .note::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- buttons ---------- */
.primary { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 9px; padding: 8px 14px; font-weight: 600; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; color: var(--text); }
.ghost:hover { background: var(--hover); }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- settings dialog ---------- */
dialog#settings { width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#settings::backdrop { background: rgb(0 0 0 / .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 42px); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 16px; margin: 0; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { border: 0; background: none; padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pane { padding: 16px 18px 18px; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.fld { display: grid; gap: 8px; }
.fld > span { font-weight: 600; font-size: 14px; }
.fld small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.fld .picker { justify-self: start; }
.dlg textarea, .dlg input { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; outline: none; resize: vertical; }
.dlg textarea:focus, .dlg input:focus { border-color: var(--accent); }
.dlg textarea:disabled { opacity: .5; }
.dlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.dlg-foot .muted { margin-right: auto; }
#prompt-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.prompt { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.prompt b { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.prompt .txt { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prompt .icon { width: 28px; height: 28px; }
.prompt-edit { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }

.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 16px; }
#me { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 760px) {
  header { grid-template-columns: minmax(0, 1fr) auto auto; }
  .picker { max-width: 150px; padding: 6px 8px; }
  #title { font-size: 15px; }
  .msg.user .msg-actions { opacity: 1; }
}

/* ---------- print / PDF ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #ccc; --user: #f1f1f1; --code: #f6f6f6; color-scheme: light; }
  #side, #scrim, #composer, .h-mid, .h-right, #menu, .msg-actions, details.think, .copy, #drop { display: none !important; }
  #app { display: block; height: auto; }
  main, #msgs { overflow: visible; display: block; }
  header { display: block; border: 0; padding: 0 0 12px; }
  .msg { break-inside: avoid; }
}

/* slash prompts: two-line items */
.menu .opt.two { align-items: flex-start; padding: 8px 12px; }
.menu .opt .txt { display: grid; gap: 1px; min-width: 0; flex: 1; }
.menu .opt .name { font: 600 13px var(--mono); color: var(--text); }
.menu .opt .desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#slash { padding: 6px; }
#slash .label { padding: 4px 12px 6px; }

/* ---------- projects ---------- */
.nav-item { display: flex; align-items: center; gap: 10px; margin: 0 6px 4px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--text); text-align: left; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .ico { color: var(--muted); }
.nav-item.active .ico { color: var(--accent); }
main.projects > :not(#pview) { display: none !important; }
#pview { flex: 1; overflow-y: auto; padding: 28px 24px 40px; }
.pv { max-width: 980px; margin: 0 auto; }
.pv-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.pv-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 0; }
.pv-head .back { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); padding: 6px 8px; border-radius: 8px; }
.pv-head .back:hover { background: var(--hover); color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: grid; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); min-height: 120px; align-content: start; }
button.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { margin-top: auto; font-size: 12px; color: var(--muted); }
.empty-card { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }

.proj { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.proj-title { width: 100%; font-size: 22px; font-weight: 700; border: 1px solid transparent; background: none; border-radius: 8px; padding: 2px 6px; margin-left: -6px; outline: none; color: var(--text); }
.proj-title:hover, .proj-title:focus { border-color: var(--line); background: var(--surface); }
.proj-desc { width: 100%; border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 6px; margin: 2px 0 18px -6px; outline: none; color: var(--muted); }
.proj-desc:hover, .proj-desc:focus { border-color: var(--line); background: var(--surface); color: var(--text); }
.start { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); text-align: left; margin-bottom: 18px; }
.start:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--text); }
.start .ico { color: var(--accent); }
.plist { display: grid; gap: 2px; }
.plist button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.plist button:hover { background: var(--hover); }
.plist button span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plist button small { color: var(--muted); white-space: nowrap; }
.plist .ico { color: var(--muted); }
.side-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 14px; display: grid; gap: 10px; margin-bottom: 14px; }
.side-card h3 { margin: 0; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.side-card textarea { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; outline: none; }
.side-card textarea:focus { border-color: var(--accent); }
.side-card .foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.side-card .foot .muted { margin-right: auto; }
.pfiles { display: grid; gap: 4px; }
.pfile { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 6px 4px 6px 8px; border-radius: 8px; }
.pfile:hover { background: var(--hover); }
.pfile a { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); text-decoration: none; }
.pfile small { color: var(--muted); white-space: nowrap; }
.pfile .icon { width: 26px; height: 26px; }
.pdrop { border: 1px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.pdrop:hover, .pdrop.drag { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.meter { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); }
.meter.over > i { background: #d39b2a; }
dialog#newproj { width: min(460px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#newproj::backdrop { background: rgb(0 0 0 / .45); }
.dlg-head .grow { flex: 1; }
@media (max-width: 860px) {
  .proj { grid-template-columns: 1fr; }
  #pview { padding: 18px 14px 30px; }
}
.primary, .ghost { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pdrop { display: flex; align-items: center; justify-content: center; gap: 6px; }

/* ---------- file preview ---------- */
dialog#preview { width: min(1100px, calc(100vw - 24px)); height: min(820px, calc(100dvh - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .45); }
dialog#preview::backdrop { background: rgb(0 0 0 / .55); }
.pv-dlg { display: flex; flex-direction: column; height: 100%; }
.pv-dlg .dlg-head { gap: 10px; }
.pv-dlg .dlg-head h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pv-dlg .dlg-head small { white-space: nowrap; }
#pr-icon .ico { color: var(--accent); }
.ghost.sm { padding: 4px 10px; font-size: 13px; }
.sheet-tabs { padding: 8px 12px 0; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.sheet-tabs .tab { border-radius: 8px 8px 0 0; white-space: nowrap; }
#pr-body { flex: 1; overflow: auto; min-height: 0; }
#pr-body.center { display: grid; place-items: center; padding: 16px; background: var(--bg); }
#pr-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
#pr-body pre { margin: 0; padding: 16px 18px; font: 13px/1.55 var(--mono); white-space: pre; tab-size: 4; }
#pr-body pre code.hljs { background: none; padding: 0; }
#pr-body .md { padding: 20px 28px; max-width: 860px; }
#pr-body .note-top { padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th, table.grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px 10px; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
table.grid thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; font-weight: 600; }
table.grid td.n, table.grid th.n { position: sticky; left: 0; background: var(--panel); color: var(--muted); text-align: right; font-weight: 400; min-width: 44px; }
table.grid thead th.n { z-index: 2; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tbody tr:hover td { background: var(--hover); }
.chip.clickable { cursor: pointer; }
.msg .atts img { cursor: zoom-in; }
.pfile .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0; background: none; text-align: left; color: var(--text); padding: 0; }
.pfile .name:hover { color: var(--accent); }

/* ---------- tasks ---------- */
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 12px; display: inline-grid; place-items: center; }
.row-conv .dot { position: absolute; top: 50%; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: translateY(-50%); }
.row-conv.unread .t { font-weight: 600; }
.row-conv.unread:hover .dot { display: none; }
.task-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: 12px; margin-right: 4px; max-width: 220px; }
.task-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-chip .ico { width: 14px; height: 14px; color: var(--accent); }
.task-chip:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.task-chip.off .ico { color: var(--muted); }
.run-mark { max-width: 820px; margin: 0 auto 10px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.run-mark .ico { width: 14px; height: 14px; }
.run-mark::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg.assistant.quiet .answer { color: var(--muted); font-size: 13px; }
dialog#taskdlg { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#taskdlg::backdrop { background: rgb(0 0 0 / .45); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.seg button { border: 0; background: none; border-radius: 9px; padding: 8px 10px; color: var(--muted); text-align: left; display: grid; gap: 2px; }
.seg button small { font-size: 12px; font-weight: 400; color: var(--muted); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg.compact button { text-align: center; padding: 6px 8px; }
.seg.mini { display: inline-grid; padding: 2px; border-radius: 9px; vertical-align: middle; }
.seg.mini button { padding: 3px 10px; font-size: 13px; }
.when { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dlg .inline input { width: auto; padding: 6px 8px; }
.dlg .inline input[type=number] { width: 70px; }
.days { display: flex; gap: 4px; }
.days button { width: 38px; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; color: var(--muted); font-size: 13px; }
.days button.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tasklist { display: grid; gap: 10px; }
.task { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.task.off { opacity: .6; }
.task .ti { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.task .ti .ico { width: 18px; height: 18px; }
.task h3 { margin: 0 0 2px; font-size: 15px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.task h3 span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task .sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.task .sub .err { color: var(--danger); }
.task .acts { display: flex; gap: 2px; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.mon { color: #d39b2a; border-color: color-mix(in srgb, #d39b2a 50%, var(--line)); }
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; border: 0; background: var(--line); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 19px; }
@media (max-width: 640px) { .task { grid-template-columns: minmax(0, 1fr); } .task .ti { display: none; } .seg { grid-auto-flow: row; } }

/* ---------- email settings ---------- */
.safe { display: flex; gap: 10px; padding: 12px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 12px; background: var(--accent-soft); font-size: 13px; color: var(--text); }
.safe .ico { color: var(--accent); flex: none; margin-top: 1px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; }
#em-status.ok { color: var(--accent); }
#em-status.err { color: var(--danger); }

/* ---------- email accounts ---------- */
.acc-list { display: grid; gap: 6px; }
.acc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.acc .ico { color: var(--accent); }
.acc .who { flex: 1; min-width: 0; display: grid; }
.acc .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc .who small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc .icon { width: 30px; height: 30px; }
.acc-form { display: grid; gap: 12px; border: 1px dashed var(--line); border-radius: 12px; padding: 14px; }
.acc-form h3 { margin: 0; font-size: 14px; }
.link-off { color: var(--muted); text-decoration: underline dotted; cursor: not-allowed; }
.link-off small { font-size: 11px; margin-left: 4px; }

/* ---------- memory & archive ---------- */
.mem-card { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 12px; background: var(--accent-soft); font-size: 14px; }
.mem-card .ico { color: var(--accent); flex: none; }
.mem-card .txt { flex: 1; min-width: 0; }
.mem-card .txt small { display: block; color: var(--muted); font-size: 12px; }
.mem-card.done { background: none; border-style: dashed; color: var(--muted); }
.mem-card button { padding: 5px 10px; font-size: 13px; }
.mem-list { display: grid; gap: 6px; }
.mem { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px; }
.mem .t { flex: 1; min-width: 0; }
.mem.pending { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.mem .tag { flex: none; }
.mem .icon { width: 28px; height: 28px; }
.mem-add { display: flex; gap: 8px; }
.mem-add input { flex: 1; }
.archive-link { display: flex; align-items: center; gap: 8px; width: calc(100% - 12px); margin: 8px 6px 0; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--muted); font-size: 13px; text-align: left; }
.archive-link:hover { background: var(--hover); color: var(--text); }

/* ---------- charts & diagrams ---------- */
figure.viz { margin: 0 0 .9em; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow-x: auto; }
figure.viz img.diagram { display: block; max-width: 100%; margin: 0 auto; cursor: zoom-in; }
.chart-box { position: relative; height: 320px; min-width: 280px; }

/* ---------- python sandbox ---------- */
.steps li.py-step { display: block; }
.steps li.py-step > div { display: flex; align-items: center; gap: 6px; }
.linkish { border: 0; background: none; color: var(--accent); font-size: 12px; padding: 0 4px; cursor: pointer; }
pre.code-view { margin: 6px 0 4px; padding: 10px 12px; background: var(--code); border: 1px solid var(--line); border-radius: 10px; font: 12px/1.5 var(--mono); overflow-x: auto; max-height: 360px; }
pre.code-view code.hljs { background: none; padding: 0; }
.out-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.out-files:empty { display: none; }
figure.viz.out { margin: 0; padding: 8px; max-width: 100%; }
figure.viz.out img { display: block; max-width: 100%; max-height: 520px; border-radius: 8px; cursor: zoom-in; }
figure.viz.out figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }

.notify-ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 16px; font-size: 13px; color: var(--muted); }
.notify-ctl .ico { color: var(--accent); }

/* ---------- login ---------- */
body.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login { width: min(380px, 100%); display: grid; gap: 14px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); text-align: center; }
.login img { margin: 0 auto; border-radius: 12px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 500; color: var(--muted); }
.login h1 b { color: var(--text); font-weight: 700; }
.login p { margin: 0; }
.login form { display: grid; gap: 12px; text-align: left; margin-top: 6px; }
.login input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none; }
.login input:focus { border-color: var(--accent); }
.login .primary { padding: 11px; margin-top: 4px; }
.login .login-err { color: var(--danger); font-size: 14px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line)); border-radius: 10px; padding: 8px 10px; }

#pw-status.ok, #lo-status.ok { color: var(--accent); }
#pw-status.err { color: var(--danger); }
.pane .fld input + input { margin-top: 0; }

/* ---------- share dialog & received copies ---------- */
dialog#sharedlg { width: min(520px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#sharedlg::backdrop { background: rgb(0 0 0 / .45); }
.people { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); text-align: left; }
.person span:not(.avatar) { flex: 1; }
.person .tick { opacity: 0; color: var(--accent); }
.person.on { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--accent-soft); }
.person.on .tick { opacity: 1; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; flex: none; background: #4fb393; }
.avatar[data-hue="1"] { background: #5b8def; } .avatar[data-hue="2"] { background: #e0a03c; } .avatar[data-hue="3"] { background: #d9665b; }
.avatar[data-hue="4"] { background: #9b7ede; } .avatar[data-hue="5"] { background: #4fb0c6; }
.shared-banner { max-width: 820px; margin: 0 auto 20px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.shared-banner .who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.shared-banner .who small { color: var(--muted); font-weight: 400; margin-left: auto; }
.shared-banner p { margin: 8px 0 0 38px; white-space: pre-wrap; color: var(--text); }
#sh-status.ok { color: var(--accent); } #sh-status.err { color: var(--danger); }

.primary:disabled, .primary[disabled] { opacity: .45; cursor: not-allowed; filter: saturate(.6); }
.share-done { display: grid; justify-items: center; gap: 10px; padding: 18px 8px 8px; text-align: center; }
.share-done > .ico { width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.share-done b { font-size: 16px; }
.share-done .primary { margin-top: 6px; min-width: 120px; }
.shared-log { max-width: 820px; margin: 0 auto 16px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.shared-log .ico { color: var(--accent); }

/* ---------- email card ---------- */
.mail-card { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.mail-card .mc-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.mail-card .mc-row > span:first-child { color: var(--muted); font-size: 13px; width: 52px; flex: none; }
.mail-card .mc-row input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); padding: 2px 0; }
.mc-from { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text); padding: 2px 0; }
.mc-from:disabled { cursor: default; }
.mc-body { display: block; width: 100%; min-height: 160px; border: 0; background: none; outline: none; resize: vertical; padding: 14px; color: var(--text); line-height: 1.55; font: inherit; }
.mc-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.mc-status { margin-right: auto; font-size: 12px; color: var(--muted); }
.mail-card.sent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.mail-card.sent .mc-status { color: var(--accent); }
.ghost.sm, .primary.sm { padding: 6px 12px; font-size: 13px; }
dialog#senddlg { width: min(560px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#senddlg::backdrop { background: rgb(0 0 0 / .45); }
.send-sum { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 14px; }
.send-sum dt { color: var(--muted); }
.send-sum dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; word-break: break-word; }
.addr { padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.addr.warn { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); font-weight: 600; }
#sd-warn { display: grid; gap: 6px; }
.sd-ok { align-self: start; }
#sd-status.err { color: var(--danger); }

/* ---------- start screen ---------- */
.empty.home { max-width: 760px; margin: 8vh auto 0; }
.empty.home h2 { font-size: 24px; margin-bottom: 18px; }
.sugg { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; text-align: left; }
.sugg-card { position: relative; display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; min-height: 76px; align-content: start; }
.sugg-card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.sugg-card .st { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.sugg-card .st .ico { color: var(--accent); }
.sugg-card .ss { font-size: 12px; color: var(--muted); }
.sugg-card .sx { position: absolute; top: 6px; right: 6px; padding: 3px; border-radius: 6px; color: var(--muted); opacity: 0; }
.sugg-card:hover .sx { opacity: 1; }
.sugg-card .sx:hover { background: var(--hover); color: var(--text); }
.home .linkish { margin-top: 10px; }
.start-sec { margin-top: 22px; text-align: left; }
.start-sec .group { padding-left: 2px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-row .chip { padding: 6px 12px 6px 10px; }
.chips-row .chip .ico { color: var(--accent); }
.recent { display: grid; gap: 2px; }
.recent-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 10px; color: var(--text); text-align: left; }
.recent-item:hover { background: var(--hover); }
.recent-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item small { color: var(--muted); }
.recent-item .ico { color: var(--muted); }
/* ---------- stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tile b { font-size: 20px; }
.tile span { font-size: 13px; color: var(--muted); }
.tile small { font-size: 11px; color: var(--muted); }
.chart-box.small { height: 180px; }
.tool-bars { display: grid; gap: 6px; }
.tb { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 8px; font-size: 13px; }
.tb .bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.tb .bar i { display: block; height: 100%; background: var(--accent); }
.tb b { text-align: right; }
.users-table { width: 100%; }
#stats-box { display: grid; gap: 10px; }

.health-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: color-mix(in srgb, var(--danger) 18%, var(--panel)); color: var(--text); font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); }
.health-bar .ico { color: var(--danger); }

/* meetings */
.badge.warn { background: var(--danger); color: #fff; }
.mtabs { margin: -6px 0 16px; }
.pv-search { margin: 0 0 14px; max-width: 460px; }
.mlist { display: grid; gap: 10px; }
.mrow { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; align-items: start; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
.mrow:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.mday { display: grid; place-content: center; justify-items: center; gap: 3px; width: 52px; height: 52px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); line-height: 1; }
.mday b { font-size: 19px; }
.mday small { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.mrow h3 { margin: 0 0 4px; font-size: 15px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.mrow h3 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow p { margin: 0 0 6px; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mrow p.err { color: var(--danger); }
.mrow .sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.mrow .sub span { display: inline-flex; align-items: center; gap: 4px; }
.tag.late { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
.mwait { display: flex; gap: 14px; align-items: center; padding: 22px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.mwait > div { flex: 1; }
.mwait.err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.mmeta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted); margin: 4px 0 4px -6px; }
.mmeta label { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding-left: 6px; }
.mmeta label.grow { flex: 1; min-width: 200px; }
.mmeta input { border: 1px solid transparent; background: none; border-radius: 8px; padding: 4px 6px; color: var(--text); outline: none; font: inherit; min-width: 0; }
.mmeta input.mpeople { flex: 1; }
.mmeta input:hover, .mmeta input:focus { border-color: var(--line); background: var(--surface); }
.msec { margin: 22px 0 0; }
.msec > h3, .msec > summary { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.msec > h3 small { font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: auto; }
.msec > h3 .icon { width: 26px; height: 26px; margin-left: auto; opacity: .6; }
.msec > h3 small + .icon, .msec > h3 .icon + small { margin-left: 0; }
.msec > h3 .icon:hover { opacity: 1; }
.msec.late > h3 { color: var(--danger); }
.msec ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; line-height: 1.5; }
.msec > summary { cursor: pointer; list-style: none; }
.msec > summary::before { content: "▸"; font-size: 11px; }
.msec[open] > summary::before { content: "▾"; }
.medit textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px; outline: none; resize: vertical; font: inherit; color: var(--text); line-height: 1.5; }
.medit textarea:focus { border-color: var(--accent); }
.medit .foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.medit .foot small { margin-right: auto; }
.msum { display: block; width: calc(100% + 12px); border: 1px solid transparent; background: none; border-radius: 8px; padding: 6px; margin-left: -6px; resize: none; overflow: hidden; color: var(--text); font: inherit; line-height: 1.6; outline: none; }
.msum:hover, .msum:focus { border-color: var(--line); background: var(--surface); }
.mitems { display: grid; gap: 2px; }
.mitem { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 6px 6px; border-radius: 10px; }
.mitem:hover { background: var(--hover); }
.mitem .chk { border: 0; background: none; color: var(--muted); padding: 4px; border-radius: 50%; display: grid; }
.mitem .chk:hover { color: var(--accent); }
.mitem.done .chk { color: var(--accent); }
.mitem.done .mi-text { text-decoration: line-through; color: var(--muted); }
.mi-text { display: block; width: calc(100% + 6px); border: 1px solid transparent; background: none; border-radius: 6px; padding: 3px 6px; margin-left: -6px; font: inherit; line-height: 1.45; color: var(--text); outline: none; resize: none; overflow: hidden; }
.mi-text:focus { border-color: var(--line); background: var(--surface); }
.mi-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; font-size: 12px; color: var(--muted); }
.mi-meta input { border: 1px solid transparent; background: none; border-radius: 6px; padding: 1px 4px; font: inherit; color: inherit; outline: none; }
.mi-meta input:hover, .mi-meta input:focus { border-color: var(--line); background: var(--surface); color: var(--text); }
.mi-meta .ico { margin-left: 6px; }
.mi-meta .ico:first-child { margin-left: 0; }
.mi-due { width: 8.5em; }
.mi-owner.mine { color: var(--accent); font-weight: 600; }
.mi-due:invalid:not(:focus) { color: transparent; width: 2.6em; cursor: pointer; }
.mitem.late .mi-due { color: var(--danger); font-weight: 600; }
.mi-meet { border: 0; background: none; color: var(--muted); padding: 1px 4px; margin-left: 6px; border-radius: 6px; font: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.mi-meet:hover { color: var(--text); background: var(--surface); }
.mitem .acts { display: flex; }
.mitem .acts .icon { width: 28px; height: 28px; }
.mitem .acts .icon.on { color: var(--accent); }
@media (hover: hover) {
  .mitem .acts .icon:not(.on) { opacity: 0; }
  .mitem:hover .acts .icon, .mitem .acts .icon:focus-visible { opacity: 1; }
}
.madd { display: grid; grid-template-columns: minmax(0, 1fr) 130px 150px auto; gap: 8px; margin-top: 10px; }
.madd input { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 7px 10px; outline: none; color: var(--text); font: inherit; min-width: 0; }
.madd input:focus { border-color: var(--accent); }
.mchips { display: flex; flex-wrap: wrap; gap: 6px; }
.mchips span { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.side-card p { margin: 0; font-size: 13px; line-height: 1.5; }
.side-card details summary { cursor: pointer; font-size: 13px; color: var(--accent); }
.msrc { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; max-height: 460px; overflow: auto; background: var(--bg); border-radius: 8px; padding: 10px; margin: 8px 0 0; }
.mbar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 4px; }
.mnames { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.mnames input { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 5px 9px; outline: none; color: var(--text); font: inherit; width: 220px; }
.mnames input:focus { border-color: var(--accent); }
.mdone { margin-top: 26px; }
dialog#meetdlg { width: min(760px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#meetdlg::backdrop { background: rgb(0 0 0 / .45); }
.grid2.wide { grid-template-columns: minmax(0, 1fr) 170px; }
#md-text { min-height: 220px; font-size: 14px; line-height: 1.5; }
#md-text.drag { border-color: var(--accent); background: var(--accent-soft); }
.filebtn { cursor: pointer; }
@media (max-width: 1100px) { .proj.meet { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .madd { grid-template-columns: 1fr 1fr; }
  .madd input:first-child { grid-column: 1 / -1; }
  .grid2.wide { grid-template-columns: 1fr; }
  .mnames input { width: 100%; }
}

/* connectors, redmine */
.conn-h { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 18px 0 2px; }
.conn-h:first-of-type { margin-top: 6px; }
.conn-h .ico { color: var(--accent); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid3.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dlg select { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 10px; padding: 9px 10px; outline: none; font: inherit; }
.dlg select:focus { border-color: var(--accent); }
#rd-create, #rd-update { display: grid; gap: 14px; }
#rd-create[hidden], #rd-update[hidden] { display: none; }
.rd-issue { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; }
dialog#rmdlg { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgb(0 0 0 / .4); }
dialog#rmdlg::backdrop { background: rgb(0 0 0 / .45); }
.rm-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin: 8px 0; overflow: hidden; }
.rm-card.sent { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.rm-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rm-head .ico { color: var(--accent); }
.rm-head .muted { margin-left: auto; font-size: 12px; text-align: right; }
.rm-body { padding: 12px 14px; display: grid; gap: 8px; }
.rm-subj { font-weight: 600; }
.rm-desc { white-space: pre-wrap; font-size: 14px; line-height: 1.5; color: var(--text); max-height: 260px; overflow: auto; }
.rm-meta { font-size: 13px; color: var(--muted); }
.rm-card .mc-foot { padding: 8px 14px 12px; }
.rm-card a.ghost { text-decoration: none; }
.mi-rm { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; color: var(--accent); text-decoration: none; font-weight: 600; padding: 1px 4px; border-radius: 6px; }
.mi-rm:hover { background: var(--surface); }
@media (max-width: 640px) { .grid3, .grid3.four { grid-template-columns: 1fr 1fr; } }

/* companies */
.co-search { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); max-width: 620px; color: var(--muted); }
.co-search:focus-within { border-color: var(--accent); }
.co-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text); font: inherit; font-size: 15px; padding: 8px 0; }
.co-hint { max-width: 620px; font-size: 13px; line-height: 1.5; margin: 10px 0 26px; }
.co-list-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.co-list-head h2 { font-size: 15px; margin: 0; flex: 1; }
.co-list { display: grid; gap: 8px; }
.co-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.co-row:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.co-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.co-main { display: grid; gap: 2px; text-align: left; border: 0; background: none; color: var(--text); padding: 0; min-width: 0; }
.co-main b, .co-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-main span { font-size: 12px; }
.co-tags { display: flex; gap: 6px; }
.tag.warn { color: #d39b2a; border-color: color-mix(in srgb, #d39b2a 50%, var(--line)); }
.tag.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.co-top { margin-bottom: 18px; display: grid; gap: 6px; }
.co-name { font-size: 24px; margin: 0; }
.co-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip3 { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip3.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); }
.chip3.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); }
.chip3.warn { color: #d39b2a; border-color: color-mix(in srgb, #d39b2a 50%, var(--line)); }
.co-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.kpi { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.kpi span { font-size: 12px; color: var(--muted); }
.kpi b { font-size: 19px; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 12px; }
.kpi small.up { color: var(--accent); }
.kpi small.down { color: var(--danger); }
.co-signals { display: grid; gap: 6px; }
.sig { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 10px; font-size: 14px; line-height: 1.45; background: var(--surface); border: 1px solid var(--line); }
.sig .ico { flex: none; margin-top: 2px; }
.sig.high { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.sig.high .ico { color: var(--danger); }
.sig.medium .ico { color: #d39b2a; }
.sig.info .ico { color: var(--muted); }
.sig.good .ico { color: var(--accent); }
.co-note { font-size: 12px; margin: 8px 0 0; }
.co-chart { position: relative; height: 260px; }
.co-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.co-table table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.co-table th, .co-table td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.co-table th:first-child, .co-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
.co-table tr:last-child td { border-bottom: 0; }
.co-table td.neg { color: var(--danger); }
.co-table tr.sep td { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); }
.co-table.cmp td, .co-table.cmp th { text-align: left; }
.co-table.cmp th .linkish { font-weight: 700; color: var(--text); white-space: normal; text-align: left; }
.co-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 13px; }
.co-dl dt { color: var(--muted); }
.co-dl dd { margin: 0; overflow-wrap: anywhere; }
.co-grid { margin-top: 6px; }
@media (max-width: 1100px) { .proj.co-grid { grid-template-columns: minmax(0, 1fr); } }
.co-grid > div { min-width: 0; }

/* security */
.sec-status { margin: -12px 0 16px; font-size: 13px; }
.sec-grid { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1100px) { .proj.sec-grid { grid-template-columns: minmax(0, 1fr); } .sec-grid > div:last-child { order: -1; } }
.sec-grid > div { min-width: 0; }
.sec-items { display: grid; gap: 4px; }
.sec-item { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto; gap: 8px; align-items: center; padding: 4px 0; }
.si-name { display: grid; min-width: 0; }
.si-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-name small { font-size: 11px; }
.si-ver, .sec-add input, .sec-add select, .sec-key { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 8px; color: var(--text); font: inherit; outline: none; min-width: 0; width: 100%; }
.si-ver:focus, .sec-add input:focus, .sec-key:focus { border-color: var(--accent); }
.sec-add { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 6px; }
.sec-add select { grid-column: 1; }
.sec-add .primary { grid-column: 2; }
.side-card > small { font-size: 12px; line-height: 1.45; }
.sec-hits { display: grid; gap: 8px; margin-top: 8px; }
.hit { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.hit.new { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.sev { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--bg); color: var(--muted); }
.sev b { font-size: 18px; font-variant-numeric: tabular-nums; }
.sev small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.sev.crit { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.sev.high { background: color-mix(in srgb, #e07b39 22%, transparent); color: #e07b39; }
.sev.med { background: color-mix(in srgb, #d39b2a 18%, transparent); color: #d39b2a; }
.hit-main { display: grid; gap: 6px; min-width: 0; }
.hit-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.hit-id { font-weight: 700; color: var(--text); text-decoration: none; font-family: var(--mono); font-size: 13px; }
.hit-id:hover { color: var(--accent); }
.hit-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.hit-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; overflow-wrap: anywhere; }
.hit-desc.open { display: block; color: var(--text); }
.hit .acts { display: flex; flex-direction: column; }
.hit .acts .icon { width: 30px; height: 30px; }

/* news */
.news-grid { grid-template-columns: minmax(0, 1fr) 320px; }
.news-grid > div { min-width: 0; }
@media (max-width: 1100px) { .proj.news-grid { grid-template-columns: minmax(0, 1fr); } }
.digest { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 14px; background: var(--surface); padding: 14px 16px; margin-bottom: 18px; }
.dg-head { display: flex; align-items: center; gap: 8px; }
.dg-head .ico { color: var(--accent); }
.dg-head .icon { width: 28px; height: 28px; }
.dg-lead { font-size: 15px; line-height: 1.55; margin: 8px 0 4px; }
.dg-sec h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dg-sec ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.dg-t a { color: var(--text); font-weight: 600; text-decoration: none; }
.dg-t a:hover { color: var(--accent); text-decoration: underline; }
.dg-t .muted { font-size: 12px; }
.dg-why { font-size: 13px; color: var(--muted); line-height: 1.5; }
.news-bar { justify-content: space-between; }
.news-search { margin: 0; flex: 1; min-width: 180px; max-width: 300px; }
.news-bar .seg button { display: inline-flex; align-items: center; gap: 4px; }
.news-list { display: grid; gap: 2px; margin-top: 6px; }
.news-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px 8px; border-radius: 10px; border-bottom: 1px solid var(--line); }
.news-item:hover { background: var(--hover); }
.news-item.hot { border-left: 3px solid var(--accent); padding-left: 10px; }
.ni-title { color: var(--text); font-weight: 600; text-decoration: none; line-height: 1.4; }
.ni-title:hover { color: var(--accent); }
.ni-title:visited { color: var(--muted); }
.ni-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 3px; align-items: center; }
.ni-sum { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.news-item .acts { display: flex; flex-direction: column; }
.news-item .acts .icon { width: 28px; height: 28px; }
.news-item .acts .icon.on { color: #d39b2a; }
@media (hover: hover) { .news-item .acts .icon:not(.on) { opacity: 0; } .news-item:hover .acts .icon { opacity: 1; } }
.src-group h4 { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.src-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.src-row.off .src-name { color: var(--muted); }
.src-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-name.err { color: var(--danger); }
.src-row .icon { width: 24px; height: 24px; }
.src-row .switch { transform: scale(.8); transform-origin: left center; }

/* sharing */
.chip3.shared { display: inline-flex; align-items: center; gap: 4px; color: #7f9cf5; border-color: color-mix(in srgb, #7f9cf5 45%, var(--line)); }
.shared-line { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.share-cur { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.share-cur span { flex: 1; }
