/* ================================================================
   app.css — GOIGOI Call AI Mock RevA0.1
   Palette from color-sample.jpg (Orange Pattern):
     Primary  #FF7F50 (Coral)   Accent   #1ABC9C (Teal)
     Warn     #FDCB6E (Yellow)  Danger   #E74C3C (Red)
     Dark     #34495E (Navy)    LightBG  #ECF0F1 (Grey)
   ================================================================ */

/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  /* Common site font foundation: Plus Jakarta Sans first fixes Vietnamese
     tone-mark alignment (e.g. "sạch"); CJK falls through to local fonts.
     Old system stack kept as the CSS-var fallback if fonts.css is absent. */
  font-family: var(--gg-font-ui-base, "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", sans-serif);
  background: #ECF0F1;
  color: #34495E;
  /* Definite viewport height so the flex chain (main -> screen -> chat-container
     -> chat-messages) is bounded and the chat list scrolls internally instead of
     growing the window and pushing the input/last reply off-screen. */
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body:lang(ja) {
  font-family: var(--gg-font-ui-ja, "Plus Jakarta Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Segoe UI", sans-serif);
}

body:lang(ko) {
  font-family: var(--gg-font-ui-ko, "Plus Jakarta Sans", "Pretendard", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif);
}

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  background: #fff;
  color: #34495E;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 10px rgba(0, 0, 0, .05);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid #FF7F50;
}

.header-title {
  font-size: 1.4rem;
  font-weight: 800;
  text-decoration: none;
  color: inherit;
  display: block;
}

.brand-accent {
  color: #FF7F50;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 14px;
  background: #f6f8f9;
  border: 1px solid #e3eaed;
}

.header-lang-label {
  font-size: .72rem;
  font-weight: 800;
  color: #6b7b88;
  letter-spacing: .04em;
}

.header-lang-select {
  border: none;
  background: transparent;
  color: #34495E;
  font-size: .82rem;
  font-weight: 700;
  outline: none;
  cursor: pointer;
}

