/* AI assistant tab — chat, composer, drafts (ported from Shelese, Eat tokens) */

.main-scroll--assistant {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0 calc(var(--sh-composer-h, 6.5rem) + var(--tab-bar-band) + 0.5rem);
  overflow: hidden;
  min-height: 0;
}

.app-bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
}

.app-bottom-dock .tab-bar {
  position: relative;
  bottom: auto;
  margin: 0;
}

.app-bottom-dock--assistant .sh-composer-bar {
  flex-shrink: 0;
}

.app-bottom-dock--assistant .sh-composer-bar__inner {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}

.eat-assistant {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.eat-chat-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: 0 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}

.sh-scrollport {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages.sh-messages--viewport {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1rem 0.75rem 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

[data-eat-chat-target="suggestion"] {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
}

.chat-messages.sh-messages--viewport:not(.sh-messages--pinned)::before {
  content: "";
  flex: 1 1 auto;
  min-height: 0;
}

.sh-welcome {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: rgba(34, 211, 238, 0.06);
}

.sh-welcome__lead {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.sh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sh-chip {
  padding: 0.35rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-ink);
  cursor: pointer;
}

/* Composer — Claude-style unified card */
.sh-composer-bar {
  display: block;
  width: 100%;
}

.sh-composer-bar__inner {
  padding: 0.6rem 0.75rem 0.65rem;
  background: linear-gradient(180deg, rgba(10, 16, 28, 0) 0%, rgba(10, 16, 28, 0.92) 30%, rgba(10, 16, 28, 0.96) 100%);
  backdrop-filter: blur(14px);
}

.sh-composer-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem 0.55rem;
  border-radius: 1.4rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.sh-composer-card.is-focused {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(56, 189, 248, 0.18);
  background: var(--color-surface);
}

/* === Multi-attachment thumbnail strip =====================================
 * Sits above the textarea inside the composer card. Shows one square preview
 * per attached photo with a kind pill (Meal / Label) and a remove × button.
 * Horizontally scrollable so several attachments don't push the input down. */
.sh-attach-strip {
  display: flex;
  gap: 0.5rem;
  padding: 0.15rem 0 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.sh-attach-strip[hidden] { display: none; }

.sh-attach-strip::-webkit-scrollbar { height: 4px; }
.sh-attach-strip::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.sh-attach-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 4.2rem;
  height: 4.2rem;
  border-radius: 0.7rem;
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
  animation: sh-attach-pop 200ms ease-out both;
}

.sh-attach-thumb--meal   { border-color: rgba(34, 211, 238, 0.55); }
.sh-attach-thumb--label  { border-color: rgba(168, 139, 250, 0.55); }

.sh-attach-thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sh-attach-thumb__kind {
  position: absolute;
  left: 0.25rem;
  bottom: 0.25rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #0b1220;
}

.sh-attach-thumb__kind--meal  { background: rgba(34, 211, 238, 0.9); }
.sh-attach-thumb__kind--label { background: rgba(168, 139, 250, 0.95); color: #1a1033; }

.sh-attach-thumb__kind:hover { filter: brightness(1.08); }
.sh-attach-thumb__kind:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.sh-attach-thumb__remove {
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 0;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  font: inherit;
}

.sh-attach-thumb__remove:hover { background: rgba(248, 113, 113, 0.9); }

.sh-attach-strip.is-uploading .sh-attach-thumb {
  animation: sh-attach-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes sh-attach-pop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes sh-attach-pulse {
  from { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.45); }
  to   { box-shadow: 0 0 0 6px rgba(34, 211, 238, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .sh-attach-thumb,
  .sh-attach-strip.is-uploading .sh-attach-thumb { animation: none; }
}

/* One-line tip explaining what'll happen when they hit send. */
.sh-attach-hint {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  color: var(--color-subtle);
  letter-spacing: 0.01em;
}

.sh-attach-hint[hidden] { display: none; }

/* Small label next to the camera/label icons, hidden on narrow screens. */
.sh-composer-attach__label {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Borderless textarea that lives inside the card */
.sh-composer-textarea {
  width: 100%;
  min-height: 2.6rem;
  max-height: 35vh;
  padding: 0.35rem 0.25rem;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-ink);
  font-family: inherit;
  font-size: 0.98rem;
  line-height: 1.45;
  resize: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: none;
}

.sh-composer-textarea::placeholder {
  color: var(--color-subtle);
  opacity: 0.85;
}

.sh-composer-textarea:focus {
  outline: none;
  box-shadow: none;
}

/* Action row inside the card */
.sh-composer-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.15rem;
}

.sh-composer-actions__spacer {
  flex: 1 1 auto;
}

.sh-composer-attach {
  position: relative;
  overflow: hidden;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-subtle);
  cursor: pointer;
}

.sh-composer-attach:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-ink);
}

.sh-composer-attach .mic-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sh-composer-attach svg {
  width: 1.1rem;
  height: 1.1rem;
}

.sh-composer-attach__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.sh-composer-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--color-accent);
  color: #0f172a;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.sh-composer-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

