/* ============================================================
   THEME — change everything here. One block to rule them all.
   ============================================================ */
:root {
  /* Surfaces */
  --bg-1: #1d1417;            /* page background base */
  --bg-2: #271a1e;            /* panels (top bar, sidebar) */
  --bg-3: #1a1114;            /* input fields, textareas */
  --bg-4: #13090c;            /* deepest wells, code blocks */

  /* Bubbles */
  --her:       #3a2530;
  --her-edge:  #4c3340;
  --me:        #d49aa4;
  --me-edge:   #c97b8d;
  --me-text:   #2a1318;

  /* Accents */
  --accent:   #f3c5c0;        /* warm peach-rose */
  --accent-2: #c97b8d;        /* dusty rose */
  --gold:     #d8b59b;        /* rose-gold hairlines */
  --gold-soft: rgba(216, 181, 155, 0.22);

  /* Text */
  --text:       #f8eee9;
  --text-muted: #c4a89f;
  --text-soft:  #8d7670;

  /* Status colors */
  --danger:  #d6526a;
  --success: #aac9a7;

  /* Glow */
  --glow-accent: 0 0 40px rgba(243, 197, 192, 0.25);
  --glow-soft:   0 0 80px rgba(201, 123, 141, 0.18);
  --glow-strong: 0 0 60px rgba(243, 197, 192, 0.45);
  --glow-danger: 0 0 32px rgba(214, 82, 106, 0.45);

  /* Type */
  --font-display: "Cormorant Garamond", "Apple Garamond", Garamond, serif;
  --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Shape */
  --radius-sm:   12px;
  --radius-md:   20px;
  --radius-lg:   28px;
  --radius-pill: 999px;

  /* Motion */
  --motion-fast: 180ms;
  --motion-med:  320ms;
  --motion-slow: 600ms;
  --motion-amb:  9000ms;

  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft:   cubic-bezier(0.45, 0, 0.15, 1);

  /* Layout */
  --sidebar-w: 280px;
}

/* ============================================================
   COOL THEME — applied via <html data-theme="cool">.
   Darker, more grounded palette: charcoal + steel-blue +
   sharp white accent. Used for the login screen and for any
   account that isn't Maya's.
   ============================================================ */
:root[data-theme="cool"] {
  /* Surfaces */
  --bg-1: #0d1014;
  --bg-2: #161a20;
  --bg-3: #0a0d11;
  --bg-4: #05070a;

  /* Bubbles */
  --her:       #1c2330;
  --her-edge:  #2a3447;
  --me:        #5a7a9b;
  --me-edge:   #3f5a78;
  --me-text:   #eef3fa;

  /* Accents — steel-blue with a sharp ice-white highlight */
  --accent:   #7ea8d6;
  --accent-2: #2f4a6b;
  --gold:     #6b7787;   /* gunmetal hairline */
  --gold-soft: rgba(107, 119, 135, 0.22);

  /* Text */
  --text:       #e6ecf3;
  --text-muted: #8a98aa;
  --text-soft:  #5a6878;

  /* Status colors */
  --danger:  #d6526a;
  --success: #88b0a0;

  /* Glow — minimal, tight, no halo bloom */
  --glow-accent: 0 0 30px rgba(126, 168, 214, 0.18);
  --glow-soft:   0 0 60px rgba(47, 74, 107, 0.20);
  --glow-strong: 0 0 50px rgba(126, 168, 214, 0.30);
  --glow-danger: 0 0 32px rgba(214, 82, 106, 0.40);
}

/* Tone the ambient drift down to cool tones too */
:root[data-theme="cool"] #ambient {
  background:
    radial-gradient(70vw 70vh at 20% 30%, rgba(47, 74, 107, 0.22), transparent 60%),
    radial-gradient(60vw 60vh at 80% 70%, rgba(107, 119, 135, 0.10), transparent 60%),
    radial-gradient(80vw 80vh at 50% 100%, rgba(126, 168, 214, 0.06), transparent 70%),
    var(--bg-1);
}

/* ============================================================
   RESET + BASE
   ============================================================ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-1);
  color: var(--text);
  font-family: var(--font-body);
  /* 100dvh follows the visible viewport — shrinks when iOS keyboard appears,
     so the composer stays above the keyboard instead of being pushed off-screen.
     Fall back to 100vh on older browsers via the prior declaration. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: 16px;
  position: relative;
}

::selection { background: var(--accent); color: var(--bg-1); }

/* ============================================================
   AMBIENT — drifting background, breathing avatar halo
   ============================================================ */
#ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70vw 70vh at 20% 30%, rgba(201, 123, 141, 0.18), transparent 60%),
    radial-gradient(60vw 60vh at 80% 70%, rgba(216, 181, 155, 0.12), transparent 60%),
    radial-gradient(80vw 80vh at 50% 100%, rgba(243, 197, 192, 0.08), transparent 70%),
    var(--bg-1);
  animation: gradient-drift var(--motion-amb) ease-in-out infinite alternate;
}
@keyframes gradient-drift {
  0%   { background-position: 0% 0%,   100% 100%, 50% 100%; filter: hue-rotate(0deg); }
  100% { background-position: 30% 10%, 70% 80%,  60% 95%;  filter: hue-rotate(-8deg); }
}

@keyframes breath {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}

@keyframes halo-pulse {
  0%, 100% { box-shadow: var(--glow-soft); }
  50%      { box-shadow: var(--glow-strong); }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes ring-expand {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(2.0); opacity: 0; }
}

@keyframes pop-in {
  0%   { transform: translateY(8px) scale(0.94); opacity: 0; }
  100% { transform: translateY(0)    scale(1);    opacity: 1; }
}

@keyframes blur-up {
  0%   { filter: blur(8px); opacity: 0; transform: scale(1.02); }
  100% { filter: blur(0);   opacity: 1; transform: scale(1); }
}

@keyframes slide-up-spring {
  0%   { transform: translateY(20px); opacity: 0; }
  60%  { transform: translateY(-4px); opacity: 1; }
  100% { transform: translateY(0);    opacity: 1; }
}

@keyframes gentle-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(180deg); }
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout { display: flex; height: 100%; }
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  position: relative;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-4) 100%);
  border-right: 1px solid var(--her-edge);
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  height: 100%;
  position: relative;
}
.sidebar::before {
  content: "";
  position: absolute;
  top: 0; right: 0; width: 1px; height: 100%;
  background: linear-gradient(180deg, transparent, var(--gold-soft) 50%, transparent);
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(env(safe-area-inset-top), 16px) 16px 14px;
  border-bottom: 1px solid var(--her-edge);
}
.sidebar-header .brand {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 0.4px;
  font-style: italic;
}

/* ---- Backdrop ---- */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 14, 0.55);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  z-index: 8;
  opacity: 0;
  transition: opacity var(--motion-med) var(--ease-soft),
              backdrop-filter var(--motion-med) var(--ease-soft);
}
body.sidebar-open .backdrop {
  display: block;
  opacity: 1;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* ---- Top bar ---- */
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: max(env(safe-area-inset-top), 14px) 20px 14px;
  background: linear-gradient(180deg, rgba(39, 26, 30, 0.85), rgba(39, 26, 30, 0.65));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--her-edge);
  position: relative;
  z-index: 2;
}
.top::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft) 50%, transparent);
  pointer-events: none;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---- Avatar + halo ---- */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  animation: breath 4.5s ease-in-out infinite;
}
.avatar-wrap::after {
  /* Halo — sits behind, glows. State-driven. */
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  box-shadow: var(--glow-soft);
  animation: halo-pulse 5s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
  transition: box-shadow var(--motion-med) var(--ease-soft);
}
.avatar-wrap.state-thinking { animation-duration: 2.6s; }
.avatar-wrap.state-thinking::after { box-shadow: var(--glow-strong); animation-duration: 2.6s; }
.avatar-wrap.state-listening::after {
  box-shadow: 0 0 60px rgba(214, 82, 106, 0.55);
  animation-duration: 1.6s;
}
.avatar-wrap.state-speaking::after {
  box-shadow: 0 0 80px rgba(243, 197, 192, 0.6);
  animation-duration: 1.1s;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 60%, var(--gold) 100%);
  background-size: 200% 200%;
  animation: gradient-shift 12s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  color: var(--bg-4);
  font-size: 19px;
  border: 1px solid var(--gold-soft);
}
.avatar.lg {
  width: 64px;
  height: 64px;
  font-size: 30px;
  margin: 0 auto 14px;
}

.title-wrap { flex: 1; min-width: 0; }
.title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.4px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.2px;
}

.iconbtn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-spring);
}
.iconbtn:hover { background: rgba(255, 255, 255, 0.06); transform: scale(1.05); }
.iconbtn:active { transform: scale(0.94); }
.drawer-only { display: none; }
.iconbtn.small { font-size: 16px; padding: 0 10px; border: 1px solid var(--her-edge); }

/* ---- Sidebar buttons ---- */
.primary-btn {
  margin: 14px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 200% 200%;
  color: var(--bg-4);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--glow-accent);
  transition: transform var(--motion-fast) var(--ease-spring),
              box-shadow var(--motion-med) var(--ease-out);
  animation: gradient-shift 8s ease-in-out infinite;
}
.primary-btn:hover { transform: translateY(-1px) scale(1.02); box-shadow: var(--glow-strong); }
.primary-btn:active { transform: translateY(0) scale(0.97); }
.primary-btn .plus { font-size: 18px; line-height: 1; }

