/* ============================================================================
   UI Moments Micro-Interactions — Adapted to Botanical Sage & Midnight Forest
   Inspired by ui-moments (01, 02, 05, 09, 14, 17, 20, 21, 28, 31)
   ============================================================================ */

:root {
  --ui-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ui-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 01 · Bars Fade (Voice Recording & TTS Speaking Equalizer) */
.ui-bars {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  height: 16px;
}

.ui-bars i {
  display: block;
  width: 2.5px;
  height: 14px;
  border-radius: 3px;
  background: currentColor;
  animation: ui-bars-fade 1.1s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.1s);
}

@keyframes ui-bars-fade {
  0%, 100% { opacity: 0.25; transform: scaleY(0.35); }
  50% { opacity: 1; transform: scaleY(1); }
}

/* 02 · Bloom Toggle (Botanical Petal Switch for Auto-TTS) */
.tts-control-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px 0 6px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-solid);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.tts-control-wrap:hover {
  border-color: var(--accent);
}

.tts-control-wrap.speaking {
  background: var(--blush-soft);
  border-color: var(--blush);
  color: var(--blush);
}

.ui-bloom-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.tts-control-wrap[aria-checked="true"] .ui-bloom-switch {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ui-bloom-switch > span {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: transform 0.6s var(--ui-spring);
}

.tts-control-wrap[aria-checked="true"] .ui-bloom-switch > span {
  transform: translateX(18px);
}

.ui-bloom-switch b {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--text-muted);
  z-index: 1;
  transition: inset 0.35s var(--ui-ease), background 0.35s ease;
}

.tts-control-wrap[aria-checked="true"] .ui-bloom-switch b {
  inset: 2.5px;
  background: var(--accent);
}

.ui-bloom-switch i {
  position: absolute;
  width: 5px;
  height: 8px;
  border-radius: 80% 80% 40% 40%;
  background: var(--accent);
  left: 5.5px;
  top: 2px;
  opacity: 0;
  transform-origin: 2.5px 6px;
  transform: rotate(calc(var(--i) * 45deg)) translateY(0);
  transition: transform 0.6s var(--ui-spring), opacity 0.3s ease;
}

.tts-control-wrap[aria-checked="true"] .ui-bloom-switch i {
  opacity: 0.9;
  transform: rotate(calc(var(--i) * 45deg)) translateY(-5.5px);
}

/* 05 · Elastic Sliding Pill (Viewport Switcher & Auth Tabs) */
.viewport-switcher,
.auth-tabs {
  position: relative;
}

.ui-slide-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-solid);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: transform 0.52s var(--ui-spring), width 0.45s var(--ui-spring);
  pointer-events: none;
  z-index: 0;
}

.auth-tabs .ui-slide-pill {
  top: 4px;
  bottom: 4px;
  border-radius: 10px;
}

.viewport-switcher .vp-btn,
.auth-tabs .auth-tab {
  position: relative;
  z-index: 1;
}

.viewport-switcher .vp-btn.active,
.auth-tabs .auth-tab.active {
  background: transparent;
  box-shadow: none;
}

/* 09 · Paper Plane Send Button */
.composer-send-btn.ui-plane-btn {
  position: relative;
  overflow: hidden;
}

.ui-plane-btn .ui-plane-svg,
.ui-plane-btn .ui-plane-check {
  position: absolute;
  width: 19px;
  height: 19px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-plane-btn .ui-plane-check {
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s ease, transform 0.35s var(--ui-spring);
}

.ui-plane-btn.sending .ui-plane-svg {
  animation: ui-plane-flight 0.72s var(--ui-ease) forwards;
}

.ui-plane-btn.sent .ui-plane-svg {
  opacity: 0;
}

.ui-plane-btn.sent .ui-plane-check {
  opacity: 1;
  transform: scale(1);
}

@keyframes ui-plane-flight {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  25% { transform: translate(-5px, 4px) rotate(-14deg); opacity: 1; }
  80%, 100% { transform: translate(34px, -30px) rotate(12deg) scale(0.4); opacity: 0; }
}

/* 14 · Swipe Confirm (Safe Destructive Action for Clearing Memories) */
.ui-swipe {
  position: relative;
  width: 100%;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid rgba(217, 112, 112, 0.35);
  overflow: hidden;
  user-select: none;
}

.ui-swipe-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blush);
  padding-left: 26px;
  pointer-events: none;
  transition: color 0.25s ease;
}

