/* ============================================================
   Panels — memory management + persona (read-only)
   Sits alongside app.css / pet.css and reuses their design tokens.
   ============================================================ */

/* ---------- drawer ---------- */

.drawer[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border-left: 1px solid rgba(143, 122, 224, 0.18);
  box-shadow: -18px 0 48px -32px rgba(74, 52, 58, 0.55);
  z-index: 40;
  animation: drawer-in 200ms ease-out;
}

@keyframes drawer-in {
  from {
    transform: translateX(14px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(143, 122, 224, 0.14);
}

.drawer-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 28px;
}

/* ---------- panels ---------- */

.panel[hidden] {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-hint {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

.panel-subtitle {
  margin: 8px 0 0;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.panel-status {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.panel-status[data-tone='error'] {
  color: var(--danger);
}

.panel-status[data-tone='ok'] {
  color: var(--ok);
}

.panel-empty {
  margin: 0;
  padding: 18px 14px;
  border: 1px dashed rgba(143, 122, 224, 0.28);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink-faint);
  text-align: center;
}

.panel-empty[hidden] {
  display: none;
}

/* ---------- memory list ---------- */

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

.memory-item {
  background: var(--surface-strong);
  border: 1px solid rgba(143, 122, 224, 0.16);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-kind {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.memory-kind[data-kind='identity'] {
  color: #8a5a2b;
  background: #ffe8cf;
}

.memory-kind[data-kind='preference'] {
  color: #a1475c;
  background: #ffe2e6;
}

.memory-kind[data-kind='fact'] {
  color: #2f6d86;
  background: #dcf0f7;
}

.memory-meta {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--ink-faint);
  font-family: var(--font-mono);
}

.memory-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.memory-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.memory-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-editor[hidden] {
  display: none;
}

.memory-editor-input {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface-solid);
  border: 1px solid rgba(143, 122, 224, 0.3);
  border-radius: var(--radius-sm);
}

.memory-editor-input:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

/* ---------- persona ---------- */

.persona-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 0.84rem;
}

.persona-meta dt {
  color: var(--ink-faint);
}

.persona-meta dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-mono);
}

.persona-core {
  margin: 0;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid rgba(143, 122, 224, 0.16);
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

.persona-trait {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface-strong);
  border: 1px solid rgba(143, 122, 224, 0.14);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.persona-trait-name {
  color: var(--ink-soft);
}

.persona-trait-value {
  font-family: var(--font-mono);
  color: var(--ink);
}

.persona-locked {
  margin: 6px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(224, 164, 76, 0.12);
  color: #8a6320;
  font-size: 0.76rem;
  line-height: 1.5;
}

/* ---------- confirm dialog ---------- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(61, 50, 56, 0.34);
  z-index: 60;
}

.modal-card {
  width: min(360px, 100%);
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1rem;
  color: var(--ink);
}

.modal-body {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- danger button ---------- */

.btn--danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid transparent;
}

.btn--danger:hover {
  background: #d2575e;
}

/* ---------- narrow screens ---------- */

@media (max-width: 620px) {
  .drawer {
    width: 100vw;
  }
}
