/* PWA Wiki pane — mobile-first project vault notes browser */
.project-wiki-pane {
  display: block;
  padding: 10px 12px 16px;
}
.wiki-pane-root {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.wiki-chat-panel-toggle:focus-visible,
.wiki-chat button:focus-visible,
.wiki-chat textarea:focus-visible {
  outline: 2px solid var(--accent, #8bd3dd);
  outline-offset: 2px;
}
.wiki-pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.wiki-pane-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wiki-pane-tabs::-webkit-scrollbar { display: none; }
.wiki-pane-title {
  font-size: 14px;
}
.wiki-source-tab {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--subtext, #9da9b8);
  cursor: pointer;
  transition: all 0.15s;
}
.wiki-source-tab:hover {
  color: var(--text, #e6edf3);
  background: rgba(255, 255, 255, 0.05);
}
.wiki-source-tab.wiki-tab-active {
  color: var(--accent, #8bd3dd);
  background: rgba(139, 211, 221, 0.1);
  border-bottom: 2px solid var(--accent, #8bd3dd);
}
.wiki-pane-freshness {
  margin-left: auto;
  font-size: 11px;
  opacity: 0.6;
}
/* === Wiki ACP chat === */
.wiki-chat-panel-toggle,
.wiki-chat-panel-close {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(139, 211, 221, 0.55);
  border-radius: 8px;
  background: rgba(139, 211, 221, 0.1);
  color: var(--accent, #8bd3dd);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.wiki-chat-panel {
  position: absolute;
  z-index: 12;
  top: 42px;
  right: 0;
  bottom: 0;
  width: min(430px, 42vw);
  min-width: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line, rgba(221, 230, 237, 0.16));
  border-radius: 14px 0 0 14px;
  background: var(--panel, #10141d);
  box-shadow: -18px 0 42px rgba(0, 0, 0, 0.32);
}
.wiki-chat-panel[hidden] {
  display: none;
}
.wiki-pane-root.wiki-chat-focused {
  overflow: hidden;
}
.wiki-pane-root.wiki-chat-focused .wiki-pane-head,
.wiki-pane-root.wiki-chat-focused .wiki-pane-body {
  display: none;
}
.wiki-pane-root.wiki-chat-focused .wiki-chat-panel {
  position: relative;
  z-index: auto;
  inset: auto;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border-radius: 14px;
  box-shadow: none;
}
.wiki-pane-root.wiki-chat-focused .wiki-chat-panel-close {
  display: none;
}
.wiki-chat-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, rgba(221, 230, 237, 0.14));
}
.wiki-chat-panel-head > div {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.wiki-chat-panel-head strong {
  font-size: 13px;
}
.wiki-chat-scope-label {
  color: var(--subtext, #9da9b8);
  font-size: 10px;
}
.wiki-chat-panel-close {
  border-color: rgba(128, 128, 128, 0.3);
  background: transparent;
  color: inherit;
}
.wiki-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  padding: 10px;
}
.wiki-chat[hidden] {
  display: none;
}
.wiki-chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wiki-chat-rag-status {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--subtext, #9da9b8);
  font-size: 10px;
}
.wiki-chat-source-plan {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent, #58a6ff);
  font-size: 11px;
}
.wiki-chat-reset,
.wiki-chat-history,
.wiki-chat-ontology-guide {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 11px;
  cursor: pointer;
}
.wiki-chat-reset,
.wiki-chat-history,
.wiki-chat-ontology-guide {
  border-radius: 7px;
  opacity: 0.7;
}
.wiki-chat-ontology-guide {
  border-color: rgba(118, 216, 223, 0.42);
  color: var(--accent, #8bd3dd);
}
.wiki-chat-ontology-guide:hover,
.wiki-chat-history:hover,
.wiki-chat-reset:hover {
  opacity: 1;
}
.wiki-chat-ontology-guide:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}
.wiki-chat-history:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}
.wiki-personal-learning-open { min-height: 44px; }
.wiki-personal-learning-modal {
  width: min(680px, calc(100vw - 32px));
  max-height: min(780px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line, rgba(128, 128, 128, 0.3));
  border-radius: 16px;
  background: var(--panel, #101722);
  color: inherit;
}
.wiki-personal-learning-modal::backdrop { background: rgba(2, 6, 23, 0.72); }
.wiki-personal-learning-body {
  display: grid;
  gap: 10px;
  max-height: calc(100dvh - 104px);
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.wiki-personal-learning-section {
  border: 1px solid rgba(128, 128, 128, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}
.wiki-personal-learning-section > summary {
  min-height: 44px;
  padding: 12px;
  font-weight: 800;
  cursor: pointer;
}
.wiki-personal-learning-section > div { display: grid; gap: 8px; padding: 0 12px 12px; }
.wiki-personal-learning-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}
.wiki-personal-learning-item small,
.wiki-personal-learning-empty { margin: 0; color: var(--subtext, #9da9b8); line-height: 1.45; }
.wiki-personal-learning-badge {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  font-size: 10px;
  font-weight: 800;
}
.wiki-learn-scope {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
}
.wiki-learn-scope[hidden] { display: none; }
.wiki-learn-scope legend { padding: 0 5px; color: #6ee7b7; font-size: 11px; font-weight: 800; }
.wiki-learn-scope label {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 8px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}
.wiki-learn-scope input { width: 20px; height: 20px; accent-color: #34d399; }
.wiki-learning-candidates { display: grid; gap: 8px; }
.wiki-learning-candidates[hidden] { display: none; }
.wiki-learning-candidate {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(52, 211, 153, 0.38);
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.07);
}
.wiki-learning-candidate div { display: flex; justify-content: space-between; gap: 8px; }
.wiki-learning-candidate p { margin: 0; font-size: 13px; line-height: 1.45; }
.wiki-learning-candidate small { color: var(--subtext, #9da9b8); overflow-wrap: anywhere; }
.wiki-learning-candidate button { min-height: 44px; border: 0; border-radius: 9px; font-weight: 800; }
.wiki-chat-messages {
  flex: 1 1 auto;
  min-height: 180px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 2px 12px;
  scrollbar-gutter: stable;
}
.wiki-chat-message {
  width: min(88%, 720px);
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid rgba(128, 128, 128, 0.2);
  border-radius: 12px;
}
.wiki-chat-message > span {
  display: block;
  margin-bottom: 4px;
  color: var(--subtext, #9da9b8);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.03em;
}
.wiki-chat-user {
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: rgba(37, 99, 235, 0.16);
}
.wiki-chat-assistant {
  border-bottom-left-radius: 4px;
  background: rgba(139, 211, 221, 0.06);
}
.wiki-chat-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(128, 128, 128, 0.18);
}
.wiki-chat-source-warning {
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 7px;
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  font-size: 11px;
  line-height: 1.45;
}
.wiki-chat-sources small {
  flex: 0 0 100%;
  color: var(--subtext, #9da9b8);
  font-size: 9px;
  font-weight: 800;
}
.wiki-chat-source {
  max-width: 100%;
  padding: 3px 7px;
  overflow: hidden;
  border: 1px solid rgba(124, 58, 237, 0.42);
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.1);
  color: #a78bfa;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.wiki-chat-streaming {
  border-color: rgba(139, 211, 221, 0.4);
}
.wiki-chat-partial {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding: 8px 9px;
  border: 1px solid rgba(251, 191, 36, 0.36);
  border-radius: 9px;
  background: rgba(245, 158, 11, 0.09);
  color: #fcd34d;
  font-size: 11px;
}
.wiki-chat-partial button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid rgba(251, 191, 36, 0.46);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
  font-weight: 750;
  cursor: pointer;
}
.wiki-chat-html-inline {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.38);
  border-radius: 11px;
  background: #09131c;
}
.wiki-chat-html-inline summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 10px;
  color: #dffaff;
  cursor: pointer;
  list-style: none;
}
.wiki-chat-html-inline summary::-webkit-details-marker {
  display: none;
}
.wiki-chat-html-inline summary::before {
  flex: 0 0 auto;
  color: #67e8f9;
  content: '▸';
  transition: transform 0.16s ease;
}
.wiki-chat-html-inline[open] summary::before {
  transform: rotate(90deg);
}
.wiki-chat-html-inline summary > span:first-of-type {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}
.wiki-chat-html-inline summary strong {
  color: #67e8f9;
  font-size: 10px;
  letter-spacing: 0.08em;
}
.wiki-chat-html-inline summary small {
  overflow: hidden;
  color: #91a3ae;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-chat-html-inline-action {
  flex: 0 0 auto;
  color: #91a3ae;
  font-size: 9px;
}
.wiki-chat-html-inline-body {
  height: clamp(260px, 46vh, 520px);
  border-top: 1px solid rgba(34, 211, 238, 0.2);
  background: var(--gray-surface, #2b3038);
}
.wiki-chat-html-inline-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--gray-surface, #2b3038);
}
.wiki-html-viewer-modal {
  width: min(96vw, 1180px);
  max-width: 96vw;
  height: min(92dvh, 940px);
  max-height: 92dvh;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.36);
  border-radius: 16px;
  background: #081019;
  color: #eaf2f6;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68);
}
.wiki-html-viewer-modal::backdrop {
  background: rgba(2, 7, 12, 0.8);
  backdrop-filter: blur(5px);
}
.wiki-html-viewer-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.2);
  background: #0d1721;
}
.wiki-html-viewer-head > div {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}
.wiki-html-viewer-head strong {
  overflow: hidden;
  color: #dffaff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-html-viewer-head span {
  color: #91a3ae;
  font-size: 10px;
}
.wiki-html-viewer-close {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 13px;
  border: 1px solid rgba(145, 163, 174, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.wiki-html-viewer-close:hover,
.wiki-html-viewer-close:focus-visible {
  border-color: rgba(103, 232, 249, 0.55);
  background: rgba(34, 211, 238, 0.1);
  outline: none;
}
.wiki-chat-history-modal {
  width: min(92vw, 560px);
  max-height: min(80dvh, 720px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.36);
  border-radius: 16px;
  background: #081019;
  color: #eaf2f6;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68);
}
.wiki-chat-history-modal::backdrop {
  background: rgba(2, 7, 12, 0.8);
  backdrop-filter: blur(5px);
}
.wiki-chat-history-close {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 13px;
  border: 1px solid rgba(145, 163, 174, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
}
.wiki-chat-history-list {
  display: grid;
  gap: 8px;
  max-height: calc(min(80dvh, 720px) - 59px);
  padding: 12px;
  overflow-y: auto;
}
.wiki-chat-history-list button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid rgba(145, 163, 174, 0.24);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.wiki-chat-history-list button[aria-current="true"] {
  border-color: rgba(34, 211, 238, 0.6);
  background: rgba(34, 211, 238, 0.1);
}
.wiki-chat-history-list strong,
.wiki-chat-history-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-chat-history-list span {
  color: #91a3ae;
  font-size: 10px;
}
.wiki-html-viewer-frame {
  display: block;
  width: 100%;
  height: calc(100% - 58px);
  border: 0;
  background: var(--gray-surface, #2b3038);
}
.wiki-chat-empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--subtext, #9da9b8);
}
.wiki-chat-empty strong {
  color: var(--text, #e6edf3);
  font-size: 14px;
}
.wiki-chat-empty span {
  max-width: 360px;
  font-size: 12px;
}
.wiki-chat-progress,
.wiki-chat-error {
  margin: 8px auto;
  font-size: 11px;
  text-align: center;
}
.wiki-chat-progress {
  color: var(--accent, #8bd3dd);
}
.wiki-chat-activities {
  width: min(94%, 720px);
  margin: 6px 0 10px;
  padding: 9px 11px;
  border: 1px solid rgba(139, 211, 221, 0.22);
  border-radius: 10px;
  background: rgba(139, 211, 221, 0.045);
}
.wiki-chat-activities > strong {
  display: block;
  margin-bottom: 5px;
  color: var(--subtext, #9da9b8);
  font-size: 9px;
  letter-spacing: 0.05em;
}
.wiki-chat-activities ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wiki-chat-activities li {
  display: grid;
  grid-template-columns: 16px auto minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  color: var(--subtext, #9da9b8);
  font-size: 10px;
}
.wiki-chat-activities li > span {
  color: var(--accent, #8bd3dd);
  font-weight: 900;
  text-align: center;
}
.wiki-chat-activities li > strong {
  color: #c4b5fd;
  font-size: 10px;
}
.wiki-chat-activities li > em {
  overflow: hidden;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-chat-activities .wiki-chat-activity-denied > span {
  color: #fb7185;
}
.wiki-chat-activities .wiki-chat-activity-completed > span,
.wiki-chat-activities .wiki-chat-activity-approved > span {
  color: #6ee7b7;
}
.wiki-chat-error {
  color: #fb7185;
}
.wiki-chat-proposal:empty {
  display: none;
}
.wiki-chat-proposal-card {
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.55);
  border-radius: 12px;
  background: rgba(62, 39, 5, 0.94);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25);
}
.wiki-chat-proposal-card > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.wiki-chat-proposal-card > div:first-child span {
  font-size: 10px;
  opacity: 0.65;
}
.wiki-chat-proposal-card pre {
  max-height: 150px;
  margin: 8px 0;
  padding: 8px;
  overflow: auto;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.22);
  font-size: 11px;
  white-space: pre-wrap;
}
.wiki-chat-proposal-card p {
  margin: 6px 0;
  font-size: 11px;
}

.wiki-chat-proposal-readback {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(103, 232, 249, 0.28);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
}

.wiki-chat-proposal-readback > div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
}

.wiki-chat-proposal-readback dt { color: #94a3b8; }
.wiki-chat-proposal-readback dd { margin: 0; overflow-wrap: anywhere; }
.wiki-chat-proposal-card .wiki-chat-gate-warning {
  color: #fbbf24;
  font-weight: 700;
}
.wiki-chat-proposal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.wiki-chat-proposal-actions button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font-weight: 750;
  cursor: pointer;
}
.wiki-chat-proposal-actions .wiki-chat-approve {
  border-color: #f59e0b;
  background: #f59e0b;
  color: #211400;
}
.wiki-chat-natural-hint {
  color: var(--subtext, #9da9b8);
  font-size: 10px;
  line-height: 1.45;
  padding: 0 3px;
}
.wiki-chat-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.wiki-chat-model-row > span {
  color: var(--subtext, #9da9b8);
  font-size: 10px;
  font-weight: 700;
}
.wiki-chat-model-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(52px, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(128, 128, 128, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
}
.wiki-chat-model-toggle button {
  min-height: 30px;
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--subtext, #9da9b8);
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}
.wiki-chat-model-toggle button.wiki-chat-model-active {
  background: var(--accent, #8bd3dd);
  color: #071219;
  box-shadow: 0 2px 8px rgba(139, 211, 221, 0.2);
}
.wiki-chat-composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-end;
  gap: 6px 8px;
  padding: 8px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 14px;
  background: rgba(8, 13, 22, 0.88);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-height: var(--wiki-chat-composer-max-height, 176px);
  overflow: hidden;
}
.wiki-chat-composer-mode {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 1px 3px 2px;
}
.wiki-chat-composer-mode[hidden] {
  display: none;
}
.wiki-chat-composer-mode strong {
  flex: 0 0 auto;
  color: var(--amber, #f2cc8f);
  font-size: 9px;
  letter-spacing: 0.08em;
}
.wiki-chat-composer-mode span {
  min-width: 0;
  color: var(--subtext, #9da9b8);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-chat-composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  max-height: var(--wiki-chat-input-max-height, 120px);
  padding: 11px 12px;
  resize: none;
  border: 0;
  border-radius: 10px;
  outline: 0;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  font: inherit;
  font-size: 13px;
  line-height: 1.45;
  overflow-y: auto;
}
.wiki-chat-composer button {
  flex: 0 0 auto;
  min-width: 58px;
  min-height: 44px;
  padding: 0 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent, #8bd3dd);
  color: #071219;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.wiki-chat button:disabled {
  cursor: default;
  opacity: 0.45;
}
/* === 상태 카드 (로딩/빈/에러 공통) === */
.wiki-pane-status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  border: 1px dashed rgba(128, 128, 128, 0.35);
  border-radius: 10px;
  text-align: center;
}
.wiki-pane-status-card .wiki-status-icon {
  font-size: 22px;
}
.wiki-pane-status-card strong {
  font-size: 13px;
}
.wiki-pane-status-card span {
  font-size: 12px;
  opacity: 0.65;
  max-width: 320px;
}
/* === 프로젝트 위키 노트 === */
.wiki-pane-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.wiki-pane-folders button {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.wiki-pane-folders button.wiki-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
.wiki-pane-folders button span {
  opacity: 0.6;
  font-size: 10px;
}
.wiki-pane-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 38vh;
  overflow-y: auto;
}
.wiki-pane-list button {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid rgba(128, 128, 128, 0.25);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wiki-pane-list button.wiki-active {
  border-color: #2563eb;
}
.wiki-pane-list button strong {
  font-size: 13px;
  word-break: break-all;
}
.wiki-pane-list button span {
  font-size: 11px;
  opacity: 0.6;
}
.wiki-note-modal {
  width: min(90vw, 860px);
  max-width: 90vw;
  max-height: 85vh;
  padding: 0;
  border: 1px solid var(--line, rgba(221, 230, 237, 0.12));
  border-radius: 8px;
  background: var(--panel, #10141d);
  color: var(--text, #e6edf3);
  overflow-y: auto;
}
.wiki-note-modal::backdrop {
  background: rgba(0, 0, 0, 0.58);
}
.wiki-note-modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line, rgba(221, 230, 237, 0.12));
  background: var(--panel, #10141d);
}
.wiki-note-modal-title {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-note-modal-meta {
  font-size: 11px;
  opacity: 0.6;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-note-modal-close {
  flex: 0 0 auto;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  cursor: pointer;
}
.wiki-note-modal-close:hover {
  background: rgba(128, 128, 128, 0.15);
}
.wiki-note-modal-body {
  padding: 12px 16px;
}
/* === 데스크톱: 좌우 분할 인라인 reader === */
.wiki-pane-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wiki-pane-notes-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wiki-pane-reader {
  display: none;
}
.wiki-pane-reader-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line, rgba(128, 128, 128, 0.25));
}
.wiki-pane-reader-head strong {
  font-size: 14px;
  word-break: break-all;
}
.wiki-pane-reader-meta {
  font-size: 11px;
  opacity: 0.6;
}
.wiki-pane-reader-close {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--line, rgba(128, 128, 128, 0.35));
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.wiki-pane-reader-body {
  overflow-y: auto;
}
@media (min-width: 769px) and (max-width: 1279px) {
  .wiki-pane-root.wiki-chat-focused .wiki-chat-panel-head {
    display: none;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.38fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-toolbar {
    grid-column: 1;
    grid-row: 1;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-model-row,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-natural-hint,
  .wiki-pane-root.wiki-chat-focused .wiki-learning-candidates,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-proposal {
    grid-column: 2;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-messages {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer {
    grid-column: 1;
    grid-row: 3;
  }
}
@media (min-width: 1280px) and (any-pointer: fine) {
  .wiki-pane-root.wiki-chat-focused .wiki-chat-panel-head {
    display: none;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat {
    display: grid;
    grid-template-columns: minmax(210px, 0.72fr) minmax(0, 2fr) minmax(220px, 0.78fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 10px;
    padding: 10px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-toolbar {
    grid-column: 1;
    grid-row: 1;
    align-content: start;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-model-row,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-natural-hint,
  .wiki-pane-root.wiki-chat-focused .wiki-learning-candidates,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-proposal {
    grid-column: 3;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-messages {
    grid-column: 2;
    grid-row: 1 / 3;
    min-height: 0;
    padding: 2px 8px 10px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer {
    grid-column: 2;
    grid-row: 3;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-message {
    width: min(92%, 820px);
  }
}
@media (min-width: 769px) {
  .wiki-pane-root {
    overflow: hidden;
  }
  .wiki-pane-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: margin-right 0.18s ease;
  }
  .wiki-pane-root.wiki-chat-panel-open .wiki-pane-body {
    margin-right: min(430px, 42vw);
  }
  .wiki-pane-notes {
    flex-direction: row;
    gap: 12px;
    min-height: 0;
    flex: 1;
  }
  .wiki-pane-notes-sidebar {
    flex: 0 0 280px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding-right: 8px;
    border-right: 1px solid var(--line, rgba(128, 128, 128, 0.25));
  }
  .wiki-pane-notes-sidebar .wiki-pane-list {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }
  .wiki-pane-reader {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  .wiki-pane-reader[hidden] {
    display: none;
  }
  .wiki-pane-reader-body {
    flex: 1;
    overflow-y: auto;
    padding-top: 8px;
  }
}
@media (max-width: 768px) {
  .wiki-personal-learning-modal {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .wiki-personal-learning-body { max-height: calc(100dvh - 64px); }
}
.wiki-md {
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
  overflow-x: hidden;
}
.wiki-md h3,
.wiki-md h4,
.wiki-md h5,
.wiki-md h6 {
  margin: 12px 0 4px;
}
.wiki-md h3 {
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}
.wiki-md p {
  margin: 6px 0;
}
.wiki-md ul {
  margin: 6px 0 6px 18px;
}
.wiki-md blockquote {
  border-left: 3px solid rgba(128, 128, 128, 0.4);
  padding-left: 8px;
  opacity: 0.85;
  margin: 6px 0;
}
.wiki-md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: rgba(128, 128, 128, 0.15);
  padding: 1px 4px;
  border-radius: 4px;
}
.wiki-md .wiki-md-code {
  background: rgba(128, 128, 128, 0.12);
  border-radius: 8px;
  padding: 8px;
  overflow-x: auto;
  margin: 6px 0;
}
.wiki-md .wiki-md-code code {
  background: transparent;
  padding: 0;
  white-space: pre;
}
.wiki-md .wiki-md-tablerow {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
  overflow-x: auto;
}
/* wikilink — 터치 가능한 칩 (모바일 탭 타깃 확보) */
.wiki-md-wikilink {
  display: inline-block;
  padding: 1px 8px;
  margin: 1px 0;
  border: 1px solid rgba(124, 58, 237, 0.45);
  border-radius: 999px;
  color: #a78bfa;
  background: rgba(124, 58, 237, 0.1);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.5;
}
.wiki-md-wikilink:hover {
  background: rgba(124, 58, 237, 0.22);
}
.wiki-md-wikilink-missing {
  opacity: 0.5;
  border-style: dashed;
  cursor: default;
}
@media (max-width: 640px) {
  .wiki-pane-list {
    max-height: none;
    overflow-y: visible;
  }
  .project-wiki-pane {
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
  }
  .wiki-chat-panel {
    position: fixed;
    z-index: 90;
    inset: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    width: auto;
    min-width: 0;
    border-radius: 14px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.56);
  }
  .wiki-chat-toolbar {
    align-items: flex-start;
  }
  .wiki-chat-reset {
    min-height: 36px;
  }
  .wiki-chat-history {
    min-height: 36px;
  }
  .wiki-chat-ontology-guide {
    min-height: 36px;
  }
  .wiki-chat-model-toggle button {
    min-width: 58px;
    min-height: 36px;
  }
  .wiki-chat-messages {
    padding-bottom: 4px;
  }
  .wiki-chat-message {
    width: 92%;
  }
  .wiki-chat-proposal-card {
    max-height: 42vh;
    overflow-y: auto;
  }
  .wiki-chat-composer {
    position: static;
    bottom: auto;
    z-index: auto;
    padding-bottom: max(7px, env(safe-area-inset-bottom));
  }
  .wiki-chat-html-inline-body {
    height: min(42dvh, 420px);
    min-height: 240px;
  }
  .wiki-html-viewer-modal {
    width: calc(100vw - 12px);
    max-width: none;
    height: calc(100dvh - 12px);
    max-height: none;
    border-radius: 12px;
  }
  /* Main Chat mobile density: keep controls thumb-friendly while giving the
     conversation and composer most of the available viewport. */
  .wiki-pane-root.wiki-chat-focused .wiki-chat-panel {
    border-radius: 12px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-panel-head {
    display: none;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat {
    gap: 6px;
    padding: 7px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-toolbar {
    display: grid;
    grid-template-columns: auto auto auto;
    align-items: center;
    gap: 5px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-ontology-guide,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-history,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-reset {
    min-height: 38px;
    padding: 5px 8px;
    white-space: nowrap;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-messages {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0 1px 3px;
    scrollbar-gutter: auto;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-messages > :first-child {
    margin-top: auto;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-message {
    width: calc(100% - 10px);
    max-width: none;
    margin: 5px 0;
    padding: 9px 10px;
    border-radius: 11px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-user {
    width: fit-content;
    max-width: 86%;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-model-row {
    display: none;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-natural-hint {
    display: none;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer {
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 4px 6px;
    padding: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    border-radius: 12px;
    background: rgba(8, 13, 22, 0.98);
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer-mode {
    gap: 5px;
    padding: 0 2px 1px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer-mode strong {
    font-size: 8px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer-mode span {
    font-size: 9px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer textarea,
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer button {
    min-height: 46px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer textarea {
    padding: 10px;
  }
  .wiki-pane-root.wiki-chat-focused .wiki-chat-composer button {
    min-width: 64px;
    padding: 0 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .wiki-source-tab,
  .wiki-pane-body,
  .wiki-chat-html-inline summary::before {
    transition: none;
  }
}

.wiki-assistant-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  border-radius: 999px;
  color: #bfdbfe;
  background: rgba(30, 64, 175, 0.18);
  font-size: 11px;
  font-weight: 700;
}
.wiki-assistant-settings {
  width: min(560px, calc(100vw - 24px));
  max-height: min(780px, calc(100dvh - 24px));
  margin: auto;
  padding: 0;
  overflow: hidden auto;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 18px;
  color: #e5e7eb;
  background: #0b1220;
}
.wiki-assistant-settings::backdrop { background: rgba(2, 6, 23, 0.72); }
.wiki-assistant-settings-form { display: grid; gap: 14px; padding: 18px; }
.wiki-assistant-settings-form header,
.wiki-assistant-settings-form footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wiki-assistant-settings-form header div { display: grid; gap: 3px; }
.wiki-assistant-settings-form label { display: grid; gap: 6px; font-size: 12px; }
.wiki-assistant-settings-form select,
.wiki-assistant-settings-form input,
.wiki-assistant-settings-form textarea { min-height: 44px; padding: 9px; color: inherit; background: #111827; border: 1px solid #334155; border-radius: 9px; }
.wiki-assistant-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.wiki-assistant-preview,
.wiki-assistant-feature-matrix { padding: 12px; border-radius: 10px; background: rgba(30, 41, 59, 0.72); }
.wiki-assistant-feature-matrix p { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.wiki-assistant-feature-matrix small { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .wiki-assistant-settings { width: 100vw; max-width: none; height: min(88dvh, 760px); max-height: none; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .wiki-assistant-settings-form { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .wiki-assistant-settings-form footer { position: sticky; bottom: 0; padding-top: 8px; background: #0b1220; }
}
