.quick-emotions {
  display: contents;
  font-family: var(--font-sans);
}

/* Keep the two touch-sized Belief action rows clear of the floating control. */
body:has(.beliefs-form) {
  --feeling-editor-clearance: calc(2 * 44px + var(--space-lg));
}

.quick-emotions__trigger {
  --feeling-float-top: max(16px, env(safe-area-inset-top));
  --feeling-float-right: max(24px, env(safe-area-inset-right));
  --feeling-float-bottom: calc(max(24px, env(safe-area-inset-bottom)) + var(--feeling-editor-clearance, 0px));
  --feeling-float-left: max(16px, env(safe-area-inset-left));
  --feeling-launcher-shadow: color-mix(in srgb, var(--nav-bg) 32%, transparent);
  position: fixed;
  inset: auto var(--feeling-float-right) var(--feeling-float-bottom) auto;
  z-index: 10000;
  width: max-content;
  margin: 0;
  scroll-margin: var(--feeling-float-top) var(--feeling-float-right) var(--feeling-float-bottom) var(--feeling-float-left);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  max-width: 100%;
  /* Popovers default to overflow: auto; this fixed control must not scroll. */
  overflow: visible;
  padding: 8px 20px 8px 8px;
  border: 0;
  outline: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ink-dark) 90%, var(--feeling-blue)), var(--ink-dark));
  color: var(--paper-base);
  box-shadow: 0 8px 24px -8px var(--feeling-launcher-shadow), 0 2px 6px -2px var(--feeling-launcher-shadow);
  font: 600 14px/1.5 var(--font-sans);
  letter-spacing: .01em;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  text-decoration: none;
  transition: transform 240ms cubic-bezier(.22, 1, .36, 1), box-shadow 180ms ease;
}

.quick-emotions__trigger-icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  background: var(--feeling-surface-coral);
  color: color-mix(in srgb, var(--feeling-coral) 70%, var(--ink-dark));
  transition: color 180ms ease, box-shadow 180ms ease;
}
.quick-emotions__trigger svg { width: 20px; height: 20px; fill: color-mix(in srgb, currentColor 22%, transparent); transition: fill 180ms ease, transform 180ms ease; }
.quick-emotions__trigger:is(:hover, :focus-visible, .is-dragging) .quick-emotions__trigger-icon { color: color-mix(in srgb, var(--feeling-coral) 45%, var(--ink-dark)); }
.quick-emotions__trigger:is(:hover, :focus-visible, .is-dragging) svg { fill: color-mix(in srgb, currentColor 72%, transparent); }
.quick-emotions__trigger:active svg { transform: scale(.9); }
.quick-emotions__trigger-label { text-decoration: none; }
.quick-emotions__trigger:hover { box-shadow: 0 10px 28px -6px var(--feeling-launcher-shadow), 0 3px 8px -2px var(--feeling-launcher-shadow); }
.quick-emotions__trigger.is-dragging {
  cursor: grabbing;
  transform: scale(1.03);
  box-shadow: 0 16px 32px -8px var(--feeling-launcher-shadow), 0 4px 12px -2px var(--feeling-launcher-shadow);
}
.quick-emotions__trigger:disabled, .quick-emotions__badge:disabled { opacity: .6; cursor: wait; }
.quick-emotions__badge:focus-visible, .quick-emotions__empty:focus-visible {
  outline: 3px solid var(--action-primary);
  outline-offset: 4px;
}
.quick-emotions__trigger:focus-visible .quick-emotions__trigger-icon { box-shadow: inset 0 0 0 2px currentColor; }
.quick-emotions__trigger.is-concealed { visibility: hidden; pointer-events: none; }