/* Quieter sibling for "Private chat" — same shape, lower visual weight. */
.primary-btn.secondary {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  margin-top: 6px;
  animation: none;
}
.primary-btn.secondary:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: none;
  transform: translateY(-1px);
}

/* Faint left border on incognito chat items so they're spottable in the list. */
.chat-item-private { border-left: 2px solid rgba(255, 255, 255, 0.25); }

/* Small notice rendered at the top of an incognito chat's message area. */
.private-notice {
  align-self: center;
  margin: 8px 0 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
  font-size: 12px;
  font-style: italic;
  letter-spacing: 0.02em;
}

/* ---- Chat list ---- */
.chat-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 4px 10px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  overflow: hidden;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out);
}
.chat-item::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px; width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: var(--radius-pill);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--motion-med) var(--ease-spring);
}
.chat-item:hover { background: rgba(243, 197, 192, 0.06); }
.chat-item.active {
  background: rgba(243, 197, 192, 0.10);
  border-color: var(--gold-soft);
  padding-left: 16px;
}
.chat-item.active::before { transform: scaleY(1); }

.chat-item-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}
.chat-item-title[contenteditable="true"] {
  outline: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 3px;
}
.chat-item-menu {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
  visibility: hidden;
  transition: opacity var(--motion-fast), color var(--motion-fast);
}
.chat-item:hover .chat-item-menu,
.chat-item.menu-open .chat-item-menu { visibility: visible; }
.chat-item-menu:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.chat-list:empty::after {
  content: "no chats yet";
  display: block;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
  padding: 20px 10px;
  font-style: italic;
}

.chat-menu-popover {
  /* Positioned by JS via getBoundingClientRect to escape overflow:hidden on
     .chat-item and overflow-y:auto on .chat-list. */
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-sm);
  padding: 4px;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), var(--glow-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  animation: pop-in var(--motion-fast) var(--ease-spring);
}
.chat-menu-popover button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--motion-fast);
}
.chat-menu-popover button:hover { background: rgba(255, 255, 255, 0.08); }
.chat-menu-popover button.danger { color: var(--danger); }

/* ---- Sidebar footer ---- */
.sidebar-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px max(env(safe-area-inset-bottom), 12px);
  border-top: 1px solid var(--her-edge);
}
.footer-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--her-edge);
  color: var(--text);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--motion-fast) var(--ease-out),
              border-color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-spring);
}
.footer-btn:hover { background: rgba(243, 197, 192, 0.08); border-color: var(--gold-soft); transform: translateY(-1px); }
.footer-btn:active { transform: translateY(0) scale(0.97); }
.footer-btn.off { opacity: 0.5; }
.footer-icon { font-size: 15px; }

/* ============================================================
   MESSAGES
   ============================================================ */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  view-transition-name: chat-view;
}
.chat-view.hidden { display: none; }
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 22px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.messages:empty::after {
  content: "Say hello to Sophie…";
  align-self: center;
  color: var(--text-soft);
  font-size: 15px;
  margin: auto;
  font-style: italic;
  font-family: var(--font-display);
}

.bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  line-height: 1.48;
  font-size: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop-in var(--motion-med) var(--ease-spring) both;
  position: relative;
}
.bubble.me {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--me), var(--me-edge));
  color: var(--me-text);
  border-bottom-right-radius: 8px;
  box-shadow: 0 4px 18px rgba(201, 123, 141, 0.25);
}
.bubble.her {
  align-self: flex-start;
  background: linear-gradient(180deg, var(--her), #2e1d25);
  border: 1px solid var(--her-edge);
  border-bottom-left-radius: 8px;
  box-shadow: var(--glow-accent);
}
.bubble.thinking {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bubble .status-text {
  font-size: 12px;
  color: var(--text-soft);
  font-style: italic;
  margin-top: 2px;
  transition: opacity var(--motion-fast) var(--ease-out);
}

/* Bubble attachments (images) */
.bubble .attachment-image {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-4);
  min-height: 120px;
  animation: blur-up var(--motion-slow) var(--ease-out);
  border: 1px solid var(--gold-soft);
  box-shadow: var(--glow-soft);
}
.bubble .attachment-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  padding: 32px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-2) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 2.4s linear infinite;
  border: 1px dashed var(--her-edge);
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  min-height: 80px;
}
.bubble .attachment-placeholder .dots { padding: 0; }
.bubble.draw-prompt { font-style: italic; opacity: 0.85; }

/* ---- Thinking dots ---- */
.dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: breath 1.3s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.18s; }
.dots span:nth-child(3) { animation-delay: 0.36s; }