.ui-swipe-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(217, 112, 112, 0.28), var(--blush));
  transition: width 0.38s var(--ui-ease);
}

.ui-swipe-knob {
  position: absolute;
  left: 4px;
  top: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--blush);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  z-index: 2;
  box-shadow: var(--shadow-sm);
  transition: transform 0.42s var(--ui-spring), background 0.25s ease;
}

.ui-swipe-knob:active {
  cursor: grabbing;
}

.ui-swipe.dragging .ui-swipe-knob,
.ui-swipe.dragging .ui-swipe-fill {
  transition: none;
}

.ui-swipe.confirmed .ui-swipe-fill {
  width: 100%;
}

.ui-swipe.confirmed .ui-swipe-text {
  color: #ffffff;
  padding-left: 0;
  padding-right: 26px;
  z-index: 1;
}

.ui-swipe.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* 17 · Menu Morph (Mobile / Tablet Sidebar Hamburger -> X) */
.ui-menu-morph {
  position: relative;
}

.ui-menu-morph i {
  position: absolute;
  left: 8px;
  top: 17px;
  width: 18px;
  height: 2px;
  border-radius: 3px;
  background: currentColor;
  transition: transform 0.5s var(--ui-spring), opacity 0.2s ease;
}

.ui-menu-morph i:first-child {
  transform: translateY(-6px);
}

.ui-menu-morph i:last-child {
  transform: translateY(6px);
}

.ui-menu-morph[aria-expanded="true"] i:first-child {
  transform: rotate(45deg);
}

.ui-menu-morph[aria-expanded="true"] i:nth-child(2) {
  transform: translateX(8px);
  opacity: 0;
}

.ui-menu-morph[aria-expanded="true"] i:last-child {
  transform: rotate(-45deg);
}

/* 20 · Worm Dots (Bouncy Thinking & Image Generation Loader) */
.ui-worm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
}

.ui-worm i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: ui-worm-hop 1.55s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}

@keyframes ui-worm-hop {
  0%, 62%, 100% { transform: translateY(0) scale(0.78); opacity: 0.4; }
  28% { transform: translateY(-7px) scale(1.18); opacity: 1; }
}

/* 21 · Download Ring (Image Studio Result Download Progress) */
.ui-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.ui-download-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ui-dl-ring {
  position: relative;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.ui-dl-ring svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-dl-track {
  stroke: var(--border-strong);
}

.ui-dl-progress {
  stroke: var(--accent);
  stroke-dasharray: 157.08;
  stroke-dashoffset: 157.08;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.14s linear;
}

.ui-dl-arrow {
  stroke: var(--accent);
  transition: opacity 0.2s ease;
}

.ui-dl-check {
  stroke: var(--accent);
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  transition: stroke-dashoffset 0.42s var(--ui-ease);
}

.ui-download-btn.loading .ui-dl-arrow,
.ui-download-btn.done .ui-dl-arrow {
  opacity: 0;
}

.ui-download-btn.done .ui-dl-check {
  stroke-dashoffset: 0;
}

/* 28 · Rubber Search (Elastic Conversation Search in Sidebar) */
.sidebar-section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 6px 16px;
  gap: 8px;
}

.sidebar-section-bar .sidebar-section-title {
  padding: 0;
  white-space: nowrap;
}