.sh-composer-send:active:not(:disabled) {
  transform: scale(0.94);
}

.sh-composer-send:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-subtle);
  cursor: not-allowed;
}

.sh-composer-send svg {
  width: 1.05rem;
  height: 1.05rem;
}

.sh-msg {
  max-width: 92%;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.45;
}

.sh-msg--user {
  align-self: flex-end;
  background: rgba(34, 211, 238, 0.15);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.sh-msg--ai {
  align-self: flex-start;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
}

/* Per-turn "extras": meal cards, today plan, weekly draft. Lives inside the
 * assistant bubble so the UI sticks to the chat history. */
.sh-msg--ai .sh-msg-extras {
  margin-top: 0.55rem;
  margin-left: -0.4rem;
  margin-right: -0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Bubbles that contain extras should be allowed to grow wider so the cards
 * don't get squeezed into a narrow column. */
.sh-msg--ai:has(.sh-msg-extras) {
  max-width: min(100%, 44rem);
  width: 100%;
}

.sh-msg--ai .sh-msg-extras > .ai-card-stack,
.sh-msg--ai .sh-msg-extras > .ai-today-plan,
.sh-msg--ai .sh-msg-extras > .ai-suggestion {
  margin: 0;
}

.sh-composer-photo-badge__kind {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(34, 211, 238, 0.85);
  margin-right: 0.15rem;
}

.sh-composer-mic.is-uploading {
  border-color: rgba(251, 113, 133, 0.55);
  color: #fca5a5;
}

.sh-composer-mic.is-uploading .camera-btn__pulse {
  background: conic-gradient(from 0deg,
    #fca5a5 0deg,
    #fca5a5 180deg,
    transparent 180deg,
    transparent 360deg);
}

/* AI cards rendered as dashboard intake-card.
 * Override the dashboard's 2-col grid (which reserves a thumb column) so
 * the body fills full width and content isn't pushed right.
 * `min-width: 0` is critical: without it, the inner edit table's min-width
 * forces the card (and its flex column ancestors) to grow off-screen. */
.ai-intake-card {
  margin: 0.5rem 0.75rem;
  grid-template-columns: 1fr;
  width: auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* When a meal photo is attached, use the same 2-col layout as the Today dashboard. */
.ai-intake-card:has(.intake-card__thumb) {
  grid-template-columns: auto 1fr;
  align-items: start;
}

.ai-intake-card .intake-card__body {
  width: 100%;
  min-width: 0;
}

/* Hide attribute MUST beat the explicit display rules below (.ai-intake-card__edit
 * uses display:flex which would otherwise win over the UA [hidden] { display:none } rule). */
.ai-intake-card__view[hidden],
.ai-intake-card__edit[hidden] {
  display: none !important;
}

.ai-intake-card--editing {
  border-color: rgba(56, 189, 248, 0.45);
}

.ai-intake-card__head {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.ai-intake-card__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.ai-intake-card__source {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-subtle);
}

.ai-intake-card__source--photo {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
}

.ai-intake-card__source--label {
  background: rgba(250, 204, 21, 0.15);
  color: #fde68a;
}

.ai-intake-card__source--verified {
  background: rgba(52, 211, 153, 0.18);
  color: #6ee7b7;
}

.ai-intake-card__verified-mark {
  margin-left: 0.15rem;
  font-size: 0.85rem;
}

.ai-intake-card__save-verified.is-saved {
  opacity: 0.85;
}

.ai-intake-card__reason {
  font-style: italic;
  color: var(--color-subtle);
}

.ai-intake-card__actions {
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ai-intake-card__slot {
  -webkit-appearance: none;
  appearance: none;
  text-transform: capitalize;
  padding: 0.15rem 0.65rem;
  border: 0;
  cursor: pointer;
}

.ai-intake-card__edit {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.65rem -0.65rem -0.65rem;
  padding: 0.75rem 0.65rem;
  border-top: 1px solid var(--color-border);
  background: rgba(15, 23, 42, 0.35);
  min-width: 0;
  max-width: calc(100% + 1.3rem);
  overflow: hidden;
}

.ai-intake-card__edit-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--color-subtle);
}

/* Horizontal scroller — clipped to the card's width so the table can scroll
 * inside without expanding the chat layout. */
.ai-intake-card__edit-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  position: relative;
  /* Subtle edge fade so the user sees content scrolls off-screen */
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1rem), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1rem), transparent 100%);
}

