* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif; background: #0f0f0f; color: #f0f0f0; padding: 16px; max-width: 480px; margin: 0 auto; padding-bottom: 40px; }

  .header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
  .header h1 { font-size: 20px; font-weight: 700; }
  .header .date { font-size: 12px; color: #888; margin-top: 3px; }
  .update-btn { background: #4D96FF; color: #fff; border: none; border-radius: 10px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }

  /* 同期ステータス */
  .sync-bar { display: flex; align-items: center; gap: 6px; background: #1a1a1a; border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 12px; }
  .sync-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .sync-dot.online { background: #6BCB77; }
  .sync-dot.offline { background: #FF6B6B; }
  .sync-dot.syncing { background: #FFD93D; animation: pulse 1s infinite; }
  @keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

  .card { background: #1a1a1a; border-radius: 16px; padding: 16px; margin-bottom: 12px; }
  .card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888; margin-bottom: 12px; }

  /* 写真 */
  .photo-area { border: 2px dashed #333; border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; margin-bottom: 12px; }
  .photo-area .placeholder { color: #555; font-size: 14px; }
  .photo-area .placeholder .icon { font-size: 32px; margin-bottom: 8px; }
  .photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
  .photo-thumb { position: relative; width: 80px; height: 80px; }
  .photo-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; cursor: pointer; }
  .photo-thumb .del { position: absolute; top: -6px; right: -6px; background: #FF6B6B; border: none; border-radius: 50%; width: 20px; height: 20px; color: #fff; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

  /* 入力 */
  .input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .input-item { background: #242424; border-radius: 12px; padding: 12px; }
  .input-label { font-size: 11px; color: #888; margin-bottom: 6px; }
  .input-row { display: flex; align-items: baseline; gap: 4px; }
  .input-field { background: transparent; border: none; border-bottom: 1px solid #444; color: #fff; font-size: 22px; font-weight: 700; width: 100%; outline: none; padding-bottom: 2px; }
  .input-field:focus { border-bottom-color: #4D96FF; }
  .input-unit { font-size: 13px; color: #888; flex-shrink: 0; }
  .input-target { font-size: 11px; color: #4CAF50; margin-top: 4px; }

  .save-btn { width: 100%; background: #4D96FF; color: #fff; border: none; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 4px; }
  .save-btn:active { background: #3a7fd4; }
  .save-btn:disabled { background: #333; color: #666; }

  /* 履歴 */
  .history-row { padding: 12px 0; border-bottom: 1px solid #2a2a2a; }
  .history-row:last-child { border-bottom: none; }
  .no-history { text-align: center; color: #555; font-size: 13px; padding: 20px 0; }

  /* ビフォーアフター */
  .before-after { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .ba-slot { border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 3/4; background: #242424; cursor: pointer; }
  .ba-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .ba-label { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,0.75); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
  .ba-date { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; font-size: 10px; color: rgba(255,255,255,0.7); }
  .ba-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #555; font-size: 12px; gap: 6px; }
  .ba-empty span { font-size: 28px; }
  .ba-del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,0.6); border: none; color: #fff; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; cursor: pointer; }

  /* タイムライン */
  .body-thumb-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
  .body-thumb { position: relative; flex-shrink: 0; width: 72px; }
  .body-thumb img { width: 72px; height: 96px; object-fit: cover; border-radius: 8px; display: block; cursor: pointer; }
  .body-thumb .bt-date { font-size: 9px; color: #666; text-align: center; margin-top: 3px; }
  .body-thumb .bt-del { position: absolute; top: -4px; right: -4px; background: #FF6B6B; border: none; border-radius: 50%; width: 18px; height: 18px; color: #fff; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

  /* モーダル */
  .modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 100; justify-content: center; align-items: center; padding: 16px; }
  .modal.open { display: flex; }
  .modal img { max-width: 100%; max-height: 90vh; border-radius: 12px; }
  .modal-close { position: fixed; top: 16px; right: 16px; background: #333; border: none; color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

  /* タブ */
  .tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
  .tab { flex-shrink: 0; background: #242424; border: none; color: #888; border-radius: 10px; padding: 9px 14px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
  .tab.active { background: #4D96FF; color: #fff; }

  .section { display: none; }
  .section.active { display: block; }

  /* 習慣 */
  .habit-row { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid #2a2a2a; }
  .habit-row:last-child { border-bottom: none; }
  .habit-day { font-size: 12px; font-weight: 700; color: #4D96FF; width: 48px; flex-shrink: 0; }
  .habit-name { font-size: 14px; flex: 1; }
  .habit-mechanism { font-size: 11px; color: #888; }
  .quote { background: #242424; border-left: 3px solid #4D96FF; padding: 12px; border-radius: 0 10px 10px 0; margin: 8px 0; font-size: 14px; line-height: 1.6; color: #ddd; font-style: italic; }

  /* ローディング */
  .loading { text-align: center; color: #555; padding: 20px; font-size: 13px; }

  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #6BCB77; color: #000; padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 600; display: none; z-index: 200; white-space: nowrap; }
  .toast.show { display: block; animation: fadeInOut 2.5s forwards; }
  @keyframes fadeInOut { 0%{opacity:0;transform:translateX(-50%) translateY(10px)} 15%{opacity:1;transform:translateX(-50%) translateY(0)} 70%{opacity:1} 100%{opacity:0} }

  .updated { text-align: center; font-size: 11px; color: #555; margin-top: 20px; }

  /* 日記 */
  .mood-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
  .mood-btn { font-size: 28px; background: #242424; border: 2px solid transparent; border-radius: 12px; padding: 8px 12px; cursor: pointer; transition: all 0.15s; }
  .mood-btn.selected { border-color: #4D96FF; background: #1a3a5c; transform: scale(1.1); }
  .journal-textarea { width: 100%; background: #242424; border: 1px solid #333; border-radius: 12px; color: #f0f0f0; font-size: 15px; line-height: 1.7; padding: 14px; min-height: 180px; resize: none; outline: none; font-family: inherit; }
  .journal-textarea:focus { border-color: #4D96FF; }
  .journal-date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
  .nav-btn { background: #242424; border: none; color: #aaa; width: 36px; height: 36px; border-radius: 10px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
  .nav-date { font-size: 15px; font-weight: 600; }
  .past-entry { padding: 14px 0; border-bottom: 1px solid #2a2a2a; }
  .past-entry:last-child { border-bottom: none; }
  .past-entry-date { font-size: 12px; color: #4D96FF; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
  .past-entry-text { font-size: 14px; color: #ccc; line-height: 1.6; white-space: pre-wrap; }

  /* 習慣タグ */
  .tag-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .tag-chip { background: #242424; border: 1.5px solid #333; border-radius: 20px; padding: 6px 14px; font-size: 13px; cursor: pointer; transition: all 0.15s; color: #aaa; white-space: nowrap; }
  .tag-chip.active { background: #1a3a5c; border-color: #4D96FF; color: #4D96FF; }
  .week-history-row { padding: 12px 0; border-bottom: 1px solid #2a2a2a; }
  .week-history-row:last-child { border-bottom: none; }
  .week-tags-display { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
  .week-tag-badge { background: #1a3a5c; color: #4D96FF; border-radius: 12px; padding: 3px 10px; font-size: 12px; }

  /* 認証画面 */
  #auth-screen { position: fixed; inset: 0; background: #0f0f0f; z-index: 500; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
  #auth-screen.hidden { display: none; }
  .auth-logo { font-size: 40px; margin-bottom: 8px; }
  .auth-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; text-align: center; }
  .auth-subtitle { font-size: 13px; color: #888; margin-bottom: 32px; text-align: center; }
  .auth-card { background: #1a1a1a; border-radius: 20px; padding: 24px; width: 100%; max-width: 360px; }
  .auth-tab-row { display: flex; gap: 8px; margin-bottom: 20px; }
  .auth-tab { flex: 1; background: #242424; border: none; color: #888; border-radius: 10px; padding: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
  .auth-tab.active { background: #4D96FF; color: #fff; }
  .auth-input { width: 100%; background: #242424; border: 1px solid #333; border-radius: 12px; color: #fff; font-size: 16px; padding: 14px; outline: none; margin-bottom: 12px; font-family: inherit; box-sizing: border-box; }
  .auth-input:focus { border-color: #4D96FF; }
  .auth-btn { width: 100%; background: #4D96FF; color: #fff; border: none; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 4px; }
  .auth-btn:active { background: #3a7fd4; }
  .auth-btn:disabled { background: #333; color: #666; }
  .auth-error { color: #FF6B6B; font-size: 13px; margin-top: 10px; text-align: center; min-height: 18px; }
  .logout-btn { background: transparent; border: 1px solid #444; color: #888; border-radius: 8px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
  .logout-btn:active { background: #333; }
  .goal-row { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
  .goal-row label { font-size:13px; color:#ccc; width:130px; flex-shrink:0; }
  .goal-input { flex:1; background:#242424; border:1px solid #333; border-radius:10px; color:#fff; font-size:15px; padding:8px 12px; outline:none; font-family:inherit; }
  .goal-input:focus { border-color:#4D96FF; }
  .goal-row span { font-size:12px; color:#888; width:24px; flex-shrink:0; }
  .header-user { font-size: 12px; color: #aaa; display: flex; align-items: center; gap: 8px; }

/* ===== 3タブv2 追加スタイル ===== */
.screen { display: none; }
.screen.active { display: block; }
main { padding-bottom: 84px; }
.screen-nav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #1a1a1a; border-top: 1px solid #2e2e2e; padding-bottom: env(safe-area-inset-bottom); z-index: 50; }
.screen-nav button { flex: 1; min-height: 56px; background: none; border: none; color: #888; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }
.screen-nav button.active { color: #4D96FF; }
