/* NoxAI chat memory panel — styles for chat-memory.js.
   Everything is scoped under dialog.noxcm so no other app CSS is touched. */

dialog.noxcm {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: auto;
  left: auto;
  margin: 0;
  width: 420px;
  max-width: none;
  max-height: none;
  height: calc(100vh - 196px);
  height: calc(100dvh - 196px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: #202122;
  color: #e9edf2;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', 'Apple SD Gothic Neo',
    'Noto Sans KR', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Author display rules would otherwise beat the UA `dialog:not([open])` rule. */
dialog.noxcm:not([open]) {
  display: none;
}

dialog.noxcm::backdrop {
  background: rgba(8, 9, 11, 0.45);
}

dialog.noxcm,
dialog.noxcm * {
  box-sizing: border-box;
}

dialog.noxcm button {
  font: inherit;
  color: inherit;
}

.noxcm__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 48px;
  padding: 4px 6px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.noxcm__title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f2f5f8;
}

.noxcm__close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b6bec8;
  cursor: pointer;
}

.noxcm__close:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #f2f5f8;
}

.noxcm__close:focus-visible {
  outline: 2px solid #7db0ff;
  outline-offset: -2px;
}

.noxcm__tabs {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
  padding: 10px 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.noxcm__tab {
  padding: 8px 13px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: #9aa4b0;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.noxcm__tab:hover {
  color: #dfe5eb;
  background: rgba(255, 255, 255, 0.04);
}

.noxcm__tab[aria-selected='true'] {
  color: #f4f7fa;
  border-bottom-color: #4f8cff;
}

.noxcm__tab:focus-visible {
  outline: 2px solid #7db0ff;
  outline-offset: -2px;
}

.noxcm__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.noxcm__body::-webkit-scrollbar {
  width: 10px;
}

.noxcm__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

.noxcm__panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.noxcm__panel[hidden] {
  display: none;
}

.noxcm__panel:focus-visible {
  outline: 2px solid rgba(125, 176, 255, 0.7);
  outline-offset: 2px;
  border-radius: 12px;
}

/* ---- auto summary switch ---- */

.noxcm__switch-row {
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 12px;
}

.noxcm__switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.noxcm__switch-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.noxcm__switch-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #eef2f6;
}

.noxcm__switch-helper {
  font-size: 12.5px;
  line-height: 1.45;
  color: #98a2ae;
  overflow-wrap: anywhere;
}

.noxcm__switch.is-off .noxcm__switch-title {
  color: #c6ccd4;
}

.noxcm__switch-input {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.noxcm__switch-input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f4f6f8;
  transition: transform 0.18s ease;
}

.noxcm__switch-input:checked {
  background: #4f8cff;
  border-color: #4f8cff;
}

.noxcm__switch-input:checked::after {
  transform: translateX(18px);
}

.noxcm__switch-input:focus-visible {
  outline: 2px solid #7db0ff;
  outline-offset: 2px;
}

/* ---- notes / cards / lists ---- */

.noxcm__note {
  margin: 0;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #f0d49a;
  background: rgba(240, 197, 110, 0.09);
  border: 1px solid rgba(240, 197, 110, 0.25);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.noxcm__card,
.noxcm__section {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  padding: 12px 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 12px;
}

.noxcm__card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #cbd3dc;
}

.noxcm__sub-title {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: #aab3be;
}