.ui-rubber-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 30px;
  height: 30px;
  border-radius: 30px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-solid);
  transition: width 0.58s var(--ui-spring), border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.ui-rubber-search.open {
  width: 164px;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ui-rubber-search input {
  width: calc(100% - 28px);
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--text-primary);
  padding: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ui-rubber-search.open input {
  padding-left: 11px;
  opacity: 1;
  transition-delay: 0.14s;
}

.ui-rubber-search button {
  position: absolute;
  right: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.ui-rubber-search button:hover {
  color: var(--accent);
}

/* 31 · Eclipse Half (Light / Dark Theme Morph Button) */
.ui-eclipse-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.ui-eclipse-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.ui-eclipse {
  position: relative;
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  background: #f0b84b;
  border: 1.5px solid rgba(180, 128, 30, 0.35);
  box-shadow: 0 0 10px rgba(240, 184, 75, 0.35);
  transition: background 0.45s var(--ui-ease), box-shadow 0.45s ease;
}

.ui-eclipse > i {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: #17211c;
  transform: translateX(-22px);
  transition: transform 0.75s var(--ui-spring);
}

[data-theme="dark"] .ui-eclipse {
  background: #d7efe2;
  border-color: rgba(154, 214, 182, 0.45);
  box-shadow: 0 0 12px rgba(126, 198, 159, 0.4);
}

[data-theme="dark"] .ui-eclipse > i {
  transform: translateX(7px);
}

/* Voice Recording Live Bars inside Composer Hint */
.voice-hint-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.voice-hint-wrap.recording {
  color: var(--blush);
  font-weight: 600;
}

/* ============================================================================
   'What to Eat Today' Meal Picker + UI Moments (12, 19, 29, 33, 34)
   ============================================================================ */

/* 34 · Flip Coin (3D Botanical Randomizer Medallion) */
.ui-coin {
  width: 58px;
  height: 58px;
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transform-style: preserve-3d;
  transition: transform 0.95s var(--ui-ease);
}

.ui-coin span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2.5px double rgba(76, 133, 103, 0.55);
  box-shadow: inset 0 0 0 4px var(--bg-surface-solid), var(--shadow-sm);
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), var(--bg-elevated) 75%);
  backface-visibility: hidden;
  font-size: 24px;
}

.ui-coin-back {
  transform: rotateY(180deg);
  color: var(--accent);
}

/* 29 · Odometer (Mechanical Rolling Digit Counter) */
.meal-odo-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.meal-odo-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.ui-odometer {
  display: inline-flex;
  gap: 3px;
}

.ui-odometer > span {
  width: 19px;
  height: 26px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08);
}

.ui-odometer i {
  display: block;
  font-style: normal;
  transition: transform 0.65s var(--ui-spring);
}

.ui-odometer b {
  display: grid;
  place-items: center;
  height: 24px;
  font: 14px var(--font-mono);
  font-weight: 700;
  color: var(--accent);
}

/* 12 · Pebble Rating (1-5 Preference Stars) */
.ui-pebble-rating {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
}

.ui-pebble-rating button {
  width: 12px;
  height: 17px;
  border-radius: 50% 50% 45% 45%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  transform: rotate(calc((var(--i) - 2) * 10deg));
  cursor: pointer;
  padding: 0;
  transition: background 0.22s ease, border-color 0.22s ease, transform 0.42s var(--ui-spring);
}

.ui-pebble-rating button.chosen {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px) rotate(0deg);
}

.ui-pebble-rating output {
  margin-left: 4px;
  font: 11px var(--font-mono);
  color: var(--text-muted);
  min-width: 24px;
}

/* 33 · Animated Checklist (Today's Picked Menu) */
.ui-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ui-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
}

.ui-check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.ui-check-label input {
  position: absolute;
  opacity: 0;
  width: 16px;
  height: 16px;
  margin: 0;
}

.ui-check-box {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.35s var(--ui-spring);
}

.ui-check-box svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 0.36s 0.08s ease;
}

.ui-check-label input:checked + .ui-check-box {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}

.ui-check-label input:checked + .ui-check-box svg {
  stroke-dashoffset: 0;
}

.ui-check-task {
  position: relative;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  transition: color 0.25s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ui-check-task::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: var(--text-muted);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ui-ease);
}

.ui-check-label input:checked ~ .ui-check-task {
  color: var(--text-muted);
}

.ui-check-label input:checked ~ .ui-check-task::after {
  transform: scaleX(1);
}

/* 19 · Ripple Pad Effect */
.ui-ripple-btn {
  position: relative;
  overflow: hidden;
}

.ui-ripple-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.38);
  width: 12px;
  height: 12px;
  margin: -6px;
  animation: ui-ripple-wave 0.72s ease-out forwards;
  pointer-events: none;
}

