/* Ziwake AI — floating assistant (v0.22). Ink button with a quiet gold glow; a right-side panel on desktop, a bottom sheet on
 * phones; answer cards with a big number, a delta, a sentence, a sparkline and a top-N list. Tokens from app.css only. */

/* ---- floating button ---------------------------------------------------------------------------------------------------- */
.asst-fab {
  position: fixed; right: var(--s-4); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 32;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  width: 54px; height: 54px; padding: 0; border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 700; letter-spacing: .01em;
  color: #FBF7EE; background: linear-gradient(140deg, #26335A 0%, #1F2B4D 45%, #141B33 100%);
  box-shadow: 0 0 0 1px rgba(217, 186, 124, .35), 0 10px 26px rgba(20, 27, 51, .32), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), opacity var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.asst-fab:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(217, 186, 124, .6), 0 14px 32px rgba(20, 27, 51, .36), inset 0 1px 0 rgba(255, 255, 255, .14); }
.asst-fab:active { transform: scale(.96); }
.asst-fab:focus-visible { outline: 3px solid var(--c-gold); outline-offset: 3px; }
.asst-fab__icon { width: 24px; height: 24px; color: #E9CF97; position: relative; z-index: 1; }
.asst-fab__glow { position: absolute; inset: -3px; border-radius: inherit; z-index: 0; pointer-events: none;
  background: conic-gradient(from 0deg, rgba(217, 186, 124, 0), rgba(217, 186, 124, .55), rgba(217, 186, 124, 0) 40%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px)); mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  animation: asst-spin 6s linear infinite; opacity: .9; }
.asst-fab__label, .asst-fab__kbd { display: none; position: relative; z-index: 1; }
.asst-fab__kbd { font: 600 11px/1 var(--font-sans); padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, .12); color: rgba(251, 247, 238, .85); }
.asst-fab[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: scale(.9); }
@keyframes asst-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .asst-fab__glow { animation: none; } }
/* Lift it above sticky save rows and the POS charge bar on phones. */
@media (max-width: 899px) {
  body:has(.form-actions) .asst-fab, body:has(.pos__charge) .asst-fab, body:has(.shop-cartbar) .asst-fab { bottom: calc(148px + env(safe-area-inset-bottom)); width: 46px; height: 46px; }
}
@media (min-width: 900px) {
  .asst-fab { right: var(--s-8); bottom: var(--s-8); width: auto; height: 50px; padding: 0 var(--s-4) 0 var(--s-3); }
  .asst-fab__icon { width: 22px; height: 22px; }
  .asst-fab__label { display: inline; }
  .asst-fab__kbd { display: inline-block; }
}
@media print { .asst-fab, .asst, .asst-backdrop { display: none !important; } }

/* ---- panel ------------------------------------------------------------------------------------------------------------- */
.asst-backdrop { position: fixed; inset: 0; z-index: 54; background: rgba(15, 14, 20, .32); animation: fade-in var(--t-med) var(--ease-out); }
.asst-backdrop[hidden], .asst[hidden] { display: none !important; }
.asst {
  position: fixed; z-index: 55; left: 0; right: 0; bottom: 0; height: min(92vh, 92dvh); display: flex; flex-direction: column;
  background: var(--c-bg); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -12px 40px rgba(22, 23, 28, .18);
  padding-bottom: env(safe-area-inset-bottom); animation: asst-up var(--t-med) var(--ease-out); overflow: hidden;
}
@keyframes asst-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes asst-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) {
  .asst { left: auto; top: 0; right: 0; bottom: 0; height: auto; width: 440px; border-radius: var(--r-lg) 0 0 var(--r-lg);
    box-shadow: -1px 0 0 var(--c-border), -20px 0 48px rgba(22, 23, 28, .14); animation-name: asst-in; }
  .asst-backdrop { background: rgba(15, 14, 20, .12); }
}
@media (prefers-reduced-motion: reduce) { .asst, .asst-backdrop { animation: none; } }