.ai-intake-card__edit-scroll::-webkit-scrollbar {
  height: 6px;
}

.ai-intake-card__edit-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}

.ai-intake-card__lines-edit {
  display: inline-flex;
  flex-direction: column;
  gap: 0.4rem;
  /* `width: max-content` lets the table size to its content (the sticky
   * name column + fixed macro cells) so it actually overflows and the
   * parent's overflow-x can scroll. */
  width: max-content;
  min-width: 100%;
  padding-right: 1.2rem; /* room for the mask fade */
}

.ai-intake-card__line {
  display: grid;
  /* All columns are fixed-width so the whole table (including the name input)
   * participates in horizontal scroll. Each row sizes to `max-content`. */
  grid-template-columns:
    14rem
    4rem
    3.4rem
    3.4rem
    3.4rem
    1.6rem;
  gap: 0.4rem;
  align-items: center;
}

.ai-intake-card__line--head {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-subtle);
  padding-bottom: 0.15rem;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.25);
}

.ai-intake-card__col {
  padding: 0 0.1rem;
}

.ai-intake-card__col--name {
  text-align: left;
  padding-left: 0.1rem;
}

.ai-intake-card__col--num {
  text-align: center;
}

.ai-intake-card__col--rm {
  text-align: right;
}

.ai-intake-card__line .input {
  padding: 0.45rem 0.55rem;
  font-size: 0.85rem;
  border-radius: 0.55rem;
}

.ai-intake-card__line-name {
  min-width: 14rem;
  background: var(--color-surface-2);
}

/* Tap-to-edit number cell */
.ai-intake-card__cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  padding: 0.3rem 0.45rem;
  border-radius: 0.55rem;
  background: var(--color-surface-2);
  border: 1px dashed rgba(148, 163, 184, 0.25);
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease, background 120ms ease;
}

.ai-intake-card__cell:hover,
.ai-intake-card__cell:focus-visible {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.08);
  outline: none;
}

.ai-intake-card__cell.is-editing {
  padding: 0;
  background: transparent;
  border: 0;
}

.ai-intake-card__cell-input {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.3rem 0.45rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  border-radius: 0.55rem;
}

.ai-intake-card__cell-display {
  display: inline-block;
  min-width: 1.4rem;
  text-align: center;
}

.ai-intake-card__line-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 0;
  background: rgba(248, 113, 113, 0.15);
  color: #fda4af;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.ai-intake-card__line-remove:hover {
  background: rgba(248, 113, 113, 0.3);
}

.ai-intake-card__edit-foot {
  display: flex;
  justify-content: flex-start;
}

.ai-suggestion,
.ai-meal-card {
  margin: 0.5rem 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

/* Vertical stack of cards that streams in as the AI replies. */
.ai-card-stack {
  margin: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-card-stack__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ai-card-stack__hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--color-subtle);
  letter-spacing: 0.02em;
}

.ai-card-stack__list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.ai-card-stack__item {
  margin: 0;
  animation: ai-card-arrive 280ms ease-out both;
}

@keyframes ai-card-arrive {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-card-stack__item { animation: none; }
}

.ai-suggestion__title {
  margin: 0 0 0.1rem;
  font-size: 1.05rem;
}

.ai-suggestion__eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.ai-suggestion__summary {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--color-ink);
}

