:root {
  --bg-color: #060606;
  --amber-primary: #ffaa00;
  --amber-bright: #ffd480;
  --amber-glow: rgba(255, 110, 0, 0.6);
  --amber-dark: #3a1500;
  --text-color: #ffffff;
  --text-muted: #8e8e93;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 背景グラデーション (モノクロ) */
.bg-gradient {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #1a1a1a 0%, var(--bg-color) 75%);
  z-index: -1;
}

/* 共通スクリーン */
.screen {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  padding: 20px;
  transition: opacity 0.5s ease, visibility 0.5s;
}

#setup-screen {
  top: 0;
  left: 0;
  align-items: center;
}

@media (max-height: 850px) {
  #setup-screen {
    align-items: flex-start;
  }
}

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

/* セットアップ画面 (枠線と背景をなくしてシンプルに) */
.setup-container {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 20px 10px;
  width: 90%;
  max-width: 440px;
  box-shadow: none;
  text-align: center;
  margin: auto 0;
}

/* Recipe Shelf①と同じタイトルスタイル */
.list-page-header {
  padding: calc(13px + env(safe-area-inset-top)) 0 15px;
  text-align: center;
}

.list-page-header h1 {
  margin: 0;
  color: var(--text-color);
  font-family: "Lobster Two", cursive;
  font-size: clamp(2rem, 8vw, 2.55rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
}

.input-group {
  text-align: left;
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-color);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
}

.input-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px;
  padding-right: 48px;
}

.input-group textarea {
  resize: none;
}

/* トグルスイッチ用のレイアウト */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #222222;
  transition: .3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: #8e8e93;
  transition: .3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: #ffffff;
  border-color: #ffffff;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: #000000;
}

.toggle-label {
  cursor: pointer;
  font-size: 0.95rem;
  color: #ffffff;
  font-weight: 500;
  user-select: none;
}

.start-btn {
  width: 100%;
  background: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 16px;
  color: #000000;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.08);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
  margin-top: 10px;
}

.start-btn:hover {
  background-color: #e5e5e5;
}

.start-btn:active {
  transform: scale(0.98);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.error-msg {
  color: #ff5533;
  font-size: 0.95rem;
  margin-top: 15px;
  text-align: left;
  min-height: 20px;
  font-weight: 500;
  word-break: break-all;
  line-height: 1.45;
  white-space: pre-wrap;
}

.input-help {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.session-status {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  color: var(--text-muted);
  text-align: center;
  white-space: pre-wrap;
  font-size: 0.85rem;
  pointer-events: none;
}

/* メイン画面 */
.controls-top {
  position: absolute;
  top: 30px;
  right: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 10;
}

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  padding: 10px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.icon-btn:hover {
  border-color: var(--amber-primary);
  color: var(--text-color);
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.1);
}

.icon-btn.active {
  border-color: #ff3c00;
  color: #ff6a00;
  background: rgba(255, 60, 0, 0.05);
}

/* Zzz 浮遊アニメーション */
.zzz-container {
  position: absolute;
  top: 12%;
  right: 25%;
  font-family: 'DM Mono', monospace;
  font-weight: 700;
  color: var(--amber-primary);
  pointer-events: none;
  z-index: 5;
}

.zzz-container span {
  position: absolute;
  opacity: 0;
  animation: zzz-float 4s infinite;
}

.zzz-container span:nth-child(1) {
  font-size: 2.2rem;
  animation-delay: 0s;
}

.zzz-container span:nth-child(2) {
  font-size: 1.6rem;
  animation-delay: 1.3s;
  transform: translate(25px, -20px);
}

.zzz-container span:nth-child(3) {
  font-size: 1.1rem;
  animation-delay: 2.6s;
  transform: translate(45px, -35px);
}

@keyframes zzz-float {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6);
  }
  20% {
    opacity: 0.8;
  }
  80% {
    opacity: 0.4;
    transform: translate(30px, -60px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate(40px, -80px) scale(0.8);
  }
}

/* 両目の配置 (間隔調整) */
.eyes-container {
  display: flex;
  gap: 90px;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 800px;
  perspective: 800px;
}

/* 目全体を動かすラッパー */
.eye-wrap {
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  justify-content: center;
  align-items: center;
  filter: drop-shadow(0 0 15px rgba(255, 130, 0, 0.65));
}

/* 琥珀色の目 (Loonaサイズ比率 140x145) */
.eye {
  width: 140px;
  height: 145px;
  background: linear-gradient(135deg, rgba(26, 6, 0, 0.85) 0%, rgba(26, 6, 0, 0) 50%), radial-gradient(circle at center, #ffe066 0%, #ffaa00 45%, #993300 80%, #150400 100%);
  position: relative;
  overflow: hidden;
  border: none;
  box-shadow: none;
  transition: box-shadow 0.3s ease, background 0.4s ease, transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, box-shadow;
}

/* 上部ガラス光沢 (立体ベベル) */
.eye::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 8%;
  width: 84%;
  height: 25px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.1) 40%, rgba(255, 255, 255, 0) 100%);
  border-radius: 50% 50% 25% 25%;
  pointer-events: none;
  z-index: 6;
}



