:root {
  --color-bg-dark: #090a10;
  --color-panel-bg: rgba(15, 22, 42, 0.65);
  --color-panel-border: rgba(255, 255, 255, 0.08);
  --color-primary: #a855f7; /* ネオンパープル */
  --color-primary-glow: rgba(168, 85, 247, 0.3);
  --color-secondary: #06b6d4; /* シアン */
  --color-secondary-glow: rgba(6, 182, 212, 0.3);
  --color-text-main: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-success: #10b981;
  --color-danger: #ef4444;
  
  --font-family: 'Outfit', 'Inter', 'Noto Sans JP', sans-serif;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* リセット */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-dark);
  color: var(--color-text-main);
  min-height: 100%;
  overflow-x: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* 背景デコレーション */
.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.45;
  pointer-events: none;
}

.bg-glow-1 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
  top: 10%;
  left: -50px;
  animation: floatGlow 15s infinite alternate ease-in-out;
}

.bg-glow-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--color-secondary) 0%, transparent 70%);
  bottom: 10%;
  right: -100px;
  animation: floatGlow 20s infinite alternate-reverse ease-in-out;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 40px) scale(1.2); }
}

/* メインアプリコンテナ */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100dvh;
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: rgba(10, 11, 22, 0.8);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
  overflow: hidden;
}

/* スマホ表示対応 */
@media (max-width: 480px) {
  body {
    display: block;
  }

  .app-container {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  body {
    display: block;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-container {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border: none;
    border-radius: 0;
    margin: 0;
  }

  .bg-glow {
    display: none;
  }

  .form-group input,
  .form-group select,
  .manual-search-box input {
    font-size: 16px;
  }
}

/* ヘッダー */
.app-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-panel-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: spinLogo 8s infinite linear;
}

@keyframes spinLogo {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #ffffff 30%, var(--color-text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-text-muted);
  box-shadow: 0 0 8px var(--color-text-muted);
  transition: var(--transition-smooth);
}

.status-dot.active {
  background-color: var(--color-success);
  box-shadow: 0 0 10px var(--color-success);
  animation: pulseGreen 1.5s infinite;
}

.status-dot.listening {
  background-color: var(--color-danger);
  box-shadow: 0 0 10px var(--color-danger);
  animation: pulseRed 1s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseRed {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

/* メインコンテンツ領域 */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: calc(100px + env(safe-area-inset-bottom)); /* ナビ＋セーフエリア余白 */
  scrollbar-width: none;
}

.app-content::-webkit-scrollbar {
  display: none;
}

/* セクション表示切り替え */
.content-section {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.content-section.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* ボタンとUIコンポーネント */
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary));
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 16px var(--color-primary-glow);
  transition: var(--transition-smooth);
  font-family: var(--font-family);
  font-size: 0.95rem;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px var(--color-primary-glow);
  opacity: 0.9;
}