.ai-suggestion__hint {
  margin: 0 0 0.65rem;
  font-size: 0.74rem;
  color: var(--color-subtle);
}

.ai-suggestion__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 0.85rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.2);
  flex-wrap: wrap;
}

/* Week planner: one column per day stacked vertically. */
.ai-week {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-week__day {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow: hidden;
  min-width: 0;
}

.ai-week__day-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--color-border);
}

.ai-week__day-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--color-ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ai-week__day-date {
  font-size: 0.72rem;
  color: var(--color-subtle);
  font-variant-numeric: tabular-nums;
}

.ai-week__day-weather {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--color-subtle);
}

.ai-week__day-weather--chilly {
  color: #93c5fd;
}

.ai-week__day-drop {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 4.2rem;
  padding: 0.5rem;
  transition: background 120ms ease, box-shadow 120ms ease;
  min-width: 0;
}

.ai-week__day-drop.has-meals {
  background: rgba(15, 23, 42, 0.15);
}

.ai-week__day-empty {
  margin: 0;
  padding: 0.45rem 0.5rem;
  font-size: 0.72rem;
  color: var(--color-subtle);
  border: 1px dashed rgba(148, 163, 184, 0.3);
  border-radius: var(--radius-sm);
  text-align: center;
}

/* Drop target highlight when a card is being dragged over. */
.ai-week__day-drop.is-drag-hover {
  background: rgba(56, 189, 248, 0.12);
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.55);
}

/* The intake card lives inside a day column — drop the outer margins. */
.ai-week__day-drop .ai-intake-card {
  margin: 0;
  cursor: default;
}

.ai-intake-card--draggable {
  position: relative;
}

/* Title row puts the drag handle inline to the left of the meal name. */
.ai-intake-card__title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0 0.35rem;
  min-width: 0;
}

.ai-intake-card__title-row .intake-card__name,
.ai-intake-card__name {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.ai-intake-card__drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-right: 0; /* gap handles spacing inside .ai-intake-card__title-row */
  flex: 0 0 auto;
  border-radius: 0.4rem;
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-subtle);
  font-size: 0.85rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.ai-intake-card__drag-handle:hover {
  background: rgba(148, 163, 184, 0.22);
  color: var(--color-ink);
}

/* Drag-state classes shared with the drag-and-drop controller. */
.ai-intake-card.is-dragging,
.ai-suggestion__chip.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.ai-intake-card.is-drop-flash {
  animation: ai-drop-flash 600ms ease-out;
}

.ai-intake-card.is-drop-error {
  animation: ai-drop-error 1.2s ease-out;
}

@keyframes ai-drop-flash {
  0%   { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.6); }
  60%  { box-shadow: 0 0 0 12px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

@keyframes ai-drop-error {
  0%, 100% { background: var(--color-surface); }
  50%      { background: rgba(248, 113, 113, 0.18); }
}

/* Legacy chip styles kept for backwards-compat fallback (not used by new planner). */
.ai-suggestion__day-drop {
  min-height: 2.5rem;
  padding: 0.35rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ai-suggestion__chip {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 0.78rem;
  cursor: grab;
}

.ai-meal-card__title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.ai-meal-card__macros {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: var(--color-subtle);
}

.ai-today-plan {
  margin: 0.5rem 0.75rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.ai-today-plan__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.ai-today-plan__title {
  margin: 0;
  font-size: 1rem;
}

/* Sparkle "AI magic" button — used in the today plan header (top right). */
.ai-magic-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  border-radius: 999px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--color-accent) 22%, transparent),
    color-mix(in srgb, var(--color-accent-2) 18%, transparent));
  color: var(--color-text);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 120ms ease, border-color 140ms ease, box-shadow 140ms ease;
  white-space: nowrap;
}

.ai-magic-btn:hover {
  transform: translateY(-1px);
  border-color: var(--color-accent);
  box-shadow: 0 4px 14px -8px color-mix(in srgb, var(--color-accent) 70%, transparent);
}

.ai-magic-btn:active { transform: translateY(0); }
.ai-magic-btn:disabled { opacity: 0.55; cursor: progress; transform: none; }

.ai-magic-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  animation: ai-magic-sparkle 2.6s ease-in-out infinite;
}

