/* ==========================================================================
   VoiceTask Mobile Design System - Safe Area & Auth/Admin Panel
   ========================================================================== */

:root {
  --bg-color: #0b0b10;
  --card-bg: rgba(22, 22, 32, 0.75);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(168, 85, 247, 0.35);
  
  --primary-purple: #9333ea;
  --primary-blue: #3b82f6;
  --gradient-main: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
  --gradient-recording: linear-gradient(135deg, #ef4444 0%, #f43f5e 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --danger-color: #ef4444;
  --success-color: #10b981;
  
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-full: 9999px;
  
  --shadow-glow: 0 0 25px rgba(168, 85, 247, 0.45);
  --shadow-recording: 0 0 40px rgba(239, 68, 68, 0.75);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(147, 51, 234, 0.18), transparent 45%),
    radial-gradient(circle at 100% 100%, rgba(59, 130, 246, 0.12), transparent 45%);
  background-attachment: fixed;
}

html {
  height: -webkit-fill-available;
}

.app-container {
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: calc(32px + env(safe-area-inset-top, 20px));
  padding-left: 18px;
  padding-right: 18px;
  padding-bottom: 150px;
  position: relative;
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   Header & Navigation
   -------------------------------------------------------------------------- */
.app-header {
  text-align: center;
  margin-top: 4px;
  margin-bottom: 14px;
}

.header-top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 4px;
}

.logo-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: #a855f7;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.5));
}

.logo-icon.large {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px auto;
}

.logo-icon.large svg {
  width: 48px;
  height: 48px;
}

.logo-icon svg {
  width: 24px;
  height: 24px;
}

.logo-text {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline {
  font-size: 0.84rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 保存場所の注意書きと利用規約へのリンク */
.app-notice {
  margin-top: 6px;
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.app-notice a {
  margin-left: 4px;
  color: #c084fc;
  font-weight: 600;
  white-space: nowrap;
}

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

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:active {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger-color);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.admin-panel-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(147, 51, 234, 0.18);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.admin-panel-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Auth Section (Login / Sign Up)
   -------------------------------------------------------------------------- */
.auth-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.auth-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.input-group input {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast);
  user-select: text;
}

.input-group input:focus {
  border-color: #a855f7;
}

.auth-error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
}

.auth-submit-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient-main);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(147, 51, 234, 0.4);
  transition: transform var(--transition-fast);
  margin-top: 8px;
}

.auth-submit-btn:active {
  transform: scale(0.97);
}

.auth-toggle {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.auth-toggle button {
  background: none;
  border: none;
  color: #c084fc;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.88rem;
}

/* --------------------------------------------------------------------------
   Pending Approval Section
   -------------------------------------------------------------------------- */
.pending-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
}

.pending-card {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  animation: slide-up 0.4s ease;
}

.pending-icon {
  width: 64px;
  height: 64px;
  color: #f59e0b;
  margin: 0 auto 16px auto;
}

.pending-icon svg {
  width: 64px;
  height: 64px;
}

.pending-card h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.pending-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.user-info-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.logout-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-secondary);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Admin Control Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}

.admin-modal {
  width: 100%;
  max-width: 420px;
  background: #14141d;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  font-size: 1.1rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.user-list-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 400px;
}

.user-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
}

.user-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-email-text {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
  user-select: text;
}

.user-status-text {
  font-size: 0.75rem;
}

.user-status-text.approved {
  color: var(--success-color);
}

.user-status-text.pending {
  color: #f59e0b;
}

/* Switch Toggle Button */
.approval-switch-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.approval-switch-btn.approve {
  background: var(--gradient-success);
  color: #ffffff;
}