/* Badges */
.badge {
  font-size: .65rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.badge-tier-free {
  background: #dfe6e9;
  color: #636e72;
}

.badge-tier-sub {
  background: #FF7F50;
  color: #fff;
}

.badge-tier-blocked {
  background: #2d3436;
  color: #fff;
}

.badge-quota {
  background: #34495E;
  color: #fff;
}

.badge-quota.low {
  background: #FDCB6E;
  color: #34495E;
}

.badge-quota.out {
  background: #E74C3C;
  color: #fff;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
  font-weight: 600;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.u-email {
  font-size: .72rem;
  color: #7f8c8d;
}

.badge-auth {
  background: #eef2f3;
  color: #34495E;
}

.badge-plan-source {
  background: #ffe8cf;
  color: #a85c32;
}

.badge-source-api {
  background: #1ABC9C;
  color: #fff;
}

.badge-source-stub {
  background: #34495E;
  color: #fff;
}

.badge-key-active {
  background: #fff4d7;
  color: #8a5b00;
}

.badge-key-saved {
  background: #e8f6f2;
  color: #12715d;
}

.btn-logout {
  background: #E74C3C;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-size: .75rem;
}

/* ── Screens ── */
.screen {
  display: none;
  flex: 1;
  padding: 20px;
}

.screen.active {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
}

/* Non-chat screens scroll internally now that body is a definite height; the
   chat screen keeps overflow:hidden and delegates scrolling to .chat-messages. */
.screen.active:not(.screen-chat) {
  overflow-y: auto;
}

.screen-home {
  /* "safe center" so it centers when it fits but falls back to flex-start when
     the content is taller than the viewport — otherwise the centered top (the
     character selection) is pushed off-screen and unreachable by scroll. */
  justify-content: safe center;
}

.home-shell {
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 420px);
  gap: 24px;
}

.home-panel {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 16px 42px rgba(52, 73, 94, .08);
}

.home-stage {
  padding: 36px;
}

.home-title {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.1;
  margin-bottom: 12px;
}

.home-subtitle {
  color: #6b7b88;
  line-height: 1.6;
  max-width: 44rem;
  margin-bottom: 24px;
}

.home-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.home-avatar-grid .avatar-card {
  width: 100%;
  min-height: 100%;
  flex: initial;
}

.home-side {
  padding: 28px;
}

.home-feature {
  border: 1px solid #edf1f3;
  background: linear-gradient(180deg, #fffaf5 0%, #ffffff 100%);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.home-feature-emoji {
  font-size: 4.2rem;
}

.home-feature-name {
  font-size: 1.45rem;
  font-weight: 800;
}

.home-feature-meta {
  color: #708090;
  font-size: .92rem;
}

.home-feature-style {
  color: #d25d35;
  font-size: .85rem;
  line-height: 1.5;
  font-weight: 700;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.home-status,
.home-note {
  color: #6b7b88;
  line-height: 1.5;
  font-size: .9rem;
}

.home-status {
  font-weight: 700;
}

.home-mock-panel {
  padding-top: 4px;
}

.home-level-group {
  margin-bottom: 0;
}

/* Secondary profile fields (age/gender/translation) are progressively disclosed
   to reduce first-screen density; everything stays one tap away. */
.home-more {
  border: 1px solid #e3e9ee;
  border-radius: 12px;
  padding: 0 12px;
  background: #fafcfe;
}

.home-more[open] {
  padding-bottom: 12px;
}

.home-more > summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 4px;
  font-size: .92rem;
  font-weight: 700;
  color: #4b5b68;
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-more > summary::-webkit-details-marker {
  display: none;
}

.home-more > summary::before {
  content: "+";
  font-weight: 800;
  color: #FF7F50;
}

.home-more[open] > summary::before {
  content: "\2212";
}

.home-more > summary + * {
  margin-top: 4px;
}

.home-more .form-group + .form-group,
.home-more .toggle-row {
  margin-top: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
  font-weight: 700;
  color: #4b5b68;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: #FF7F50;
}

.btn-home-primary {
  margin-top: 6px;
}

.btn-inline-action {
  width: auto;
  padding: 10px 16px;
}

.btn-apple {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px dashed #cbd5dc;
  background: #f9fbfc;
  color: #34495E;
  font-weight: 800;
  cursor: pointer;
}

.btn-apple:hover {
  border-color: #9caab5;
  background: #ffffff;
}

.btn-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: .7rem;
  color: #d25d35;
}

.btn-ghost {
  background: #fff;
  color: #34495E;
  border: 1px solid #dfe6e9;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: #FF7F50;
  color: #d25d35;
}

/* ── Login Screen ── */
.screen-login {
  justify-content: safe center;
}

.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.hero-mark {
  font-size: 4rem;
  margin-bottom: 20px;
}

.login-subtitle {
  margin: 10px 0 24px;
  color: #7f8c8d;
  line-height: 1.5;
}

.login-note,
.mock-primary {
  margin-top: 14px;
  font-size: .85rem;
  color: #7f8c8d;
  line-height: 1.5;
}

.auth-separator {
  height: 1px;
  background: linear-gradient(90deg, transparent, #dfe6e9, transparent);
  margin: 22px 0;
}

.mock-panel {
  text-align: left;
}

.btn-secondary {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid #FF7F50;
  background: #fffaf0;
  color: #d25d35;
  font-weight: 800;
  cursor: pointer;
}

.btn-google {
  background: #fff;
  border: 2px solid #dfe6e9;
  padding: 14px 24px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  font-size: 1.1rem;
}

.btn-google:hover {
  border-color: #FF7F50;
  background: #fffaf0;
}

.btn-google svg {
  width: 24px;
  height: 24px;
}

.btn-google-inline {
  width: auto;
  padding: 10px 16px;
  font-size: .95rem;
}

.btn-apple-inline {
  width: auto;
}

/* ── Language & Profile Card Style ── */
.card-form {
  background: #fff;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .05);
  width: 100%;
  max-width: 400px;
}

.section-title {
  margin-bottom: 20px;
  text-align: center;
}

.lang-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.lang-btn {
  background: #fff;
  border: 2px solid #eee;
  padding: 20px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 700;
  transition: .2s;
}

.lang-btn:hover {
  border-color: #FF7F50;
  transform: translateY(-2px);
}

.lang-btn .flag {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
  width: 100%;
}

.form-group label {
  display: block;
  font-weight: 700;
  font-size: .85rem;
  margin-bottom: 8px;
  color: #636e72;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #eee;
  border-radius: 12px;
  outline: none;
  font-size: 1rem;
}

.form-group input:focus {
  border-color: #FF7F50;
}

.btn-primary {
  background: #FF7F50;
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 14px;
  width: 100%;
  font-weight: 800;
  cursor: pointer;
  font-size: 1.1rem;
}

/* ── Chat Screen ── */
.screen-chat {
  width: 100%;
  padding: 0;
  align-items: stretch !important;
  overflow: hidden;
  min-height: 0;
}

.key-window-body {
  background: #f8fafb;
}

.screen-key-window {
  display: flex;
  justify-content: center;
  padding: 24px;
}

.key-window-main {
  min-height: 100vh;
}

.key-window-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 16px 42px rgba(52, 73, 94, .08);
  padding: 28px;
}

.key-window-title {
  font-size: 1.9rem;
  margin-bottom: 10px;
}

.key-window-subtitle {
  margin-bottom: 18px;
}

.key-window-status {
  border: 1px solid #edf1f3;
  background: #fffaf5;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
}

.key-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.key-status-item {
  border: 1px solid #edf1f3;
  border-radius: 14px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.key-status-item span {
  font-size: .75rem;
  color: #7f8c8d;
  font-weight: 700;
}

.key-status-item strong {
  font-size: .92rem;
  color: #34495E;
  word-break: break-all;
}

.key-window-flash {
  background: #eef8ff;
  color: #286a94;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: .9rem;
  font-weight: 700;
}

.key-window-inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.byo-guide-box {
  border: 1px solid #dbe8ef;
  background: #f6fbff;
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.byo-guide-step {
  font-size: .92rem;
  line-height: 1.55;
  color: #486170;
  margin-top: 8px;
}

.byo-guide-open-link {
  width: 100%;
  margin-top: 14px;
}

.key-window-toggle {
  margin-bottom: 14px;
}

.key-window-note,
.key-window-close-hint {
  margin-top: 10px;
}

.key-window-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 250;
}

.modal-layer.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(52, 73, 94, .46);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  max-height: min(92vh, 860px);
  overflow: auto;
}

.modal-key-card {
  box-shadow: 0 20px 60px rgba(27, 39, 49, .18);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #34495E;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(52, 73, 94, .12);
}

.modal-close:hover {
  background: #fff;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  width: 100%;
  background: #f8fafb;
}

.chat-topmeta {
  font-size: .85rem;
  font-weight: 700;
  color: #6b7b88;
}

.chat-auth-strip {
  margin: 14px 20px 0;
  padding: 16px 18px;
  border-radius: 20px;
  background: #fff7f2;
  border: 1px solid #ffe0d1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chat-auth-copy {
  min-width: 0;
}

.chat-auth-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.chat-auth-note {
  color: #6b7b88;
  line-height: 1.5;
  font-size: .9rem;
}

.chat-auth-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Large Avatar Cards */
.avatar-selector {
  display: flex;
  gap: 15px;
  padding: 20px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.avatar-card {
  flex: 0 0 160px;
  background: #fff;
  border: 2px solid #eee;
  border-radius: 20px;
  padding: 20px 15px;
  text-align: center;
  cursor: pointer;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.avatar-card:hover {
  border-color: #FF7F50;
  transform: translateY(-4px);
}

.avatar-card.active {
  border-color: #FF7F50;
  background: #fffaf0;
  box-shadow: 0 8px 24px rgba(255, 127, 80, .15);
}

.avatar-card .avatar-emoji {
  font-size: 3rem;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .1));
}

.avatar-card .avatar-name {
  font-weight: 800;
  font-size: 1.1rem;
  color: #34495E;
}

.avatar-card .avatar-meta {
  font-size: .7rem;
  color: #7f8c8d;
  line-height: 1.3;
}

.avatar-style {
  font-size: .68rem;
  color: #d25d35;
  line-height: 1.4;
  font-weight: 700;
}

/* Chat Area */
.chat-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f8fafb;
}

/* The whole area above the input scrolls as one (chrome + messages); the input
   stays pinned. This keeps the input and the latest reply visible regardless of
   how tall the auth strip / avatar row get on small screens. */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  padding: 20px 25px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.input-area {
  flex-shrink: 0;
}

/* ── Compact global header (tier 1 nav) ── */
.header {
  padding: 8px 14px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.lang-globe {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border-radius: 12px;
  background: #f6f8f9;
  cursor: pointer;
}

.lang-globe-icon {
  font-size: .95rem;
  line-height: 1;
  pointer-events: none;
}

.lang-globe-code {
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .03em;
  color: #34495E;
  pointer-events: none;
}

.lang-globe select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  cursor: pointer;
}

.header-acct {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: #f6f8f9;
  cursor: pointer;
  line-height: 1;
}

.header-acct-icon {
  font-size: 1rem;
}

.header-acct-src {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .03em;
  color: #6b7b88;
}

.header-acct-quota {
  font-size: .82rem;
  font-weight: 800;
  color: #34495E;
}

.header-acct-quota.low {
  color: #e67e22;
}

.header-acct-quota.out {
  color: #e74c3c;
}

/* Shared AI runtime status strip is debug-only on call (its info now lives in
   the top-bar key/quota chip and the account sheet). Toggle with ?debug=1.
   !important because /components/ai/css/feature_runtime.css loads after app.css. */
.gg-ai-runtime-strip {
  display: none !important;
}

body.ai-debug .gg-ai-runtime-strip {
  display: block !important;
}

/* ── Account / settings sheet ── */
#sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
}

