/* AI 도우미(시험 — views/assistant.js). 색은 셸의 토큰 + 도우미 색 하나(보라 — 앱 색과 겹치지 않게) */
:root { --ai: #6D4AE0; --ai-d: #5233C2; --ai-t: #F1EDFE; }
.appicon.assistant { background: var(--ai); }

.ai-page { display: flex; flex-direction: column; gap: 14px; max-width: 920px; margin: 0 auto; min-height: calc(100dvh - var(--top) - 32px); }
.ai-head { display: flex; align-items: center; gap: 14px; }
.ai-head h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.ai-mark { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--ai-t); color: var(--ai); }
.ai-mark .ic { width: 26px; height: 26px; }
.ai-pilot { font-size: 12.5px; }
.ai-sub { margin: 4px 0 0; color: var(--ink3); font-size: 14px; line-height: 1.55; }

.ai-log { flex: 1; min-height: 320px; display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow-y: auto; }
.ai-empty { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 24px 8px; }
.ai-hello { margin: 0; font-size: 20px; font-weight: 700; }
.ai-tip { margin: 0 0 8px; color: var(--ink3); font-size: 14.5px; max-width: 560px; }
.ai-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-ex { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--line2); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14.5px; text-align: left; cursor: pointer; }
.ai-ex:hover, .ai-ex:focus-visible { border-color: var(--ai); background: var(--ai-t); }
.ai-ex .ic { color: var(--ai); flex: none; }

.ai-msg { display: flex; gap: 10px; }
.ai-msg.me { justify-content: flex-end; }
.ai-msg.me .ai-bub { max-width: 78%; background: var(--ai); color: #fff; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.ai-msg.bot .ai-col { flex: 1; min-width: 0; max-width: 88%; display: flex; flex-direction: column; gap: 6px; }
.ai-msg.bot .ai-bub { background: var(--soft); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; }
.ai-bub { padding: 11px 15px; font-size: 15.5px; line-height: 1.7; overflow-wrap: anywhere; }
.ai-bub p { margin: 0 0 8px; }
.ai-bub p:last-child, .ai-bub ul:last-child, .ai-bub ol:last-child { margin-bottom: 0; }
.ai-bub ul, .ai-bub ol { margin: 0 0 8px; padding-left: 22px; }
.ai-bub li { margin: 2px 0; }
.ai-bub code { padding: 1px 5px; border-radius: 6px; background: var(--hover); font-family: var(--mono); font-size: 13.5px; }
.ai-bub .ai-h { font-weight: 700; margin-top: 4px; }
.ai-ava { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--ai-t); color: var(--ai); }
.ai-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--ink3); }
.ai-src { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ai-chip { padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--ink2); }
.ai-copy { font-size: 12.5px; min-height: 32px; }
.ai-ms { margin-left: auto; }
.ai-err { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; color: var(--dgr); font-size: 14px; }
.ai-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); opacity: .35; animation: aiDot 1.2s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-dots i { animation: none; opacity: .7; } }

.ai-compose { position: sticky; bottom: 0; display: flex; align-items: flex-end; gap: 10px; padding: 10px; border: 1px solid var(--line2); border-radius: 16px; background: var(--surface); box-shadow: 0 6px 20px rgba(23, 33, 46, .06); }
.ai-compose .ai-input { flex: 1; min-height: 48px; max-height: 200px; resize: none; border: none; box-shadow: none; padding: 12px 10px; font-size: 16px; line-height: 1.5; background: transparent; }
.ai-compose .ai-input:focus { outline: none; box-shadow: none; border: none; }
.ai-compose:focus-within { border-color: var(--ai); }
.ai-send { min-height: 48px; flex: none; }
.ai-send.primary { background: var(--ai); border-color: var(--ai); }
.ai-send.primary:hover { background: var(--ai-d); }
.ai-note { margin: 0; color: var(--ink3); font-size: 12.5px; text-align: center; }

