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

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

body {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  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 fullscreen layout
------------------------------------------------------- */
.main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  height: calc(100vh - 64px);
}

/* Stage wrapper — fullscreen background layer */
.stage-wrapper {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, #1a1030 0%, #0f0f23 70%);
  overflow: hidden;
}

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

/* -------------------------------------------------------
   Loading overlay
------------------------------------------------------- */
.loading-overlay {
  position: absolute;
  inset: 0;
  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;
  inset: 0;
  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;
}

/* -------------------------------------------------------
   Stage status indicator (top-right 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);
  backdrop-filter: blur(6px);
}

/* -------------------------------------------------------
   Expression controls — floating panel (top-left overlay)
------------------------------------------------------- */
.controls-toggle {
  position: fixed;
  bottom: 170px;
  right: 8px;
  z-index: 25;
}

.controls-toggle-btn {
  background: rgba(26, 29, 39, 0.5);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.controls-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.controls {
  position: fixed;
  bottom: 200px;
  left: 8px;
  right: 8px;
  z-index: 25;
  background: rgba(26, 29, 39, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  backdrop-filter: blur(12px);
  display: none;
}

.controls.open {
  display: block;
}

.controls-title {
  display: none;
}

.controls-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.controls-row::-webkit-scrollbar { display: none; }

.ctrl-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 11px;
  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 inside controls panel */
.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 {
  position: absolute;
  bottom: 80px;
  left: 20px;
  right: 20px;
  z-index: 15;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 10px 20px;
  background: rgba(15, 17, 23, 0.8);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  word-break: break-all;
  pointer-events: none;
}

#subtitle.empty {
  display: none;
}

#subtitle.thinking { color: var(--accent-light); }
#subtitle.ai       { color: var(--text); }
#subtitle.user     { color: var(--text-muted); font-style: italic; }
#subtitle.system   { color: var(--text-dim); font-style: italic; }

/* -------------------------------------------------------
   Responsive
------------------------------------------------------- */
@media (max-width: 640px) {
  .header { padding: 0 12px; height: 56px; }
  .header-subtitle { display: none; }
  .nav-link { padding: 4px 8px; font-size: 11px; }
  body { height: 100dvh; overflow: hidden; }
  .main { height: calc(100dvh - 56px); }
}

@media (max-width: 600px) {
  body { height: 100dvh; overflow: hidden; }
  .header { padding: 0 8px; height: 48px; }
  .header-subtitle { display: none; }
  .header-icon { width: 28px; height: 28px; font-size: 14px; }
  .header-title { font-size: 15px; }
  .header-right { gap: 2px; }
  .nav-link { padding: 4px 6px; font-size: 11px; }
  .main { height: calc(100dvh - 48px); }

  .controls {
    left: 8px;
    right: 8px;
  }

  #subtitle {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    font-size: 14px;
    padding: 8px 14px;
    min-height: 40px;
    z-index: 190;
  }
}