#sheet-layer.active {
  display: block;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(52, 73, 94, .46);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .18);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sheet-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: #7f8c8d;
}

.sheet-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.sheet-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
  color: #34495E;
  padding: 8px 12px;
  background: #f6f8f9;
  border-radius: 10px;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sheet-note {
  font-size: .85rem;
  color: #6b7b88;
}

/* ── Chat status bar (tier 2) ── */
.chat-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #eef2f3;
  overflow-x: auto;
  white-space: nowrap;
}

.chat-status-back {
  flex-shrink: 0;
  border: none;
  background: #f6f8f9;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

.chat-status-persona {
  font-weight: 800;
  color: #34495E;
  flex-shrink: 0;
}

.chat-status-chip {
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 700;
  color: #6b7b88;
  background: #f1f5f6;
  padding: 4px 10px;
  border-radius: 999px;
}

.chat-status-chip.key {
  color: #d25d35;
  background: #fff1ea;
}

/* Bubbles */
.msg {
  max-width: 85%;
}

.msg-user {
  align-self: flex-end;
}

.msg-bot {
  align-self: flex-start;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 1rem;
  line-height: 1.5;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .03);
}

.msg-user .msg-bubble {
  background: #1ABC9C;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bot .msg-bubble {
  background: #fff;
  color: #34495E;
  border: 1px solid #eef2f3;
  border-bottom-left-radius: 4px;
}