/* ---- Memory toast ---- */
.memory-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: rgba(243, 197, 192, 0.10);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text);
  font-style: italic;
  animation: slide-up-spring var(--motion-med) var(--ease-spring);
  box-shadow: var(--glow-soft);
}
.memory-toast.hidden { display: none; }
.memory-toast.success {
  background: rgba(170, 201, 167, 0.12);
  border-color: rgba(170, 201, 167, 0.45);
  color: var(--success);
}
.toast-dots { display: inline-flex; gap: 3px; }
.toast-dots span {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: breath 1.2s ease-in-out infinite;
}
.toast-dots span:nth-child(2) { animation-delay: 0.15s; }
.toast-dots span:nth-child(3) { animation-delay: 0.30s; }
.memory-toast.success .toast-dots { display: none; }

/* ============================================================
   COMPOSER
   ============================================================ */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px max(env(safe-area-inset-bottom), 12px);
  background: linear-gradient(180deg, rgba(39, 26, 30, 0.7), rgba(39, 26, 30, 0.95));
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--her-edge);
  position: relative;
  z-index: 2;
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 12px 16px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  line-height: 1.45;
  transition: border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-med) var(--ease-out);
}
.composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 197, 192, 0.15);
}
.composer textarea::placeholder { color: var(--text-muted); font-style: italic; }

.mic, .send, .draw, .attach {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 120ms var(--ease-spring),
              box-shadow var(--motion-med) var(--ease-out),
              background var(--motion-fast);
}
.mic:hover, .send:hover, .draw:hover, .attach:hover { transform: translateY(-1px) scale(1.05); }
.mic:active, .send:active, .draw:active, .attach:active { transform: scale(0.92); }

.mic    { background: var(--her-edge); }
.draw   { background: var(--her-edge); }
.attach { background: var(--her-edge); font-size: 18px; }
.draw:hover   { background: rgba(243, 197, 192, 0.25); box-shadow: var(--glow-soft); }
.attach:hover { background: rgba(243, 197, 192, 0.25); box-shadow: var(--glow-soft); }
.mic:hover    { background: var(--her); box-shadow: var(--glow-soft); }

/* Attachment tray (above the composer) */
.attach-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--her-edge);
}
.attach-tray.hidden { display: none; }
.attach-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gold-soft);
  background: var(--bg-4);
  animation: pop-in var(--motion-fast) var(--ease-spring);
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(20, 12, 14, 0.8);
  color: white;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attach-thumb-remove:hover { background: var(--danger); }
.attach-thumb .uploading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 12, 14, 0.6);
  color: var(--accent);
  font-size: 12px;
  font-style: italic;
}

.mic.recording {
  background: var(--danger);
  box-shadow: var(--glow-danger);
  animation: halo-pulse 1.2s ease-in-out infinite;
}
.mic.recording::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  animation: ring-expand 1.4s ease-out infinite;
}

.send {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 200% 200%;
  color: var(--bg-4);
  box-shadow: var(--glow-accent);
  animation: gradient-shift 6s ease-in-out infinite;
}
.send:disabled { opacity: 0.4; cursor: not-allowed; animation: none; }

.stop {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-danger);
  animation: halo-pulse 1.4s ease-in-out infinite;
  transition: transform 120ms var(--ease-spring);
}
.stop:hover  { transform: scale(1.05); }
.stop:active { transform: scale(0.92); }
.stop.hidden { display: none; }

/* ============================================================
   LOGIN — full-screen "stage" with drifting orbs and a glass card
   ============================================================ */
.login {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120vw 90vh at 30% 20%, rgba(0,0,0,0.45), transparent 60%),
    radial-gradient(100vw 80vh at 70% 80%, rgba(0,0,0,0.55), transparent 60%),
    var(--bg-1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow: hidden;
  isolation: isolate;
  animation: login-fade-in var(--motion-slow) var(--ease-out);
}
.login.hidden { display: none; }

@keyframes login-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* --- drifting ambient orbs (decorative; pure CSS) --- */
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.login-orb-a {
  width: 520px; height: 520px;
  background: radial-gradient(circle, var(--accent), transparent 65%);
  top: -120px; left: -120px;
  animation: orb-drift-a 18s ease-in-out infinite alternate;
}
.login-orb-b {
  width: 460px; height: 460px;
  background: radial-gradient(circle, var(--accent-2), transparent 65%);
  bottom: -140px; right: -100px;
  animation: orb-drift-b 22s ease-in-out infinite alternate;
}
.login-orb-c {
  width: 340px; height: 340px;
  background: radial-gradient(circle, var(--gold), transparent 70%);
  top: 45%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.30;
  animation: orb-drift-c 28s ease-in-out infinite alternate;
}
@keyframes orb-drift-a {
  0%   { transform: translate(0,   0)    scale(1);    }
  100% { transform: translate(80px, 60px) scale(1.15); }
}
@keyframes orb-drift-b {
  0%   { transform: translate(0,   0)    scale(1);    }
  100% { transform: translate(-90px, -40px) scale(1.08); }
}
@keyframes orb-drift-c {
  0%   { transform: translate(-50%, -50%) scale(1);    }
  100% { transform: translate(-40%, -55%) scale(1.18); }
}