/* 傾きを少し弱めて自然な台形に (rotateX -8deg) */
#left-eye {
  transform: perspective(400px) rotateX(-8deg) rotateZ(-2.5deg);
  clip-path: url(#clip-eye-left);
}

#right-eye {
  transform: perspective(400px) rotateX(-8deg) rotateZ(2.5deg);
  clip-path: url(#clip-eye-right);
}

/* 瞬きのためのラッパー */
.eye-blink-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  transform-origin: center;
}

/* 瞬きのアニメーション（長方形全体を閉じる、台形変形と整合） */
.blink-active#left-eye {
  transform: scaleY(0.05) perspective(400px) rotateX(-8deg) rotateZ(-2.5deg) !important;
}
.blink-active#right-eye {
  transform: scaleY(0.05) perspective(400px) rotateX(-8deg) rotateZ(2.5deg) !important;
}

/* 瞳 (Loona比率に合わせて縦長にし、白の輝度をアップ) */
.eye-pupil {
  width: 58px;
  height: 64px;
  background: radial-gradient(circle at center, #ffffff 0%, #ffffff 65%, #ffeaa6 85%, rgba(255, 234, 166, 0) 100%);
  border-radius: 35% 35% 25% 25%;
  position: absolute;
  top: 40px;
  filter: blur(4px);
  transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

#left-pupil {
  left: 46px; /* 新しい瞳のサイズ(58px)に合わせて少し右（内側）へ */
}

#right-pupil {
  left: 36px; /* 新しい瞳のサイズ(58px)に合わせて少し左（内側）へ */
}

/* ハイライト (ぼかしを抑えてくっきり立体感を出す) */
.eye-hl {
  width: 18px;
  height: 11px;
  background: radial-gradient(ellipse at center, #ffffff 0%, #ffffff 75%, rgba(255, 255, 255, 0) 100%);
  border-radius: 50%;
  position: absolute;
  top: 24px;
  left: 84px;
  transform: rotate(20deg);
  filter: blur(1.2px);
  transition: transform 0.18s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* 小さなスパーク (Loonaには不要なため非表示に) */
.eye-spark {
  display: none;
}

/* --- アニメーション状態クラス --- */

/* idle 浮遊 */
.state-idle {
  animation: idle-float 4s ease-in-out infinite;
}
@keyframes idle-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.state-idle .eye {
  box-shadow: 0 0 30px rgba(255, 110, 0, 0.3), inset 0 0 12px rgba(0,0,0,0.65);
}

/* listening パルス */
.state-listening {
  animation: listening-pulse 1.3s ease-in-out infinite;
}
@keyframes listening-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.state-listening .eye {
  box-shadow: 0 0 45px rgba(255, 110, 0, 0.65), inset 0 0 12px rgba(0,0,0,0.65);
}

/* speaking (喋るときのモーフィング伸び縮みアニメーションを削除) */
.state-speaking {
  /* 伸び縮みなし */
}
.state-speaking .eye {
  box-shadow: 0 0 60px rgba(255, 110, 0, 0.9), inset 0 0 12px rgba(0,0,0,0.65);
}

/* モノクロテーマ：DOMと動作は琥珀色の目と共通にし、描画だけを切り替える */
#main-screen[data-eye-theme="monochrome"] .eyes-container {
  gap: 160px;
}

#main-screen[data-eye-theme="monochrome"] .eye-wrap {
  filter: none;
}

#main-screen[data-eye-theme="monochrome"] .eye {
  background: #020202;
  border: 12px solid #ffffff;
  border-radius: 26% 26% 24% 24% / 26% 26% 26% 26%;
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] #left-eye,
#main-screen[data-eye-theme="monochrome"] #right-eye {
  clip-path: none;
}

#main-screen[data-eye-theme="monochrome"] .eye::before {
  display: none;
}

#main-screen[data-eye-theme="monochrome"] .eye-pupil {
  width: 64px;
  height: 64px;
  top: 42px;
  left: 50%;
  margin-left: -32px;
  background: #ffffff;
  border-radius: 24%;
  filter: none;
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] .eye-hl {
  width: 22px;
  height: 14px;
  top: 24px;
  left: 82px;
  background: #ffffff;
  filter: none;
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] .state-idle .eye {
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] .state-listening .eye {
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] .state-speaking .eye {
  box-shadow: none;
}

#main-screen[data-eye-theme="monochrome"] .zzz-container {
  color: #ffffff;
  text-shadow: none;
}

/* 睡眠時は上下の白い枠線を厚くし、隙間をなくして一本線へ収束させる */
#main-screen[data-eye-theme="monochrome"] .eye.sleeping-bar {
  box-shadow: none;
  border-top-width: 72px;
  border-bottom-width: 72px;
}

#main-screen[data-eye-theme="monochrome"] .eye.sleeping-bar .eye-blink-wrap {
  visibility: hidden;
}

/* narrow 凝視（目を細める） */
.eye-wrap.narrow .eye {
  transform: scaleY(0.85);
}