@media (max-width: 719px) {
  .ai-page { gap: 10px; min-height: calc(100dvh - var(--top) - 16px); }
  .ai-head h1 { font-size: 19px; }
  .ai-sub { font-size: 13px; }
  .ai-log { padding: 12px; border-radius: 12px; }
  .ai-msg.me .ai-bub { max-width: 88%; }
  .ai-msg.bot .ai-col { max-width: 100%; }
  .ai-ava { display: none; }
}

/* 대화 판(전체 화면 · 오른쪽 팝업 공용) */
.ai-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }

/* 오른쪽 아래 버튼 — 쓸 수 있는 사람에게만(views/assistant.js#syncAssistant). 팝업이 열려 있으면 감춘다 */
.ai-fab { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px 0 16px;
  border: none; border-radius: 999px; background: var(--ai); color: #fff; font: inherit; font-size: 15.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 28px rgba(82, 51, 194, .35); }
.ai-fab:hover { background: var(--ai-d); }
.ai-fab:focus-visible { outline: 3px solid var(--ai-t); outline-offset: 2px; }
.ai-fab .ic { width: 22px; height: 22px; }
body.ai-open .ai-fab { display: none; }

/* 오른쪽 팝업 — 화면 위에 겹친다(내용은 그대로). 휴대폰은 화면 전체 */
.ai-drawer { position: fixed; top: var(--top); right: 0; bottom: 0; z-index: 50; width: 440px; max-width: 100vw; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -18px 0 40px rgba(23, 33, 46, .14); animation: aiIn .18s ease-out; }
@keyframes aiIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ai-drawer { animation: none; } }
.ai-dhead { flex: none; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); }
.ai-dhead b { flex: 1 1 0%; min-width: 0; white-space: nowrap; display: flex; align-items: center; gap: 6px; font-size: 16px; }
.ai-ibtn { display: grid; place-items: center; width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent; color: var(--ink2); cursor: pointer; }
.ai-ibtn:hover, .ai-ibtn:focus-visible { background: var(--hover); color: var(--ink); }
.ai-drawer .ai-panel { padding: 12px; gap: 10px; }
.ai-panel.compact .ai-log { min-height: 0; padding: 12px; border: none; border-radius: 0; background: transparent; }
.ai-panel.compact .ai-empty { padding: 12px 4px; }
.ai-panel.compact .ai-hello { font-size: 18px; }
.ai-panel.compact .ai-tip { font-size: 13.5px; }
.ai-panel.compact .ai-examples { flex-direction: column; align-items: stretch; }
.ai-panel.compact .ai-ex { border-radius: 12px; }
.ai-panel.compact .ai-msg.me .ai-bub { max-width: 88%; }
.ai-panel.compact .ai-msg.bot .ai-col { max-width: 100%; }
.ai-panel.compact .ai-ava { display: none; }
.ai-panel.compact .ai-bub { font-size: 14.5px; padding: 10px 13px; }
.ai-panel.compact .ai-compose { position: static; box-shadow: none; }
.ai-panel.compact .ai-note { font-size: var(--fs-min); }

@media (max-width: 719px) {
  .ai-fab { right: 16px; bottom: 16px; width: 56px; height: 56px; padding: 0; justify-content: center; }
  .ai-fab span { display: none; }
  .ai-drawer { top: 0; width: 100vw; border-left: none; }
}

