/* Context menu, modals, viewer, skills/connectors managers, toast. */
/* context menu */
.cmenu { position: fixed; z-index: 50; min-width: 170px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--menu-shadow); padding: 4px; display: none; }
.cmenu.open { display: block; }
.cmenu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.cmenu button:hover { background: var(--panel-2); }
.cmenu button.danger { color: var(--err); }
.cmenu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }

/* modals */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 40; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border-radius: 14px; padding: 20px; width: 100%; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.25); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { max-width: 980px; height: min(760px, calc(100vh - 32px)); padding: 0; }
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal p { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.field input, .field textarea, .modal input.plain { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.field textarea { resize: vertical; min-height: 80px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.err-text { color: var(--err); font-size: 13px; min-height: 1em; margin: -4px 0 10px; }
.mhead { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.mhead .ttl { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbody { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
.editor { width: 100%; height: 100%; min-height: 300px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); padding: 12px; font-family: "JetBrains Mono", monospace; font-size: 12.5px; line-height: 1.6; resize: none; outline: none; }
.viewer-pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.viewer-img { max-width: 100%; border-radius: 8px; display: block; margin: 0 auto; }
.mbody.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pdf-pages { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.pdf-page { width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.25); }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 3px 10px; font-size: 12.5px; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); font-weight: 600; }
.frame-note { padding: 6px 12px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--border); }

/* skills manager */
.skills-layout { display: grid; grid-template-columns: 260px 1fr; flex: 1; min-height: 0; }
.skills-list { border-right: 1px solid var(--border); overflow-y: auto; padding: 8px; }
.skill-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.skill-item:hover { background: var(--panel-2); }
.skill-item.active { background: var(--user-bg); }
.skill-item .n { font-weight: 600; font-family: "JetBrains Mono", monospace; font-size: 13px; }
.skill-item .d { color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.skill-edit { display: flex; flex-direction: column; min-height: 0; padding: 14px 16px; gap: 10px; overflow-y: auto; }
.skill-edit .editor { flex: 1; min-height: 260px; }
.skill-files { border: 1px solid var(--border); border-radius: 8px; padding: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 9; display: none; }
.backdrop.open { display: block; }

/* Workspace settings modal */
.ws-settings { max-width: 760px; height: min(820px, calc(100vh - 32px)); }
.ws-settings .mbody { padding: 0 18px; }
.ws-sec { padding: 16px 0; border-bottom: 1px solid var(--border); }
.ws-sec:last-child { border-bottom: 0; }
.ws-sec-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.ws-sec-head b { font-size: 14px; }
.ws-mode { margin-bottom: 6px; }
.ws-mode-help { margin-bottom: 8px; }
.ws-prompt { min-height: 220px; height: 260px; resize: vertical; margin-bottom: 4px; }
.ws-radio { display: flex; align-items: flex-start; gap: 9px; padding: 7px 4px; cursor: pointer; font-size: 13px; }
.ws-radio input { margin-top: 3px; }
.ws-radio span { display: flex; flex-direction: column; }
.ws-radio em { font-style: normal; color: var(--muted); font-size: 12px; }
.ws-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px 12px; margin: 4px 0 0 26px; }
.ws-checks.ws-tools { margin-left: 0; }
.ws-checks.disabled { opacity: .45; }
.ws-check { display: flex; align-items: baseline; gap: 7px; padding: 5px 4px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.ws-check:hover { background: var(--panel-2); }
.ws-check .note { font-size: 11.5px; }
.ws-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.ws-foot .err-text { flex: 1; margin: 0; }
.ws-ret-custom input[type="number"] { width: 72px; margin: 0 4px; padding: 3px 6px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.ws-ret-custom input[type="number"]:disabled { opacity: .5; }