/* --- the glass card --- */
.login-card {
  position: relative;
  width: min(380px, 90vw);
  padding: 2px;                  /* room for the animated border-glow layer */
  border-radius: calc(var(--radius-lg) + 4px);
  z-index: 1;
  animation: login-card-rise 700ms var(--ease-spring) both;
}
@keyframes login-card-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

.login-card-glow {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: conic-gradient(
    from 0deg,
    var(--accent),
    var(--accent-2),
    var(--gold),
    var(--accent)
  );
  filter: blur(14px);
  opacity: 0.55;
  z-index: -1;
  animation: login-card-spin 14s linear infinite;
}
@keyframes login-card-spin {
  to { transform: rotate(360deg); }
}

.login-card-inner {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)),
    var(--bg-2);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-lg);
  padding: 36px 30px 28px;
  text-align: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    0 30px 80px -20px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

/* --- avatar --- */
.login-avatar-wrap {
  position: relative;
  width: 84px; height: 84px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
}
.login-avatar {
  position: relative;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 34px;
  display: grid;
  place-items: center;
  box-shadow: var(--glow-accent), inset 0 1px 0 rgba(255,255,255,0.25);
  animation: breath 4.5s ease-in-out infinite;
  z-index: 1;
}
.login-avatar-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  filter: blur(14px);
  opacity: 0.55;
  animation: halo-pulse 4.5s ease-in-out infinite;
}

/* --- text --- */
.login-brand {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: 38px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.login-tagline {
  margin: 0 0 26px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0.3px;
  min-height: 18px;
  transition: opacity var(--motion-med);
}

/* --- floating-label fields --- */
.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field {
  position: relative;
  display: block;
  text-align: left;
}
.login-field input {
  width: 100%;
  padding: 18px 16px 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--her-edge);
  color: var(--text);
  border-radius: var(--radius-md);
  font-size: 15px;
  outline: none;
  transition: border-color var(--motion-fast), box-shadow var(--motion-med), background var(--motion-fast);
}
.login-field input:hover { background: rgba(0,0,0,0.32); }
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.35);
}
.login-field-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-size: 14px;
  pointer-events: none;
  transition: top var(--motion-fast) var(--ease-out),
              font-size var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out);
}
.login-field input:focus + .login-field-label,
.login-field input:not(:placeholder-shown) + .login-field-label {
  top: 10px;
  transform: translateY(0);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
}

/* --- submit button --- */
.login-btn {
  position: relative;
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  background-size: 200% 200%;
  color: var(--bg-4);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: var(--glow-accent), inset 0 1px 0 rgba(255,255,255,0.25);
  animation: gradient-shift 5s ease-in-out infinite;
  transition: transform var(--motion-fast) var(--ease-spring),
              box-shadow var(--motion-med);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
}
.login-btn-arrow {
  display: inline-block;
  transition: transform var(--motion-med) var(--ease-spring);
}
.login-btn:hover {
  transform: translateY(-1px) scale(1.015);
  box-shadow: var(--glow-strong), inset 0 1px 0 rgba(255,255,255,0.3);
}
.login-btn:hover .login-btn-arrow { transform: translateX(4px); }
.login-btn:active { transform: scale(0.97); }
.login-btn:disabled {
  opacity: 0.6;
  cursor: progress;
  animation: none;
}

.error { color: var(--danger); margin-top: 10px; min-height: 18px; font-size: 14px; }

/* Honor reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .login-orb, .login-card-glow, .login-avatar, .login-avatar-halo, .login-btn {
    animation: none !important;
  }
  .login-card { animation: none; }
}

/* ============================================================
   MODAL (Settings / About me)
   ============================================================ */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--text);
  width: min(640px, 92vw);
  max-height: 90vh;
}
.modal-wide { width: min(700px, 94vw); }
.modal::backdrop {
  background: rgba(20, 12, 14, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: fade-in var(--motion-med) var(--ease-out);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--her-edge);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), var(--glow-soft);
  animation: pop-in var(--motion-med) var(--ease-spring);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.4px;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-right: 4px;
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-actions .spacer { flex: 1; }
.modal-actions button {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--her-edge);
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: transform var(--motion-fast) var(--ease-spring), background var(--motion-fast);
}
.modal-actions button:hover { background: rgba(255, 255, 255, 0.04); transform: translateY(-1px); }
.modal-actions button:active { transform: scale(0.97); }
.modal-actions button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  border: none;
  font-weight: 600;
  box-shadow: var(--glow-accent);
}
.modal-actions .link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.modal-actions .link-btn:hover { color: var(--accent); background: none; transform: none; }
.modal-actions .link-btn.danger:hover { color: var(--danger); }