.quick-emotions__panel {
  --feeling-focus-paper: color-mix(in srgb, var(--paper-base) 88%, transparent);
  --feeling-focus-light: var(--dialog-key-surface);
  --feeling-focus-edge: color-mix(in srgb, var(--leather-brown) 10%, transparent);
  position: fixed;
  isolation: isolate;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  box-sizing: border-box;
  margin: 0;
  padding: max(32px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  border: 0;
  background:
    radial-gradient(ellipse at 50% 46%, color-mix(in srgb, var(--feeling-focus-light) 75%, transparent) 0 17%, color-mix(in srgb, var(--feeling-focus-light) 42%, transparent) 40%, transparent 74%),
    radial-gradient(ellipse at center, transparent 35%, var(--feeling-focus-edge) 100%),
    var(--feeling-focus-paper);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  color: var(--ink-dark);
  overflow: hidden;
  clip-path: inset(0 round 0);
  outline: none;
}
.quick-emotions__panel[hidden] { display: none; }
.quick-emotions__panel[open] { display: grid; place-items: center; }
.quick-emotions__panel::backdrop { background: transparent; }
.quick-emotions__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 240px 160px at var(--feeling-focus-x, 50%) var(--feeling-focus-y, 50%), color-mix(in srgb, var(--feeling-focus-light) 88%, transparent), transparent);
  opacity: 0;
  transition: opacity 260ms ease-out;
}
.quick-emotions__panel.has-hold::before { opacity: .75; }
.quick-emotions__inner { width: min(820px, 100%); min-width: 0; min-height: 0; max-height: 100%; container-type: inline-size; }
.quick-emotions__panel.is-opening .quick-emotions__inner { visibility: hidden; }
.quick-emotions__badges {
  --feeling-columns: 2;
  display: grid;
  grid-template-columns: repeat(var(--feeling-columns), minmax(0, 1fr));
  align-items: stretch;
  gap: 18px 16px;
  max-height: calc(100dvh - 96px);
  padding: 16px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--sepia-line) transparent;
}

@container (min-width: 560px) {
  .quick-emotions__badges { --feeling-columns: 3; }
}

.quick-emotions__measure { position: fixed; visibility: hidden; pointer-events: none; width: max-content; white-space: nowrap; }

.quick-emotions__badge {
  --feeling-tone: var(--feeling-gold);
  --feeling-surface: var(--feeling-surface-gold);
  --hold-progress: 100%;
  --hold-angle: 360deg;
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 64px;
  width: 100%;
  max-width: 100%;
  padding: 14px 20px;
  border: 1px solid color-mix(in srgb, var(--feeling-tone) 65%, var(--paper-shadow));
  border-radius: var(--radius-pill);
  background: linear-gradient(120deg, color-mix(in srgb, var(--feeling-surface) 40%, var(--paper-aged)) 0%, var(--feeling-surface) 55%, color-mix(in srgb, var(--feeling-tone) 14%, var(--feeling-surface)) 100%);
  color: var(--ink-dark);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--feeling-tone) 30%, var(--paper-aged)), 0 4px 9px color-mix(in srgb, var(--feeling-tone) 12%, transparent), inset 0 1px 0 color-mix(in srgb, var(--paper-aged) 85%, transparent);
  font: 500 var(--text-md)/1.5 var(--font-sans);
  text-align: left;
  overflow: hidden;
  overflow-wrap: anywhere;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
  transition: transform 160ms ease-out, box-shadow 160ms ease-out, opacity 180ms ease-out, background 180ms ease-out;
}
.quick-emotions__badge::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -1;
  width: var(--hold-progress);
  opacity: 0;
  background: linear-gradient(120deg, color-mix(in srgb, var(--feeling-tone) 15%, var(--feeling-surface)), color-mix(in srgb, var(--feeling-tone) 28%, var(--feeling-surface)));
}
.quick-emotions__badge[hidden] { display: none; }
.quick-emotions__badges.has-single-feeling .quick-emotions__badge { width: min(360px, 100%); justify-self: center; }
.quick-emotions__badge > span:first-child { min-width: 0; text-wrap: balance; }
.quick-emotions__badge-score {
  position: relative;
  isolation: isolate;
  display: grid;
  flex: 0 0 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--paper-aged) 70%, transparent);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}