/* 바로 가기(답 아래) — 그 일을 하는 화면으로 */
.ai-go { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ai-golink { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--ai); border-radius: 999px; background: var(--ai-t); color: var(--ai-d); font-size: 13px; font-weight: 600; text-decoration: none; }
.ai-golink:hover, .ai-golink:focus-visible { background: var(--ai); color: #fff; }

/* 지난 대화 */
.ai-hist { display: flex; flex-direction: column; gap: 6px; }
.ai-hist-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ai-hist-h b { font-size: 16px; }
.ai-hist-h .ai-tip { margin: 0; flex: 1; font-size: 12.5px; }
.ai-hist-row { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ai-hist-row.on { border-color: var(--ai); background: var(--ai-t); }
.ai-hist-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; min-height: 52px; padding: 8px 12px; border: none; background: transparent; text-align: left; cursor: pointer; color: var(--ink); }
.ai-hist-t { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-hist-d { font-size: 12.5px; color: var(--ink3); }

/* 닫기 — PC 는 아이콘, 휴대폰은 글자까지(눈에 띄게, 누르는 곳 44px) */
.ai-close span { display: none; }
@media (max-width: 719px) {
  .ai-dhead { height: 60px; padding: 0 8px 0 14px; }
  .ai-ibtn { width: 44px; height: 44px; }
  .ai-wide { display: none; }
  .ai-close { display: inline-flex; align-items: center; width: auto; gap: 4px; padding: 0 14px; border: 1px solid var(--line2); border-radius: 999px; background: var(--soft); color: var(--ink); font: inherit; font-size: 15px; font-weight: 700; }
  .ai-close span { display: inline; }
}

/* 👍 · 👎(답 아래) — 👎 는 까닭을 골라 보낸다 */
.ai-votes { display: inline-flex; gap: 2px; }
.ai-vote { width: 32px; height: 32px; color: var(--ink3); }
.ai-vote.on { color: var(--ai-d); background: var(--ai-t); }
.ai-vote.on.dn { color: var(--dgr); background: var(--dgr-t); }
.ai-dn { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { min-height: 32px; padding: 4px 12px; border: 1px solid var(--line2); border-radius: 999px; background: var(--surface); color: var(--ink2); font: inherit; font-size: 13px; cursor: pointer; }
.ai-chip.on { border-color: var(--ai); background: var(--ai-t); color: var(--ai-d); font-weight: 600; }
.ai-dn-row { display: flex; gap: 6px; align-items: center; }
.ai-dn-note { flex: 1; min-width: 0; }
@media (max-width: 719px) {
  .ai-vote { width: 40px; height: 40px; }
  .ai-chip { min-height: 40px; }
  .ai-dn-row { flex-wrap: wrap; }
  .ai-dn-note { flex-basis: 100%; }
}

/* AI 도우미 관리(#/assistant/admin) */
.aa-page { display: flex; flex-direction: column; gap: 14px; max-width: 1080px; margin: 0 auto; }
.aa-body { display: flex; flex-direction: column; gap: 12px; }
.aa-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.aa-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.aa-stat span { font-size: 12.5px; color: var(--ink3); }
.aa-stat b { font-size: 22px; }
.aa-stat small { font-size: 12px; color: var(--ink3); }
.aa-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.aa-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: none; border-bottom: 2px solid transparent; background: none; color: var(--ink2); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.aa-tab.on { border-bottom-color: var(--ai); color: var(--ink); font-weight: 700; }
.aa-n { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--soft); font-size: 12px; text-align: center; }
.aa-tip { margin: 0; }
.aa-list { display: flex; flex-direction: column; gap: 8px; }
.aa-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.aa-row.off { opacity: .6; }
.aa-row .grow { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.aa-row .hint { margin: 0; font-size: 12.5px; color: var(--ink3); }
.aa-q { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.aa-q b { font-size: 14.5px; }
.aa-prev { margin: 0; font-size: 13px; color: var(--ink2); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.aa-acts { display: flex; gap: 6px; flex-shrink: 0; }
.aa-form { display: flex; flex-direction: column; gap: 12px; }
.aa-answer { min-height: 150px; resize: vertical; }
.aa-link { display: grid; grid-template-columns: 1fr 2fr; gap: 6px; }
.aa-ctx { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-size: 13px; }
.aa-ctx b { font-size: 12px; color: var(--ink3); }
.aa-ctx p { margin: 0 0 6px; white-space: pre-wrap; }
.aa-old { max-height: 120px; overflow: auto; color: var(--ink2); }
@media (max-width: 719px) {
  .aa-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aa-row { flex-direction: column; }
  .aa-acts { width: 100%; }
  .aa-acts .btn { flex: 1; min-height: 44px; }
  .aa-link { grid-template-columns: 1fr; }
}
