/* ============================================
   恋愛人格コード — 和風デザイン v4.0
   日式美学：桜色・墨色・和紙・余白・枯山水
   ============================================ */

:root {
  /* 和風配色 — Japanese palette */
  --bg-deep: #faf7f2;           /* 和紙 warm washi cream */
  --bg-surface: #ffffff;
  --glass: rgba(255,255,255,0.88);
  --glass-hover: rgba(250,247,242,0.95);
  --accent: #c8756d;             /* 桜・紅 — sakura / vermilion */
  --accent-soft: rgba(200,117,109,0.1);
  --accent-glow: rgba(200,117,109,0.18);
  --accent-gold: #b8964a;        /* 金彩 gold/brass detail */
  --text: #38332e;               /* 墨色 sumi ink */
  --text-dim: #6b6560;           /* 淡墨 */
  --text-muted: #9b9590;         /* 薄墨 */
  --border: rgba(160,145,130,0.22);
  --border-active: rgba(200,117,109,0.35);
  --radius: 10px;
  --radius-sm: 5px;

  /* フォント — Type */
  --font-display: 'Noto Serif SC', 'Shippori Mincho', 'Source Han Serif SC', serif;
  --font-body: 'Noto Sans SC', 'Zen Kaku Gothic New', 'Source Han Sans SC', sans-serif;
  --font-accent: 'Noto Serif SC', 'Shippori Mincho', serif;

  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

/* ============================================
   背景 — 和紙テクスチャ + 青海波
   ============================================ */
.bg-ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 25% 25%, rgba(200,150,120,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 75% 65%, rgba(200,117,109,0.03) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 50% 85%, rgba(180,150,80,0.02) 0%, transparent 70%);
}

.bg-ambient::before {
  content: '';
  position: absolute; inset: 0;
  /* 青海波パターン — Seigaiha pattern via SVG */
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c8756d' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='30'/%3E%3Ccircle cx='0' cy='30' r='30'/%3E%3Ccircle cx='60' cy='30' r='30'/%3E%3Ccircle cx='30' cy='0' r='30'/%3E%3Ccircle cx='30' cy='60' r='30'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

/* 桜の花びら — sakura petals (subtle) */
.bg-ambient::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(240,180,180,0.15) 0%, transparent 3%),
    radial-gradient(circle at 72% 35%, rgba(240,180,180,0.1) 0%, transparent 3%),
    radial-gradient(circle at 45% 70%, rgba(240,180,180,0.12) 0%, transparent 3%),
    radial-gradient(circle at 88% 80%, rgba(240,180,180,0.08) 0%, transparent 3%),
    radial-gradient(circle at 30% 90%, rgba(240,180,180,0.1) 0%, transparent 3%);
  animation: petalDrift 12s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes petalDrift {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 0.7; transform: translateY(-8px); }
}

/* ---- Progress ---- */
.progress-wrap {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 3px; background: rgba(200,117,109,0.06);
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), #e0a09a);
  width: 0%; transition: width 0.5s var(--ease-out);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ---- App Shell ---- */
#app {
  position: relative; z-index: 1;
  max-width: 880px; margin: 0 auto;
  padding: 0 28px; min-height: 100dvh;
  display: flex; flex-direction: column;
}

.screen { display: none; flex: 1; animation: screenIn 0.55s var(--ease-out); }
.screen.active { display: flex; flex-direction: column; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Form Elements ---- */
.nickname-input {
  font-family: var(--font-body);
  font-size: 0.95rem; padding: 13px 18px;
  background: var(--glass); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius); outline: none;
  transition: all 0.35s var(--ease-out);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.nickname-input::placeholder { color: var(--text-muted); }

.nickname-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 20px rgba(200,117,109,0.08);
}

.btn {
  font-family: var(--font-display);
  font-size: 0.9rem; font-weight: 500;
  padding: 12px 26px; border: none;
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.32s var(--ease-out);
  letter-spacing: 0.03em;
  display: inline-flex; align-items: center; gap: 7px;
}

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 14px rgba(200,117,109,0.22);
}