/* Section dividers in modal */
.section { display: flex; flex-direction: column; gap: 12px; }
.section-title {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  border-bottom: 1px solid var(--her-edge);
  padding-bottom: 8px;
  font-style: italic;
}

/* Fields ---------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.field-label { font-size: 14px; color: var(--text); font-weight: 500; }
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-hint code {
  background: var(--bg-4);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
}
.field input[type="text"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color var(--motion-fast), box-shadow var(--motion-med);
}
.field input[type="text"]:focus,
.field input[type="password"]:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 197, 192, 0.15);
}
.field textarea { resize: vertical; line-height: 1.45; }
#me-textarea {
  min-height: 220px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
}
.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
  cursor: pointer;
}

/* Radio dials -------------------------------------------- */
.dial {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 12px;
}
.dial-label { font-size: 14px; color: var(--text); font-weight: 500; }
.dial-options {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: 6px;
  background: var(--bg-3);
  padding: 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--her-edge);
}
.dial-option {
  padding: 9px 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-spring),
              box-shadow var(--motion-med) var(--ease-out);
}
.dial-option:hover { color: var(--text); }
.dial-option.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  font-weight: 600;
  box-shadow: var(--glow-accent);
  animation: pop-in var(--motion-fast) var(--ease-spring);
}
@media (max-width: 480px) {
  .dial { grid-template-columns: 1fr; gap: 6px; }
}

/* Switch ------------------------------------------------- */
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 46px;
  height: 26px;
  background: var(--bg-3);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-pill);
  position: relative;
  cursor: pointer;
  transition: background var(--motion-med) var(--ease-out),
              border-color var(--motion-med) var(--ease-out);
  margin: 0;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--motion-med) var(--ease-spring),
              background var(--motion-med) var(--ease-out);
}
.switch:checked {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}
.switch:checked::after { transform: translateX(20px); background: white; }

/* Password row ------------------------------------------- */
.password-row { display: flex; gap: 6px; }
.password-row input { flex: 1; }

/* Inline error ------------------------------------------- */
.error.inline {
  flex: 1;
  text-align: left;
  font-size: 13px;
  min-height: 0;
}
.field-hint .link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  margin-left: auto;
  transition: color var(--motion-fast);
}
.field-hint .link-btn:hover { color: var(--danger); }

/* ============================================================
   WARDROBE — full-page view (sibling of chat-view)
   ============================================================ */
.wardrobe-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-1);
}
.wardrobe-view.hidden { display: none; }
.wardrobe-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px max(env(safe-area-inset-bottom), 16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* hide composer + memory toast + chat-view when in wardrobe view */
body.view-wardrobe #composer,
body.view-wardrobe #attach-tray,
body.view-wardrobe #memory-toast,
body.view-wardrobe .chat-view { display: none !important; }


.wardrobe-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
.wardrobe-toolbar .footer-btn,
.wardrobe-toolbar .primary-btn {
  flex: 1 1 auto;
  min-width: 110px;
  padding: 10px 12px;
  font-size: 13px;
  height: 42px;
}
.wardrobe-upload-btn {
  margin: 0;
  cursor: pointer;
  flex: 1 1 auto;
  white-space: nowrap;
}
.wardrobe-actions { padding-top: 2px; }

.wardrobe-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0;
}
.wardrobe-subfilters {
  padding-top: 0;
  padding-left: 12px;
  border-left: 2px solid var(--gold-soft);
  margin-left: 4px;
}
.wardrobe-subfilters.hidden { display: none; }
.wardrobe-subfilters .wardrobe-chip { font-size: 12px; padding: 5px 10px; }
.wardrobe-chip {
  padding: 6px 12px;
  background: var(--bg-3);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: capitalize;
  transition: background var(--motion-fast) var(--ease-out),
              color var(--motion-fast) var(--ease-out),
              transform var(--motion-fast) var(--ease-spring);
}
.wardrobe-chip:hover { color: var(--text); transform: translateY(-1px); }
.wardrobe-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  font-weight: 600;
  border-color: transparent;
  box-shadow: var(--glow-accent);
}

.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 4px;
}
/* When filtered to one category we re-use .wardrobe-grid as a vertical
   container of (header, subgrid, header, subgrid…). Subgrids do the
   actual cards-per-row layout. */