.asst__head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-border);
  background: linear-gradient(180deg, var(--c-surface), var(--c-bg)); flex: none; }
.asst__head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--c-border); }
@media (min-width: 900px) { .asst__head::before { display: none; } }
.asst__mark { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(140deg, #26335A, #141B33); color: #E9CF97; box-shadow: 0 0 0 1px rgba(217, 186, 124, .35); }
.asst__mark .icon { width: 20px; height: 20px; }
.asst__titles { display: flex; flex-direction: column; min-width: 0; }
.asst__title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: var(--fs-xl); letter-spacing: 0; line-height: 1.1; }
.asst__sub { font-size: var(--fs-xs); color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asst__icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--c-text-2); cursor: pointer; text-decoration: none; }
.asst__icon-btn:hover { background: var(--c-surface-2); color: var(--c-text); }
.asst__body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.asst-skeleton { padding: var(--s-5) var(--s-4); display: grid; gap: var(--s-3); }
.asst-skeleton span { display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--c-surface-2), var(--c-surface), var(--c-surface-2)); background-size: 200% 100%; animation: asst-shimmer 1.2s linear infinite; }
.asst-skeleton span:nth-child(2) { width: 70%; } .asst-skeleton span:nth-child(3) { width: 45%; }
@keyframes asst-shimmer { to { background-position: -200% 0; } }

.asst-tabs { display: flex; gap: var(--s-1); padding: var(--s-2) var(--s-3) 0; flex: none; }
.asst-tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--c-text-2); font: inherit; font-size: var(--fs-sm); font-weight: 650; cursor: pointer; }
.asst-tab[aria-selected="true"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-1); }
.asst-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.asst-pane[hidden] { display: none; }
.asst-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-4) var(--s-4) var(--s-3); display: flex; flex-direction: column; gap: var(--s-4); scroll-behavior: smooth; }
.asst-hello__hi { margin: 0; font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1.15; }
.asst-hello__q { margin: 4px 0 0; color: var(--c-text-2); }
.asst-sec { display: flex; flex-direction: column; gap: var(--s-2); }
.asst-sec[hidden] { display: none; }
.asst-sec__title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--c-text-3); }
.asst-sec__title .icon { color: var(--c-gold); }
.asst-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.asst-chips[hidden] { display: none; }
.asst-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: var(--r-pill); cursor: pointer; text-align: left;
  border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.3;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.asst-chip:hover { border-color: var(--c-gold); background: var(--c-gold-soft); }
.asst-chip:active { transform: scale(.98); }
.asst-chip--ghost { background: transparent; color: var(--c-text-2); font-weight: 550; }
.asst-chips--list { flex-direction: column; gap: 0; border-radius: var(--r-md); background: var(--c-surface); box-shadow: var(--shadow-1); overflow: hidden; }
.asst-chip--row { width: 100%; justify-content: space-between; border: 0; border-radius: 0; min-height: 46px; padding: 10px 14px; background: transparent; }
.asst-chip--row + .asst-chip--row { border-top: 1px solid var(--c-hairline); }
.asst-chip--row:hover { background: var(--c-surface-2); }
.asst-chip--row .icon { color: var(--c-text-3); flex: none; }
.asst-cats { display: flex; gap: var(--s-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 calc(-1 * var(--s-4)); padding-inline: var(--s-4); }
.asst-cats::-webkit-scrollbar { display: none; }
.asst-cat { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--c-border);
  background: transparent; color: var(--c-text-2); font: inherit; font-size: var(--fs-xs); font-weight: 650; cursor: pointer; white-space: nowrap; }
.asst-cat[aria-selected="true"] { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-on-accent); }
.asst-cat__n { font-size: 11px; opacity: .7; }

.asst-ask { flex: none; display: flex; align-items: center; gap: 6px; margin: 0 var(--s-3) 0; padding: 6px 6px 6px var(--s-4); border-radius: var(--r-pill);
  background: var(--c-surface); box-shadow: 0 0 0 1px var(--c-border), 0 6px 18px rgba(22, 23, 28, .06); }
