/* ================================================================ 챗봇 모드 */
body.mode-bots .only-programs, body.mode-programs .only-bots { display: none !important; }
.row { display: flex; gap: 6px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.side-title.row { justify-content: space-between; padding-right: 4px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 0 4px 10px; }
.mode-switch button { border: none; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 4px; border-radius: 9px; cursor: pointer; }
.mode-switch button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.bot-list { display: flex; flex-direction: column; gap: 2px; }
.bot-link { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.bot-link:hover { background: var(--surface-2); }
.bot-link.active { background: var(--accent-soft); }
.bot-link .t { display: flex; align-items: center; gap: 6px; font-weight: 600; min-width: 0; }
.bot-link .t .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bot-link.active .t { color: var(--accent); }
.mini-prog { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.mini-prog i, .prog i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .2s; }
.prog { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.pf { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.pf.babechat { background: #ffe1ec; color: #c2185b; }
.pf.crack { background: #ffe9d6; color: #c2410c; }
.st-live { background: #dcfce7; color: #166534; }
.st-dev { background: #e0e7ff; color: #3730a3; }
.st-private { background: #e5e7eb; color: #4b5563; }
.st-paused { background: #fef3c7; color: #92400e; }
:root[data-theme="dark"] .pf.babechat { background: #4a1d31; color: #f9a8d4; }
:root[data-theme="dark"] .pf.crack { background: #4a2a14; color: #fdba74; }
:root[data-theme="dark"] .st-live { background: #14361f; color: #86efac; }
:root[data-theme="dark"] .st-dev { background: #23264a; color: #a5b4fc; }
:root[data-theme="dark"] .st-private { background: #2a2f3d; color: #9ca3af; }
:root[data-theme="dark"] .st-paused { background: #3a2f10; color: #fcd34d; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pf.babechat { background: #4a1d31; color: #f9a8d4; }
  :root:not([data-theme="light"]) .pf.crack { background: #4a2a14; color: #fdba74; }
  :root:not([data-theme="light"]) .st-live { background: #14361f; color: #86efac; }
  :root:not([data-theme="light"]) .st-dev { background: #23264a; color: #a5b4fc; }
  :root:not([data-theme="light"]) .st-private { background: #2a2f3d; color: #9ca3af; }
  :root:not([data-theme="light"]) .st-paused { background: #3a2f10; color: #fcd34d; }
}
.card-del { background: none; border: none; cursor: pointer; font-size: 15px; opacity: 0; padding: 4px; border-radius: 8px; transition: opacity .12s; }
.bot-card:hover .card-del { opacity: .55; }
.card-del:hover { opacity: 1 !important; background: var(--surface-2); }
@media (hover: none) { .card-del { opacity: .55; } }
.bot-card .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.bot-card .prog-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bot-card .prog-row .prog { flex: 1; }

/* 챗봇 상세 */
.bot-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0 12px; }
.bot-head h2 { margin: 0; font-size: 22px; }
.bot-tabs { padding: 0; margin-bottom: 16px; }
.bot-body { min-width: 0; }
.panel h4 { margin: 0 0 10px; font-size: 14px; }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-2 label, .stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form-2 .full { grid-column: 1 / -1; }
.checks { display: flex; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.checks label { flex-direction: row !important; align-items: center; gap: 6px; color: var(--text) !important; font-size: 14px !important; cursor: pointer; }
.checks input { width: auto; }
.save-bar { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.dirty { color: var(--warn); font-size: 12px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ov-side { display: flex; flex-direction: column; gap: 16px; }

/* 캐릭터 · 이미지 */
.chars-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }
.char-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; }
.char-item { padding: 8px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.char-item:hover { background: var(--surface-2); }
.char-item.active { background: var(--accent-soft); }
.char-item .t { display: flex; gap: 6px; align-items: baseline; font-weight: 600; min-width: 0; }
.char-item .t .ab { font-weight: 400; font-size: 11.5px; color: var(--muted); }
.char-item .t .n { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.char-item .warn { font-size: 11px; color: var(--warn); }
.char-panel { min-width: 0; }
.char-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.char-head h3 { margin: 0; font-size: 19px; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: none; background: none; font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tray { background: var(--surface); border: 1px dashed var(--warn); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; }
.tray-h { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 8px; gap: 8px; }
.tray-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tray-list .slot { width: 100px; flex-shrink: 0; }
.cat-block { margin-bottom: 18px; }
.cat-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.slot { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: border-color .12s, transform .12s; min-width: 0; }
.slot:hover { border-color: var(--accent); }
.slot .img { aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.slot .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot.empty .img { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, var(--surface) 8px, var(--surface) 16px); color: var(--muted); font-size: 12px; text-align: center; }
.slot .cap { padding: 6px 8px; display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.slot .cap b { font-size: 12.5px; flex-shrink: 0; }
.slot .cap span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.drop-over { border-color: var(--accent); transform: scale(1.03); box-shadow: 0 0 0 3px var(--accent-soft); }
.slot.add-next { border-style: dashed; justify-content: center; align-items: center; color: var(--muted); min-height: 120px; font-size: 13px; text-align: center; padding: 8px; }
.slot.add-next b { font-size: 20px; display: block; }
.slot.dragging { opacity: .4; }
.slot .del-code { margin-left: auto; background: none; border: none; color: var(--muted); cursor: pointer; opacity: 0; padding: 0 2px; font-size: 12px; }
.slot:hover .del-code { opacity: 1; }

/* 프롬프트 · 로어북 */
.prompt-area { width: 100%; min-height: 420px; font-family: ui-monospace, "D2Coding", Consolas, monospace; font-size: 13px; line-height: 1.6; }
.prompt-area.short { min-height: 160px; }
.count { font-size: 12px; color: var(--muted); }
.prompt-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
.hist-item { padding: 8px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.hist-item:hover { background: var(--surface-2); }
.lore-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.lore-sum { display: flex; gap: 10px; align-items: center; padding: 10px 14px; cursor: pointer; min-width: 0; }
.lore-sum .tt { font-weight: 600; flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lore-sum .pv { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lore-edit { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.lore-edit textarea { min-height: 200px; font-size: 13px; line-height: 1.6; }

/* 라이트박스 */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8,10,16,.92); display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.lb-stage { position: relative; display: grid; place-items: center; padding: 20px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 40px); object-fit: contain; border-radius: 8px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: none; font-size: 34px; width: 48px; height: 72px; border-radius: 12px; cursor: pointer; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
.lb-side { background: var(--surface); padding: 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.lb-side label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.lb-top { display: flex; justify-content: space-between; align-items: center; }
.lb-info { font-size: 13px; display: flex; flex-direction: column; gap: 4px; word-break: break-all; }
.lb-info .big { font-size: 22px; font-weight: 800; }

.upload-bar { position: fixed; right: 20px; bottom: 20px; z-index: 70; width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.2); display: flex; flex-direction: column; gap: 8px; }
.preset-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.preset-group h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.preset-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px; }
.preset-items label { display: flex; gap: 6px; align-items: center; font-size: 13.5px; cursor: pointer; }
.preset-items input, .sens-toggle input { width: auto; }
.sens-toggle { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.form-grid .chk { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.form-grid .chk input { width: auto; }

@media (max-width: 860px) {
  .chars-layout, .prompt-grid, .form-2, .ov-grid { grid-template-columns: 1fr; }
  .char-list { position: static; max-height: 220px; }
  .lightbox { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .lb-side { max-height: 45vh; }
  .slots { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .upload-bar { left: 16px; right: 16px; width: auto; }
}