.wardrobe-grid:has(.wardrobe-section-header) {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wardrobe-section-header {
  margin: 8px 4px 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.4px;
  color: var(--accent);
  text-transform: lowercase;
  border-bottom: 1px solid var(--gold-soft);
  padding-bottom: 6px;
}
.wardrobe-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.wardrobe-card {
  background: var(--bg-3);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  animation: pop-in var(--motion-med) var(--ease-spring) both;
  transition: transform var(--motion-fast) var(--ease-spring),
              border-color var(--motion-fast) var(--ease-out),
              box-shadow var(--motion-med) var(--ease-out);
}
.wardrobe-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-soft);
  box-shadow: var(--glow-soft);
}
.wardrobe-card.outfit-pick {
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
}
.wardrobe-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-4);
  display: block;
}
.wardrobe-card-placeholder {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-4), var(--bg-2));
  font-family: var(--font-display);
  font-size: 36px;
  color: var(--gold);
  font-style: italic;
}
.wardrobe-card-meta {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wardrobe-card-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wardrobe-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wardrobe-empty {
  text-align: center;
  color: var(--text-soft);
  font-style: italic;
  padding: 40px 12px;
}

/* Upload-progress banner */
.upload-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, rgba(243, 197, 192, 0.16), rgba(201, 123, 141, 0.14));
  border: 1px solid var(--gold-soft);
  color: var(--text);
  font-size: 14px;
  font-style: italic;
  animation: slide-up-spring var(--motion-med) var(--ease-spring);
  box-shadow: var(--glow-soft);
}
.upload-banner.hidden { display: none; }
.upload-banner .toast-dots span { background: var(--accent); }

/* Skeleton card (placeholder while a photo is uploading/tagging) */
.wardrobe-card.skeleton {
  cursor: default;
  pointer-events: none;
  opacity: 0.85;
}
.wardrobe-card.skeleton .wardrobe-card-img,
.wardrobe-card.skeleton .wardrobe-card-placeholder {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-2) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 2.2s linear infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-style: italic;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}
.wardrobe-card.skeleton.failed {
  border-color: var(--danger);
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}
.wardrobe-card.skeleton.failed .wardrobe-card-img,
.wardrobe-card.skeleton.failed .wardrobe-card-placeholder {
  animation: none;
  background: var(--bg-4);
  color: var(--danger);
}

/* Split-photo modal */
.split-preview-wrap {
  position: relative;
  width: 100%;
  background: var(--bg-4);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 50vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.split-preview {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  object-fit: contain;
}
.split-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.split-overlay .gridline {
  position: absolute;
  background: rgba(243, 197, 192, 0.9);
  box-shadow: 0 0 8px rgba(243, 197, 192, 0.7);
}
.split-overlay .gridline.h { left: 0; right: 0; height: 2px; }
.split-overlay .gridline.v { top: 0; bottom: 0; width: 2px; }
.split-layout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.split-layout-btn {
  padding: 12px 10px;
  border: 1px solid var(--her-edge);
  background: var(--bg-3);
  color: var(--text);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform var(--motion-fast) var(--ease-spring),
              border-color var(--motion-fast) var(--ease-out),
              background var(--motion-fast) var(--ease-out);
}
.split-layout-btn:hover { transform: translateY(-1px); border-color: var(--gold-soft); }
.split-layout-btn.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  border-color: transparent;
  box-shadow: var(--glow-accent);
  font-weight: 600;
}
.split-layout-btn svg {
  width: 36px;
  height: 36px;
  opacity: 0.8;
}
.split-layout-btn.selected svg { opacity: 1; }

/* Split candidate cards (from Relook) */
.split-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}
.split-card {
  display: flex;
  gap: 12px;
  background: var(--bg-3);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-md);
  padding: 10px;
}
.split-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex: 0 0 80px;
}
.split-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.split-list-items { font-size: 13px; color: var(--text-muted); }
.split-actions { display: flex; gap: 6px; margin-top: 4px; }
.split-actions .footer-btn { padding: 6px 10px; font-size: 13px; flex: 0 0 auto; }
.split-actions .split-yes {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  border: none;
  font-weight: 600;
}
.wardrobe-empty.hidden,
.wardrobe-result.hidden { display: none; }

.wardrobe-result {
  background: rgba(243, 197, 192, 0.08);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: slide-up-spring var(--motion-med) var(--ease-spring);
}
.wardrobe-result .reasoning {
  font-style: italic;
  color: var(--text);
  line-height: 1.45;
}
.outfit-filter-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  vertical-align: middle;
}

.persona-baked-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.wardrobe-result .gap-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wardrobe-result .pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.wardrobe-result .pick-grid img,
.wardrobe-result .pick-grid .wardrobe-card-placeholder {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  font-size: 24px;
}

/* Wardrobe item detail modal */
.wi-image {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--her-edge);
}
.wi-image[src=""], .wi-image:not([src]) { display: none; }

.wi-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.wi-gallery:empty { display: none; }
.wi-gallery .wi-photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-4);
  border: 1px solid var(--her-edge);
}
.wi-gallery .wi-photo.cover {
  border-color: var(--gold);
  box-shadow: var(--glow-soft);
}
.wi-gallery .wi-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wi-gallery .wi-photo .badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(20, 12, 14, 0.7);
  color: var(--gold);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-style: italic;
}
.wi-gallery .wi-photo .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(20, 12, 14, 0.8);
  color: white;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wi-gallery .wi-photo .remove:hover { background: var(--danger); }