.quick-emotions__badge.is-holding::before { opacity: 1; }
.quick-emotions__badge.is-holding .quick-emotions__badge-score { background: conic-gradient(var(--feeling-tone) var(--hold-angle), color-mix(in srgb, var(--feeling-tone) 12%, var(--paper-aged)) 0); }
.quick-emotions__badge.is-holding .quick-emotions__badge-score::before { content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: inherit; background: var(--paper-aged); }
.quick-emotions__panel.has-hold .quick-emotions__badge:not(.is-holding) { opacity: .42; }
.quick-emotions__badge.is-leaving { pointer-events: none; }
.quick-emotions__badge:hover { border-color: var(--feeling-tone); transform: translateY(-1px); }
.quick-emotions__badge.is-holding {
  transform: translateY(2px) scale(.98);
  background: var(--paper-aged);
  border-color: var(--feeling-tone);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--feeling-tone) 8%, transparent), inset 0 2px 5px color-mix(in srgb, var(--feeling-tone) 15%, transparent);
}
.quick-emotions__badge--gold { --feeling-tone: var(--feeling-gold); --feeling-surface: var(--feeling-surface-gold); }
.quick-emotions__badge--lilac { --feeling-tone: var(--feeling-lilac); --feeling-surface: var(--feeling-surface-lilac); }
.quick-emotions__badge--coral { --feeling-tone: var(--feeling-coral); --feeling-surface: var(--feeling-surface-coral); }
.quick-emotions__badge--blue { --feeling-tone: var(--feeling-blue); --feeling-surface: var(--feeling-surface-blue); }
.quick-emotions__badge--sage { --feeling-tone: var(--feeling-sage); --feeling-surface: var(--feeling-surface-sage); }
.quick-emotions__badge--pink { --feeling-tone: var(--feeling-pink); --feeling-surface: var(--feeling-surface-pink); }
.quick-emotions__empty { grid-column: 1 / -1; justify-self: center; display: inline-flex; align-items: center; min-height: 44px; padding: 14px 20px; border: 1px solid var(--sepia-line); border-radius: var(--radius-pill); background: var(--paper-aged); color: var(--leather-brown); }
.quick-emotions__status { display: block; margin: 0; color: var(--ink-muted); font: 400 var(--text-sm)/1.5 var(--font-sans); overflow-wrap: anywhere; }
.quick-emotions__status:not(.is-error) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.quick-emotions__status:empty { display: none; }
.quick-emotions__status.is-error { padding: 8px; color: var(--danger); text-align: center; }

@media (max-width: 559px) {
  .quick-emotions__trigger { --feeling-float-right: max(16px, env(safe-area-inset-right)); --feeling-float-bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--feeling-editor-clearance, 0px)); min-height: 52px; padding: 7px 17px 7px 7px; border-radius: 18px; }
  .quick-emotions__trigger-icon { flex-basis: 36px; width: 36px; height: 36px; border-radius: 12px; }
  .quick-emotions__panel { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .quick-emotions__badges { gap: 14px 10px; }
  .quick-emotions__badge { min-height: 56px; gap: 8px; padding: 12px 14px; font-size: 15px; }
  .quick-emotions__badge-score { flex-basis: 26px; height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .quick-emotions__panel, .quick-emotions__panel::backdrop, .quick-emotions__panel::before, .quick-emotions__badge, .quick-emotions__trigger, .quick-emotions__trigger-icon, .quick-emotions__trigger svg { transition: none; }
  .quick-emotions__trigger:active svg { transform: none; }
  .quick-emotions__badge:is(:hover, .is-holding), .quick-emotions__trigger:is(:hover, :active, .is-dragging) { transform: none; }
}

@media (forced-colors: active) {
  .quick-emotions__trigger { color: ButtonText; background: ButtonFace; box-shadow: none; }
  .quick-emotions__trigger-icon { color: ButtonText; background: ButtonFace; }
  .quick-emotions__trigger svg { fill: none; }
  .quick-emotions__trigger:is(:hover, :focus-visible, .is-dragging) .quick-emotions__trigger-icon { color: Highlight; }
  .quick-emotions__trigger:is(:hover, :focus-visible, .is-dragging) svg { fill: Highlight; }
  .quick-emotions__trigger:focus-visible .quick-emotions__trigger-icon { outline: 2px solid Highlight; outline-offset: -2px; }
  .quick-emotions__panel { background: Canvas; }
  .quick-emotions__panel::before { display: none; }
  .quick-emotions__badge { color: ButtonText; background: ButtonFace; border-color: ButtonText; box-shadow: none; }
  .quick-emotions__badge.is-holding { outline: 3px solid Highlight; }
  .quick-emotions__badge.is-holding::before { display: none; }
  .quick-emotions__badge-score, .quick-emotions__badge.is-holding .quick-emotions__badge-score { color: ButtonText; background: ButtonFace; }
  .quick-emotions__badge.is-holding .quick-emotions__badge-score::before { background: ButtonFace; }
}
