/* =============================================
   共通デザインシステム
   ============================================= */

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

/* デザイントークン */
:root {
  --color-primary: #4f6ef7;
  --color-primary-light: #e8ecff;
  --color-primary-dark: #3b55d4;
  --color-bg: #f8f9fc;
  --color-surface: #ffffff;
  --color-text: #1e1e2e;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-error: #ef4444;
  --color-error-bg: #fef2f2;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 10px 25px -5px rgba(79, 110, 247, 0.1), 0 8px 10px -6px rgba(79, 110, 247, 0.1);
  --shadow-card: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --transition: 0.2s ease;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* =============================================
   共通コンポーネント
   ============================================= */

/* スピナー */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(79, 110, 247, 0.15);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner--sm {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.spinner--xs {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-color: rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  animation-duration: 0.8s;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* フォーム要素 */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text);
  background: #fcfdfe;
  transition: all var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.15);
}

/* エラー表示 */
.error-box {
  background: var(--color-error-bg);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--color-error);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  display: none;
  animation: fadeIn 0.2s ease;
}

.success-box {
  background: #ecfdf5;
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #047857;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-xs);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  display: none;
  animation: fadeIn 0.2s ease;
}

/* ボタン */
.btn-primary {
  width: 100%;
  padding: 0.8rem;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.2);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 6px 16px rgba(79, 110, 247, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: #a5b4fc;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* =============================================
   index.html - ローディングページ
   ============================================= */
.loader-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.loader-container .spinner {
  margin-bottom: 1.5rem;
}

.loader-container .message {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* =============================================
   login.html - ログインページ
   ============================================= */
.login-page {
  background: linear-gradient(135deg, #f0f4ff 0%, #f6f0ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-container {
  background: var(--color-surface);
  border: 1px solid rgba(229, 231, 235, 0.5);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  position: relative;
}

.brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.brand-subtitle {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.auth-link {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.875rem;
}

.auth-link a,
.text-link {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-link a:hover,
.text-link:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.verify-form {
  margin-top: 1.25rem;
}

.register-result {
  margin-top: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fcfdfe;
  text-align: center;
}

.register-result p {
  margin-bottom: 0.75rem;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 600;
}

.password-box {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-xs);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-family: Consolas, 'Courier New', monospace;
  font-size: 1rem;
  font-weight: 700;
  word-break: break-all;
}

/* =============================================
   toppage.html - マイページ
   ============================================= */
.toppage {
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.btn-logout {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-xs);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-logout:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #ef4444;
}

/* メインコンテンツ */
.toppage main {
  flex: 1;
  padding: 3rem 2rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ローダー表示 */
.page-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-loader .loader-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* ウェルカムカード */
.welcome-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 3rem 2rem;
  box-shadow: var(--shadow-card);
  text-align: center;
  max-width: 480px;
  width: 100%;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease;
}

.welcome-card.show {
  opacity: 1;
  transform: translateY(0);
}

.welcome-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.welcome-card h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.welcome-card p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* カードの区切り線 */
.card-divider {
  border: 0;
  height: 1px;
  background: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0));
  margin: 2rem 0;
}

/* おみくじセクション */
.omikuji-section {
  text-align: center;
}

.omikuji-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.omikuji-desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.btn-omikuji {
  background: linear-gradient(135deg, var(--color-primary) 0%, #764ba2 100%);
  color: #ffffff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(118, 75, 162, 0.3);
  transition: all var(--transition);
  outline: none;
}

.btn-omikuji:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(118, 75, 162, 0.4);
  filter: brightness(1.1);
}

.btn-omikuji:active {
  transform: translateY(0);
}

.btn-omikuji:disabled {
  background: #cccccc;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* おみくじ結果 */
.omikuji-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  display: none;
  opacity: 0;
  transform: scale(0.95);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.omikuji-result.show {
  display: block;
  opacity: 1;
  transform: scale(1);
}

.omikuji-result-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #764ba2;
  margin-bottom: 0.75rem;
}

.omikuji-result-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  white-space: pre-wrap;
  text-align: left;
}

/* 匿名相談ボックス */
.consultation-section {
  text-align: left;
}

.consultation-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.5rem;
  text-align: center;
}

.consultation-desc {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  text-align: center;
}

.consultation-form {
  text-align: left;
}

.consultation-textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.char-counter {
  margin-top: 0.4rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-align: right;
}

.consultation-result {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
}

.consultation-result.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.consultation-result-title {
  color: var(--color-primary-dark);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.consultation-reply {
  color: var(--color-text);
  font-size: 0.95rem;
  line-height: 1.7;
  white-space: pre-wrap;
}