.asst-ask:focus-within { box-shadow: 0 0 0 2px var(--c-accent), 0 6px 18px rgba(22, 23, 28, .08); }
.asst-ask__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--c-text); font: inherit; font-size: 16px; min-height: 40px; }
.asst-ask__input::placeholder { color: var(--c-text-3); }
.asst-ask__btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; cursor: pointer; }
.asst-ask__btn[hidden] { display: none; }
.asst-ask__mic { background: transparent; color: var(--c-text-2); }
.asst-ask__mic:hover { background: var(--c-surface-2); color: var(--c-text); }
.asst-ask__mic.is-listening { background: var(--c-danger-soft); color: var(--c-danger); animation: asst-pulse 1.2s ease-in-out infinite; }
@keyframes asst-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--c-danger) 18%, transparent); } }
.asst-ask__send { background: var(--c-accent); color: var(--c-on-accent); }
.asst-ask__send:hover { background: var(--c-accent-hover); }
.asst-ask__send[aria-busy="true"] { opacity: .6; }
.asst-foot { flex: none; display: flex; align-items: flex-start; gap: 6px; margin: var(--s-2) var(--s-4) var(--s-3); font-size: 12px; line-height: 1.4; color: var(--c-text-3); }
.asst-foot .icon { flex: none; width: 14px; height: 14px; margin-top: 1px; color: var(--c-gold); }
.asst-steps { margin: 0; padding-left: 1.3em; color: var(--c-text-2); font-size: var(--fs-sm); display: grid; gap: 4px; }

/* ---- conversation ------------------------------------------------------------------------------------------------------- */
.asst-q { align-self: flex-end; max-width: 86%; padding: 9px 14px; border-radius: 18px 18px 4px 18px; background: var(--c-accent); color: var(--c-on-accent);
  font-size: var(--fs-sm); font-weight: 550; line-height: 1.4; overflow-wrap: anywhere; animation: fade-in var(--t-fast); }
.asst-thinking { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 18px; background: var(--c-surface); box-shadow: var(--shadow-1);
  color: var(--c-text-2); font-size: var(--fs-sm); align-self: flex-start; }
.asst-dots { display: inline-flex; gap: 3px; } .asst-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c-gold); animation: asst-dot 1s infinite; }
.asst-dots i:nth-child(2) { animation-delay: .15s; } .asst-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes asst-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---- answer card ---------------------------------------------------------------------------------------------------------- */
.asst-card { position: relative; display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-lg); background: var(--c-surface);
  box-shadow: var(--shadow-1); animation: asst-up var(--t-med) var(--ease-out); min-width: 0; }
.asst-card--page { box-shadow: var(--shadow-1); }
.asst-card__top { display: flex; align-items: flex-start; gap: var(--s-2); }
.asst-card__title { margin: 0; font-size: var(--fs-md); font-weight: 700; line-height: 1.3; flex: 1; min-width: 0; }
.asst-card__period { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--c-text-3); }
.asst-badge { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700;
  background: var(--c-gold-soft); color: var(--c-text); white-space: nowrap; }