.wi-gallery .wi-photo.uploading::after {
  content: "uploading…";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 12, 14, 0.55);
  color: var(--accent);
  font-style: italic;
  font-size: 12px;
}

.wi-add-photo-btn {
  margin: 0;
  cursor: pointer;
  padding: 9px 14px;
  font-size: 13px;
  align-self: flex-start;
}

/* ============================================================
   MEMORY NOTES (Feature 4) + FACTS PANEL (Feature 6)
   ============================================================ */
.memory-note-icon {
  position: absolute;
  bottom: 4px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(243, 197, 192, 0.18);
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: opacity var(--motion-fast), transform var(--motion-fast) var(--ease-spring),
              background var(--motion-fast);
}
.memory-note-icon:hover {
  opacity: 1;
  transform: scale(1.15);
  background: rgba(243, 197, 192, 0.4);
}
.bubble { position: relative; }
.bubble.her { padding-bottom: 18px; }   /* leave room for the icon */

.memory-popover {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(243, 197, 192, 0.10);
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  align-self: flex-start;
  max-width: 80%;
  animation: slide-up-spring var(--motion-fast) var(--ease-spring);
}
.memory-popover .label { color: var(--accent); font-weight: 600; margin-right: 6px; }

/* Facts panel in the Me modal */
.facts-panel {
  background: var(--bg-3);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.facts-panel summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: var(--text);
  list-style: none;
  user-select: none;
}
.facts-panel summary::-webkit-details-marker { display: none; }
.facts-panel summary::before {
  content: "▸ ";
  color: var(--accent);
  display: inline-block;
  transition: transform var(--motion-fast);
}
.facts-panel[open] summary::before { content: "▾ "; }
.facts-panel #facts-count {
  color: var(--text-soft);
  font-weight: 400;
  margin-left: 4px;
}
.facts-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.facts-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-4);
  font-size: 13px;
  color: var(--text);
}
.facts-list li:hover { background: rgba(243, 197, 192, 0.06); }
.facts-list .fact-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  background: rgba(243, 197, 192, 0.10);
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  flex: 0 0 auto;
}
.facts-list .fact-subject { font-weight: 600; color: var(--gold); }
.facts-list .fact-text { flex: 1; color: var(--text-muted); }
.facts-list .fact-del {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--motion-fast), color var(--motion-fast);
}
.facts-list li:hover .fact-del { opacity: 1; }
.facts-list .fact-del:hover { color: var(--danger); }
.facts-empty {
  color: var(--text-soft);
  font-style: italic;
  font-size: 13px;
  padding: 6px 0 0;
}
.facts-empty.hidden { display: none; }

/* Needs-review badge on the grid card */
.wardrobe-card-review {
  position: absolute;
  top: 6px;
  left: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--bg-4);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-style: italic;
  pointer-events: none;
  box-shadow: var(--glow-accent);
  animation: halo-pulse 2.4s ease-in-out infinite;
}

/* Floating review banner (above the grid, when any item needs review) */
.review-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  width: 100%;
  background: linear-gradient(135deg, rgba(243, 197, 192, 0.18), rgba(201, 123, 141, 0.16));
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  animation: slide-up-spring var(--motion-med) var(--ease-spring);
  box-shadow: var(--glow-soft);
  transition: transform var(--motion-fast) var(--ease-spring);
}
.review-banner.hidden { display: none; }
.review-banner:hover { transform: translateY(-1px); }
.review-banner .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
  box-shadow: 0 0 8px var(--accent);
  animation: halo-pulse 1.6s ease-in-out infinite;
}
.review-banner #review-banner-text { flex: 1; font-style: italic; }
.review-banner .chev {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

/* Multi-image badge on the grid card */
.wardrobe-card-multi {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(20, 12, 14, 0.7);
  color: var(--gold);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-style: italic;
  pointer-events: none;
}
.wardrobe-card { position: relative; }
#wi-fields {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 12px;
  font-size: 14px;
}
#wi-fields .k { color: var(--text-muted); }
#wi-fields .v { color: var(--text); }
#wi-fields input, #wi-fields select {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--her-edge);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
  font-family: inherit;
}

/* ============================================================
   VIEW TRANSITIONS (chat switching)
   ============================================================ */
::view-transition-old(chat-view) {
  animation: fade-out var(--motion-fast) var(--ease-out);
}
::view-transition-new(chat-view) {
  animation: fade-in var(--motion-med) var(--ease-spring);
}
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }

/* Stagger child bubbles when re-rendered */
.messages > .bubble {
  animation-delay: calc(var(--i, 0) * 35ms);
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    z-index: 9;
    transform: translateX(-100%);
    transition: transform var(--motion-med) var(--ease-spring);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .drawer-only { display: inline-flex; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