.msg-sender {
  font-size: .75rem;
  font-weight: 800;
  margin-bottom: 5px;
  opacity: .8;
}

.msg-user .msg-sender {
  text-align: right;
  color: #1ABC9C;
}

.msg-bot .msg-sender {
  color: #FF7F50;
}

/* Details */
.msg-details {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
}

.msg-details summary {
  font-size: .8rem;
  font-weight: 700;
  color: #FF7F50;
  cursor: pointer;
  padding: 5px 0;
  outline: none;
}

.detail-content {
  background: #fffaf0;
  border-left: 4px solid #FF7F50;
  padding: 12px;
  font-size: .85rem;
  border-radius: 0 8px 8px 0;
}

.detail-label {
  font-weight: 800;
  text-transform: uppercase;
  font-size: .65rem;
  color: #ff9f7d;
  margin-bottom: 4px;
}

.detail-text {
  margin-bottom: 10px;
  line-height: 1.5;
}

.detail-text:last-child {
  margin-bottom: 0;
}

.msg-qc {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .65rem;
  letter-spacing: .05em;
  background: #eef2f3;
  color: #636e72;
}

.msg-qc-warn {
  background: #FDCB6E;
  color: #34495E;
}

.msg-qc-fail {
  background: #E74C3C;
  color: #fff;
}