@keyframes ui-ripple-wave {
  to { transform: scale(16); opacity: 0; }
}

/* Meal Studio Layout */
.meal-studio-card {
  max-width: 920px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}

.meal-top-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
}

.meal-roller-card,
.meal-today-card,
.meal-book-section {
  padding: 16px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meal-roller-top {
  display: flex;
  align-items: center;
  gap: 14px;
  perspective: 600px;
}

.meal-spotlight {
  min-width: 0;
  flex: 1;
}

.meal-spotlight-sub {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}

.meal-spotlight-dish {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-roll-controls {
  display: flex;
  gap: 8px;
}

.meal-roll-controls select,
.meal-add-recipe-form select {
  padding: 8px 10px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.meal-roll-controls .btn {
  flex: 1;
}

.meal-manual-form {
  display: flex;
  gap: 8px;
}

.meal-manual-form input,
.meal-add-recipe-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}

.meal-manual-form input:focus,
.meal-add-recipe-form input:focus {
  border-color: var(--accent);
}

.meal-today-head,
.meal-book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.meal-today-list {
  max-height: 175px;
  overflow-y: auto;
}

.meal-pick-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.meal-tag-pill {
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.meal-tag-pill.cooldown {
  background: var(--blush-soft);
  color: var(--blush);
}

.meal-add-recipe-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.meal-recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.meal-recipe-card {
  padding: 11px 12px;
  border-radius: 13px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.16s ease, opacity 0.2s ease;
}

.meal-recipe-card.in-cooldown {
  opacity: 0.68;
  border-style: dashed;
}

.meal-recipe-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.meal-recipe-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.meal-recipe-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.meal-recipe-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}

@media (max-width: 820px) {
  .meal-top-grid {
    grid-template-columns: 1fr;
  }
  .meal-recipe-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .meal-recipe-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* ==========================================================================
   Admin & Sub-Admin Console (v2.4.0 RBAC, Separate Permissions & Invites)
   ========================================================================== */

.admin-console-card {
  width: min(920px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-tab {
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.admin-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

.admin-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-box-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: center;
}

.admin-create-grid input,
.admin-create-grid select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  font-size: 13px;
}

.admin-perm-select-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.admin-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
}

.admin-users-list,
.admin-invites-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-user-card,
.admin-invite-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}

.admin-user-card.disabled-user,
.admin-invite-card.inactive {
  opacity: 0.68;
  border-style: dashed;
}

.admin-user-top,
.admin-invite-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-user-identity,
.admin-invite-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.admin-user-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.admin-user-name {
  font-size: 14.5px;
  color: var(--text-primary);
}

.admin-account-id,
.invite-code-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.invite-code-badge {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.admin-user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-inline-select {
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12.5px;
}

.role-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.role-badge.role-admin {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.role-badge.role-sub-admin {
  background: rgba(59, 130, 246, 0.14);
  color: #1d4ed8;
}

.role-badge.role-user {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

[data-theme="dark"] .role-badge.role-admin {
  color: #fbbf24;
}

[data-theme="dark"] .role-badge.role-sub-admin {
  color: #93c5fd;
}

.status-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
}

.status-badge.disabled {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.status-badge.self {
  background: var(--accent-soft, rgba(58, 134, 91, 0.14));
  color: var(--accent);
}

[data-theme="dark"] .status-badge.active {
  color: #86efac;
}

[data-theme="dark"] .status-badge.disabled {
  color: #fca5a5;
}

.admin-user-perms {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
}

.admin-perms-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.perm-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perm-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.18s ease, border-color 0.18s ease;
}

.perm-pill:not(.locked):not(.static):hover {
  transform: translateY(-1px);
}

.perm-pill.on {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.38);
  color: #15803d;
}

.perm-pill.off {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-muted);
  text-decoration: line-through;
}

[data-theme="dark"] .perm-pill.on {
  color: #86efac;
}

.perm-pill.locked,
.perm-pill.static {
  cursor: default;
}

.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.18);
}

[data-theme="dark"] .btn-danger-ghost {
  color: #fca5a5;
}