.noxcm__card-body {
  margin: 0;
  font-size: 13.5px;
  color: #e3e8ee;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.noxcm__card-hint,
.noxcm__turn-hint {
  margin: 0;
  font-size: 12px;
  color: #8b95a1;
}

.noxcm__card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.noxcm__copy,
.noxcm__pager-btn {
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: #e6eaef;
  font-size: 13px;
  cursor: pointer;
}

.noxcm__copy:hover,
.noxcm__pager-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.noxcm__copy:focus-visible,
.noxcm__pager-btn:focus-visible {
  outline: 2px solid #7db0ff;
  outline-offset: 2px;
}

.noxcm__pager-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.noxcm__copy-status {
  font-size: 12px;
  color: #9fb6d8;
  overflow-wrap: anywhere;
}

.noxcm__empty {
  margin: 0;
  padding: 10px 11px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #98a1ac;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow-wrap: anywhere;
}

.noxcm__empty--error {
  color: #f3b6b6;
  background: rgba(226, 106, 106, 0.08);
  border-color: rgba(226, 106, 106, 0.32);
}

/* ---- turn list ---- */

.noxcm__turns-host {
  min-width: 0;
}

.noxcm__turns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.noxcm__turn {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.noxcm__turn-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.noxcm__turn-index {
  flex: 0 0 auto;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #b9c4d1;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
}

.noxcm__turn-meta {
  min-width: 0;
  font-size: 12px;
  color: #8d97a3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.noxcm__turn-body {
  margin: 0;
  font-size: 13.5px;
  color: #dfe4ea;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.noxcm__pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.noxcm__pager-info {
  font-size: 12.5px;
  color: #98a2ae;
  white-space: nowrap;
}

/* ---- state tab ---- */

.noxcm__rows {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}

.noxcm__row-key {
  font-size: 12.5px;
  color: #98a2ae;
}

.noxcm__row-value {
  margin: 0;
  font-size: 13.5px;
  color: #e3e8ee;
  overflow-wrap: anywhere;
}

.noxcm__group {
  display: block;
  min-width: 0;
}

.noxcm__list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.noxcm__list-item {
  position: relative;
  padding-left: 12px;
  font-size: 13.5px;
  color: #dfe4ea;
  overflow-wrap: anywhere;
}

.noxcm__list-item::before {
  content: '·';
  position: absolute;
  left: 0;
  color: #7f8b98;
}

.noxcm__thought {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 0;
}

.noxcm__thought::before {
  content: none;
}

.noxcm__thought-who {
  font-size: 12px;
  font-weight: 600;
  color: #a8b4c2;
}

.noxcm__thought-text {
  overflow-wrap: anywhere;
}

.noxcm__npc {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.noxcm__npc-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.noxcm__npc-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #eef2f6;
  overflow-wrap: anywhere;
}

.noxcm__npc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.noxcm__chip {
  padding: 2px 8px;
  font-size: 11.5px;
  color: #bcc7d4;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  white-space: nowrap;
}

.noxcm__npc-reason {
  margin: 0;
  font-size: 13px;
  color: #c9d1da;
  overflow-wrap: anywhere;
}

/* ---- mobile sheet ---- */

@media (max-width: 640px) {
  dialog.noxcm {
    top: 56px;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100vw;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
  }

  .noxcm__body {
    padding: 12px 12px 16px;
  }

  .noxcm__tabs {
    padding: 8px 10px 0;
    overflow-x: auto;
  }

  .noxcm__pager {
    justify-content: space-between;
  }

  .noxcm__copy,
  .noxcm__pager-btn {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.noxcm *,
  dialog.noxcm *::before,
  dialog.noxcm *::after {
    transition: none !important;
    animation: none !important;
  }
}
/* Match the chat reference: flat dark panel and compact pill tabs. */
dialog.noxcm { width: 400px; height: calc(100dvh - 168px); background: #1a1c1c; border: 0; border-radius: 0; box-shadow: none; font-family: inherit; }
.noxcm__header { border-bottom: 0; padding: 12px 16px 4px; }
.noxcm__title { font-size: 18px; }
.noxcm__tabs { gap: 8px; padding: 8px 16px 12px; border-bottom: 0; }
.noxcm__tab { min-height: 34px; padding: 6px 16px; border: 1px solid #ffffff24; border-radius: 999px; color: #a1a1aa; }
.noxcm__tab[aria-selected='true'] { background: #e5e7eb; color: #18181b; border-color: #e5e7eb; }
.noxcm__switch-input:checked { background: #e5e7eb; border-color: #e5e7eb; }
.noxcm__switch-input:checked::after { background: #27272a; }
@media(max-width:640px) { dialog.noxcm { width: 100%; height: calc(100dvh - 56px); } }