/* Typing */
.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  background: #fff;
  border-radius: 20px;
  width: fit-content;
  border: 1px solid #eee;
}

.typing-avatar {
  flex: none;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  background: #FF7F50;
  border-radius: 50%;
  animation: bounce .6s infinite alternate;
}

.dot:nth-child(2) {
  animation-delay: .2s;
}

.dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes bounce {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-6px);
  }
}

/* Input Bar */
.input-area {
  position: relative;
  background: #fff;
  border: 1.5px solid #e7ddcc;
  border-radius: 18px;
  margin: 30px 8px 8px;
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.chat-input {
  flex: 1;
  padding: 14px 20px;
  border-radius: 30px;
  border: 2px solid #eee;
  outline: none;
  font-size: 1rem;
  transition: .2s;
}

.chat-input:focus {
  border-color: #FF7F50;
}

.chat-input:disabled {
  background: #f5f6f7;
  cursor: not-allowed;
}

.btn-send {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #FF7F50;
  color: #fff;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .2s;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.1) rotate(-10deg);
  box-shadow: 0 4px 15px rgba(255, 127, 80, .4);
}

.btn-send:disabled {
  background: #bdc3c7;
  cursor: not-allowed;
}

/* Quota Warning */
.quota-msg {
  font-size: .75rem;
  font-weight: 700;
  color: #E74C3C;
  text-align: center;
  width: 100%;
  display: none;
}

.quota-out .quota-msg {
  display: block;
}

@media (max-width: 720px) {
  .header {
    align-items: flex-start;
    gap: 12px;
  }

  .home-shell {
    grid-template-columns: 1fr;
  }

  .home-stage,
  .home-side {
    padding: 24px;
  }

  .home-avatar-grid {
    grid-template-columns: 1fr;
  }

  .chat-topbar {
    padding: 14px 14px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chat-auth-strip {
    margin: 12px 14px 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-auth-actions {
    width: 100%;
    justify-content: stretch;
  }

  .btn-google-inline,
  .btn-apple-inline,
  .btn-inline-action {
    width: 100%;
    justify-content: center;
  }

  .header-right,
  .user-info {
    justify-content: flex-start;
  }

  .header-lang-picker {
    width: 100%;
    justify-content: center;
  }

  .screen {
    padding: 14px;
  }

  .login-card,
  .card-form {
    padding: 24px;
  }

  .avatar-card {
    flex-basis: 140px;
    padding: 18px 12px;
  }

  .chat-messages {
    padding: 18px 14px;
  }

  .input-area {
    margin: 30px 6px 6px;
    padding: 10px 8px 8px;
  }

  .key-status-grid {
    grid-template-columns: 1fr;
  }

  .modal-layer {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-panel {
    width: 100%;
    max-height: 88vh;
  }

  .modal-key-card {
    border-radius: 24px 24px 18px 18px;
  }
}

/* ================================================================
   v5 additions — omakase hero, avatar visuals, relation chips,
   scene chips, pronoun HUD, coach strip, quick replies, recap
   ================================================================ */

/* ── Omakase hero ── */
.home-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.btn-omakase {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 14px auto 8px;
  padding: 16px 24px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #FF7F50, #FF9F6E);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(255, 127, 80, .35);
  transition: transform .12s ease, box-shadow .12s ease;
}

.btn-omakase:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(255, 127, 80, .45);
}

.home-omakase-note {
  font-size: .82rem;
  color: #7F8C8D;
}

.home-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  color: #95A5A6;
  font-size: .82rem;
  font-weight: 700;
}

.home-divider::before,
.home-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #D8DEE0;
}

/* ── Avatar visuals ── */
.avatar-visual {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  font-size: 2rem;
  vertical-align: middle;
}

.avatar-visual-lg {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  font-size: 3rem;
}

.avatar-visual-sm {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 1.2rem;
}

.avatar-visual-xs {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: .95rem;
}

.avatar-card .avatar-visual {
  margin-bottom: 6px;
}

/* ── Relation chip ── */
.relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #EAF7F4;
  border: 1px solid #BFE8DF;
  color: #148F76;
  font-size: .74rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.relation-k {
  font-weight: 500;
  color: #52A493;
}

.relation-arrow {
  color: #91C9BD;
}

.avatar-card .relation-chip {
  margin-top: 6px;
  font-size: .68rem;
}

.home-feature-relation {
  margin: 8px 0 4px;
}

/* ── Scene chips ── */
.scene-chips-label {
  margin-top: 12px;
  font-size: .78rem;
  font-weight: 700;
  color: #7F8C8D;
  text-align: left;
}

.scene-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.scene-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid #D8DEE0;
  background: #fff;
  color: #34495E;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}

.scene-chip:hover {
  border-color: #FF9F6E;
}

.scene-chip.active {
  border-color: #FF7F50;
  background: #FFF1EA;
  color: #D35F33;
}

.chat-scene-chip {
  cursor: pointer;
}

/* ── Pronoun HUD ── */
.pronoun-hud {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #F6FBFA;
  border-bottom: 1px solid #E2EFEB;
  overflow: hidden;
}

.pronoun-hud.active {
  display: flex;
}

.hud-note {
  font-size: .72rem;
  color: #7F8C8D;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ── Coach strip ── */
.coach-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 2px 0 8px;
  padding: 8px 12px;
  background: #FFF8E9;
  border: 1px solid #F4E3B8;
  border-left: 4px solid #FDCB6E;
  border-radius: 10px;
  max-width: 92%;
}

.coach-label {
  font-size: .72rem;
  font-weight: 800;
  color: #B8860B;
  letter-spacing: .02em;
}

.coach-suggested {
  border: 1px dashed #E0B84C;
  background: #fff;
  color: #34495E;
  font-size: .92rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.coach-suggested:hover {
  background: #FFF3D6;
}

.coach-explain {
  flex-basis: 100%;
  font-size: .8rem;
  color: #6B5B2E;
  line-height: 1.45;
}

/* ── Bot bubble translation subline ── */
.msg-translation {
  font-size: .78rem;
  color: #95A5A6;
  margin: 4px 2px 0;
  max-width: 88%;
}

/* ── Quick replies ── */
.quick-replies {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
}

.quick-replies.active {
  display: flex;
}

.qr-label {
  font-size: .72rem;
  color: #95A5A6;
  font-weight: 600;
}

.qr-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid #A7DED2;
  background: #F2FBF8;
  color: #117A63;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease;
}

.qr-chip:hover {
  background: #DFF4EC;
}

/* ── Recap sheet ── */
.recap-panel {
  max-height: 82vh;
  overflow-y: auto;
}

.recap-empty {
  padding: 18px 4px;
  color: #7F8C8D;
  font-size: .9rem;
}

.recap-section {
  margin: 14px 0;
}

.recap-section-title {
  font-size: .8rem;
  font-weight: 800;
  color: #7F8C8D;
  margin-bottom: 8px;
}

.recap-correction {
  padding: 8px 10px;
  border-radius: 10px;
  background: #F8F9FA;
  border: 1px solid #E8ECED;
  margin-bottom: 8px;
}

.recap-before {
  color: #95A5A6;
  font-size: .85rem;
  text-decoration: line-through;
  text-decoration-color: rgba(231, 76, 60, .5);
}

.recap-after {
  color: #148F76;
  font-weight: 700;
  font-size: .95rem;
  margin-top: 2px;
}

.recap-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recap-word {
  padding: 6px 12px;
  border-radius: 999px;
  background: #F0F3F4;
  border: 1px solid #DDE3E5;
  color: #566573;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
}

.recap-word.linked {
  background: #EAF7F4;
  border-color: #9BD9CA;
  color: #0E7A62;
}

.recap-word.linked:hover {
  background: #DCF2EC;
}

.recap-note {
  margin-top: 8px;
  font-size: .74rem;
  color: #95A5A6;
}

/* ── Chat status: keep chips on one row on small screens ── */
.chat-recap-btn {
  margin-left: auto;
  cursor: pointer;
}

@media (max-width: 720px) {
  .btn-omakase {
    font-size: 1.05rem;
    padding: 14px 18px;
  }

  .coach-strip {
    max-width: 100%;
  }

  .hud-note {
    display: none;
  }
}
