/* ===== リセットと基本設定 ===== */
/* box-sizing: border-box → padding や border を幅に含める（レイアウトが直感的になる） */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* カラーパレット（ダーク系） */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e6e6e6;
  --text-secondary: #a0a0b0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --border: #2a2a4a;
  --input-bg: #12122a;
  --success: #4ecca3;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  /* safe-area-inset: iPhoneのノッチやホームバーを避けるための余白 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ===== 共通ユーティリティ ===== */
.hidden {
  display: none !important;
}

.screen {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== ログイン画面 ===== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 16px;
}

.app-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

#password-input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#password-input:focus {
  border-color: var(--accent);
}

.error-text {
  color: var(--accent);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== ボタン ===== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* ===== メイン画面: ヘッダー ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.app-title-small {
  font-size: 1.2rem;
  font-weight: 700;
}

.date-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ===== メイン画面: 入力エリア ===== */
.input-area {
  margin-bottom: 24px;
}

#memo-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  min-height: 80px;
}

#memo-input:focus {
  border-color: var(--accent);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.char-count {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ===== メイン画面: メモ一覧 ===== */
.memo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memo-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  /* アニメーション: 新しいメモがスライドインする効果 */
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.memo-text {
  font-size: 0.95rem;
  line-height: 1.6;
  /* white-space: pre-wrap → 改行やスペースをそのまま表示する */
  white-space: pre-wrap;
  word-break: break-word;
}

.memo-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 8px;
}

/* ===== 空の状態 ===== */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}

.empty-hint {
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ===== レスポンシブ対応 ===== */
/* 画面幅が480px以下（スマートフォン）のとき */
@media (max-width: 480px) {
  .screen {
    padding: 12px;
  }

  .app-title {
    font-size: 1.6rem;
  }

  #memo-input {
    font-size: 16px; /* iOS でズームを防ぐ: 16px未満だとiOSが自動ズームする */
  }
}