.empty-hint {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 760px) {
  .admin-create-grid {
    grid-template-columns: 1fr 1fr;
  }
  .admin-create-grid button[type="submit"] {
    grid-column: 1 / -1;
  }
}


/* ==========================================================================
   v2.5.0 Multi-Page Workspace, Pure-Icon Dock, Collapsible Composer & Hover Tooltips
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Dedicated Full-Area Workspace Pages (replaces floating modals/drawers) */
.feature-page {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: page-enter 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.feature-page.hidden,
.workspace-page.hidden {
  display: none !important;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-page-header {
  height: var(--header-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.25);
}

[data-theme="dark"] .feature-page-header {
  background: rgba(15, 23, 19, 0.35);
}

.feature-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.feature-page-header .studio-header-title h3 {
  margin: 0;
  font-size: 16px;
}

.feature-page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feature-narrow-body {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.profile-page-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.memory-page-list {
  flex: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memory-page-danger-zone {
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* Pure-Icon Sidebar Navigation Dock */
.sidebar-icon-dock {
  flex-direction: row !important;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  gap: 4px !important;
  padding: 8px 8px !important;
}

.dock-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.dock-icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dock-icon-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.dock-icon-btn.danger-subtle:hover {
  background: var(--blush-soft);
  color: var(--blush);
}

.dock-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  pointer-events: none;
}

.dock-status-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  border: 1.5px solid var(--bg-surface-solid);
  pointer-events: none;
}

.dock-status-dot.warn {
  background: #f59e0b;
}

/* Pure-Icon Header TTS Toggle */
.tts-control-wrap.icon-only-tts {
  padding: 4px 8px;
  gap: 5px;
  min-width: 36px;
  height: 36px;
  justify-content: center;
}

.tts-control-wrap.icon-only-tts .tts-icon-glyph {
  font-size: 14px;
  line-height: 1;
}

/* Collapsible Composer '+' Tool Tray */
.composer-more-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.composer-more-btn {
  transition: transform 0.22s var(--ui-spring), background 0.16s ease, color 0.16s ease;
}

.composer-more-btn.open {
  transform: rotate(45deg);
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-tools-popover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  min-width: 156px;
  padding: 6px;
  border-radius: 14px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg, 0 12px 30px rgba(0, 0, 0, 0.16));
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 60;
  animation: popover-rise 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.composer-tools-popover.hidden {
  display: none !important;
}

@keyframes popover-rise {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.composer-tool-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease;
}

.composer-tool-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.composer-tool-item.recording {
  background: var(--blush-soft);
  color: var(--blush);
}

.voice-recording-banner {
  margin: 0 auto 8px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: var(--blush-soft);
  color: var(--blush);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.voice-recording-banner.hidden {
  display: none !important;
}

/* Pointer/Cursor-Only Crisp Hover Tooltips (never stuck on touch devices) */
@media (hover: hover) and (pointer: fine) {
  [data-tooltip] {
    position: relative;
  }

  [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    padding: 5px 9px;
    border-radius: 8px;
    background: rgba(24, 32, 28, 0.92);
    color: #f8faf9;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    z-index: 120;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  [data-theme="dark"] [data-tooltip]::after {
    background: rgba(242, 247, 244, 0.95);
    color: #15201b;
  }

  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  [data-tooltip][data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
    transform: translateX(-50%) translateY(-4px);
  }

  [data-tooltip][data-tooltip-pos="bottom"]:hover::after,
  [data-tooltip][data-tooltip-pos="bottom"]:focus-visible::after {
    transform: translateX(-50%) translateY(0);
  }
}

/* Admin tabs spacing inside full page */
.feature-page .admin-tabs {
  padding: 10px 22px;
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .feature-page-scroll {
    padding: 14px 14px 24px;
  }
}


/* ==========================================================================
   v3.0.0 Multimodal Attachments, Settings Studio (AI Key/Avatar/Voice) & Family Space
   ========================================================================== */

.composer-attachments-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 8px;
}

.composer-attachments-strip.hidden {
  display: none !important;
}

.att-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--text-primary);
  max-width: 220px;
}

.att-chip img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.att-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.att-chip-remove {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
}

.att-chip-remove:hover {
  color: var(--blush);
}

.msg-attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.msg-att-img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  object-fit: cover;
  display: block;
}

