/* ── HNA Assistant — floating character widget ──────────────────────── */

#hna-assistant-widget {
  position: fixed;
  bottom: 84px; /* above bottom nav */
  right: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  pointer-events: none;
}

#hna-assistant-widget.hna-hidden  { display: none; }
#hna-assistant-widget.hna-visible { pointer-events: auto; animation: hna-slide-in 0.3s ease-out; }

@keyframes hna-slide-in {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ── Speech bubble ──────────────────────────────────────────────────── */

.hna-bubble {
  background: #fff;
  border: 2px solid #6b4dd4;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 14px;
  max-width: 220px;
  font-size: 13px;
  line-height: 1.5;
  color: #2d1f5e;
  box-shadow: 0 4px 16px rgba(107, 77, 212, 0.18);
  position: relative;
  margin-bottom: 8px;
}

/* Tail pointing down-right toward character */
.hna-bubble::after {
  content: '';
  position: absolute;
  bottom: -12px;
  right: 20px;
  border: 7px solid transparent;
  border-top-color: #6b4dd4;
}
.hna-bubble::before {
  content: '';
  position: absolute;
  bottom: -9px;
  right: 21px;
  border: 6px solid transparent;
  border-top-color: #fff;
  z-index: 1;
}

.hna-bubble-text   { word-wrap: break-word; }
.hna-bubble-actions { display: flex; gap: 6px; margin-top: 10px; }

.hna-btn-dismiss {
  font-size: 11px;
  color: #7b6aaa;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}

/* ── Character compositor ───────────────────────────────────────────── */

.hna-char-wrap {
  position: relative;
  width: 80px;
  height: 120px;
}

.hna-char-container {
  position: relative;
  width: 80px;
  height: 120px;
}

#hna-char-container .char-inner {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform-origin: top center;
}

#hna-char-container .char-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
  object-position: bottom center;
}

.hna-close {
  position: absolute;
  top: -8px; right: -8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #6b4dd4;
  color: #fff;
  border: none;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(107, 77, 212, 0.3);
  padding: 0;
  line-height: 1;
}

@media (hover: hover) and (pointer: fine) {
  .hna-close:hover { background: #5a3db8; }
}

/* ── Guide ? button — under-7 (all plans) ───────────────────────────── */

#hna-guide-btn {
  position: fixed;
  bottom: 84px;
  right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #6b4dd4;
  color: #fff;
  border: none;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  z-index: 1100;
  box-shadow: 0 2px 8px rgba(107, 77, 212, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.15s;
}

#hna-guide-btn.hna-guide-visible { display: flex; }
#hna-guide-btn.hna-guide-playing { background: #e74c3c; }
@media (hover: hover) and (pointer: fine) {
  #hna-guide-btn:hover             { background: #5a3db8; }
  #hna-guide-btn.hna-guide-playing:hover { background: #c0392b; }
}

/* Paid-plan widget shifts ? button left of itself when both visible */
#hna-assistant-widget.hna-visible ~ #hna-guide-btn {
  right: 108px;
}

/* ── Character picker overlay ───────────────────────────────────────── */

#hna-char-picker {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(45, 31, 94, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px 0;
  animation: hna-fade 0.2s ease;
}

@keyframes hna-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.hna-picker-box {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 340px;
  width: calc(100vw - 40px);
  text-align: center;
  box-shadow: 0 8px 40px rgba(107, 77, 212, 0.2);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.hna-picker-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: #2d1f5e;
  margin: 0 0 6px;
}

.hna-picker-box p {
  font-size: 14px;
  color: #7b6aaa;
  margin: 0 0 20px;
}

