/* ==========================================================================
   nihonvisa floating chat widget
   ========================================================================== */

.nv-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  font-family: var(--nv-sans);
  color: var(--nv-ink);
}

/* ---------- Launcher ---------- */
.nv-chat__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--nv-ink);
  color: var(--nv-bg);
  font: 600 14px/1 var(--nv-sans);
  letter-spacing: .01em;
  box-shadow: var(--nv-shadow);
  cursor: pointer;
  transition: transform .18s, background .18s;
}
.nv-chat__launcher:hover { background: #1c150f; transform: translateY(-1px); }
.nv-chat__launcher:focus-visible { outline: 2px solid var(--nv-coral); outline-offset: 3px; }
.nv-chat__launcher .nv-chat__icon--open { color: var(--nv-coral); }
.nv-chat__icon--close { display: none; }

.nv-chat.is-open .nv-chat__launcher { padding: 0; width: 52px; justify-content: center; }
.nv-chat.is-open .nv-chat__launcher-label,
.nv-chat.is-open .nv-chat__icon--open { display: none; }
.nv-chat.is-open .nv-chat__icon--close { display: block; }

/* ---------- Panel ---------- */
.nv-chat__panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 360px;
  max-height: min(560px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--nv-paper);
  border: 1px solid var(--nv-line);
  border-radius: 16px;
  box-shadow: var(--nv-shadow);
  overflow: hidden;
  animation: nv-chat-in .2s ease-out;
}
.nv-chat__panel[hidden] { display: none; }

@keyframes nv-chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.nv-chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  background: var(--nv-ink);
  color: var(--nv-bg);
}
.nv-chat__title {
  font: 500 19px/1.2 var(--nv-serif);
}
.nv-chat__sub {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.4;
  color: rgba(251, 247, 239, .72);
}
.nv-chat__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--nv-bg);
  cursor: pointer;
}
.nv-chat__close:hover { background: rgba(251, 247, 239, .1); }

.nv-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--nv-bg);
}

/* ---------- Bubbles ---------- */
.nv-chat__bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.nv-chat__bubble[hidden] { display: none; }
.nv-chat__bubble--in {
  align-self: flex-start;
  background: var(--nv-paper);
  border: 1px solid var(--nv-line);
  border-bottom-left-radius: 4px;
}
.nv-chat__bubble--out {
  align-self: flex-end;
  background: var(--nv-coral);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ---------- Topic chips ---------- */
.nv-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.nv-chat__chips[hidden] { display: none; }
.nv-chat__chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  border: 1px solid var(--nv-coral);
  border-radius: 999px;
  background: transparent;
  color: var(--nv-coral-deep);
  font: 500 13px/1.2 var(--nv-sans);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nv-chat__chip:hover { background: var(--nv-coral); color: #fff; }
.nv-chat__chip:focus-visible { outline: 2px solid var(--nv-ink); outline-offset: 2px; }
.nv-chat__chip--link { border-color: var(--nv-line-2); color: var(--nv-ink-2); }
.nv-chat__chip--link:hover { background: var(--nv-ink); border-color: var(--nv-ink); color: var(--nv-bg); }

/* ---------- Form ---------- */
.nv-chat__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nv-chat__form[hidden] { display: none; }
.nv-chat__form textarea,
.nv-chat__form input[type="text"],
.nv-chat__form input[type="email"] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--nv-line-2);
  border-radius: 10px;
  background: var(--nv-paper);
  color: var(--nv-ink);
  font: 400 16px/1.4 var(--nv-sans); /* 16px stops iOS zoom on focus */
  resize: vertical;
}
.nv-chat__form textarea { min-height: 88px; }
.nv-chat__form textarea:focus,
.nv-chat__form input:focus {
  outline: none;
  border-color: var(--nv-coral);
  box-shadow: 0 0 0 3px var(--nv-coral-soft);
}
.nv-chat__send {
  align-self: flex-end;
  height: 42px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--nv-coral);
  color: #fff;
  font: 600 14px/1 var(--nv-sans);
  cursor: pointer;
  transition: background .15s;
}
.nv-chat__send:hover { background: var(--nv-coral-deep); }
.nv-chat__send:disabled { opacity: .6; cursor: progress; }

.nv-chat__error {
  margin: 0;
  font-size: 13px;
  color: var(--nv-coral-deep);
}
.nv-chat__error[hidden] { display: none; }

.nv-chat__fine {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--nv-ink-dim);
}
.nv-chat__fine a { color: inherit; }

.nv-chat__sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.nv-chat__hp {
  position: absolute !important;
  left: -9999px;
  width: 1px; height: 1px;
  overflow: hidden;
}

/* Japanese text reads better in the serif for the header title */
html.is-ja .nv-chat__title { font-family: var(--nv-jp); font-size: 17px; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .nv-chat { right: 14px; bottom: 14px; }
  .nv-chat__launcher { height: 48px; padding: 0 16px 0 13px; font-size: 13px; }
  .nv-chat.is-open .nv-chat__launcher { width: 48px; }
  .nv-chat__panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 72px;
    width: auto;
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nv-chat__panel { animation: none; }
  .nv-chat__launcher { transition: none; }
}

@media print {
  .nv-chat { display: none; }
}

/* ---------- Eligibility check in chat (v1.9.0) ---------- */
.nv-chat__thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nv-chat__thread:empty { display: none; }

.nv-chat__chip--primary {
  background: var(--nv-coral);
  border-color: var(--nv-coral);
  color: #fff;
}
.nv-chat__chip--primary:hover { background: var(--nv-coral-deep); border-color: var(--nv-coral-deep); }

.nv-chat__qnum {
  display: block;
  margin-bottom: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--nv-ink-dim);
}

.nv-chat__bubble--result {
  max-width: 100%;
  border-color: var(--nv-coral);
  border-left-width: 3px;
}
.nv-chat__verdict-label,
.nv-chat__gaps-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--nv-ink-dim);
}
.nv-chat__gaps-label { margin-top: 10px; }
.nv-chat__verdict {
  display: block;
  margin: 2px 0 6px;
  font: 500 21px/1.2 var(--nv-serif);
  color: var(--nv-coral-deep);
}
html.is-ja .nv-chat__verdict { font-family: var(--nv-jp); font-size: 18px; }
.nv-chat__advice { display: block; }
.nv-chat__gaps {
  margin: 4px 0 0;
  padding-left: 18px;
}
.nv-chat__gaps li { margin: 2px 0; }

.nv-chat__bubble--note {
  font-size: 12.5px;
  color: var(--nv-ink-2);
  background: transparent;
  border-style: dashed;
}