.msg-att-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: inherit;
  text-decoration: none;
}

/* Avatar Packs & Voice Catalog in Settings Studio */
.avatar-packs-grid,
.voice-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.avatar-pack-card,
.voice-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.avatar-pack-card.active,
.voice-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.avatar-pack-thumb {
  height: 112px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.avatar-pack-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.avatar-pack-info,
.voice-card-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.avatar-pack-actions,
.voice-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.avatar-uploader-stage {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.avatar-uploader-preview {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: var(--bg-surface-solid);
  object-fit: contain;
  padding: 6px;
}

/* Family Space */
.family-empty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.family-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.family-chat-preview {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-elevated);
  font-size: 12.5px;
  line-height: 1.55;
  max-height: 220px;
  overflow-y: auto;
}

.family-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.family-image-card {
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.family-img-wrap {
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  display: block;
  overflow: hidden;
}

.family-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.family-img-meta {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.family-img-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ==========================================================================
   v3.0.1 Hold-to-Talk Voice Mode Composer
   ========================================================================== */

.hold-to-talk-btn {
  flex: 1;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, color 0.16s ease;
}

.hold-to-talk-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.hold-to-talk-btn.recording {
  background: var(--blush-soft);
  border-color: var(--blush);
  color: var(--blush);
  transform: scale(0.985);
  box-shadow: 0 0 0 4px rgba(217, 112, 112, 0.18);
}

.hold-to-talk-btn.hidden {
  display: none !important;
}


/* ==========================================================================
   v3.1.0 Collapsible Sidebar Feature Dock & Personal Ledger System
   ========================================================================== */

.sidebar-dock-wrap {
  position: relative;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-dock-wrap .sidebar-icon-dock {
  border-top: none;
}

.sidebar-dock-drawer {
  padding: 10px 10px 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  animation: popover-rise 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-dock-drawer.hidden {
  display: none !important;
}

.dock-app-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 9px 4px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--bg-surface-solid);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.dock-app-tile:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
}

.dock-app-tile.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.dock-app-tile.hidden {
  display: none !important;
}

.dock-icon-btn.open {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Ledger Page */
.ledger-month-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.ledger-month-input {
  padding: 5px 8px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.ledger-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ledger-kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ledger-kpi-card strong {
  font-size: 22px;
  font-family: var(--font-mono);
}

.ledger-kpi-card.expense strong {
  color: var(--blush);
}

.ledger-kpi-card.income strong {
  color: var(--accent);
}

.ledger-kpi-card.balance strong.negative {
  color: var(--blush);
}

.ledger-kind-toggle {
  display: inline-flex;
  gap: 6px;
}

.ledger-breakdown-list,
.ledger-entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ledger-bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ledger-bar-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.ledger-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-surface-solid);
  overflow: hidden;
}

.ledger-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #6bc493);
  transition: width 0.35s ease;
}

.ledger-entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border-subtle);
}