.btn-primary:disabled {
  background: var(--color-panel-border);
  color: var(--color-text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary-sm {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary-sm:hover {
  opacity: 0.9;
  transform: scale(1.02);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-main);
  border: 1px solid var(--color-panel-border);
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ガラスパネル */
.glass-panel {
  background: var(--color-panel-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: 16px;
  padding: 16px;
  backdrop-filter: blur(10px);
}

/* アシスタントタブのUI */
.assistant-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.assistant-welcome {
  text-align: center;
  margin: 10px 0 20px;
}

.assistant-welcome h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 40%, var(--color-text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.assistant-welcome p {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.chat-history {
  flex: 1;
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: none;
}

.chat-history::-webkit-scrollbar {
  display: none;
}

.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
  animation: popIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.bubble-time {
  display: block;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  text-align: right;
}

.chat-bubble.user .bubble-time {
  color: rgba(255, 255, 255, 0.7);
}

.voice-control-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 10px;
}

.mic-button {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  box-shadow: 0 10px 25px var(--color-primary-glow), 0 0 0 0px rgba(168, 85, 247, 0.4);
  transition: var(--transition-smooth);
  position: relative;
}

.mic-button::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--color-secondary);
  opacity: 0;
  transform: scale(1);
  transition: var(--transition-smooth);
}

.mic-button.listening {
  animation: pulseMic 1.5s infinite;
  background: linear-gradient(135deg, var(--color-danger), #dc2626);
  box-shadow: 0 10px 25px rgba(220, 38, 38, 0.4);
}

.mic-button.listening::after {
  animation: waveSpread 1.5s infinite;
  opacity: 1;
}

@keyframes pulseMic {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes waveSpread {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* 音声入力波形 */
.speech-wave {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  height: 30px;
  visibility: hidden;
  opacity: 0;
  transition: var(--transition-smooth);
}

.speech-wave.active {
  visibility: visible;
  opacity: 1;
}

.speech-wave span {
  display: block;
  width: 4px;
  height: 8px;
  background-color: var(--color-secondary);
  border-radius: 2px;
  animation: waveHeight 1.2s infinite ease-in-out;
}

.speech-wave span:nth-child(2) { animation-delay: 0.15s; }
.speech-wave span:nth-child(3) { animation-delay: 0.3s; }
.speech-wave span:nth-child(4) { animation-delay: 0.45s; }
.speech-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes waveHeight {
  0%, 100% { height: 8px; }
  50% { height: 28px; }
}

.voice-help-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* タスクタブのUI */
.task-form-card {
  margin-bottom: 20px;
  animation: slideDown 0.3s ease;
}

.task-form-card.hidden {
  display: none;
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.form-group input, .form-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-panel-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.list-filter {
  display: flex;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}

.filter-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-panel-bg);
  border: 1px solid var(--color-panel-border);
  padding: 12px 16px;
  border-radius: 12px;
  gap: 12px;
  transition: var(--transition-smooth);
  animation: popIn 0.3s ease;
}

.task-item.completed {
  opacity: 0.6;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.02);
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-smooth);
  flex-shrink: 0;
}

.task-checkbox::after {
  content: '✓';
  color: #fff;
  font-size: 0.75rem;
  opacity: 0;
  transition: var(--transition-smooth);
}

.task-item.completed .task-checkbox {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.task-item.completed .task-checkbox::after {
  opacity: 1;
}

.task-details {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition-smooth);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.task-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  align-items: center;
}

.task-badge-reminder {
  background: var(--color-secondary-glow);
  color: var(--color-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.task-btn-delete {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: var(--transition-smooth);
}

.task-btn-delete:hover {
  color: var(--color-danger);
  transform: scale(1.1);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

/* 統計タブのUI */
.stats-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.stats-card.full-width {
  width: 100%;
}

.stats-card h3 {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  align-self: flex-start;
}

.progress-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring__circle {
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 0.8s ease-in-out;
  stroke-linecap: round;
}

.progress-text {
  position: absolute;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
}

.stats-details {
  display: flex;
  gap: 20px;
  margin-top: 16px;
  font-size: 0.85rem;
}

.stats-details span {
  font-weight: 600;
}

.stats-summary-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
}

.summary-item {
  flex: 1;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--color-panel-border);
  padding: 12px 8px;
  border-radius: 12px;
}

.summary-val {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-secondary);
  font-family: 'Outfit', sans-serif;
  margin-bottom: 4px;
}

.summary-lbl {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

/* カレンダーヒートマップ風のチャート */
.activity-chart-container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.activity-chart {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 100px;
  width: 100%;
  max-width: 320px;
  justify-content: space-around;
}

.chart-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.chart-bar-wrap {
  width: 14px;
  height: 70px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.chart-bar-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, var(--color-primary), var(--color-secondary));
  position: absolute;
  bottom: 0;
  border-radius: 4px;
  transition: height 0.6s ease;
}

.chart-bar-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

.chart-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 10px;
}

/* 調べもの & 学習タブのUI */
.learning-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-container {
  text-align: center;
}

.quiz-intro {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.quiz-box {
  padding: 10px 0;
}

.quiz-question-box {
  text-align: left;
  margin-bottom: 16px;
}

.quiz-question-box p {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-panel-border);
  color: var(--color-text-main);
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  font-family: var(--font-family);
  transition: var(--transition-smooth);
}

.quiz-option-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-primary);
}

.quiz-option-btn.correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--color-success);
  color: #fff;
}

.quiz-option-btn.wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--color-danger);
  color: #fff;
}

.quiz-feedback {
  margin-top: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.quiz-feedback.success { color: var(--color-success); }
.quiz-feedback.error { color: var(--color-danger); }

/* 学習カードライブラリ */
.learning-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 12px 0;
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: none;
}

.learning-cards-grid::-webkit-scrollbar {
  display: none;
}

.learning-card {
  position: relative;
  animation: popIn 0.3s ease;
}

.learning-card h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-secondary);
}

.learning-card p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.card-btn-delete {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.card-btn-delete:hover {
  color: var(--color-danger);
}

.manual-search-box {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.manual-search-box input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-panel-border);
  border-radius: 10px;
  padding: 10px;
  color: #fff;
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
}

.manual-search-box input:focus {
  border-color: var(--color-secondary);
}

/* ナビゲーションバー */
.app-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(70px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(15, 22, 42, 0.85);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-panel-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 10;
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  flex: 1;
  height: 100%;
  justify-content: center;
  transition: var(--transition-smooth);
}

.nav-item.active {
  color: #fff;
  position: relative;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  width: 30px;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 10px var(--color-primary);
}

.nav-icon {
  font-size: 1.25rem;
  transition: var(--transition-smooth);
}

.nav-item.active .nav-icon {
  transform: translateY(-2px);
  text-shadow: 0 0 10px var(--color-primary-glow);
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 500;
}