.hna-picker-chars {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.hna-picker-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 14px 16px;
  border: 2.5px solid #e0d9f7;
  border-radius: 16px;
  background: #f8f6ff;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

@media (hover: hover) and (pointer: fine) {
  .hna-picker-char:hover { border-color: #6b4dd4; background: #f0eeff; }
}

.hna-picker-char-name {
  font-size: 14px;
  font-weight: 600;
  color: #2d1f5e;
}

.hna-picker-char.hna-picker-sel,
.hna-picker-alt.hna-picker-sel {
  border-color: #6b4dd4;
  background: #e8e4f8;
  box-shadow: 0 0 0 3px rgba(107, 77, 212, 0.25);
}

.hna-picker-alts {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.hna-picker-alt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border: 2.5px solid #e0d9f7;
  border-radius: 14px;
  background: #f8f6ff;
  font-size: 24px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.hna-picker-alt span {
  font-size: 12px;
  font-weight: 600;
  color: #2d1f5e;
}

@media (hover: hover) and (pointer: fine) {
  .hna-picker-alt:hover { border-color: #6b4dd4; background: #f0eeff; }
}

.hna-picker-confirm {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: #6b4dd4;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .hna-picker-confirm:hover { background: #5a3db8; }
}
.hna-picker-confirm.hna-hidden { display: none; }

.hna-picker-more {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px 6px;
  min-height: 44px;
  background: none;
  border: none;
  color: #6b4dd4;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: opacity 0.15s;
}
.hna-picker-more:hover { opacity: 0.75; }

.hna-picker-chars-extra { margin-top: 10px; }
.hna-picker-chars-extra.hna-hidden { display: none; }

/* ── Mini re-open tab ───────────────────────────────────────────────── */

#hna-char-tab {
  position: fixed;
  bottom: 84px;
  right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #6b4dd4;
  color: #fff;
  border: 2.5px solid #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 1100;
  box-shadow: 0 2px 8px rgba(107, 77, 212, 0.3);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: background 0.15s;
}

#hna-char-tab.hna-char-tab-visible { display: flex; }
@media (hover: hover) and (pointer: fine) {
  #hna-char-tab:hover { background: #5a3db8; }
}

/* ── U7 per-chip guide "?" buttons ──────────────────────────────────── */

.ch-chip-grp {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.ch-chip-guide,
.ch-tile-guide {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(107, 77, 212, 0.12);
  color: #6b4dd4;
  border: 1.5px solid #6b4dd4;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.ch-chip-guide:hover,
.ch-tile-guide:hover { background: rgba(107, 77, 212, 0.25); }

.ch-simple-tile-grp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ch-u7-card-grp {
  position: relative;
}
.ch-u7-card-grp .ch-tile-guide {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
}
.u7-read-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 1;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 50%;
  opacity: 0.75;
  transition: opacity 0.15s, background 0.15s;
}
.u7-read-btn:hover { opacity: 1; background: rgba(0, 0, 0, 0.13); }

/* ── Feedback button ───────────────────────────────────────────────── */
#hna-feedback-btn {
  position: fixed;
  /* Float 8 px above whatever's docked at the bottom (nav alone, or nav +
     install bar). --ux-nav-clearance updates automatically when the install
     bar mounts, so this position tracks both. */
  bottom: calc(var(--ux-nav-clearance, 80px) + 8px);
  right: 14px;
  /* Above the bottom nav (z=900) so it can't be clipped, but below the
     install bar (z=9998) so the bar's dismiss/install actions take priority. */
  z-index: 950;
  display: none;        /* shown via FeedbackWidget.setVisible(true) */
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #6b4dd4;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
#hna-feedback-btn:not(.hna-hidden) { display: flex; }
/* Tiny phones (iPhone SE-class, ≤360 px wide) — shrink + tuck right so it
   doesn't fight CTA buttons that span most of the column width. */
@media (max-width: 360px) {
  #hna-feedback-btn {
    width: 34px;
    height: 34px;
    right: 8px;
    font-size: 1.05rem;
  }
}
@media (hover: hover) and (pointer: fine) {
  #hna-feedback-btn:hover          { background: #5a3db8; }
}

/* ── Feedback modal ─────────────────────────────────────────────────── */
.hna-feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.hna-feedback-modal.hna-hidden { display: none; }

.hna-feedback-card {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 540px;
  padding: 20px 20px 32px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
}

.hna-feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.hna-feedback-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a1a2e;
}
#hna-feedback-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 2px 6px;
}

.hna-feedback-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin: 12px 0 5px;
}
.hna-feedback-select,
.hna-feedback-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #222;
  background: #fafafa;
  resize: vertical;
}
.hna-feedback-select:focus,
.hna-feedback-textarea:focus { outline: none; border-color: #6b4dd4; }

.hna-feedback-err {
  color: #c0392b;
  font-size: 0.82rem;
  margin: 8px 0 0;
}
.hna-feedback-err.hna-hidden { display: none; }

.hna-feedback-footer {
  margin-top: 16px;
  text-align: right;
}
.hna-feedback-submit {
  background: #6b4dd4;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.hna-feedback-submit:disabled { opacity: 0.6; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .hna-feedback-submit:not(:disabled):hover { background: #5a3db8; }
}

.hna-feedback-thanks {
  text-align: center;
  padding: 16px 0 8px;
  color: #27ae60;
  font-weight: 600;
}
.hna-feedback-thanks.hna-hidden { display: none; }
.hna-feedback-thanks button {
  margin-top: 12px;
  background: #6b4dd4;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 22px;
  font-size: 0.9rem;
  cursor: pointer;
}

/* ── Assistant widget clearance ────────────────────────────────────────
   When the widget is visible, JS sets --hna-assistant-clearance on :root
   to the measured widget height + 8px buffer. Screens reserve that extra
   padding-bottom so the last card is never hidden behind the widget.
   The widget sits at bottom:84px (above the nav), so this is additive to
   the existing --ux-nav-clearance without doubling it. Cleared when hidden. */
.screen { padding-bottom: calc(var(--ux-nav-clearance, 0px) + var(--hna-assistant-clearance, 0px)); }