.ledger-entry-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.ledger-entry-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ledger-entry-note {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ledger-entry-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ledger-amount {
  font-family: var(--font-mono);
  font-size: 14px;
}

.ledger-amount.expense {
  color: var(--blush);
}

.ledger-amount.income {
  color: var(--accent);
}

@media (max-width: 640px) {
  .ledger-kpi-grid {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   v3.1.1 Mobile Phone Layout Polish (Eliminate Crowding, Squishing & iOS Zoom)
   ========================================================================== */

/* Full-bleed edge-to-edge feature pages on mobile & tablet */
html[data-viewport="tablet"] .feature-page,
html[data-viewport="mobile"] .feature-page {
  border-radius: 0;
  border: none;
}

/* Hide desktop/tablet/mobile preview switcher on actual narrow mobile screens */
@media (max-width: 640px) {
  .viewport-switcher {
    display: none !important;
  }
}

html[data-viewport="mobile"] .chat-header {
  padding: 0 10px;
  height: 54px;
  gap: 6px;
}

html[data-viewport="mobile"] .chat-header-actions {
  gap: 4px;
}

html[data-viewport="mobile"] .chat-header-actions .icon-btn,
html[data-viewport="mobile"] .chat-header-actions .ui-eclipse-btn,
html[data-viewport="mobile"] .chat-header-actions .tts-control-wrap.icon-only-tts {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
}

html[data-viewport="mobile"] .chat-title {
  font-size: 15px;
  max-width: 165px;
}

/* Lighter, less intrusive mobile top-right avatar dock */
html[data-viewport="mobile"] .avatar-dock {
  top: 58px;
  right: 8px;
}

html[data-viewport="mobile"] .avatar-character-wrap {
  width: 54px;
  height: 76px;
}

html[data-viewport="mobile"] .avatar-status-pill {
  padding: 2px 7px;
  font-size: 10px;
}

html[data-viewport="mobile"] .avatar-mini-controls {
  opacity: 0;
  pointer-events: none;
}

html[data-viewport="mobile"] .avatar-mover:focus-within .avatar-mini-controls {
  opacity: 1;
  pointer-events: auto;
}

html[data-viewport="mobile"] .messages-scroll {
  padding: 84px 12px 14px 12px;
}

html[data-viewport="mobile"] .msg-row {
  gap: 8px;
}

html[data-viewport="mobile"] .msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 12px;
}

html[data-viewport="mobile"] .msg-bubble {
  padding: 10px 13px;
  font-size: 14.5px;
  line-height: 1.6;
}

html[data-viewport="mobile"] .composer-box {
  padding: 6px 8px;
  gap: 6px;
  border-radius: 18px;
}

/* Prevent iOS Safari auto-zoom on focused inputs */
@media (max-width: 640px) {
  .composer-textarea,
  .auth-form input,
  .profile-page-card input,
  .profile-page-card textarea,
  .admin-create-grid input,
  .admin-create-grid select,
  .meal-manual-form input,
  .meal-add-recipe-form input,
  .meal-add-recipe-form select,
  .memory-add-form input,
  .studio-textarea {
    font-size: 16px !important;
  }

  .auth-overlay {
    padding: 16px;
    overflow-y: auto;
    align-items: flex-start;
  }

  .auth-card {
    margin: auto 0;
    padding: 22px 18px;
    border-radius: 20px;
  }

  /* Feature pages header breathing room */
  .feature-page-header {
    height: auto;
    min-height: 52px;
    padding: 8px 10px;
    gap: 6px;
  }

  .feature-header-left {
    gap: 4px;
  }

  .feature-page-header .studio-status-pill {
    display: none;
  }

  .feature-page-header .studio-header-title h3 {
    font-size: 15px;
    white-space: nowrap;
  }

  .feature-page-scroll {
    padding: 12px 12px calc(22px + env(safe-area-inset-bottom));
    gap: 12px;
  }

  /* Scrollable single-line tab bars (no awkward wrapping) */
  .admin-tabs,
  .feature-page .admin-tabs {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12.5px;
  }

  /* Stack multi-column forms cleanly on phones */
  .admin-create-grid,
  .meal-top-grid,
  .meal-add-recipe-form,
  .family-empty-grid {
    grid-template-columns: 1fr !important;
  }

  .meal-manual-form {
    flex-direction: column;
    align-items: stretch;
  }

  .meal-odo-label {
    display: none;
  }

  /* Compact 3-column KPI cards on Ledger mobile so user sees stats at a glance */
  .ledger-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px;
  }

  .ledger-kpi-card {
    padding: 10px 8px;
    border-radius: 12px;
  }

  .ledger-kpi-card .muted-inline {
    font-size: 11px;
  }

  .ledger-kpi-card strong {
    font-size: 14.5px;
  }

  .ledger-month-input {
    width: 108px;
    font-size: 12px;
    padding: 4px 5px;
  }

  /* Cleaner sidebar drawer width on narrow phones */
  html[data-viewport="mobile"] .sidebar {
    width: min(82vw, 300px);
  }

  .avatar-packs-grid,
  .voice-catalog-grid {
    grid-template-columns: 1fr;
  }

  .family-images-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}