.btn-primary:hover {
  background: #d4847c;
  box-shadow: 0 4px 22px rgba(200,117,109,0.3);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent; color: var(--text-dim);
  border: 1.5px solid var(--border);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.btn-ghost:hover {
  background: var(--glass-hover);
  border-color: var(--border-active);
  color: var(--text);
}
.btn-small { font-size: 0.82rem; padding: 9px 18px; }

/* ---- Question Screen ---- */
#screen-questions { padding: 12vh 0 4vh; }
#screen-questions.active { display: flex; flex-direction: column; }

.question-wrap { flex: 1; display: flex; flex-direction: column; gap: 28px; }

.question-header {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-display);
  font-size: 0.82rem; color: var(--text-muted);
  letter-spacing: 0.08em;
}

.question-counter {
  color: var(--accent); font-weight: 600;
  font-family: var(--font-accent);
}

.question-text {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  font-weight: 500; line-height: 1.6;
  color: var(--text); max-width: 32ch;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px; max-width: 680px;
}

.option-btn {
  font-family: var(--font-body);
  font-size: 0.9rem; line-height: 1.55;
  padding: 16px 18px; text-align: left;
  background: var(--glass); color: var(--text-dim);
  border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: all 0.32s var(--ease-out);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: relative; overflow: hidden;
}

.option-btn::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(200,117,109,0.05) 0%, transparent 60%);
  opacity: 0; transition: opacity 0.32s;
}

.option-btn:hover {
  border-color: var(--border-active); color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.option-btn:hover::before { opacity: 1; }

.option-btn.selected {
  border-color: var(--accent); color: var(--text);
  background: linear-gradient(135deg, rgba(200,117,109,0.12), rgba(200,150,120,0.06));
  transform: scale(1.01);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 0 28px rgba(200,117,109,0.12), 0 6px 20px rgba(0,0,0,0.05);
}

.option-btn.selected::before { opacity: 1; }

.option-label {
  display: inline-block; font-family: var(--font-display);
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
  margin-right: 8px; letter-spacing: 0.05em;
}

.question-fade-enter { animation: qFadeIn 0.45s var(--ease-out); }

@keyframes qFadeIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- Results Screen ---- */
#screen-results { padding: 5vh 0; }
#screen-results.active { display: flex; flex-direction: column; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px; align-items: start;
}

.result-card {
  background: var(--glass);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 0 30px rgba(200,117,109,0.04);
  animation: cardReveal 0.7s var(--ease-out);
  position: relative; overflow: hidden;
}

/* 和紙の飾り — decorative corner */
.result-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  background: linear-gradient(135deg, transparent 50%, rgba(200,117,109,0.04) 50%);
  pointer-events: none;
}

@keyframes cardReveal {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-type-emoji { font-size: 2.8rem; line-height: 1; margin-bottom: 8px; }

.result-type-name {
  font-family: var(--font-accent);
  font-size: 1.7rem; font-weight: 600;
  color: var(--accent); line-height: 1.2; margin-bottom: 6px;
}

.result-code {
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 500;
  color: var(--text-dim); letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.result-type-desc {
  font-size: 0.9rem; color: var(--text-dim);
  line-height: 1.8; margin-bottom: 18px;
}

.result-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }

.result-tag {
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 500;
  padding: 5px 12px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-active);
}

.result-section { margin-bottom: 14px; }

.result-section-title {
  font-family: var(--font-display);
  font-size: 0.83rem; font-weight: 600;
  color: var(--text); margin-bottom: 7px;
  letter-spacing: 0.03em;
}

.result-section-body {
  font-size: 0.86rem; color: var(--text-dim);
  line-height: 1.78;
  padding: 14px 16px;
  background: rgba(200,150,120,0.04);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent);
}