.asst-badge .icon { width: 12px; height: 12px; color: var(--c-gold); }
.asst-badge--ai { background: var(--c-accent-soft); color: var(--c-accent); }
.asst-card__value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--fs-3xl); font-weight: 750; line-height: 1.05; letter-spacing: -0.02em; color: var(--c-text); overflow-wrap: anywhere; }
.asst-card__value--text { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-2xl); letter-spacing: 0; }
.asst-card__value--good { color: var(--c-ok); } .asst-card__value--bad { color: var(--c-danger); } .asst-card__value--warn { color: var(--c-warn); }
.asst-card__caption { font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 650; color: var(--c-text-2); letter-spacing: 0; }
.asst-delta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--fs-sm); color: var(--c-text-2); }
.asst-delta__pill { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 8px; border-radius: var(--r-pill); font-weight: 750; font-variant-numeric: tabular-nums; }
.asst-delta__pill .icon { width: 14px; height: 14px; }
.asst-delta--good .asst-delta__pill { background: var(--c-ok-soft); color: var(--c-ok); }
.asst-delta--bad .asst-delta__pill { background: var(--c-danger-soft); color: var(--c-danger); }
.asst-delta--flat .asst-delta__pill { background: var(--c-surface-2); color: var(--c-text-2); }
.asst-card__text { margin: 0; line-height: 1.5; }
.asst-spark { display: block; width: 100%; height: 64px; }
.asst-spark rect { fill: color-mix(in srgb, var(--c-accent) 26%, transparent); }
.asst-spark rect.is-hl { fill: var(--c-accent); }
.asst-spark rect.is-neg { fill: color-mix(in srgb, var(--c-danger) 45%, transparent); }
.asst-spark rect.is-neg.is-hl { fill: var(--c-danger); }
.asst-spark line { stroke: var(--c-border); stroke-width: .4; }
.asst-spark-labels { display: flex; justify-content: space-between; margin-top: -6px; font-size: 10.5px; color: var(--c-text-3); }
.asst-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.asst-pair__item { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-xs); color: var(--c-text-2); }
.asst-pair__bar { height: 8px; border-radius: 6px; background: color-mix(in srgb, var(--c-accent) 22%, transparent); }
.asst-pair__item.is-hl .asst-pair__bar { background: var(--c-accent); }
.asst-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--s-2); margin: 0; }
.asst-stats div { padding: 8px 10px; border-radius: var(--r-sm); background: var(--c-surface-2); min-width: 0; }
.asst-stats dt { font-size: 11.5px; color: var(--c-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asst-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.asst-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.asst-list__title { margin: 0 0 2px; font-size: var(--fs-xs); font-weight: 700; color: var(--c-text-3); text-transform: uppercase; letter-spacing: .05em; }
.asst-list li + li { border-top: 1px solid var(--c-hairline); }
.asst-row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); align-items: center; padding: 8px 2px; color: var(--c-text); text-decoration: none; position: relative; }
a.asst-row:hover .asst-row__label { color: var(--c-accent); text-decoration: underline; }
.asst-row__label { font-size: var(--fs-sm); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asst-row__value { font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.asst-row__sub { grid-column: 1 / -1; font-size: 12px; color: var(--c-text-3); }
.asst-row__bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--c-surface-2); overflow: hidden; }
.asst-row__bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--c-gold), color-mix(in srgb, var(--c-gold) 55%, var(--c-accent))); }
.asst-row--warn .asst-row__value { color: var(--c-warn); } .asst-row--bad .asst-row__value { color: var(--c-danger); }
.asst-links { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); padding-top: var(--s-2); border-top: 1px solid var(--c-hairline); }
.asst-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 650; text-decoration: none; }
.asst-link:hover { text-decoration: underline; }
.asst-link .icon { width: 14px; height: 14px; }
.asst-follow { display: flex; flex-wrap: wrap; gap: 6px; }
.asst-follow .asst-chip { min-height: 32px; padding: 4px 12px; font-size: var(--fs-xs); }
.asst-card__note { margin: 0; font-size: 12px; color: var(--c-text-3); }
.asst-ai-btn { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 42px; padding: 0 16px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 700; color: #FBF7EE; background: linear-gradient(140deg, #26335A, #141B33); box-shadow: 0 0 0 1px rgba(217, 186, 124, .4); }
.asst-ai-btn .icon { color: #E9CF97; }
.asst-ai-btn small { font-weight: 550; opacity: .75; }

/* ---- the /app/ask page uses the same card ------------------------------------------------------------------------------- */
.ask-page { display: grid; gap: var(--s-5); max-width: 760px; }
.ask-page .asst-ask { margin: 0; }
.ask-page .asst-cats { margin: 0; padding-inline: 0; }
