/* avatar.css — Live2Dアバター固有スタイル（共通スタイルはcommon.cssを参照） */

html {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* avatar.cssのheader-rightのgapは固有で16px */
.header-right {
  gap: 16px;
}

/* avatar.cssのnav-linkはpadding 6px 10px・font-size 13px（共通と差異あり） */
.nav-link {
  padding: 6px 10px;
  font-size: 13px;
}

.nav-link.active {
  background: rgba(124, 58, 237, 0.15);
  border: none;
}

/* Main layout */
.main {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Stage container */
.stage-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  background: radial-gradient(ellipse at center, #1a1030 0%, #0f0f23 70%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(124, 58, 237, 0.1);
}

.stage-wrapper::before {
  content: '';
  display: block;
  padding-top: 75%;
}

@media (max-width: 600px) {
  .stage-wrapper::before {
    padding-top: 60%;
  }
}

#live2d-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none !important;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, #1a1030 0%, #0f0f23 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 10;
  transition: opacity 0.6s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  color: var(--text-muted);
  font-size: 14px;
}

.loading-progress {
  width: 200px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  width: 0%;
  transition: width 0.3s ease;
  animation: loading-anim 2s ease-in-out infinite;
}

@keyframes loading-anim {
  0% { width: 10%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 10%; margin-left: 90%; }
}

/* Error overlay */
.error-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, #1a1030 0%, #0f0f23 70%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
  padding: 40px;
  text-align: center;
}

.error-overlay.visible {
  display: flex;
}

.error-icon {
  font-size: 48px;
  opacity: 0.6;
}

.error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.error-msg {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 400px;
}

.error-detail {
  font-size: 11px;
  color: var(--text-dim);
  font-family: monospace;
  background: var(--card2);
  padding: 8px 12px;
  border-radius: 6px;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Controls panel */
.controls {
  width: 100%;
  max-width: 800px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.controls-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ctrl-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(124, 58, 237, 0.1);
}

.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-color: transparent;
  color: #fff;
}

.ctrl-btn.primary:hover {
  box-shadow: 0 0 12px var(--accent-glow);
}

.ctrl-label {
  font-size: 12px;
  color: var(--text-dim);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: pulse-dot 2s infinite;
}

.status-dot.loading {
  background: var(--yellow);
  box-shadow: 0 0 6px var(--yellow);
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* -------------------------------------------------------
   Subtitle overlay (字幕エリア)
------------------------------------------------------- */
.subtitle-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}

.subtitle-bubble {
  max-width: 85%;
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  animation: fadeInUp 0.25s ease;
}

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

.subtitle-bubble.user {
  align-self: flex-end;
  background: rgba(30, 30, 50, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: right;
}

.subtitle-bubble.ai {
  align-self: flex-start;
  background: rgba(124, 58, 237, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #fff;
}

.subtitle-bubble.interim {
  opacity: 0.6;
  font-style: italic;
}

/* -------------------------------------------------------
   Mic button (固定フッター)
------------------------------------------------------- */
.mic-bar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 10px;
  width: 100%;
  max-width: 800px;
}

.mic-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  box-shadow: 0 4px 24px rgba(124, 58, 237, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mic-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 32px rgba(124, 58, 237, 0.65);
}

.mic-btn:active {
  transform: scale(0.95);
}

.mic-btn.recording {
  background: linear-gradient(135deg, var(--red), #ff6b6b);
  box-shadow: 0 4px 24px rgba(239, 68, 68, 0.6);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.mic-btn.processing {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  box-shadow: 0 4px 24px rgba(59, 130, 246, 0.5);
  animation: mic-spin 1s linear infinite;
}

.mic-btn.speaking {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 24px rgba(16, 185, 129, 0.5);
  animation: mic-pulse 0.8s ease-in-out infinite;
}

.mic-btn.connected {
  background: linear-gradient(135deg, #059669, #10b981);
  box-shadow: 0 4px 24px rgba(16, 185, 129, 0.5);
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(239, 68, 68, 0.6); }
  50%       { box-shadow: 0 4px 40px rgba(239, 68, 68, 0.9), 0 0 0 10px rgba(239,68,68,0.15); }
}

@keyframes mic-spin {
  to { filter: hue-rotate(360deg); }
}

.mic-status {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  min-width: 80px;
}

.mic-status.recording { color: var(--red); }
.mic-status.processing { color: var(--blue); }
.mic-status.speaking { color: var(--green); }
.mic-status.connected { color: var(--green); }

/* API mode badge */
.gemini-badge {
  position: fixed;
  top: 72px;
  right: 16px;
  background: linear-gradient(135deg, #1565c0, #1976d2);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 300;
  letter-spacing: 0.3px;
  box-shadow: 0 2px 8px rgba(21, 101, 192, 0.4);
  display: none;
}
.gemini-badge.visible { display: block; }

/* No speech API warning */
.no-speech-warn {
  background: rgba(234,179,8,0.15);
  border: 1px solid rgba(234,179,8,0.4);
  color: var(--yellow);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  margin-top: 8px;
}

/* Stage status overlay */
.stage-status {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 17, 23, 0.8);
  padding: 4px 10px;
  border-radius: 12px;
  z-index: 15;
  font-size: 11px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
  .header { padding: 0 12px; }
  .header-subtitle { display: none; }
  .nav-link { padding: 4px 6px; font-size: 11px; }
  .main { padding: 12px 12px 12px; gap: 12px; }
  .controls { padding: 12px 14px; }
  .subtitle-bubble { font-size: 13px; }
}
