/* ============================================================
   CKN Works — default theme (compact)
   3-column shell: [ left menu | center work area | right chat ]
   Left and right panels can be hidden/shown (all screen sizes).
   NOTE: styles live here (not inline in the EJS) because the app's
   CSP is `style-src 'self'` — inline <style> is blocked.
   ============================================================ */

:root {
    --ckn-primary: #991b1b;        /* dark red  */
    --ckn-primary-dark: #7f1d1d;   /* dark red — hover / active */
    --ckn-primary-soft: #fef2f2;   /* red tint */
    --ckn-sidebar: #f7f7f8;        /* light gray */
    --ckn-border: #e5e7eb;         /* gray */
    --ckn-work-bg: #ffffff;        /* white */
    --ckn-chat-bg: #fafafa;        /* off-white gray */
    --ckn-ink: #171717;            /* near black */
    --ckn-muted: #6b7280;          /* gray */
    --ckn-menu-w: 220px;
    --ckn-menu-rail-w: 56px;       /* collapsed left menu: logo + icons only */
    --ckn-chat-w: 336px;
}

* {
    font-family: 'Prompt', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans Thai', sans-serif;
}

html { font-size: 15px; }               /* global compaction */
html, body { height: 100%; }
body { margin: 0; overflow: hidden; color: var(--ckn-ink); background: #fff; }

.app-shell { display: flex; height: 100vh; position: relative; }

/* icon-only ghost button used for panel toggles */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent;
    background: transparent; color: var(--ckn-muted); cursor: pointer; font-size: 1rem; line-height: 1;
}
.icon-btn:hover { background: #eef0f2; color: var(--ckn-ink); }

/* Bootstrap primary → red tone (Bootstrap 5.0.2 uses hard-coded blue; override it) */
.btn-primary { background-color: var(--ckn-primary); border-color: var(--ckn-primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background-color: var(--ckn-primary-dark); border-color: var(--ckn-primary-dark); color: #fff; }
.btn-outline-primary { color: var(--ckn-primary); border-color: var(--ckn-primary); }
.btn-outline-primary:hover, .btn-outline-primary:active { background-color: var(--ckn-primary); border-color: var(--ckn-primary); color: #fff; }
.btn-primary:focus, .btn-outline-primary:focus { box-shadow: 0 0 0 .2rem rgba(153, 27, 27, .3); }
.text-bg-light { color: var(--ckn-ink) !important; }

/* ============================================================
   LEFT: menu panel
   ============================================================ */
.side-panel {
    width: var(--ckn-menu-w); flex: 0 0 var(--ckn-menu-w);
    background: var(--ckn-sidebar);
    border-right: 1px solid var(--ckn-border);
    display: flex; flex-direction: column;
}
.side-brand {
    display: flex; align-items: center; gap: .5rem;
    padding: .65rem .55rem .65rem .8rem; border-bottom: 1px solid var(--ckn-border);
}
.side-brand .brand-logo { height: 26px; width: auto; flex: 0 0 auto; display: block; }
.side-brand .brand-name { font-weight: 600; line-height: 1.1; font-size: .92rem; }
.side-brand .brand-sub { font-size: .68rem; color: var(--ckn-muted); }
.side-brand .brand-text { flex: 1 1 auto; min-width: 0; }

.side-nav { flex: 1 1 auto; overflow-y: auto; padding: .5rem .45rem; }
.side-nav .nav-label {
    font-size: .64rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--ckn-muted); padding: .45rem .5rem .25rem;
}
.side-nav a.menu-item {
    display: flex; align-items: center; gap: .55rem;
    padding: .42rem .5rem; margin-bottom: 1px; border-radius: 7px;
    color: #374151; text-decoration: none; font-size: .85rem;
}
.side-nav a.menu-item .ico { width: 1.1rem; text-align: center; font-size: .95rem; }
.side-nav a.menu-item:hover { background: #eef0f2; color: var(--ckn-ink); }
.side-nav a.menu-item.active { background: var(--ckn-primary-soft); color: var(--ckn-primary); font-weight: 500; }

.side-foot {
    border-top: 1px solid var(--ckn-border); padding: .55rem .8rem;
    display: flex; align-items: center; gap: .55rem; font-size: .8rem;
}
.side-foot .avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
    background: #e5e7eb; color: #374151; font-weight: 600;
    display: flex; align-items: center; justify-content: center; font-size: .72rem;
}
.side-foot .who { line-height: 1.1; overflow: hidden; flex: 1 1 auto; min-width: 0; }
.side-foot .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who small { color: var(--ckn-muted); font-size: .72rem; }

/* ============================================================
   CENTER: work area (the main workspace)
   ============================================================ */
.work-panel {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column; background: var(--ckn-work-bg);
}
.work-header {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .5rem .8rem; border-bottom: 1px solid var(--ckn-border); background: #fff;
}
.work-header .wh-left, .work-header .wh-right { display: flex; align-items: center; gap: .5rem; }
.work-header .title { font-weight: 600; line-height: 1.05; font-size: .95rem; }
.work-header .subtitle { font-size: .72rem; color: var(--ckn-muted); }

.work-body { flex: 1 1 auto; overflow-y: auto; padding: 1.4rem 1.25rem; }
.work-inner { max-width: 920px; margin: 0 auto; }

.work-hero h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 .25rem; }
.work-hero p { color: var(--ckn-muted); margin: 0; font-size: .88rem; }

.quick-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem; margin-top: 1.25rem;
}
.quick-card {
    border: 1px solid var(--ckn-border); border-radius: 12px; padding: .9rem;
    background: #fff; text-decoration: none; color: inherit; display: block;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.quick-card:hover {
    border-color: var(--ckn-primary);
    box-shadow: 0 6px 16px rgba(153, 27, 27,.10); transform: translateY(-2px);
}
.quick-card .qc-ico {
    width: 38px; height: 38px; border-radius: 10px; background: var(--ckn-primary-soft);
    color: var(--ckn-primary);
    display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.quick-card .qc-title { font-weight: 600; margin-top: .55rem; font-size: .92rem; }
.quick-card .qc-desc { font-size: .8rem; color: var(--ckn-muted); margin-top: .15rem; line-height: 1.4; }

/* ============================================================
   RIGHT: chat assistant (fixed column)
   ============================================================ */
.chat-panel {
    width: var(--ckn-chat-w); flex: 0 0 var(--ckn-chat-w);
    border-left: 1px solid var(--ckn-border);
    display: flex; flex-direction: column; background: var(--ckn-chat-bg);
}
.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem .55rem .5rem .85rem; border-bottom: 1px solid var(--ckn-border); background: #fff;
}
.chat-header .title { font-weight: 600; font-size: .9rem; }
.chat-header .subtitle { font-size: .7rem; color: var(--ckn-muted); }
.chat-header .ch-actions { display: flex; align-items: center; gap: .1rem; }
/* right-panel tabs: Assistant | Claude Code */
.chat-tabs { display: flex; gap: .15rem; min-width: 0; }
.chat-tab { display: inline-flex; align-items: center; gap: .35rem; border: 0; background: transparent; color: var(--ckn-muted); font-size: .82rem; font-weight: 500; padding: .3rem .5rem; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.chat-tab:hover { background: #eef0f2; color: var(--ckn-ink); }
.chat-tab.active { color: var(--ckn-primary); background: var(--ckn-primary-soft); font-weight: 600; }
/* each tab's body fills the panel below the header; only the active one shows */
.chat-section { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* Claude Code tab: model/effort bar + streamed task bubbles */
.cc-bar { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; padding: .5rem .6rem; border-bottom: 1px solid var(--ckn-border); background: var(--ckn-sidebar); }
.cc-field { display: flex; flex-direction: column; gap: .12rem; font-size: .62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ckn-muted); font-weight: 600; }
.cc-field select { width: auto; min-width: 90px; }
.cc-progress { margin-left: auto; align-self: center; font-size: .72rem; color: var(--ckn-muted); }
.cc-progress.err { color: var(--ckn-primary); }
.cc-hint { text-align: center; color: var(--ckn-muted); padding: 1.6rem 1rem; }
.cc-hint .bi { font-size: 1.8rem; opacity: .5; display: block; margin-bottom: .5rem; }
.cc-hint p { font-size: .82rem; line-height: 1.5; margin: 0; }
.cc-task .bubble { width: 100%; }
.cc-task-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .35rem; }
.cc-task-name { font-weight: 600; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-task-spacer { flex: 1 1 auto; }
.cc-task-out { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .73rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; margin: 0; color: var(--ckn-ink); }
.cc-task-out.err { color: var(--ckn-primary); }
.cc-plan { width: 100%; }
.cc-plan-head { font-weight: 600; font-size: .8rem; margin-bottom: .4rem; }
.cc-plan-list { list-style: none; margin: 0 0 .3rem; padding: 0; }
.cc-plan-list li { display: flex; flex-direction: column; padding: .2rem 0; border-top: 1px solid var(--ckn-border); }
.cc-plan-list li:first-child { border-top: none; }
.cc-plan-name { font-size: .78rem; font-weight: 500; }
.cc-plan-list.run .cc-plan-name { color: var(--ckn-ink); }
.cc-plan-list.skip .cc-plan-name { color: var(--ckn-muted); }
.cc-plan-reason { font-size: .7rem; color: var(--ckn-muted); line-height: 1.35; margin-top: .05rem; }
.cc-files { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .35rem; }
.cc-files-label { flex: 1 0 100%; font-size: .7rem; font-weight: 600; color: var(--ckn-muted); margin-bottom: .1rem; }
.cc-file {
    display: inline-flex; align-items: center; gap: .3rem; max-width: 100%;
    font-size: .74rem; text-decoration: none;
    color: var(--ckn-primary); background: var(--ckn-primary-soft);
    border: 1px solid rgba(153, 27, 27, .25); border-radius: 6px; padding: .12rem .45rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cc-file:hover { background: var(--ckn-primary); color: #fff; border-color: var(--ckn-primary); }
.cc-file .bi { font-size: .8rem; }
.cc-meta { font-size: .68rem; color: var(--ckn-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; margin-right: .35rem; }
.status-dot.thinking { background: var(--ckn-primary); animation: ckn-pulse 1s ease-in-out infinite; }
@keyframes ckn-pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* typing indicator + error bubble */
.bubble .typing { display: inline-flex; gap: .22rem; align-items: center; }
.bubble .typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ckn-muted); display: inline-block; animation: ckn-blink 1.2s infinite both; }
.bubble .typing i:nth-child(2) { animation-delay: .2s; }
.bubble .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes ckn-blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }
.bubble .err { color: var(--ckn-primary); }

.chat-messages { flex: 1 1 auto; overflow-y: auto; padding: .85rem; }
.chat-inner { display: flex; flex-direction: column; }

.msg { display: flex; gap: .5rem; margin-bottom: .8rem; }
.msg .bubble {
    padding: .55rem .75rem; border-radius: 11px; font-size: .85rem; line-height: 1.45;
    max-width: 85%; box-shadow: 0 1px 2px rgba(16,24,40,.05); word-wrap: break-word;
}
.msg .msg-avatar {
    width: 27px; height: 27px; border-radius: 7px; flex: 0 0 27px;
    display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 600;
}
.msg.assistant .msg-avatar { background: var(--ckn-primary); color: #fff; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--ckn-border); }
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-avatar { background: #e5e7eb; color: #374151; }
.msg.user .bubble { background: var(--ckn-primary); color: #fff; }

.suggestions { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .5rem 1.85rem; }
.suggestions .chip {
    display: inline-flex; align-items: center; gap: .3rem;
    border: 1px solid var(--ckn-border); background: #fff; border-radius: 18px;
    padding: .25rem .6rem; font-size: .77rem; color: #374151; cursor: pointer; text-align: left;
}
.suggestions .chip:hover { border-color: var(--ckn-primary); color: var(--ckn-primary); }

.chat-input { border-top: 1px solid var(--ckn-border); background: #fff; padding: .6rem; }
.chat-input textarea {
    resize: none; border-radius: 10px; border: 1px solid var(--ckn-border);
    padding: .5rem .7rem; max-height: 140px; font-size: .85rem;
}
.chat-input textarea:focus { border-color: var(--ckn-primary); box-shadow: 0 0 0 .2rem rgba(153, 27, 27,.12); }
.chat-input .send-btn { border-radius: 9px; }
.chat-input .hint { font-size: .7rem; color: var(--ckn-muted); text-align: center; margin-top: .35rem; }

/* ============================================================
   Hide / show panels (works at all widths)
   ============================================================ */
/* Animate the open/close of both side panels. `.anim-ready` is added a frame after
   load (JS) so the initial state paints without a slide. Transitions are suppressed
   while dragging a resizer (that updates width live via CSSOM — see body.is-resizing). */
.app-shell.anim-ready .side-panel,
.app-shell.anim-ready .chat-panel {
    transition: width .24s ease, flex-basis .24s ease, opacity .2s ease, transform .24s ease;
}
body.is-resizing .side-panel, body.is-resizing .chat-panel { transition: none !important; }

/* Chat "hidden" = collapse to zero width (animatable) rather than display:none. */
.app-shell.chat-hidden .chat-panel {
    width: 0; flex-basis: 0; opacity: 0; overflow: hidden; border-left: none;
}

/* Left menu "hidden" = collapsed to a narrow icon rail (keeps the CKN logo + nav
   icons visible). On narrow screens it fully hides instead — see the media query. */
.app-shell.menu-hidden .side-panel {
    width: var(--ckn-menu-rail-w); flex: 0 0 var(--ckn-menu-rail-w); overflow: hidden;
}
/* rail brand: stack the logo above the (now expand) toggle; drop the wordmark */
.app-shell.menu-hidden .side-brand {
    flex-direction: column; gap: .4rem; padding: .55rem .3rem;
}
.app-shell.menu-hidden .side-brand .brand-text { display: none; }
.app-shell.menu-hidden #menuHide i { transform: rotate(180deg); }   /* chevron points right → expand */
/* rail nav: center each icon, hide labels + section headers */
.app-shell.menu-hidden .side-nav { padding: .5rem .25rem; }
.app-shell.menu-hidden .side-nav .nav-label { display: none; }
.app-shell.menu-hidden .side-nav a.menu-item { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
.app-shell.menu-hidden .side-nav a.menu-item .mi-label { display: none; }
/* rail footer: keep the avatar, drop the name + sign-out */
.app-shell.menu-hidden .side-foot { justify-content: center; padding: .55rem .3rem; }
.app-shell.menu-hidden .side-foot .who,
.app-shell.menu-hidden .side-foot > a.icon-btn { display: none; }

/* When the chat is closed, let the work content use the full available width
   (default caps it at 920px centered for readability while both panels are open). */
.app-shell.chat-hidden .work-inner { max-width: none; }

/* "show chat" button in the work header only appears when chat is hidden */
#showChatBtn { display: none; }
.app-shell.chat-hidden #showChatBtn { display: inline-flex; }

/* full-screen chat assistant (toggled from the chat header) */
.app-shell.chat-full .chat-panel {
    position: fixed; inset: 0; width: 100%; z-index: 1050; border-left: none;
}
.app-shell.chat-full .resizer-chat { display: none; }
.app-shell.chat-full .chat-inner,
.app-shell.chat-full .chat-input .composer {
    max-width: 820px; width: 100%; margin-left: auto; margin-right: auto;
}

/* backdrop for overlay mode (narrow screens) */
.panel-backdrop { display: none; position: fixed; inset: 0; z-index: 1030; background: rgba(15,23,42,.35); }

/* ============================================================
   Login page (/login) — standalone, no 3-column shell
   ============================================================ */
.login-body { background: var(--ckn-sidebar); overflow: auto; }
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card {
    width: 100%; max-width: 360px; background: #fff;
    border: 1px solid var(--ckn-border); border-radius: 14px; padding: 1.7rem 1.5rem;
    box-shadow: 0 10px 30px rgba(16,24,40,.08);
}
.login-brand { text-align: center; margin-bottom: 1.1rem; }
.login-logo { height: 40px; width: auto; }
.login-title { font-weight: 700; font-size: 1.1rem; margin-top: .5rem; }
.login-sub { font-size: .74rem; color: var(--ckn-muted); }
.login-form { display: flex; flex-direction: column; }
.login-label { font-size: .74rem; color: var(--ckn-muted); margin: .6rem 0 .2rem; }
.login-form .form-control { font-size: .9rem; }
.login-form .form-control:focus { border-color: var(--ckn-primary); box-shadow: 0 0 0 .2rem rgba(153, 27, 27,.12); }
.login-btn { margin-top: 1.15rem; width: 100%; }
.login-error {
    background: var(--ckn-primary-soft); color: var(--ckn-primary-dark);
    border: 1px solid #fecaca; border-radius: 8px; padding: .5rem .7rem; font-size: .8rem; margin-bottom: .5rem;
}

/* ============================================================
   Agents management page (/agents)
   ============================================================ */
.agents-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.agents-title { font-size: 1.15rem; font-weight: 600; margin: 0; }
.agents-sub { font-size: .82rem; color: var(--ckn-muted); margin: .15rem 0 0; }
/* Sub-group tabs + group-scoped tools on the Projects page */
.proj-tabs { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .85rem; border-bottom: 1px solid var(--ckn-border); padding-bottom: .5rem; }
.proj-tabs-list { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; min-width: 0; }
.proj-tabs-actions { display: flex; align-items: center; gap: .35rem; }
.proj-tabs-scope { font-size: .72rem; color: var(--ckn-muted); display: inline-flex; align-items: center; gap: .25rem; margin-right: .1rem; white-space: nowrap; }
.proj-tab-wrap { display: inline-flex; align-items: center; border-radius: 8px; }
.proj-tab-wrap.active { background: var(--ckn-primary-soft); }
.proj-tab { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: transparent; color: var(--ckn-muted); font-size: .85rem; font-weight: 500; padding: .35rem .6rem; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.proj-tab:hover { color: var(--ckn-ink); background: #eef0f2; }
.proj-tab-wrap.active .proj-tab, .proj-tab.active { color: var(--ckn-primary); font-weight: 600; background: transparent; }
.proj-tab-count { font-size: .68rem; font-weight: 600; color: var(--ckn-muted); background: #f3f4f6; border-radius: 20px; padding: 0 .4rem; min-width: 1.1rem; text-align: center; }
.proj-tab-wrap.active .proj-tab-count { color: var(--ckn-primary); background: #fff; }
.proj-tab-edit { border: 0; background: transparent; color: var(--ckn-muted); cursor: pointer; padding: .2rem .35rem .2rem .1rem; border-radius: 6px; font-size: .8rem; line-height: 1; }
.proj-tab-edit:hover { color: var(--ckn-primary); }
.proj-tab-add { display: inline-flex; align-items: center; gap: .3rem; border: 1px dashed var(--ckn-border); background: transparent; color: var(--ckn-muted); font-size: .8rem; font-weight: 500; padding: .3rem .6rem; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.proj-tab-add:hover { color: var(--ckn-primary); border-color: var(--ckn-primary); background: var(--ckn-primary-soft); }

.agents-table-wrap { overflow-x: auto; border: 1px solid var(--ckn-border); border-radius: 12px; background: #fff; }
.agents-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.agents-table thead th {
    text-align: left; font-size: .66rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--ckn-muted); font-weight: 600; padding: .55rem .75rem; white-space: nowrap;
    border-bottom: 1px solid var(--ckn-border); background: var(--ckn-sidebar);
}
.agents-table tbody td { padding: .55rem .75rem; border-bottom: 1px solid var(--ckn-border); vertical-align: middle; }
.agents-table tbody tr:last-child td { border-bottom: none; }
.agents-table tbody tr:hover { background: #fafafa; }
.agents-table tr.is-default,
.agents-table tr.is-default:hover { background: var(--ckn-primary-soft); }
.agents-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: var(--ckn-muted); }
.agents-table .ta-actions { text-align: right; white-space: nowrap; }
.agents-table .ta-actions-inner { display: inline-flex; align-items: center; gap: .3rem; }
.agents-table .ta-actions .inline-form { display: inline-flex; margin: 0; }
.agents-empty-row td { text-align: center; color: var(--ckn-muted); padding: 1.3rem; }

.agent-name { font-weight: 600; font-size: .88rem; display: inline-flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.badge-default {
    font-size: .62rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--ckn-primary); background: #fff; border: 1px solid var(--ckn-primary);
    border-radius: 20px; padding: .05rem .45rem; display: inline-flex; align-items: center; gap: .2rem;
}
.icon-btn.danger:hover { color: var(--ckn-primary); background: var(--ckn-primary-soft); }

.agent-form { display: flex; flex-direction: column; gap: .6rem; }
.agent-form .form-title { font-size: .95rem; font-weight: 600; margin: 0 0 .3rem; }

/* status pills (providers table — API key column) */
.pill { font-size: .68rem; font-weight: 600; border-radius: 20px; padding: .1rem .5rem; display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap; }
.pill-on { color: var(--ckn-primary); background: var(--ckn-primary-soft); border: 1px solid rgba(153, 27, 27,.3); }
.pill-off { color: var(--ckn-muted); background: #f3f4f6; border: 1px solid var(--ckn-border); }
.agents-sub code { background: #f3f4f6; padding: 0 .28rem; border-radius: 4px; font-size: .95em; color: var(--ckn-ink); }

/* checkbox / switch use the red accent (not Bootstrap blue) */
.form-check-input:checked { background-color: var(--ckn-primary); border-color: var(--ckn-primary); }
.form-check-input:focus { border-color: var(--ckn-primary); box-shadow: 0 0 0 .2rem rgba(153, 27, 27,.15); }
.status-switch { margin: 0; padding-left: 2.4em; min-height: auto; }
.status-switch .status-toggle { cursor: pointer; }

/* projects: git actions modal */
.git-branch { margin-bottom: .6rem; }
.git-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.git-commit { margin-bottom: .7rem; }
.git-output {
    background: #0b0f14; color: #d1d5db; border-radius: 8px; padding: .7rem .85rem; margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto;
}

/* projects: Pull All modal */
.pull-all-warn { font-size: .82rem; color: var(--ckn-muted); margin: 0 0 .6rem; }
.pull-all-warn .bi { color: var(--ckn-primary); }
.pull-all-progress { font-size: .8rem; font-weight: 600; color: var(--ckn-ink); margin-bottom: .5rem; min-height: 1.2rem; }
.pull-all-progress.err { color: var(--ckn-primary); }

/* projects: background Claude Code tasks (modal task list + running indicator) */
.task-dot {
    display: inline-block; width: .5rem; height: .5rem; border-radius: 50%;
    background: #fff; margin-left: .35rem; animation: task-pulse 1.2s ease-in-out infinite;
}
@keyframes task-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.task-list-head { display: flex; align-items: baseline; gap: .5rem; margin: .7rem 0 .3rem; flex-wrap: wrap; }
.task-list-title { font-size: .82rem; font-weight: 600; color: var(--ckn-ink); }
.task-list-hint { font-size: .7rem; color: var(--ckn-muted); }
.task-list {
    border: 1px solid var(--ckn-border); border-radius: 8px; margin-bottom: .7rem;
    max-height: 150px; overflow: auto; font-size: .78rem; color: var(--ckn-muted);
    display: flex; flex-direction: column; padding: .15rem;
}
.task-row {
    display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
    background: none; border: 0; border-radius: 6px; padding: .3rem .45rem; cursor: pointer;
    color: var(--ckn-ink); font-size: .78rem;
}
.task-row:hover { background: var(--ckn-sidebar); }
.task-row.active { background: var(--ckn-primary-soft); }
.task-prompt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-when { color: var(--ckn-muted); font-size: .68rem; white-space: nowrap; }
.task-pill { font-size: .64rem; font-weight: 600; border-radius: 20px; padding: .05rem .45rem; white-space: nowrap; }
.task-running { color: #fff; background: var(--ckn-primary); }
.task-done { color: var(--ckn-ink); background: #f3f4f6; border: 1px solid var(--ckn-border); }
.task-failed { color: var(--ckn-primary-dark); background: var(--ckn-primary-soft); border: 1px solid rgba(153, 27, 27,.3); }
.task-stopped { color: var(--ckn-muted); background: #f3f4f6; border: 1px solid var(--ckn-border); }
.task-error { color: var(--ckn-primary-dark); background: var(--ckn-primary-soft); border: 1px solid rgba(153, 27, 27,.3); }
.task-starting { color: var(--ckn-muted); background: #eef0f2; border: 1px solid var(--ckn-border); }

/* knowledge page: retrieval search + results + tags */
.k-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.k-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 820px) { .k-layout { grid-template-columns: 1fr; } }
.k-docs { min-width: 0; }

.k-collections { border: 1px solid var(--ckn-border); border-radius: 12px; padding: .5rem; background: #fff; }
.k-col-title { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ckn-muted); font-weight: 600; padding: .3rem .5rem .4rem; }
.k-col-row { display: flex; align-items: center; }
.k-col {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .4rem .5rem; border-radius: 7px; text-decoration: none; color: #374151; font-size: .84rem;
}
.k-col > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .45rem; }
.k-col:hover { background: #eef0f2; color: var(--ckn-ink); }
.k-col.active { background: var(--ckn-primary-soft); color: var(--ckn-primary); font-weight: 500; }
.k-col-count { font-size: .72rem; color: var(--ckn-muted); background: #f3f4f6; border-radius: 20px; padding: 0 .4rem; flex: 0 0 auto; }
.k-col.active .k-col-count { color: var(--ckn-primary); background: #fff; }
.k-col-actions { display: none; align-items: center; gap: .05rem; flex: 0 0 auto; }
.k-col-row:hover .k-col-actions { display: flex; }
.k-col-actions .icon-btn { width: 24px; height: 24px; font-size: .8rem; }
.k-col-actions .inline-form { display: inline-flex; margin: 0; }

.k-search { margin-bottom: 1rem; max-width: 560px; }
.k-search .input-group-text { background: #fff; border-color: var(--ckn-border); color: var(--ckn-muted); }
.k-results { margin-bottom: 1.2rem; border: 1px solid var(--ckn-border); border-radius: 12px; padding: .8rem; background: var(--ckn-chat-bg); }
.k-results-head { font-size: .78rem; color: var(--ckn-muted); margin-bottom: .5rem; }
.k-result { padding: .5rem .6rem; border: 1px solid var(--ckn-border); border-radius: 8px; background: #fff; margin-bottom: .5rem; }
.k-result:last-child { margin-bottom: 0; }
.k-result-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.k-result-title { font-weight: 600; font-size: .86rem; }
.k-score { font-size: .7rem; color: var(--ckn-muted); white-space: nowrap; }
.k-snippet { font-size: .8rem; color: #374151; margin-top: .25rem; line-height: 1.45; white-space: pre-wrap; }
.k-tag { display: inline-block; font-size: .68rem; background: #f3f4f6; border: 1px solid var(--ckn-border); border-radius: 20px; padding: .02rem .45rem; margin: 0 .2rem .2rem 0; color: #374151; }

/* models editor (provider modal): one model per row */
.fld .fld-label { font-size: .76rem; color: var(--ckn-muted); }
.fld .fld-hint { font-weight: 400; color: var(--ckn-muted); font-size: .95em; }
.models-editor { border: 1px solid var(--ckn-border); border-radius: 8px; padding: .45rem; }
.models-table { width: 100%; border-collapse: collapse; }
.models-table td { padding: .1rem; vertical-align: middle; }
.models-table td:last-child { width: 32px; text-align: right; }
.models-table .form-control { font-size: .82rem; }
#addModelRow { margin-top: .4rem; }
.agent-form .fld { display: flex; flex-direction: column; gap: .2rem; font-size: .76rem; color: var(--ckn-muted); }
.agent-form .fld .form-control { font-size: .85rem; }
.agent-form .fld-row { display: flex; gap: .55rem; }
.agent-form .fld-row .fld { flex: 1 1 0; min-width: 0; }
.agent-form .form-control:focus { border-color: var(--ckn-primary); box-shadow: 0 0 0 .2rem rgba(153, 27, 27,.12); }
.agent-form .chk { flex-direction: row; align-items: center; gap: .45rem; font-size: .8rem; color: var(--ckn-ink); margin-top: .15rem; }
.agent-form .form-actions { display: flex; gap: .5rem; margin-top: .55rem; }

/* ============================================================
   Drag-to-resize handles (left menu & right chat)
   Thin grab strips centered on each panel's divider; dragging updates
   --ckn-menu-w / --ckn-chat-w on the shell via JS (CSSOM — CSP-safe).
   Double-click a handle to reset to the default width.
   ============================================================ */
.resizer {
    position: absolute; top: 0; bottom: 0; width: 8px; z-index: 50;
    cursor: col-resize; background: transparent; touch-action: none;
}
.resizer::before {
    content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
    width: 2px; transform: translateX(-1px); background: transparent;
    transition: background .15s ease;
}
.resizer:hover::before, .resizer.is-active::before { background: var(--ckn-primary); }
.resizer-menu { left: var(--ckn-menu-w); margin-left: -4px; }
.resizer-chat { right: var(--ckn-chat-w); margin-right: -4px; }

/* hide a handle when its own panel is hidden */
.app-shell.menu-hidden .resizer-menu { display: none; }
.app-shell.chat-hidden .resizer-chat { display: none; }

/* while dragging: suppress text selection + keep the resize cursor everywhere */
body.is-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }

/* On narrow screens the panels float as overlays instead of squeezing the center */
@media (max-width: 991.98px) {
    .side-panel { position: fixed; z-index: 1040; top: 0; left: 0; height: 100vh; width: var(--ckn-menu-w); flex-basis: var(--ckn-menu-w); box-shadow: 0 0 40px rgba(0,0,0,.15); transform: translateX(0); }
    .chat-panel { position: fixed; z-index: 1040; top: 0; right: 0; height: 100vh; width: min(90vw, var(--ckn-chat-w)); box-shadow: 0 0 40px rgba(0,0,0,.15); transform: translateX(0); }
    /* overlay panels slide off-screen when closed (no rail, full-width overlay) */
    .app-shell.menu-hidden .side-panel { width: var(--ckn-menu-w); flex-basis: var(--ckn-menu-w); overflow: visible; transform: translateX(-100%); }
    .app-shell.chat-hidden .chat-panel { width: min(90vw, var(--ckn-chat-w)); flex-basis: auto; opacity: 1; overflow: visible; border-left: 1px solid var(--ckn-border); transform: translateX(100%); }
    .app-shell.overlay-open .panel-backdrop { display: block; }
    .resizer { display: none; }   /* overlay panels aren't resizable */
}

/* ============================================================
   Studio — VS-Code-style explorer + CodeMirror editor + preview
   (fullscreen modal on the Projects pages)
   ============================================================ */
.studio-body { padding: 0; display: flex; min-height: 0; flex: 1 1 auto; }

/* Left: explorer / source tree */
.studio-explorer {
    width: 280px; flex: 0 0 280px; display: flex; flex-direction: column;
    background: var(--ckn-sidebar); border-right: 1px solid var(--ckn-border); min-height: 0;
}
.studio-explorer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem .6rem; border-bottom: 1px solid var(--ckn-border);
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--ckn-muted);
}
/* Universal source-code search (git grep, honours .gitignore) */
.studio-search { display: flex; align-items: center; gap: .35rem; padding: .4rem .5rem; border-bottom: 1px solid var(--ckn-border); }
.studio-search > .bi { color: var(--ckn-muted); font-size: .8rem; flex: 0 0 auto; }
.studio-search-input {
    flex: 1 1 auto; min-width: 0; border: 1px solid var(--ckn-border); border-radius: 6px;
    background: #fff; padding: .25rem .45rem; font-size: .8rem; color: var(--ckn-ink);
}
.studio-search-input:focus { outline: none; border-color: var(--ckn-primary); box-shadow: 0 0 0 .15rem rgba(153, 27, 27, .12); }
.studio-search-clear { width: 24px; height: 24px; flex: 0 0 auto; font-size: .75rem; }

.studio-results { flex: 1 1 auto; overflow: auto; padding: .3rem 0 .8rem; font-size: .8rem; }
.studio-results .sr-file {
    display: flex; align-items: center; gap: .35rem; padding: .3rem .6rem .15rem;
    color: var(--ckn-muted); font-weight: 600; font-size: .72rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.studio-results .sr-file .bi { flex: 0 0 auto; }
.studio-results .sr-hit {
    display: flex; gap: .45rem; width: 100%; border: 0; background: transparent; cursor: pointer;
    text-align: left; padding: .12rem .6rem .12rem 1.3rem; color: var(--ckn-ink); line-height: 1.35;
}
.studio-results .sr-hit:hover { background: #eef0f2; }
.studio-results .sr-line { flex: 0 0 auto; color: var(--ckn-muted); font-variant-numeric: tabular-nums; min-width: 2.2rem; text-align: right; }
.studio-results .sr-text { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
.studio-results .sr-empty { padding: .5rem .7rem; color: var(--ckn-muted); }
.studio-results .sr-empty.err { color: var(--ckn-primary); }
.studio-results .sr-note { padding: .3rem .7rem; color: var(--ckn-muted); font-size: .72rem; }
/* transient highlight of the jumped-to line in the editor */
.CodeMirror .cm-search-hit { background: var(--ckn-primary-soft); }

.studio-tree { flex: 1 1 auto; overflow: auto; padding: .35rem 0 .8rem; font-size: .82rem; }
.studio-tree .tree-children { list-style: none; margin: 0; padding: 0; }
.studio-tree .tree-children .tree-children { margin-left: .8rem; border-left: 1px solid var(--ckn-border); }
.tree-node {
    display: flex; align-items: center; gap: .35rem; width: 100%;
    padding: .18rem .5rem; border: 0; background: transparent; cursor: pointer;
    color: var(--ckn-ink); text-align: left; border-radius: 4px; line-height: 1.4;
}
.tree-node:hover { background: #eef0f2; }
.tree-node.active { background: var(--ckn-primary-soft); color: var(--ckn-primary); font-weight: 500; }
.tree-node .bi { font-size: .82rem; color: var(--ckn-muted); flex: 0 0 auto; }
.tree-node.active .bi { color: var(--ckn-primary); }
.tree-node .tree-caret { width: .8rem; text-align: center; transition: transform .12s ease; }
.tree-node .tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-empty, .tree-error { padding: .4rem .7rem; color: var(--ckn-muted); font-size: .78rem; }
.tree-error { color: var(--ckn-primary); }

/* Right: editor + preview */
.studio-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.studio-toolbar {
    display: flex; align-items: center; gap: .5rem;
    padding: .4rem .6rem; border-bottom: 1px solid var(--ckn-border); background: var(--ckn-work-bg);
}
.studio-filepath { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: var(--ckn-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.studio-lang { font-size: .68rem; color: var(--ckn-muted); text-transform: uppercase; letter-spacing: .03em; }
.studio-dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--ckn-primary); display: none; }
.studio-dirty.on { display: inline-block; }
.studio-toolbar-spacer { flex: 1 1 auto; }

.studio-panes { flex: 1 1 auto; display: flex; min-height: 0; }
/* Before a file is opened, show the placeholder and hide the (empty) editor textarea. */
.studio-placeholder { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: var(--ckn-muted); text-align: center; padding: 2rem; }
.studio-placeholder .bi { font-size: 2.4rem; opacity: .55; }
.studio-placeholder p { margin: 0; font-size: .9rem; }
.studio-panes.has-file .studio-placeholder { display: none; }
.studio-panes:not(.has-file) .studio-editor { display: none; }
.studio-editor { flex: 1 1 100%; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
/* Let flexbox size CodeMirror directly (flex:1 + height:auto) instead of a percentage
   height, which does not resolve reliably inside a flex column in a modal. */
.studio-editor .CodeMirror { flex: 1 1 auto; height: auto; min-height: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
/* a little breathing room inside the editor (native CodeMirror padding, cursor-safe) */
.studio-editor .CodeMirror-lines { padding: 10px 8px; }
/* Line-number gutter: gray column with numbers flush to its left edge
   (CodeMirror right-aligns them by default, which drifts them toward the code). */
.studio-editor .CodeMirror-gutters { background: var(--ckn-sidebar); border-right: 1px solid var(--ckn-border); }
.studio-editor .CodeMirror-linenumber { text-align: left; padding-left: 8px; color: var(--ckn-muted); }
.studio-preview { flex: 0 0 0; min-width: 0; overflow: auto; border-left: 1px solid var(--ckn-border); background: var(--ckn-work-bg); display: none; }
.studio-panes.preview-on .studio-editor { flex: 0 0 50%; }
.studio-panes.preview-on .studio-preview { flex: 0 0 50%; display: block; }
.studio-frame { width: 100%; height: 100%; border: 0; background: #fff; display: none; }
.studio-preview.mode-html .studio-frame { display: block; }
.studio-preview.mode-html .md-preview { display: none; }

.studio-status { padding: .3rem .6rem; border-top: 1px solid var(--ckn-border); font-size: .72rem; color: var(--ckn-muted); min-height: 1.4rem; }
.studio-status.err { color: var(--ckn-primary); }

/* Studio terminal — xterm.js over a WebSocket PTY, a bottom panel of the editor area */
.studio-terminal { display: none; flex: 0 0 260px; flex-direction: column; min-height: 0; border-top: 1px solid var(--ckn-border); background: #0b0f14; }
.studio-main.terminal-on .studio-terminal { display: flex; }
.docs-main.terminal-on .docs-terminal { display: flex; flex: 0 0 300px; }
.studio-terminal-head { display: flex; align-items: center; justify-content: space-between; padding: .25rem .5rem; background: var(--ckn-sidebar); border-bottom: 1px solid var(--ckn-border); font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--ckn-muted); }
.studio-terminal-head .mono { text-transform: none; font-weight: 500; }
.studio-terminal-body { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: .35rem .5rem; }
.studio-terminal-body .xterm { height: 100%; }

/* ============================================================
   Documents — per-project file manager (fullscreen modal)
   ============================================================ */
.docs-body { padding: 0; display: flex; min-height: 0; flex: 1 1 auto; }
.docs-explorer { width: 280px; flex: 0 0 280px; display: flex; flex-direction: column; background: var(--ckn-sidebar); border-right: 1px solid var(--ckn-border); min-height: 0; }
.docs-explorer-head { display: flex; align-items: center; justify-content: space-between; padding: .5rem .6rem; border-bottom: 1px solid var(--ckn-border); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ckn-muted); }
.docs-tree { flex: 1 1 auto; overflow: auto; padding: .35rem 0 .8rem; font-size: .82rem; }
.docs-node { display: flex; align-items: center; gap: .35rem; width: 100%; padding: .2rem .5rem; border: 0; background: transparent; cursor: pointer; color: var(--ckn-ink); text-align: left; border-radius: 4px; line-height: 1.4; }
.docs-node:hover { background: #eef0f2; }
.docs-node.active { background: var(--ckn-primary-soft); color: var(--ckn-primary); font-weight: 500; }
.docs-node .bi { font-size: .82rem; color: var(--ckn-muted); flex: 0 0 auto; }
.docs-node.active .bi { color: var(--ckn-primary); }
.docs-node .docs-node-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.docs-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.docs-toolbar { display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border-bottom: 1px solid var(--ckn-border); }
.docs-toolbar-spacer { flex: 1 1 auto; }
.docs-breadcrumb { display: flex; align-items: center; gap: .2rem; font-size: .82rem; flex-wrap: wrap; }
.docs-breadcrumb .crumb { background: transparent; border: 0; color: var(--ckn-primary); cursor: pointer; padding: 0 .1rem; }
.docs-breadcrumb .crumb.current { color: var(--ckn-ink); cursor: default; font-weight: 500; }
.docs-breadcrumb .sep { color: var(--ckn-muted); }

.docs-browser { flex: 1 1 auto; overflow: auto; padding: .5rem .7rem 1rem; position: relative; }
.docs-table { width: 100%; }
.docs-row-empty td { color: var(--ckn-muted); }
.docs-name { display: inline-flex; align-items: center; gap: .4rem; }
.docs-name.folder { cursor: pointer; color: var(--ckn-ink); }
.docs-name.folder:hover { color: var(--ckn-primary); }
.docs-name .bi { color: var(--ckn-muted); }

.docs-drop-hint { display: none; position: absolute; inset: .5rem; border: 2px dashed var(--ckn-primary); border-radius: 12px; background: rgba(153, 27, 27,.06); color: var(--ckn-primary); align-items: center; justify-content: center; flex-direction: column; gap: .4rem; font-weight: 600; pointer-events: none; z-index: 5; }
.docs-drop-hint .bi { font-size: 2rem; }
.docs-body.drag-over .docs-drop-hint { display: flex; }

.docs-status { padding: .3rem .7rem; border-top: 1px solid var(--ckn-border); font-size: .72rem; color: var(--ckn-muted); min-height: 1.4rem; }
.docs-status.err { color: var(--ckn-primary); }
/* clickable file name in the browser table */
.docs-name.file { cursor: pointer; }
.docs-name.file:hover { color: var(--ckn-primary); }
.docs-name.file:hover .bi { color: var(--ckn-primary); }

/* ============================================================
   Document viewer — in-browser preview modal
   ============================================================ */
.docview-head-actions { display: inline-flex; align-items: center; gap: .6rem; }
.docview-body { padding: 0; display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; background: var(--ckn-work-bg); }
.docview-status { padding: .3rem .7rem; border-bottom: 1px solid var(--ckn-border); font-size: .72rem; color: var(--ckn-muted); min-height: 1.4rem; }
.docview-status.err { color: var(--ckn-primary); }
.docview-content { flex: 1 1 auto; min-height: 0; overflow: auto; }
/* full-bleed frame for pdf / html previews */
.docview-content .docview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
/* plain-text / code preview */
.docview-content .docview-pre { margin: 0; padding: 1rem 1.25rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--ckn-ink); }
/* rendered rich content (markdown / docx / xlsx / pptx) sits on a centred page */
.docview-doc { max-width: 900px; margin: 0 auto; padding: 1.5rem 1.75rem; color: var(--ckn-ink); font-size: .92rem; line-height: 1.6; }
.docview-doc img { max-width: 100%; height: auto; }
.docview-doc table { border-collapse: collapse; margin: .6rem 0; font-size: .85rem; }
.docview-doc table td, .docview-doc table th { border: 1px solid var(--ckn-border); padding: .25rem .5rem; text-align: left; vertical-align: top; }
.docview-doc h1, .docview-doc h2, .docview-doc h3 { line-height: 1.25; margin: 1.1rem 0 .5rem; }
.docview-doc pre { background: var(--ckn-sidebar); padding: .7rem .9rem; border-radius: 8px; overflow: auto; }
.docview-doc code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
/* xlsx: one block per sheet, horizontally scrollable */
.docview-sheet { max-width: 100%; margin: 0 auto 1.5rem; padding: 0 1.25rem; }
.docview-sheet-name { font-weight: 600; font-size: .8rem; color: var(--ckn-muted); margin: 1rem 0 .35rem; text-transform: uppercase; letter-spacing: .03em; }
.docview-sheet-scroll { overflow-x: auto; border: 1px solid var(--ckn-border); border-radius: 8px; }
.docview-sheet table { border-collapse: collapse; font-size: .82rem; width: 100%; }
.docview-sheet td, .docview-sheet th { border: 1px solid var(--ckn-border); padding: .2rem .45rem; white-space: nowrap; }
.docview-sheet tr:first-child td { background: var(--ckn-sidebar); font-weight: 600; }
/* pptx: best-effort slide cards */
.docview-slides { max-width: 960px; margin: 0 auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.docview-slide { border: 1px solid var(--ckn-border); border-radius: 10px; padding: 1rem 1.2rem; background: #fff; }
.docview-slide-num { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ckn-muted); font-weight: 600; margin-bottom: .5rem; }
.docview-slide p { margin: .2rem 0; }
.docview-slide-imgs { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.docview-slide-imgs img { max-width: 220px; max-height: 160px; border: 1px solid var(--ckn-border); border-radius: 6px; }
.docview-empty { padding: 2.5rem; text-align: center; color: var(--ckn-muted); }
.docview-empty .bi { font-size: 2.4rem; opacity: .55; display: block; margin-bottom: .6rem; }
/* CSP (style-src 'self') blocks xterm's inline foreground/cursor styles, so text
   would render black on the dark panel. Force white via the stylesheet instead. */
.studio-terminal-body .xterm,
.studio-terminal-body .xterm .xterm-rows { color: #ffffff; }
.studio-terminal-body .xterm .xterm-cursor-block { background-color: #ffffff; color: #0b0f14; }
.studio-terminal-body .xterm .xterm-cursor-bar,
.studio-terminal-body .xterm .xterm-cursor-underline { color: #ffffff; }

/* Right chat-assistant panel inside the Studio modal (reuses .msg/.bubble/.chat-* classes) */
.studio-assistant { flex: 0 0 0; width: 0; min-height: 0; overflow: hidden; display: none; flex-direction: column; border-left: 1px solid var(--ckn-border); background: var(--ckn-chat-bg); }
.studio-body.assistant-on .studio-assistant { display: flex; flex: 0 0 340px; width: 340px; }
.studio-assistant-head { display: flex; align-items: center; justify-content: space-between; padding: .5rem .6rem; border-bottom: 1px solid var(--ckn-border); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ckn-muted); }
.studio-assistant-actions { display: inline-flex; gap: .1rem; }
.studio-assistant-msgs { flex: 1 1 auto; min-height: 0; }
.studio-assistant .chat-input .input-group { align-items: flex-end; }
.studio-assistant .chat-input textarea { resize: none; }

/* Markdown preview — clean, token-based (no inline styles) */
.md-preview { padding: 1rem 1.2rem; font-size: .9rem; line-height: 1.6; color: var(--ckn-ink); }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 1.1em 0 .5em; line-height: 1.25; }
.md-preview h1 { font-size: 1.5rem; border-bottom: 1px solid var(--ckn-border); padding-bottom: .3em; }
.md-preview h2 { font-size: 1.25rem; border-bottom: 1px solid var(--ckn-border); padding-bottom: .25em; }
.md-preview h3 { font-size: 1.08rem; }
.md-preview p, .md-preview ul, .md-preview ol, .md-preview blockquote, .md-preview table { margin: .5em 0; }
.md-preview code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--ckn-sidebar); padding: .1em .35em; border-radius: 4px; }
.md-preview pre { background: var(--ckn-sidebar); padding: .8em 1em; border-radius: 6px; overflow: auto; border: 1px solid var(--ckn-border); }
.md-preview pre code { background: transparent; padding: 0; }
.md-preview blockquote { border-left: 3px solid var(--ckn-border); padding-left: .9em; color: var(--ckn-muted); }
.md-preview a { color: var(--ckn-primary); }
.md-preview table { border-collapse: collapse; }
.md-preview th, .md-preview td { border: 1px solid var(--ckn-border); padding: .35em .6em; }
.md-preview img { max-width: 100%; }
.tree-item { list-style: none; }
.tree-item.open > .tree-node .tree-caret { transform: rotate(90deg); }

/* ============================================================
   TODO board — Microsoft-Planner style (buckets → tasks → subtasks)
   Fullscreen modal on the Projects pages.
   ============================================================ */
.todo-head-spacer { flex: 1 1 auto; }
.todo-head-status { font-size: .74rem; color: var(--ckn-muted); margin-right: .6rem; }
.todo-head-status.err { color: var(--ckn-primary); }
.todo-add-list-btn { margin-left: .6rem; }

.todo-body { padding: 0; display: flex; min-height: 0; flex: 1 1 auto; background: var(--ckn-sidebar); }
.todo-board { flex: 1 1 auto; display: flex; align-items: flex-start; gap: .8rem; overflow-x: auto; overflow-y: hidden; padding: .9rem; height: 100%; }

/* a bucket = one "Todo list" column */
.todo-bucket {
    flex: 0 0 300px; width: 300px; max-height: 100%;
    display: flex; flex-direction: column;
    background: var(--ckn-work-bg); border: 1px solid var(--ckn-border); border-radius: 12px;
}
.todo-bucket.drop-target { border-color: var(--ckn-primary); box-shadow: 0 0 0 2px rgba(153, 27, 27, .15); }
.todo-bucket-head { display: flex; align-items: center; gap: .4rem; padding: .6rem .7rem .4rem; }
.todo-bucket-name { font-weight: 600; font-size: .9rem; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid transparent; border-radius: 6px; padding: .15rem .3rem; background: transparent; color: var(--ckn-ink); }
.todo-bucket-name:focus { outline: none; border-color: var(--ckn-primary); background: #fff; }
.todo-bucket-count { font-size: .72rem; color: var(--ckn-muted); flex: 0 0 auto; }
.todo-tasks { flex: 1 1 auto; overflow-y: auto; padding: .3rem .55rem .55rem; display: flex; flex-direction: column; gap: .45rem; min-height: 2.5rem; }

/* task card */
.todo-card { background: #fff; border: 1px solid var(--ckn-border); border-radius: 9px; padding: .5rem .55rem; cursor: pointer; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.todo-card:hover { border-color: #d1d5db; box-shadow: 0 2px 6px rgba(16,24,40,.08); }
.todo-card.dragging { opacity: .5; }
.todo-card-top { display: flex; align-items: flex-start; gap: .45rem; }
.todo-check { flex: 0 0 auto; margin-top: .1rem; width: 16px; height: 16px; cursor: pointer; accent-color: var(--ckn-primary); }
.todo-card-title { flex: 1 1 auto; font-size: .84rem; line-height: 1.3; color: var(--ckn-ink); word-break: break-word; }
.todo-card.done .todo-card-title { text-decoration: line-through; color: var(--ckn-muted); }
.todo-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .4rem; padding-left: 1.5rem; }
.todo-chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .68rem; padding: .1rem .4rem; border-radius: 999px; background: var(--ckn-sidebar); color: var(--ckn-muted); border: 1px solid var(--ckn-border); }
.todo-chip.overdue { color: #fff; background: var(--ckn-primary); border-color: var(--ckn-primary); }
.todo-chip .bi { font-size: .72rem; }
.todo-assignee { display: inline-flex; align-items: center; gap: .3rem; font-size: .68rem; color: var(--ckn-muted); }
.todo-avatar { width: 18px; height: 18px; border-radius: 50%; background: #e5e7eb; color: #374151; font-weight: 600; font-size: .58rem; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }

/* add-task footer inside a bucket */
.todo-add-task { display: flex; padding: 0 .55rem .55rem; }
.todo-add-task input { border: 1px dashed var(--ckn-border); border-radius: 7px; background: transparent; padding: .35rem .5rem; font-size: .82rem; width: 100%; color: var(--ckn-ink); }
.todo-add-task input:focus { outline: none; border-style: solid; border-color: var(--ckn-primary); background: #fff; }
.todo-add-task-btn { display: inline-flex; align-items: center; gap: .3rem; width: 100%; justify-content: center; border: 1px dashed var(--ckn-border); border-radius: 7px; background: transparent; padding: .35rem .5rem; font-size: .82rem; color: var(--ckn-muted); cursor: pointer; }
.todo-add-task-btn:hover { border-style: solid; border-color: var(--ckn-primary); background: #fff; color: var(--ckn-primary); }

.todo-bucket-del { flex: 0 0 auto; }

/* task detail modal */
.todo-field-label { display: block; font-size: .72rem; color: var(--ckn-muted); margin: .7rem 0 .2rem; text-transform: uppercase; letter-spacing: .04em; }
.todo-field-label:first-child { margin-top: 0; }
.todo-field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.todo-checklist-label { margin-top: 1rem; }
.todo-sub-progress { text-transform: none; letter-spacing: 0; color: var(--ckn-primary); font-weight: 600; margin-left: .3rem; }
.todo-checklist { display: flex; flex-direction: column; gap: .25rem; }
.todo-check-item { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border: 1px solid var(--ckn-border); border-radius: 7px; }
.todo-check-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--ckn-primary); flex: 0 0 auto; cursor: pointer; }
.todo-check-item .todo-check-title { flex: 1 1 auto; font-size: .84rem; }
.todo-check-item.done .todo-check-title { text-decoration: line-through; color: var(--ckn-muted); }
.todo-add-sub { margin-top: .5rem; }
.todo-empty { color: var(--ckn-muted); font-size: .8rem; padding: .5rem .3rem; }

/* keep destructive buttons on the red/white/gray/black palette */
.btn-outline-danger { color: var(--ckn-primary); border-color: var(--ckn-primary); }
.btn-outline-danger:hover, .btn-outline-danger:active, .btn-outline-danger:focus { background-color: var(--ckn-primary); border-color: var(--ckn-primary); color: #fff; }

/* Projects table: keep the Name column on one line (description column still wraps) */
#projectsPage .agents-table td:first-child { white-space: nowrap; }
#projectsPage .agent-name { flex-wrap: nowrap; }

/* ===== Code Quality review: selectable findings checklist ===== */
.review-toolbar { display: flex; align-items: center; gap: .75rem; margin: .3rem 0 .5rem; }
.review-selectall { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; font-weight: 600; color: var(--ckn-ink); cursor: pointer; }
.review-selectall input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--ckn-primary); cursor: pointer; }
.review-count { font-size: .78rem; color: var(--ckn-muted); }
.review-findings { display: flex; flex-direction: column; gap: .4rem; max-height: 45vh; overflow-y: auto; margin-bottom: .5rem; }
.review-item { display: flex; gap: .55rem; padding: .5rem .6rem; border: 1px solid var(--ckn-border); border-radius: 9px; background: #fff; }
.review-item:hover { border-color: var(--ckn-primary); }
.review-item.checked { background: var(--ckn-primary-soft); border-color: var(--ckn-primary); }
.review-item > input[type="checkbox"] { width: 16px; height: 16px; margin-top: .12rem; accent-color: var(--ckn-primary); flex: 0 0 auto; cursor: pointer; }
.review-item-body { flex: 1 1 auto; min-width: 0; }
.review-item-title { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .85rem; font-weight: 600; color: var(--ckn-ink); }
.review-sev { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .08rem .35rem; border-radius: 999px; border: 1px solid var(--ckn-border); color: var(--ckn-muted); }
.review-sev.high { background: var(--ckn-primary); border-color: var(--ckn-primary); color: #fff; }
.review-sev.medium { background: var(--ckn-primary-soft); border-color: var(--ckn-primary); color: var(--ckn-primary-dark); }
.review-sev.low { background: var(--ckn-sidebar); }
.review-cat { font-size: .66rem; color: var(--ckn-muted); text-transform: uppercase; letter-spacing: .03em; }
.review-file { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .72rem; color: var(--ckn-muted); word-break: break-all; margin-top: .15rem; }
.review-detail { font-size: .8rem; color: var(--ckn-ink); margin-top: .2rem; }
.review-suggest { font-size: .78rem; color: var(--ckn-muted); margin-top: .15rem; }
.review-suggest .bi { color: var(--ckn-primary); }

/* ===== Rich-text editor (TODO details) ===== */
.rte { border: 1px solid var(--ckn-border); border-radius: 8px; overflow: hidden; }
.rte-toolbar { display: flex; align-items: center; gap: .15rem; padding: .3rem .4rem; background: var(--ckn-sidebar); border-bottom: 1px solid var(--ckn-border); flex-wrap: wrap; }
.rte-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ckn-ink); cursor: pointer; font-size: .9rem; padding: 0; }
.rte-btn:hover { background: #fff; border-color: var(--ckn-border); }
.rte-btn.active { background: var(--ckn-primary-soft); border-color: var(--ckn-primary); color: var(--ckn-primary-dark); }
.rte-sep { width: 1px; align-self: stretch; background: var(--ckn-border); margin: .1rem .2rem; }
.rte-area { min-height: 7rem; max-height: 22rem; overflow-y: auto; border: none; border-radius: 0; padding: .5rem .6rem; font-size: .85rem; line-height: 1.5; }
.rte-area:focus { outline: none; box-shadow: none; }
.rte-area:empty::before { content: attr(data-placeholder); color: var(--ckn-muted); }
.rte-area img { max-width: 100%; height: auto; border-radius: 6px; margin: .25rem 0; display: block; }
.rte-area p { margin: 0 0 .4rem; }
.rte-area ul, .rte-area ol { margin: 0 0 .4rem; padding-left: 1.4rem; }
