/* AI Super-Easy Estimate — chatbot styles.
 * Brand language adopted from Torii Honten theme (style.css):
 *   navy #12295b, body #1a1a1a, surface #fff, soft #f8f9fa, border #ececec,
 *   body font Helvetica Neue, heading font Noto Serif JP, 6px corners. */

.ase-chatbot {
  --ase-navy:   #12295b;
  --ase-navy-2: #0e1f47;
  --ase-text:   #1a1a1a;
  --ase-muted:  #6b7180;
  --ase-bg:     #ffffff;
  --ase-soft:   #f8f9fa;
  --ase-line:   #ececec;
  --ase-beige:  #f4ece1;

  font-family: "Helvetica Neue", Helvetica, Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  font-size: 15px;
  color: var(--ase-text);
  line-height: 1.55;
}

.ase-chatbot, .ase-chatbot *, .ase-chatbot *::before, .ase-chatbot *::after { box-sizing: border-box; }

.ase-chatbot [hidden] { display: none !important; }

/* ───── Launcher ────────────────────────────────────────────── */
.ase-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 50px;
  padding: 8px 16px 8px 58px;
  overflow: visible;
  background: #e6f4f8;
  color: var(--ase-navy); border: 1px solid #c7e0e8; border-radius: 6px;
  box-shadow: 0 6px 16px rgba(18,41,91,.22);
  cursor: pointer;
  transition:
    background-color .15s ease,
    transform .22s cubic-bezier(.2,.7,.2,1),
    opacity .2s ease;
  will-change: transform, opacity;
  font-family: inherit;
}
.ase-launcher:hover { background: #d6ecf2; transform: translateY(-1px); }
.ase-launcher.is-hiding {
  opacity: 0;
  transform: scale(.92) translateY(4px);
  pointer-events: none;
}
.ase-launcher-avatar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: transparent;
  width: 50px;
  border-radius: 6px 0 0 6px;
  flex-shrink: 0; overflow: hidden;
}
.ase-launcher-avatar .ase-avatar-img {
  border-radius: 0;
  object-fit: cover;
  object-position: center top;
}
.ase-launcher-label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.ase-launcher-title { font-family: 'Noto Serif JP', 'Yu Mincho', serif; font-weight: 600; font-size: 14px; letter-spacing: .02em; }
.ase-launcher-sub   { font-size: 11px; opacity: .85; margin-top: 2px; }

.ase-avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: center top; display: block; }

/* ───── Window shell ────────────────────────────────────────── */
.ase-window {
  position: fixed; right: 24px; bottom: 24px; z-index: 9999;
  width: 360px;
  height: min(70vh, 560px);
  max-height: calc(100vh - 48px);
  background: var(--ase-bg);
  border: none;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0,0,0,.14);
  display: flex; flex-direction: column;
  transform-origin: 100% 100%;
  opacity: 0;
  transform: scale(.85) translateY(12px);
  transition:
    opacity .26s cubic-bezier(.2,.7,.2,1),
    transform .32s cubic-bezier(.2,.7,.2,1);
  will-change: transform, opacity;
}
.ase-window.is-open {
  opacity: 1;
  transform: scale(1) translateY(0);
}
.ase-window.is-closing {
  opacity: 0;
  transform: scale(.9) translateY(8px);
}
@media (prefers-reduced-motion: reduce) {
  .ase-window,
  .ase-launcher { transition: none; }
}
@media (max-width: 480px) {
  .ase-window {
    right: 12px; left: 12px; width: auto;
    bottom: 24px;
    height: min(70dvh, 560px);
    max-height: calc(100dvh - 48px);
  }
}

