/* BzDesk — bz 제품군 색(primary #8B65DA)을 따르는 사내 도구 화면 */
:root {
  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #f1eef8;
  --text: #1d1b22;
  --text-2: #4a4655;
  --muted: #6e6979;
  --line: #e4e0ec;
  --primary: #8b65da;
  --primary-strong: #6b45bd;
  --primary-ink: #5a36a8;
  --success: #1f8a4c;
  --warning: #a8670a;
  --danger: #c23a3a;
  --radius: 16px;
  --radius-sm: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141218;
    --surface: #1d1a23;
    --surface-2: #272231;
    --text: #f2eff7;
    --text-2: #cfc9da;
    --muted: #9c95aa;
    --line: #342f3e;
    --primary: #a283e6;
    --primary-strong: #7a55cc;
    --primary-ink: #c3adf2;
    --success: #5fcf8b;
    --warning: #e3a64a;
    --danger: #f07b7b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-2);
  font: 15px/1.55 "Pretendard", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2 { color: var(--text); line-height: 1.3; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 17px; margin: 32px 0 12px; }
a { color: var(--primary-ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 17px; }
.mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--primary-strong), #2bb3c8); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker { position: relative; }
.picker summary { list-style: none; cursor: pointer; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-weight: 600; white-space: nowrap; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary::after { content: " ▾"; color: var(--muted); }
.picker summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.picker.partial summary { border-color: var(--primary); color: var(--primary-ink); }
.picker #picker-count { overflow: visible; font-variant-numeric: tabular-nums; }
.picker-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 260px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.picker-pop > p { margin: 0 0 8px; }
.picker-all { display: flex; gap: 12px; margin-bottom: 4px; }
.picker-pop label.check { margin: 6px 0 0; font-weight: 500; color: var(--text); }
.layout { max-width: 1320px; margin: 0 auto; padding: 24px 16px 64px; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.layout.single { grid-template-columns: minmax(0, 920px); justify-content: center; }
.app { min-width: 0; }

/* 오른쪽 스킬 안내 */
.skills { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.skills h2 { margin: 0 0 6px; }
.skills > p { margin: 0 0 10px; }
.skill { border-top: 1px solid var(--line); padding: 10px 0; }
.skill summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; cursor: pointer; color: var(--text); font-size: 14px; margin: 0; list-style: none; }
.skill summary::-webkit-details-marker { display: none; }
.skill summary::before { content: "›"; color: var(--muted); transition: transform .15s; display: inline-block; width: 10px; }
.skill[open] summary::before { transform: rotate(90deg); }
.skill-title { flex: 1; font-weight: 600; }
.skill-out { font-size: 12px; color: var(--muted); white-space: nowrap; }
.skill p { font-size: 14px; margin: 8px 0 0; }
.skill .chip { display: block; width: 100%; margin-top: 6px; white-space: pre-wrap; border-radius: var(--radius); padding: 10px 12px; }
.skill-id code { font: 12px ui-monospace, "SFMono-Regular", Menlo, monospace; color: var(--muted); }
.skills-foot { border-top: 1px solid var(--line); padding-top: 10px; margin: 0 !important; }
.skills-link { display: none; margin-right: 4px; }
@media (max-width: 1040px) {
  .skills-link { display: inline; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .skills { position: static; max-height: none; }
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 12px; }

label { display: block; font-size: 14px; font-weight: 600; color: var(--text); margin: 12px 0 6px; }
input, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
}
textarea { resize: vertical; min-height: 110px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

button { font: inherit; cursor: pointer; }
button.primary { background: var(--primary-strong); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 10px 18px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
button.primary:disabled { opacity: .6; cursor: progress; }
button.link { background: none; border: 0; padding: 0; color: var(--primary-ink); text-decoration: underline; }
button.link.danger { color: var(--danger); }
.chip { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; text-align: left; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ask-foot { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-top: 10px; }
.ask-foot p { margin: 4px 0 0; }
.attach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 14px; font-weight: 600; font-size: 14px; }
button.secondary:hover { border-color: var(--primary); }
.attach-list { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 4px; font-size: 14px; }
.attach-list:empty { display: none; }
.attach-list li { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.attach-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#ask-form.dragging { outline: 2px dashed var(--primary); outline-offset: 6px; border-radius: var(--radius-sm); }
label.check { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-weight: 600; margin: 12px 0 0; cursor: pointer; }
label.check .muted { font-weight: 400; }
label.check input { width: auto; margin: 0; accent-color: var(--primary-strong); }
.hint { color: var(--warning); margin: 6px 0 0; }
.inputs { margin: -4px 0 10px; overflow-wrap: anywhere; }
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 14px; color: var(--primary-ink); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin-top: 20px; }
.login-card button.primary { width: 100%; margin-top: 14px; }
.login-card button.link { margin-top: 12px; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid currentColor; }
.pill.primary { color: var(--primary-ink); }
.pill.success { color: var(--success); }
.pill.warning { color: var(--warning); }
.pill.danger { color: var(--danger); }
.pill.neutral { color: var(--muted); }

.job-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.spacer { flex: 1; }
.prompt { color: var(--text); white-space: pre-wrap; margin: 10px 0; overflow-wrap: anywhere; }
.summary { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; margin: 10px 0; }
details summary { cursor: pointer; color: var(--primary-ink); font-size: 14px; margin: 6px 0; }
.error { color: var(--danger); white-space: pre-wrap; overflow-wrap: anywhere; }

.files { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.files li { overflow-wrap: anywhere; }
.files a { font-weight: 600; }
.mail { margin: 8px 0 0; overflow-wrap: anywhere; }

.todos { margin: 8px 0; }
.todos p { margin: 0 0 4px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .4s; }
.todos ol { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.todo.completed { color: var(--muted); text-decoration: line-through; }
.todo.in_progress { color: var(--primary-ink); font-weight: 600; }

.log { list-style: none; margin: 10px 0; padding: 10px 12px; max-height: 320px; overflow: auto; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; display: grid; gap: 4px; }
.ev { overflow-wrap: anywhere; }
.ev.tool { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; color: var(--text-2); }
.ev.tool b { color: var(--primary-ink); font-weight: 600; }
.ev.text { color: var(--text); white-space: pre-wrap; }
.ev.nested { padding-left: 16px; opacity: .8; }
.ev.init { color: var(--muted); }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; }
.pager .page { min-width: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager .page:hover:not(:disabled):not(.cur) { border-color: var(--primary); color: var(--primary-ink); }
.pager .page.cur { background: var(--primary-strong); border-color: var(--primary-strong); color: #fff; font-weight: 600; cursor: default; }
.pager .page:disabled { opacity: .45; cursor: default; }
.pager .gap { color: var(--muted); padding: 0 2px; }
#history-total { font-weight: 400; margin-left: 4px; }

/* 자료 만들기 / 질문하기 */
.modes { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.mode { border: 0; background: none; color: var(--text-2); padding: 6px 16px; border-radius: 999px; font-weight: 600; }
.mode[aria-selected="true"] { background: var(--surface); color: var(--primary-ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.mode:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#chat-note { margin: -4px 0 4px; }
.nav { font-size: 14px; white-space: nowrap; }
.share-wrap { margin: 10px 0 12px; }
/* admin */
.layout.single.wide { grid-template-columns: minmax(0, 1200px); }
.admin h2 { margin-top: 24px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat { padding: 14px 16px; }
.stats .card + .card { margin-top: 0; }
.stat p { margin: 0; }
.stat-v { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin: 2px 0 !important; }
.table-wrap { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.admin-table th, .admin-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.admin-table td.err { white-space: normal; color: var(--danger); min-width: 240px; overflow-wrap: anywhere; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.filters select, .filters input { width: auto; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
#job-detail { margin-top: 14px; }
.kv { border-collapse: collapse; margin: 10px 0; }
.kv th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 16px 4px 0; vertical-align: top; white-space: nowrap; }
.kv td { padding: 4px 0; overflow-wrap: anywhere; }
.usage { white-space: nowrap; }
.usage.warn { color: var(--warning); font-weight: 600; }
fieldset.depth { border: 0; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
fieldset.depth label { display: inline-flex; align-items: baseline; gap: 6px; margin: 0; font-weight: 600; cursor: pointer; }
fieldset.depth .muted { font-weight: 400; }
fieldset.depth input { width: auto; margin: 0; accent-color: var(--primary-strong); }
.saved { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.saved-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; }
.saved-chip .link { text-decoration: none; color: var(--text-2); }
.saved-chip .link:hover { text-decoration: underline; }
.foot-actions { display: inline-flex; align-items: center; gap: 14px; flex-shrink: 0; }
.bot-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 8px; }
.bot-foot .copy { margin: 0; }
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.bot-foot .feedback { margin: 0; }
.fb { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 2px 10px; font-size: 14px; line-height: 1.6; }
.fb.on { border-color: var(--primary); background: var(--surface-2); }
.fb-form { display: flex; gap: 6px; flex: 1 1 240px; }
.fb-form input { padding: 4px 10px; font-size: 13px; }
.fb-comment { font-style: italic; }
.fb-msg { color: var(--danger); }
.fb-msg:empty { display: none; }
.share-wrap summary { cursor: pointer; color: var(--primary-ink); }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 8px; }
.share-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; }
.share-form { display: flex; gap: 6px; flex: 1 1 260px; }
.share-form input { padding: 6px 10px; }
.share .msg { color: var(--danger); flex-basis: 100%; }
.share .msg:empty { display: none; }
.crumbs { font-size: 14px; margin: 8px 0 10px; }
.ws-list { list-style: none; margin: 0; padding: 0; }
.ws-list li { display: flex; gap: 12px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); }
.ws-list li:first-child { border-top: 0; }
.ws-list li > a:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; text-decoration: none; color: var(--text); }
.ws-list li > a:first-child:hover, .ws-list a.cur { text-decoration: underline; color: var(--primary-ink); }
.ws-list li.dir > a:first-child { font-weight: 600; }
.preview-pane { margin-top: 12px; }
.preview-pane .md { margin-top: 10px; }
.ws-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); max-height: 70vh; overflow: auto; }
.from { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0 0 8px; }
.from b { color: var(--text); font-weight: 600; }
.follow .attach-list { margin: 6px 0 0; }
.follow-foot .link { margin-left: auto; }
.revise { margin-top: 16px; }
.revise h2 { margin: 0 0 4px; }
.revise .follow-foot { justify-content: flex-end; }
.revise .msg:empty { display: none; }
.revisions { margin: 10px 0 0; }
.revise-link { margin: 8px 0 0; }
.parent { margin: 8px 0 0; }
[hidden] { display: none !important; }
.pill.kind { background: var(--surface-2); color: var(--primary-ink); border: 1px solid var(--line); }
.job.chat .preview { color: var(--text-2); margin: 6px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 대화 화면 */
.thread-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: 14px; }
.turn { display: flex; flex-direction: column; gap: 10px; }
.bubble { border-radius: var(--radius); padding: 12px 16px; max-width: 100%; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; max-width: min(640px, 92%); background: var(--primary-strong); color: #fff; border-bottom-right-radius: 6px; }
.bubble.me .q { margin: 0; white-space: pre-wrap; }
.bubble.me .when { margin: 4px 0 0; color: rgb(255 255 255 / .75); text-align: right; }
.bubble.me a { color: #fff; }
.bubble.me .inputs { margin: 6px 0 0; }
.bubble.me .inputs .muted { color: rgb(255 255 255 / .75); }
.bubble.bot { align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.bot.working p { margin: 0; color: var(--text-2); }
.bubble.bot.working .md.draft { margin-bottom: 8px; }
.bubble.bot.failed { border-color: var(--danger); }
.bubble.bot .copy { margin-top: 8px; }
.steps { list-style: none; padding: 0; margin: 8px 0; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.steps li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps b { color: var(--primary-ink); font-weight: 600; }
.dots { display: inline-block; width: 22px; height: 8px; background: radial-gradient(circle, var(--primary) 3px, transparent 3.5px) 0 50% / 8px 8px repeat-x; animation: dots 1.2s steps(4) infinite; vertical-align: middle; }
@keyframes dots { from { width: 0; } to { width: 32px; } }
@media (prefers-reduced-motion: reduce) { .dots { animation: none; width: 22px; } }

.md { color: var(--text); line-height: 1.65; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h3, .md h4, .md h5, .md h6 { margin: 16px 0 8px; color: var(--text); font-size: 16px; }
.md h4, .md h5, .md h6 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.md pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; overflow: auto; margin: 0 0 10px; }
.md pre code { background: none; padding: 0; font-size: 13px; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--primary); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md .table-wrap { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); color: var(--text); }

.follow { position: sticky; bottom: 12px; margin-top: 18px; padding: 12px; box-shadow: 0 6px 20px rgb(0 0 0 / .08); }
.follow textarea { min-height: 56px; }
.follow-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.follow-foot p { margin: 0; }
.follow .msg { margin: 6px 0 0; }
.follow .msg:empty { display: none; }

@media (max-width: 600px) {
  .top { padding: 12px 16px; }
  .who > span { display: none; }
  .picker-pop { width: min(260px, calc(100vw - 32px)); }
  .ask-foot { flex-direction: column; }
  .ask-foot button { width: 100%; }
  .bubble.me { max-width: 100%; }
}