@keyframes ai-magic-sparkle {
  0%, 100% { transform: rotate(0deg) scale(1); filter: drop-shadow(0 0 0 transparent); }
  50%      { transform: rotate(8deg) scale(1.08); filter: drop-shadow(0 0 4px color-mix(in srgb, var(--color-accent) 60%, transparent)); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-magic-btn__icon { animation: none; }
}

/* Remove button on each meal card — destructive ghost style, sits next to Tweak. */
.ai-intake-card__remove {
  color: color-mix(in srgb, var(--color-danger) 80%, var(--color-text));
}

.ai-intake-card__remove:hover {
  background: color-mix(in srgb, var(--color-danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--color-danger) 45%, var(--color-border));
  color: var(--color-danger);
}

.ai-intake-card--leaving {
  pointer-events: none;
}

.ai-today-plan__summary {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--color-subtle);
}

.ai-today-plan__slots {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ai-today-plan .ai-intake-card {
  margin: 0;
}

.ai-today-plan__slot {
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.ai-today-plan__slot-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-accent);
}

.ai-today-plan__meal-name {
  margin: 0.25rem 0;
  font-size: 0.95rem;
}

.ai-today-plan__macros {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--color-subtle);
}

.ai-today-plan__reason {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  color: var(--color-subtle);
}

.meal-quick-add-dialog {
  border: none;
  padding: 0;
  max-width: 28rem;
  width: calc(100% - 1.5rem);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.meal-quick-add-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

.meal-quick-add-dialog__panel {
  display: flex;
  flex-direction: column;
  max-height: 80dvh;
}

.meal-quick-add-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.meal-quick-add-dialog__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.meal-quick-add-dialog__body {
  padding: 0.85rem 1rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.meal-quick-add-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 1rem 0.85rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.meal-library-modal__section + .meal-library-modal__section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.meal-library-modal__section-title {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.meal-library-modal__section .muted--small {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--color-subtle);
  line-height: 1.4;
}

.meal-library-modal__section textarea.input {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.45;
  font-size: 0.9rem;
}

.stack--gap-sm {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.form-actions--end {
  justify-content: flex-end;
}

#a2ui-host-node {
  min-height: 0;
  margin: 0.35rem 0.75rem;
}

#a2ui-host-node:not(:empty) {
  min-height: 3rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}

.hidden {
  display: none !important;
}

/* Animated "thinker" — brain glyph + pulsing dots while the AI is composing. */
.sh-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.08);
  color: var(--color-accent);
  font-size: 0.78rem;
  line-height: 1;
}

.sh-typing__brain {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  color: var(--color-accent);
}

.sh-typing__brain svg {
  width: 1.2rem;
  height: 1.2rem;
  animation: thinker-wobble 2.8s ease-in-out infinite;
}

.sh-typing__pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.45) 0%, rgba(34, 211, 238, 0) 70%);
  filter: blur(1px);
  animation: thinker-pulse 1.6s ease-in-out infinite;
  pointer-events: none;
}

.sh-typing__dots {
  display: inline-flex;
  align-items: center;
  gap: 0.18rem;
}

.sh-typing__dots > span {
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--color-accent);
  opacity: 0.45;
  animation: thinker-dot 1.2s ease-in-out infinite;
}

.sh-typing__dots > span:nth-child(2) {
  animation-delay: 0.15s;
}

.sh-typing__dots > span:nth-child(3) {
  animation-delay: 0.3s;
}

.sh-typing__label {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.74rem;
  color: var(--color-accent);
  text-transform: lowercase;
}

.sh-typing--dots-only {
  padding: 0;
  background: transparent;
  gap: 0;
}

@keyframes thinker-wobble {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  25%      { transform: rotate(0deg)  scale(1.04); }
  50%      { transform: rotate(3deg)  scale(1); }
  75%      { transform: rotate(0deg)  scale(1.04); }
}

@keyframes thinker-pulse {
  0%, 100% { opacity: 0.0; transform: scale(0.85); }
  50%      { opacity: 0.85; transform: scale(1.1); }
}

@keyframes thinker-dot {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50%      { opacity: 1;    transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .sh-typing__brain svg,
  .sh-typing__pulse,
  .sh-typing__dots > span {
    animation: none;
  }
  .sh-typing__pulse {
    opacity: 0.4;
  }
}