/* ───── Header ──────────────────────────────────────────────── */
.ase-header {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px;
  background: var(--ase-navy); color: #fff;
  flex-shrink: 0;
  border: 1px solid var(--ase-navy-2);
  border-bottom: none;
  overflow: hidden;
}
.ase-header-persona {
  display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;
  transition: transform 320ms cubic-bezier(.2,.8,.2,1), opacity 240ms ease;
}
.ase-header[data-lang-expanded="true"] .ase-header-persona {
  transform: translateX(-16px);
  opacity: 0;
  pointer-events: none;
}
.ase-header-persona > div { min-width: 0; }
.ase-header-title {
  font-family: 'Noto Serif JP', 'Yu Mincho', serif;
  font-weight: 600; font-size: 14px; letter-spacing: .02em;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ase-header-sub {
  font-size: 11px; opacity: .8; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ase-header-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.ase-lang-toggle {
  position: static;
  display: inline-flex;
  align-items: center;
  background: transparent;
  padding: 0;
  border-radius: 0;
  min-width: 0;
}

.ase-lang-trigger {
  background: transparent;
  color: #fff;
  border: none;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  flex-shrink: 0;
  transition: transform 320ms cubic-bezier(.2,.8,.2,1);
}
.ase-lang-trigger:hover { color: #fff; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-trigger { transform: translateX(-4px); }

.ase-lang-current {
  display: inline-block;
  transition: opacity 150ms ease;
}
.ase-lang-current.is-swapping { opacity: 0; }

.ase-lang-options {
  position: static;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  max-width: 0;
  max-height: none;
  margin-left: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
  overflow-y: hidden;
  transform: none;
  opacity: 1;
  pointer-events: auto;
  transition: max-width 380ms cubic-bezier(.2,.8,.2,1), margin-left 380ms cubic-bezier(.2,.8,.2,1);
  scrollbar-width: none;
}
.ase-lang-options::-webkit-scrollbar { display: none; }

.ase-lang-toggle[data-expanded="true"] .ase-lang-options {
  max-width: min(260px, calc(100vw - 140px));
  margin-left: 8px;
}

.ase-lang-option {
  background: transparent !important;
  color: rgba(255,255,255,.7);
  border: none;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .05em;
  border-radius: 0;
  flex-shrink: 0;
  white-space: nowrap;
  transform: translateX(12px);
  opacity: 0;
  transition: transform 340ms cubic-bezier(.2,.8,.2,1), opacity 280ms ease, color .15s ease;
}
.ase-lang-option:hover:not(:disabled) { color: #fff; }
.ase-lang-option + .ase-lang-option { border-left: 1px solid rgba(255,255,255,.25); margin-left: 2px; padding-left: 8px; }

.ase-lang-toggle[data-expanded="true"] .ase-lang-option {
  transform: translateX(0);
  opacity: 1;
}
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(1) { transition-delay: 0ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(2) { transition-delay: 40ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(3) { transition-delay: 80ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(4) { transition-delay: 120ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(5) { transition-delay: 160ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(6) { transition-delay: 200ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(7) { transition-delay: 240ms; }
.ase-lang-toggle[data-expanded="true"] .ase-lang-option:nth-child(n+8) { transition-delay: 280ms; }

.ase-lang-option[aria-current="true"] {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .ase-header-persona,
  .ase-lang-trigger,
  .ase-lang-options,
  .ase-lang-current,
  .ase-lang-option { transition: none !important; }
}

.ase-close {
  background: transparent; color: #fff; border: none;
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
  cursor: pointer; border-radius: 4px;
}
.ase-close:hover { background: rgba(255,255,255,.12); }

/* ───── Body / messages ─────────────────────────────────────── */
.ase-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 14px;
  padding-bottom: 16px;
  background: var(--ase-soft);
  scroll-behavior: smooth;
  border-left: 1px solid var(--ase-line);
  border-right: 1px solid var(--ase-line);
}

.ase-messages { display: flex; flex-direction: column; gap: 8px; padding-bottom: 120px; }
.ase-body:has(.ase-proposal:not([hidden])) .ase-messages { padding-bottom: 0; }
#ase-messages-after { padding-bottom: 0; margin-top: 16px; }
#ase-messages-after:empty { display: none; }
.ase-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.6;
  font-size: 14px;
  word-wrap: break-word;
}
.ase-msg-bot  { align-self: flex-start; background: var(--ase-bg); border: 1px solid var(--ase-line); border-bottom-right-radius: 2px; }
.ase-msg-user { align-self: flex-end;   background: var(--ase-navy); color: #fff; border-bottom-right-radius: 2px; }

/* Consecutive bot bubbles read as one continuous speech column. The flex
   container uses gap: 8px, so cancel it with a negative margin on the
   trailing edge, strip the touching border, trim padding at the join, and
   reshape border-radius so only the outer corners stay rounded. */
.ase-msg-bot.ase-msg-grouped-next { margin-bottom: -8px; border-bottom: 0; padding-bottom: 4px; }
.ase-msg-bot.ase-msg-grouped-prev { border-top: 0; padding-top: 4px; }
.ase-msg-bot.ase-msg-grouped-next:not(.ase-msg-grouped-prev) { border-radius: 6px 6px 0 0; }
.ase-msg-bot.ase-msg-grouped-prev.ase-msg-grouped-next { border-radius: 0; }
.ase-msg-bot.ase-msg-grouped-prev:not(.ase-msg-grouped-next) { border-radius: 0 0 6px 6px; border-bottom-right-radius: 2px; }
.ase-msg-system { align-self: center; font-size: 12px; color: var(--ase-muted); background: transparent; padding: 2px 4px; }
/* Bot bubbles waiting their turn in the typewriter queue are kept out of layout
 * entirely — otherwise the empty bubble collapses to padding-width and shows
 * as a tiny stub next to the bubble currently typing. */
.ase-msg.ase-msg-pending { display: none; }
/* When the visually-next bubble is still queued, the current "last visible"
 * bot bubble needs its bottom contour back — the grouped-next styling
 * assumes a follow-on bubble will continue the group below. */
.ase-msg-bot.ase-msg-grouped-next:has(+ .ase-msg-pending) {
  margin-bottom: 0;
  border-bottom: 1px solid var(--ase-line);
  padding-bottom: 10px;
  border-radius: 6px;
  border-bottom-right-radius: 2px;
}

.ase-msg,
.ase-debug,
.ase-typing {
  transition:
    opacity .24s cubic-bezier(.2,.7,.2,1),
    transform .24s cubic-bezier(.2,.7,.2,1);
}
.ase-msg-entering {
  opacity: 0;
  transform: translateY(4px) scale(.985);
}
.ase-msg-user.ase-msg-entering {
  opacity: 0;
  transform: translate(14px, 6px) scale(.92);
}
.ase-msg-user.ase-msg-send-in {
  animation: aseUserSendIn .32s cubic-bezier(.2,.8,.2,1.1) both;
}
@keyframes aseUserSendIn {
  0%   { opacity: 0; transform: translate(14px, 6px) scale(.92); }
  70%  { opacity: 1; transform: translate(-2px, 0)  scale(1.02); }
  100% { opacity: 1; transform: translate(0, 0)    scale(1); }
}
.ase-msg-leaving {
  opacity: 0;
  pointer-events: none;
  transition:
    opacity .22s cubic-bezier(.2,.7,.2,1),
    transform .22s cubic-bezier(.2,.7,.2,1),
    margin .26s cubic-bezier(.2,.7,.2,1),
    max-height .26s cubic-bezier(.2,.7,.2,1),
    padding .26s cubic-bezier(.2,.7,.2,1),
    border-width .26s cubic-bezier(.2,.7,.2,1);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  overflow: hidden;
}
.ase-msg-leaving.ase-msg-bot  { transform: translateX(-8px) scale(.985); }
.ase-msg-leaving.ase-msg-user { transform: translateX( 8px) scale(.985); }
.ase-msg-leaving.ase-debug,
.ase-msg-leaving.ase-typing   { transform: translateY(-4px) scale(.985); }

@media (prefers-reduced-motion: reduce) {
  .ase-msg, .ase-debug, .ase-typing { transition: opacity .12s linear; }
  .ase-msg-entering { transform: none; }
  .ase-msg-user.ase-msg-entering { transform: none; }
  .ase-msg-user.ase-msg-send-in  { animation: none; }
  .ase-msg-leaving  { transform: none; transition: opacity .12s linear, max-height .14s linear, margin .14s linear, padding .14s linear; }
  .ase-typing-label { animation: none; }
  .ase-typing-dot   { animation: none; opacity: .6; }
}
.ase-typing {
  font-size: 12px; color: var(--ase-muted); padding: 2px 4px;
  display: inline-flex; align-items: center; gap: 6px;
}
.ase-typing-label {
  animation: ase-typing-shimmer 1.6s ease-in-out infinite;
}
.ase-typing-dots {
  display: inline-flex; align-items: flex-end; gap: 3px;
  line-height: 1;
}
.ase-typing-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: .35;
  animation: ase-typing-bounce 1.2s ease-in-out infinite;
}
.ase-typing-dot:nth-child(2) { animation-delay: .15s; }
.ase-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes ase-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40%           { transform: translateY(-3px); opacity: 1; }
}
@keyframes ase-typing-shimmer {
  0%, 100% { color: var(--ase-muted); }
  50%      { color: #a0a4ad; }
}
.ase-dev-badge { display: none; }
#ase-root.ase-dev .ase-dev-badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  background: #ffb300; color: #1a1a1a;
  border-radius: 4px;
  font-family: inherit;
}
#ase-root.ase-dev .ase-window {
  box-shadow: 0 0 0 2px #ffb300, 0 12px 32px rgba(0,0,0,.14);
}
.ase-debug { display: none; }
#ase-root.ase-dev .ase-debug {
  display: block;
  align-self: flex-end;
  max-width: 80%;
  font-size: 11px;
  line-height: 1.4;
  color: #5a4a1a;
  background: #fff7d6;
  border: 1px dashed #c8b275;
  border-radius: 6px;
  padding: 4px 8px;
  margin-top: -4px;
  white-space: pre-wrap;
  word-break: break-word;
}
.ase-debug-cache {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 4px; padding-top: 4px;
  border-top: 1px dashed #d8c590;
}
.ase-debug-pill {
  display: inline-flex; align-items: center;
  padding: 1px 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  border-radius: 10px;
}
.ase-debug-pill-cache { background: #d4f4d4; color: #1b5e1b; }
.ase-debug-pill-fresh { background: #e5e5e5; color: #444; }
.ase-debug-key { font-family: ui-monospace, monospace; font-size: 10px; word-break: break-all; }
.ase-debug-remove {
  margin-left: auto;
  background: #fff; color: #5a4a1a;
  border: 1px solid #c8b275; border-radius: 4px;
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; cursor: pointer;
}
.ase-debug-remove:hover { background: #fff2c0; }
.ase-debug-remove:disabled { opacity: .6; cursor: default; }

/* ───── Pills ───────────────────────────────────────────────── */
.ase-pills {
  position: absolute;
  left: 0; right: 0;
  bottom: 58px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 110px 14px 12px;
  background: transparent;
  border: none;
  z-index: 1;
  pointer-events: none;
}
.ase-pills:empty { display: none; }
.ase-pill {
  pointer-events: auto;
  background: var(--ase-bg);
  color: var(--ase-navy);
  border: 1px solid var(--ase-navy);
  padding: 8px 10px;
  border-radius: 6px;
  min-height: 38px;
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  font-family: inherit;
  transition:
    background-color .15s ease,
    color .15s ease,
    opacity .22s cubic-bezier(.2,.7,.2,1),
    transform .22s cubic-bezier(.2,.7,.2,1);
}
.ase-pill:hover, .ase-pill:focus { background: var(--ase-navy); color: #fff; outline: none; }
.ase-pill-entering {
  opacity: 0;
  transform: translateY(6px) scale(.985);
}
.ase-pill-tapped {
  background: var(--ase-navy);
  color: #fff;
  transform: scale(.94);
  transition:
    background-color .09s ease,
    color .09s ease,
    transform .09s cubic-bezier(.2,.7,.2,1);
}
.ase-pill-flying {
  opacity: 0;
  transform: translateY(-8px) scale(.6);
  transition:
    opacity .18s cubic-bezier(.2,.8,.2,1.1),
    transform .18s cubic-bezier(.2,.8,.2,1.1);
  pointer-events: none;
}
.ase-body.is-rewinding { overflow-anchor: none; }
@media (prefers-reduced-motion: reduce) {
  .ase-pill-entering { transform: none; transition: opacity .12s linear; }
  .ase-pill-tapped   { transform: none; transition: background-color .09s linear, color .09s linear; }
  .ase-pill-flying   { transform: none; transition: opacity .12s linear; }
}

/* ───── Input row ───────────────────────────────────────────── */
.ase-input {
  position: relative;
  display: flex; gap: 8px; align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--ase-line);
  border-left: 1px solid var(--ase-line);
  border-right: 1px solid var(--ase-line);
  border-bottom: 1px solid var(--ase-line);
  background: var(--ase-bg);
  flex-shrink: 0;
}
.ase-input-avatar {
  position: absolute;
  right: -6px;
  bottom: 100%;
  width: 96px; height: 96px;
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}
.ase-input-avatar .ase-avatar-img--portrait {
  width: 100%; height: 100%;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
  object-position: bottom center;
}
.ase-input-avatar .ase-avatar-talking,
.ase-input-avatar .ase-avatar-waving {
  position: absolute;
  inset: 0;
  display: none;
}
/* Idle = body (maskout) + eyes (maskin) overlaid; the eyes glide toward the
   cursor on hover (see the eye-tracking IIFE in ase-flow.js). */
.ase-input-avatar .ase-avatar-idle { position: absolute; inset: 0; }
.ase-input-avatar .ase-avatar-single,
.ase-input-avatar .ase-avatar-maskout,
.ase-input-avatar .ase-avatar-maskin { position: absolute; inset: 0; }
/* Default = eye-tracking off => single self-contained idle gif; the split mask
   layers only appear when the admin enables eye-tracking (ase-eyes-tracking). */
.ase-input-avatar .ase-avatar-maskout,
.ase-input-avatar .ase-avatar-maskin { display: none; }
#ase-window.ase-eyes-tracking .ase-input-avatar .ase-avatar-single { display: none; }
#ase-window.ase-eyes-tracking .ase-input-avatar .ase-avatar-maskout,
#ase-window.ase-eyes-tracking .ase-input-avatar .ase-avatar-maskin { display: block; }
.ase-input-avatar .ase-avatar-maskin {   /* after maskout in the DOM => paints on top */
  transform: translate(0, 0);            /* neutral / centered */
  transition: transform .45s cubic-bezier(.22, .61, .36, 1); /* slow, smooth ease-out */
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .ase-input-avatar .ase-avatar-maskin { transition: none; transform: none; }
}
/* Admin "eyes behind body": flip stacking so maskout (body, with eye holes) paints
   on top and the shifted eyes peek through the holes. Default = maskin on top. */
#ase-window.ase-eyes-behind .ase-input-avatar .ase-avatar-maskin  { z-index: 0; }
#ase-window.ase-eyes-behind .ase-input-avatar .ase-avatar-maskout { z-index: 1; }
/* Only the idle portrait is interactive (container stays click-through so it
   never blocks the input row). Click it to play the one-shot wave — but only
   when the admin enabled it (ase-wave-on, set from /api/ase/config). Otherwise
   it stays click-through with the default cursor, so it never looks clickable. */
#ase-window.ase-wave-on .ase-input-avatar .ase-avatar-idle { pointer-events: auto; cursor: pointer; }
#ase-window.ase-typewriting .ase-input-avatar .ase-avatar-idle { display: none; }
#ase-window.ase-typewriting .ase-input-avatar .ase-avatar-talking { display: block; }
#ase-window.ase-waving .ase-input-avatar .ase-avatar-idle { display: none; }
#ase-window.ase-waving .ase-input-avatar .ase-avatar-waving { display: block; }
/* Talking wins if the AI starts replying mid-wave. */
#ase-window.ase-typewriting .ase-input-avatar .ase-avatar-waving { display: none; }
.ase-text {
  flex: 1; padding: 10px 12px;
  border: 1px solid #d6d9e0; border-radius: 6px;
  font-size: 14px; font-family: inherit;
  color: var(--ase-text); background: #fff;
}
.ase-text:focus { outline: none; border-color: var(--ase-navy); }
.ase-send {
  background: var(--ase-navy); color: #fff;
  border: none; padding: 10px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  font-family: inherit;
  transition: background-color .15s ease, transform .12s cubic-bezier(.2,.7,.2,1);
}
.ase-send:hover { background: var(--ase-navy-2); }
.ase-send:active { transform: scale(.92); }
@media (prefers-reduced-motion: reduce) {
  .ase-send:active { transform: none; }
}
.ase-back {
  background: transparent; color: var(--ase-muted);
  border: none; padding: 10px 6px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
  font-family: inherit;
}
.ase-back:hover { color: var(--ase-text); }

/* ───── Proposal card ───────────────────────────────────────── */
.ase-proposal {
  background: var(--ase-bg);
  border: 1px solid var(--ase-line);
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
  transition:
    opacity .26s cubic-bezier(.2,.7,.2,1),
    transform .26s cubic-bezier(.2,.7,.2,1),
    margin .3s cubic-bezier(.2,.7,.2,1),
    max-height .3s cubic-bezier(.2,.7,.2,1),
    padding .3s cubic-bezier(.2,.7,.2,1),
    border-width .3s cubic-bezier(.2,.7,.2,1);
}
.ase-proposal-leaving {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.985);
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-width: 0;
  border-bottom-width: 0;
  overflow: hidden;
}
@media (prefers-reduced-motion: reduce) {
  .ase-proposal { transition: opacity .12s linear, max-height .14s linear, margin .14s linear, padding .14s linear; }
  .ase-proposal-leaving { transform: none; }
}
.ase-proposal-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ase-line);
  margin-bottom: 12px;
}
.ase-proposal-tier {
  font-family: 'Noto Serif JP', 'Yu Mincho', serif;
  font-weight: 600; font-size: 15px; color: var(--ase-navy);
  line-height: 1.4;
}
.ase-proposal-total { text-align: right; flex-shrink: 0; }
.ase-proposal-total-label {
  display: block; font-size: 10px; color: var(--ase-muted);
  letter-spacing: .08em; text-transform: uppercase; margin-bottom: 2px;
}
.ase-proposal-total-value { font-size: 19px; font-weight: 700; color: var(--ase-text); }
.ase-proposal-lead { font-size: 13px; line-height: 1.65; margin: 0 0 12px; color: var(--ase-text); }
.ase-proposal-headline { font-size: 12px; line-height: 1.55; margin: 0 0 12px; color: var(--ase-muted); }
/* Honest budget-fit line under the lead. Shown only when the proposal is over
 * budget (within-budget proposals show nothing): a neutral gray callout with
 * the gap + the top cost drivers that explain it. */
.ase-proposal-budget {
  font-size: 12px; line-height: 1.55; margin: 0 0 12px;
  color: var(--ase-muted);
  padding: 8px 10px; border-radius: 6px; background: #f4f6fa;
  border: 1px solid var(--ase-line);
}
.ase-proposal-budget.is-over {
  color: var(--ase-text); background: #f4f6fa; border-color: var(--ase-line);
}
.ase-proposal-items { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; }
.ase-proposal-item {
  display: block;
  padding: 0;
  border-bottom: 1px solid var(--ase-line);
}
.ase-proposal-item:last-child { border-bottom: none; }
.ase-proposal-item-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px;
  margin-inline: -14px;
  cursor: pointer;
  border-radius: 0;
  transition: background-color .15s ease;
}
.ase-proposal-item-row:hover { background: var(--ase-soft); }
.ase-proposal-item:first-child .ase-proposal-item-row { padding-top: 0; }
.ase-proposal-item:last-child .ase-proposal-item-row { padding-bottom: 0; }
.ase-proposal-item-thumb {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--ase-line);
  background: var(--ase-soft); flex-shrink: 0;
}
.ase-proposal-item-body { flex: 1; min-width: 0; }
.ase-proposal-item-name { font-size: 13px; font-weight: 600; color: var(--ase-text); }
.ase-proposal-item-desc { font-size: 11px; color: var(--ase-muted); margin-top: 2px; }
.ase-proposal-item-price {
  font-size: 13px; font-weight: 600; color: var(--ase-text);
  white-space: nowrap; min-width: 72px; text-align: right;
}
.ase-proposal-item-chevron {
  font-size: 18px; color: var(--ase-muted); line-height: 1;
  flex-shrink: 0; padding-left: 2px;
  transition: transform .22s ease, color .15s ease;
}
.ase-proposal-item.is-open .ase-proposal-item-chevron {
  transform: rotate(90deg); color: var(--ase-navy);
}

/* Itemized cost breakdown under the photo cards. Visually secondary to the
 * cards: no photos, muted prices, light dividers. Lets the family see where the
 * headline total comes from without competing with the swappable card items. */
.ase-proposal-breakdown {
  margin: 4px 0 14px;
  padding-top: 12px;
  border-top: 1px solid var(--ase-line);
}
.ase-proposal-breakdown-heading {
  font-size: 10px; color: var(--ase-muted);
  letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 6px;
}
.ase-proposal-breakdown-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 12.5px;
  border-bottom: 1px solid var(--ase-line);
}
.ase-proposal-breakdown-row:last-of-type { border-bottom: none; }
.ase-proposal-breakdown-label { color: var(--ase-text); }
.ase-proposal-breakdown-price {
  color: var(--ase-muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ase-proposal-breakdown-note {
  font-size: 11px; color: var(--ase-muted);
  margin: 8px 0 0; line-height: 1.5;
}

/* Grow-to-natural-height accordion via grid-template-rows 0fr → 1fr.
 * `display:none` (which [hidden] applies) can't animate, so the drawer
 * stays mounted in flow at height 0 and grows when the parent <li>
 * receives .is-open. Inner wrapper carries overflow + padding so the
 * outer row can interpolate cleanly from 0fr. */
.ase-proposal-swap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows .34s cubic-bezier(.2,.7,.2,1),
    opacity            .24s cubic-bezier(.2,.7,.2,1);
}
.ase-proposal-swap-inner {
  overflow: hidden;
  min-height: 0;
}
.ase-proposal-item.is-open .ase-proposal-swap {
  grid-template-rows: 1fr;
  opacity: 1;
}
.ase-proposal-item.is-open .ase-proposal-swap-inner {
  padding: 10px 0 12px;
}
.ase-proposal-swap-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.ase-proposal-swap-title {
  font-size: 11px; color: var(--ase-muted);
  letter-spacing: .04em;
}
.ase-proposal-swap-close {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--ase-muted); line-height: 1;
  padding: 4px 6px; border-radius: 4px;
  font-family: inherit;
}
.ase-proposal-swap-close:hover { color: var(--ase-navy); background: var(--ase-soft); }
.ase-proposal-swap-strip {
  display: flex; gap: 8px;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 6px;
}
.ase-proposal-swap-tile {
  flex: 0 0 96px;
  display: flex; flex-direction: column; align-items: stretch;
  gap: 4px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--ase-line);
  border-radius: 6px;
  cursor: pointer;
  scroll-snap-align: start;
  font-family: inherit;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.ase-proposal-swap-tile:hover {
  border-color: var(--ase-navy);
  transform: translateY(-1px);
}
.ase-proposal-swap-tile.is-selected {
  border-color: #78a9f6;
  box-shadow: 0 0 0 2px rgba(120, 169, 246, .35);
}
.ase-proposal-swap-tile img {
  width: 100%; height: 64px; object-fit: cover;
  border-radius: 4px;
  background: var(--ase-soft);
}
.ase-proposal-swap-tile-noneicon {
  display: flex; align-items: center; justify-content: center;
  height: 64px; border-radius: 4px;
  background: var(--ase-soft);
  color: var(--ase-muted); font-size: 22px; line-height: 1;
}
.ase-proposal-swap-tile-name {
  font-size: 11px; color: var(--ase-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ase-proposal-swap-tile-price {
  font-size: 12px; font-weight: 600; color: var(--ase-text);
}
@media (prefers-reduced-motion: reduce) {
  .ase-proposal-item-chevron,
  .ase-proposal-swap,
  .ase-proposal-swap-tile { transition: none; }
}
.ase-proposal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ase-cta {
  padding: 12px 16px; border-radius: 6px;
  font-size: 14px; font-weight: 600;
  text-align: center; cursor: pointer; border: none;
  text-decoration: none; display: block;
  font-family: inherit;
  transition: background-color .15s ease, color .15s ease;
}
.ase-cta-primary { background: var(--ase-navy); color: #fff; }
.ase-cta-primary:hover { background: var(--ase-navy-2); }
.ase-cta-ghost { background: var(--ase-bg); color: var(--ase-navy); border: 1px solid var(--ase-navy); }
.ase-cta-ghost:hover { background: var(--ase-navy); color: #fff; }
.ase-proposal-note { font-size: 11px; color: var(--ase-muted); margin: 12px 0 0; text-align: center; line-height: 1.5; }

/* Admin toggle: hide AI avatar (launcher + input) when /api/ase/config returns showAvatar:false. */
.ase-chatbot.ase-no-avatar .ase-launcher-avatar,
.ase-chatbot.ase-no-avatar .ase-input-avatar { display: none; }
/* Drop the avatar gutter on the launcher and the right-side pill carve-out
   (the ::before exists to flow pills around the input avatar). */
.ase-chatbot.ase-no-avatar .ase-launcher { padding-left: 16px; }
.ase-chatbot.ase-no-avatar .ase-pills { padding-right: 12px; }

/* Synchronous, pre-paint hide via cached localStorage value (see launcher.php). */
html.ase-no-avatar-cached .ase-launcher-avatar,
html.ase-no-avatar-cached .ase-input-avatar { display: none; }
html.ase-no-avatar-cached .ase-launcher { padding-left: 16px; }
html.ase-no-avatar-cached .ase-pills { padding-right: 12px; }

/* Admin master toggle: hide the entire chatbot (launcher + window) when
   /api/ase/config returns chatbotEnabled:false. The cached html-class variant
   hides it synchronously pre-paint (see launcher.php) so there's no flicker. */
.ase-chatbot.ase-chatbot-off,
html.ase-chatbot-off-cached .ase-chatbot { display: none !important; }

/* RTL support for Urdu / Arabic. Additive: scoped to the chatbot root only. */
.ase-chatbot[dir="rtl"] { text-align: right; }
.ase-chatbot[dir="rtl"] .ase-pills { flex-direction: row-reverse; }
.ase-chatbot[dir="rtl"] .ase-messages { direction: rtl; }
.ase-chatbot[dir="rtl"] .ase-message-bot { align-self: flex-end; }
.ase-chatbot[dir="rtl"] .ase-message-user { align-self: flex-start; }
.ase-chatbot[dir="rtl"] .ase-back::before { content: ''; }
.ase-chatbot[dir="rtl"] .ase-back { transform: scaleX(-1); }
.ase-chatbot[dir="rtl"] .ase-proposal-items { padding-right: 0; }
.ase-chatbot[dir="rtl"] .ase-launcher-label { text-align: right; }
.ase-chatbot[dir="rtl"] .ase-header-persona { flex-direction: row-reverse; }
.ase-chatbot[dir="rtl"] .ase-input { flex-direction: row-reverse; }