.result-section-body.pain { border-left-color: #c49b8a; }

/* ---- Radar Card ---- */
.radar-card {
  background: var(--glass);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: 0 0 30px rgba(200,117,109,0.04);
}

.radar-title {
  font-family: var(--font-display);
  font-size: 0.88rem; font-weight: 500;
  color: var(--text-dim); letter-spacing: 0.04em;
}

.radar-card canvas { max-width: 100%; height: auto; }

.radar-legend {
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
  font-size: 0.78rem; color: var(--text-dim);
}

.radar-legend span { display: flex; align-items: center; gap: 5px; }

.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot.D { background: #c8756d; }
.legend-dot.S { background: #c49b8a; }
.legend-dot.E { background: #b8964a; }
.legend-dot.O { background: #9b8070; }

.result-actions {
  display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap;
}

/* ---- Toast ---- */
.toast {
  position: fixed; bottom: 36px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,0.92); color: var(--text);
  border: 1px solid var(--border-active);
  padding: 11px 22px; border-radius: var(--radius);
  font-size: 0.88rem; z-index: 200;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
  animation: toastIn 0.4s var(--ease-spring);
  pointer-events: none;
}

.toast.out { animation: toastOut 0.3s ease-in forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

/* ---- Admin ---- */
.admin-trigger { text-align: center; padding: 24px 0 40px; }

.admin-trigger button {
  font-family: var(--font-body);
  font-size: 0.8rem; color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  transition: color 0.3s;
}

.admin-trigger button:hover { color: var(--text-dim); }

.admin-overlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(56,51,46,0.65);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}

.admin-overlay.open { display: flex; }

.admin-panel {
  background: var(--bg-surface); color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 32px; max-width: 860px; width: 92vw; max-height: 82dvh;
  overflow-y: auto; position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.1);
}

.admin-panel h3 {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 600; margin-bottom: 18px;
  color: var(--text);
}

.admin-close {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; color: var(--text-muted);
  font-size: 1.4rem; cursor: pointer; padding: 4px 8px;
}

.admin-close:hover { color: var(--text); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.76rem; }

.admin-table th {
  text-align: left; padding: 10px 8px;
  font-family: var(--font-display); font-weight: 500;
  color: var(--text-dim); border-bottom: 1px solid var(--border);
  font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase;
}

.admin-table td {
  padding: 10px 8px; color: var(--text-dim);
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

.admin-table tr:hover td { color: var(--text); background: rgba(200,150,120,0.04); }

.admin-empty { text-align: center; padding: 40px; color: var(--text-muted); }

.admin-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---- Detail Overlay ---- */
.detail-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(56,51,46,0.5); z-index: 1001;
  display: flex; align-items: center; justify-content: center;
}
.detail-content { max-width: 540px; width: 90%; max-height: 85vh; }
.detail-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.detail-card .admin-close { position: absolute; top: 12px; right: 16px; }

/* ---- Spinner ---- */
.spinner {
  width: 30px; height: 30px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Mode Select ---- */
#screen-psychologist,
#screen-chat,
#screen-gallery { display: none; flex: 1; width: 100%; }
#screen-mode-select { display: flex; flex-direction: column; align-items: center; padding: 10px 0; flex: 1; width: 100%; }
#screen-psychologist.active,
#screen-chat.active,
#screen-gallery.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }
#screen-chat.active { justify-content: flex-start; padding: 0; max-height: calc(100dvh - 80px); }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 520px; }

.mode-card {
  background: var(--glass); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 26px 22px; cursor: pointer;
  transition: all 0.35s var(--ease-out); position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.mode-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 60px; height: 60px;
  background: linear-gradient(135deg, transparent 50%, rgba(200,117,109,0.03) 50%);
  pointer-events: none; transition: opacity 0.35s;
}

.mode-card:hover {
  background: var(--glass-hover); border-color: var(--border-active);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
}

.mode-card:hover::after { opacity: 0.6; }

.mode-icon { font-size: 1.8rem; line-height: 1; }

.mode-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 600;
  color: var(--text);
}

.mode-desc {
  font-size: 0.8rem; color: var(--text-dim);
  line-height: 1.55;
}

/* ---- Psychologist Cards ---- */
.psycho-grid { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 480px; }

.psycho-card {
  background: var(--glass); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; cursor: pointer;
  transition: all 0.32s var(--ease-out);
  display: flex; align-items: center; gap: 14px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.psycho-card:hover {
  background: var(--glass-hover); border-color: var(--border-active);
  transform: translateX(4px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.03);
}

.psycho-avatar { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; border: 2px solid var(--border); flex-shrink: 0; }
.psycho-avatar svg { width: 100%; height: 100%; display: block; }
.psycho-name { font-family: var(--font-display); font-size: 0.93rem; font-weight: 600; color: var(--text); }
.psycho-theory { font-size: 0.7rem; color: var(--text-dim); }
.psycho-desc-text { font-size: 0.73rem; color: var(--text-muted); line-height: 1.45; }

/* ---- Navigation Bar ---- */
.nav-bar { display: flex; align-items: center; gap: 10px; padding: 14px 0; width: 100%; max-width: 600px; }
.nav-back {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 0.83rem;
  font-family: var(--font-body);
}
.nav-back:hover { border-color: var(--border-active); color: var(--text); }
.nav-title { font-family: var(--font-display); font-size: 0.95rem; color: var(--text); display: flex; align-items: center; gap: 8px; }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; }

/* ---- Chat UI ---- */
.chat-container {
  flex: 1; width: 100%; max-width: 600px; overflow-y: auto;
  padding: 12px 0 120px; display: flex; flex-direction: column; gap: 14px;
}

.chat-msg { display: flex; gap: 10px; max-width: 84%; animation: msgIn 0.4s var(--ease-out); }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-msg.ai { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-avatar { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.chat-bubble {
  padding: 11px 16px; border-radius: 16px; font-size: 0.88rem; line-height: 1.68;
  color: var(--text); word-break: break-word;
}
.chat-msg.ai .chat-bubble {
  background: var(--glass); border: 1px solid var(--border);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.02);
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, var(--accent), #da8e87);
  color: #fff; border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(200,117,109,0.2);
}
.chat-actions { display: flex; gap: 5px; margin-top: 4px; }
.chat-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 3px 10px; border-radius: 6px; cursor: pointer; font-size: 0.7rem;
}
.chat-btn:hover { border-color: var(--border-active); color: var(--text); }
.chat-btn.playing { border-color: var(--accent); color: var(--accent); animation: pulseBtn 0.8s infinite; }
@keyframes pulseBtn { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.chat-input-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 600px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg-deep) 40%);
  display: flex; gap: 8px; z-index: 50;
}
.chat-input {
  flex: 1; background: var(--glass); border: 1.5px solid var(--border);
  border-radius: 22px; padding: 11px 18px; color: var(--text);
  font-size: 0.88rem; outline: none; font-family: var(--font-body);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  background: var(--accent); border: none; border-radius: 50%;
  width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; font-size: 1.1rem; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(200,117,109,0.2);
}
.chat-send:hover { background: #d4847c; box-shadow: 0 4px 14px rgba(200,117,109,0.3); }
.chat-send:disabled { opacity: 0.35; cursor: default; filter: none; }

/* ---- Typing Indicator ---- */
.typing-dots { display: flex; gap: 4px; padding: 13px 18px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted); animation: dotBounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---- Gallery ---- */
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; width: 100%; max-width: 900px; padding: 16px 0;
}

.gallery-card {
  background: var(--glass); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer;
  transition: all 0.32s var(--ease-out);
  display: flex; flex-direction: column; gap: 8px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}

.gallery-card:hover {
  background: var(--glass-hover); border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.gallery-card.expanded { grid-column: span 2; }
.gallery-emoji { font-size: 2rem; }
.gallery-name { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }
.gallery-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.gallery-tag {
  font-size: 0.66rem; padding: 3px 8px; border-radius: 5px;
  background: var(--accent-soft); color: var(--accent);
}
.gallery-detail {
  display: none; font-size: 0.8rem; color: var(--text-dim);
  line-height: 1.65; padding-top: 10px; border-top: 1px solid var(--border);
  margin-top: 4px;
}
.gallery-card.expanded .gallery-detail { display: block; }

/* ---- Screen Header ---- */
.screen-header { text-align: center; margin-bottom: 22px; }
.screen-header h2 {
  font-family: var(--font-display); font-size: 1.4rem;
  margin-bottom: 4px; color: var(--text);
}
.screen-header p { color: var(--text-dim); font-size: 0.83rem; }

/* ---- AI Analysis ---- */
.ai-analysis {
  margin-top: 18px; padding: 18px;
  background: var(--glass); border: 1.5px solid var(--border);
  border-radius: var(--radius); display: none;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.ai-analysis.visible { display: block; animation: msgIn 0.5s var(--ease-out); }
.ai-analysis-title { font-family: var(--font-display); font-size: 0.95rem; margin-bottom: 10px; color: var(--accent); }
.ai-analysis-text { font-size: 0.86rem; line-height: 1.75; color: var(--text-dim); }
.ai-loading { text-align: center; padding: 20px; color: var(--text-muted); }
.chat-error { text-align: center; padding: 32px; color: var(--text-muted); }
.chat-error button {
  margin-top: 12px; background: var(--accent); border: none; color: #fff;
  padding: 10px 20px; border-radius: 8px; cursor: pointer;
}

/* ---- Mode Select Hero ---- */
.mode-hero { text-align: center; padding: 0 0 8px; }
.mode-hero-orb {
  font-size: 1.6rem; margin-bottom: 2px;
  animation: orbFloat 3s ease-in-out infinite;
}
.mode-hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  font-weight: 600; line-height: 1.2; color: var(--text);
}
.mode-hero-title span {
  font-family: var(--font-accent);
  font-style: italic; color: var(--accent);
}
.mode-hero-desc { font-size: 0.83rem; color: var(--text-dim); margin-top: 4px; }
.mode-nickname-wrap { display: flex; justify-content: center; margin-top: 8px; }
.mode-nickname-wrap .nickname-input { max-width: 280px; text-align: center; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .options-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; gap: 22px; }
  .result-card { padding: 24px 20px; }
  .result-type-emoji { font-size: 2.2rem; }
  .result-type-name { font-size: 1.3rem; }
  #screen-questions { padding: 8vh 0 3vh; }
  .mode-grid, .psycho-grid { grid-template-columns: 1fr; max-width: 360px; }
  .gallery-grid { grid-template-columns: 1fr; }
  .gallery-card.expanded { grid-column: auto; }
  .chat-input-bar { max-width: 100%; }
}

@media (max-width: 480px) {
  #app { padding: 0 14px; }
  .btn { padding: 11px 18px; font-size: 0.9rem; min-height: 44px; }
  .btn-small { padding: 8px 14px; font-size: 0.78rem; min-height: 36px; }
  .option-btn { padding: 14px 14px; font-size: 0.88rem; }
  .question-text { font-size: 1rem; }
  .nickname-input { font-size: 0.95rem; padding: 11px 14px; }
  .admin-panel { padding: 16px; width: 96vw; border-radius: 12px; }
  .admin-table { font-size: 0.63rem; }
  .admin-table th, .admin-table td { padding: 5px 4px; }
  .result-type-emoji { font-size: 1.8rem; }
  .result-type-name { font-size: 1.15rem; }
  .result-type-desc { font-size: 0.85rem; }
  .result-code { font-size: 0.78rem; }
  .result-actions { flex-direction: column; gap: 8px; }
  .result-actions .btn { width: 100%; }
  .detail-card { padding: 16px; }
  .toast { left: 12px; right: 12px; bottom: 12px; font-size: 0.82rem; }
  .chat-msg { max-width: 90%; }
  .chat-bubble { padding: 10px 14px; font-size: 0.83rem; }
}

/* ============================================
   无障碍 & 交互增强
   ============================================ */
* { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- 悬浮后台入口按钮 ---- */
.admin-trigger-btn {
  position: fixed; bottom: 20px; right: 20px; z-index: 99;
  background: var(--glass); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 10px 18px; font-size: 0.82rem; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-family: var(--font-body);
  transition: color 0.3s, border-color 0.3s, transform 0.3s;
}
.admin-trigger-btn:hover {
  color: #38332e; border-color: rgba(200,117,109,0.4);
  transform: translateY(-1px);
}

/* ---- 高屏下让首页选择区垂直居中 ---- */
@media (min-height: 760px) {
  #screen-mode-select { justify-content: center; }
}

/* ---- 减少动态效果偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