.approval-switch-btn.revoke {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* --------------------------------------------------------------------------
   Voice Wave & Main Controls
   -------------------------------------------------------------------------- */
.voice-status-section {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  height: 28px;
}

.sound-wave {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.voice-status-section.recording .sound-wave {
  opacity: 1;
}

.sound-wave span {
  width: 3px;
  height: 100%;
  background: #f43f5e;
  border-radius: 3px;
  animation: sound-bar 1.2s ease-in-out infinite alternate;
}

.sound-wave span:nth-child(1) { animation-delay: 0.1s; height: 30%; }
.sound-wave span:nth-child(2) { animation-delay: 0.3s; height: 80%; }
.sound-wave span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
.sound-wave span:nth-child(4) { animation-delay: 0.4s; height: 60%; }
.sound-wave span:nth-child(5) { animation-delay: 0.15s; height: 40%; }

@keyframes sound-bar {
  0% { transform: scaleY(0.2); }
  100% { transform: scaleY(1); }
}

/* --------------------------------------------------------------------------
   Manual Task Input Section
   -------------------------------------------------------------------------- */
.manual-input-section {
  margin-bottom: 16px;
}

.manual-input-form {
  display: flex;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 16px;
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: border-color var(--transition-fast);
}

.manual-input-form:focus-within {
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 4px 24px rgba(168, 85, 247, 0.15);
}

.manual-input-form input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  user-select: text;
}

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

.add-task-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gradient-main);
  border: none;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}

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

.add-task-btn svg {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Task Section
   -------------------------------------------------------------------------- */
.task-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 4px 4px;
}

.task-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.clear-completed-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color var(--transition-fast);
}

.clear-completed-btn:active {
  color: var(--danger-color);
  background: rgba(239, 68, 68, 0.1);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform var(--transition-smooth), border-color var(--transition-smooth), opacity var(--transition-smooth);
  animation: slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.task-card.removing {
  opacity: 0;
  transform: translateX(30px);
}

.checkbox-wrapper {
  margin-top: 2px;
  padding: 4px;
  margin-left: -4px;
  cursor: pointer;
}

.custom-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid #8b5cf6;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.task-card.completed .custom-checkbox {
  background-color: #8b5cf6;
  border-color: #8b5cf6;
}

.custom-checkbox svg {
  width: 15px;
  height: 15px;
  color: #ffffff;
  opacity: 0;
  transform: scale(0.6);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.task-card.completed .custom-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.task-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: text;
}

.task-text {
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--text-primary);
  word-break: break-word;
  transition: color var(--transition-fast);
}

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

.task-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* 編集用インライン入力フォーム (枠なし・オートリサイズ) */
.edit-task-textarea {
  width: 100%;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--text-primary);
  font-size: 0.98rem;
  line-height: 1.5;
  font-family: inherit;
  resize: none;
  overflow-y: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  caret-color: #3b82f6;
}

.edit-task-textarea:focus {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

.task-action-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.task-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.task-action-btn:active {
  background-color: rgba(255, 255, 255, 0.1);
}

.task-action-btn svg {
  width: 18px;
  height: 18px;
}

.edit-btn:hover, .edit-btn:active {
  color: #c084fc;
  background-color: rgba(168, 85, 247, 0.15);
}

.save-btn {
  color: var(--success-color);
  background-color: rgba(16, 185, 129, 0.15);
}

.save-btn:hover, .save-btn:active {
  background-color: rgba(16, 185, 129, 0.3);
}

.cancel-btn:hover, .cancel-btn:active {
  color: var(--danger-color);
  background-color: rgba(239, 68, 68, 0.15);
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  margin-right: -4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.delete-btn:active {
  color: var(--danger-color);
  background-color: rgba(239, 68, 68, 0.15);
}

.delete-btn svg {
  width: 18px;
  height: 18px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  opacity: 0.35;
}

/* --------------------------------------------------------------------------
   Mobile Floating Main Mic Button
   -------------------------------------------------------------------------- */
.bottom-action {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px)) 20px;
  background: linear-gradient(to top, rgba(11, 11, 16, 0.98) 75%, transparent 100%);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 100;
}

.btn-outer-glow {
  position: absolute;
  top: 16px;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--gradient-main);
  filter: blur(20px);
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.mic-trigger-btn {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--gradient-main);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(147, 51, 234, 0.45);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.3s ease;
  outline: none;
  z-index: 2;
}

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

.mic-trigger-btn.recording {
  background: var(--gradient-recording);
  box-shadow: 0 8px 35px rgba(239, 68, 68, 0.85);
  animation: pulse-btn 1.4s infinite;
}

.mic-trigger-btn.recording ~ .btn-outer-glow {
  background: var(--gradient-recording);
  opacity: 0.85;
  transform: scale(1.3);
}

@keyframes pulse-btn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.btn-icon svg {
  width: 36px;
  height: 36px;
}

.icon-stop.hidden {
  display: none;
}

.btn-label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color var(--transition-fast);
}

.mic-trigger-btn.recording ~ .btn-label {
  color: #f87171;
  font-weight: 700;
}
