/* ============================================================
   tenshi note — 水色ベース天使界隈デザイン
   apple-design スキル適用:
   - 即時フィードバック (pointer-down で scale, 100ms)
   - 半透明マテリアル (backdrop-filter) で階層表現
   - transform / opacity のみアニメーション
   - 往路と復路で対称のイージング (空間的一貫性)
   - サイズ依存のトラッキング / 行送り
   - prefers-reduced-motion → クロスフェード
   ============================================================ */

:root {
  --blue-050: #f2faff;
  --blue-100: #e3f3ff;
  --blue-200: #c9e8fc;
  --blue-300: #a5d8f7;
  --blue-400: #7cc3ef;
  --blue-500: #57abdf;
  --blue-600: #3f92c9;
  --ink: #3d5a76;
  --ink-soft: #7d99b2;
  --white: #ffffff;

  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.85);
  --bar-bg: rgba(240, 249, 255, 0.65);

  --r-lg: 26px;
  --r-md: 16px;
  --r-sm: 12px;

  --shadow-card: 0 10px 30px rgba(87, 171, 223, 0.18), 0 2px 6px rgba(87, 171, 223, 0.10);
  --shadow-bar: 0 -4px 24px rgba(87, 171, 223, 0.14);

  --ease-spring: cubic-bezier(0.32, 0.72, 0.25, 1);
  --dur-fast: 180ms;
  --dur-med: 340ms;

  font: 100%/1.55 system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
        "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
  background: linear-gradient(180deg, var(--blue-100) 0%, var(--blue-050) 45%, #fdfeff 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 背景の雲 ---------- */
.sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  filter: blur(2px);
  box-shadow:
    34px 8px 0 6px rgba(255,255,255,0.45),
    -30px 12px 0 2px rgba(255,255,255,0.4);
  animation: drift 60s ease-in-out infinite alternate;
}
.cloud-a { width: 130px; height: 44px; top: 12%; left: 8%; }
.cloud-b { width: 90px; height: 32px; top: 34%; right: 10%; animation-duration: 75s; }
.cloud-c { width: 110px; height: 38px; bottom: 18%; left: 14%; animation-duration: 90s; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(40px); } }

/* ---------- ロゴ ---------- */
.logo-lg { width: 76px; height: 76px; filter: drop-shadow(0 6px 16px rgba(87, 171, 223, 0.4)); }
.logo-sm { width: 30px; height: 30px; }

/* ---------- 共通マテリアル ---------- */
.material-card {
  background: var(--card-bg);
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.material-bar {
  background: var(--bar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

/* ---------- 即時フィードバック ---------- */
.pressable {
  transition: transform 100ms ease-out, opacity 100ms ease-out;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pressable:active { transform: scale(0.96); opacity: 0.9; }

/* ---------- ボタン ---------- */
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-500));
  color: var(--white);
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(87, 171, 223, 0.45), inset 0 1px 0 rgba(255,255,255,0.35);
}
.btn-primary:disabled { opacity: 0.55; cursor: default; }

.btn-ghost {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-ghost:hover { background: rgba(255,255,255,0.6); }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: var(--blue-500);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: rgba(255,255,255,0.7); }

/* ---------- 認証ビュー ---------- */
.view { position: relative; z-index: 1; }

.view-auth {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(400px, 100%);
  padding: 44px 28px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: rise var(--dur-med) var(--ease-spring);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.auth-title {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.auth-sub { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 6px; }

/* セグメントコントロール */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  background: rgba(201, 232, 252, 0.5);
  border-radius: 999px;
  padding: 4px;
}
.seg-btn {
  position: relative; z-index: 1;
  padding: 9px 0;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  transition: color var(--dur-fast) var(--ease-spring);
}
.seg-btn.active { color: var(--ink); }
.seg-thumb {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: var(--white);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(87,171,223,0.25);
  transition: transform var(--dur-med) var(--ease-spring);
}
.seg.right .seg-thumb { transform: translateX(100%); }

/* フォーム */
#auth-form { width: 100%; display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.03em; }
.field input, textarea, .task-form input {
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--blue-200);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.85);
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.field input:focus, textarea:focus, .task-form input:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 4px rgba(124, 195, 239, 0.25);
}
.form-error { font-size: 0.8rem; color: #d0698a; }

/* ---------- アプリシェル ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 4px 20px rgba(87,171,223,0.12);
}
.app-title { font-weight: 800; letter-spacing: -0.01em; flex: 1; }

main {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 22px 18px calc(96px + env(safe-area-inset-bottom));
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 4px 2px 16px;
}

.view-enter { animation: view-in var(--dur-med) var(--ease-spring); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- クイック追加 (今日のタスク) ---------- */
.quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.quick-add input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  outline: none;
  padding: 8px 0;
}
.quick-add input::placeholder { color: var(--ink-soft); }
.btn-add {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-500));
  color: #fff;
  box-shadow: 0 4px 12px rgba(87,171,223,0.4);
}
.btn-add svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 16px;
}
.cal-dow {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 4px 0 8px;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 35%;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background var(--dur-fast) ease, transform 100ms ease-out;
}
.cal-cell:active { transform: scale(0.93); }
.cal-cell.other { color: var(--blue-300); }
.cal-cell.today { background: rgba(124, 195, 239, 0.28); box-shadow: inset 0 0 0 1.5px var(--blue-400); }
.cal-cell.has-record { background: rgba(255,255,255,0.75); }
.cal-cell .dots { display: flex; gap: 3px; height: 5px; }
.cal-cell .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue-400); }
.cal-hint { margin-top: 12px; text-align: center; font-size: 0.75rem; color: var(--ink-soft); }

/* ---------- 比較カード ---------- */
.cmp-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.cmp-card { padding: 14px 12px; text-align: center; }
.cmp-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-soft); }
.cmp-value { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; margin: 4px 0 2px; }
.cmp-diff { font-size: 0.72rem; font-weight: 700; }
.cmp-diff.up { color: #2f9e6e; }
.cmp-diff.down { color: #d0698a; }
.cmp-diff.flat { color: var(--ink-soft); }
.cmp-sub { font-size: 0.65rem; color: var(--ink-soft); }

/* ---------- パネル ---------- */
.panel { padding: 18px; margin-bottom: 14px; }
.panel-title { font-size: 0.95rem; font-weight: 800; letter-spacing: -0.005em; margin-bottom: 14px; }
.panel-sub { font-size: 0.7rem; font-weight: 600; color: var(--ink-soft); margin-left: 6px; }

/* ---------- ヒートマップ ---------- */
.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 1fr);
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.hm-cell { width: 15px; height: 15px; border-radius: 5px; background: var(--blue-100); }
.hm-cell[data-level="1"] { background: var(--blue-200); }
.hm-cell[data-level="2"] { background: var(--blue-300); }
.hm-cell[data-level="3"] { background: var(--blue-400); }
.hm-cell[data-level="4"] { background: var(--blue-500); }
.hm-cell.future { background: transparent; }

/* ---------- チャート ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis-label { font-size: 9px; fill: var(--ink-soft); }
.chart .bar { fill: var(--blue-300); rx: 5; }
.chart .bar.current { fill: var(--blue-500); }

/* ---------- レポート ---------- */
.report-cta { text-align: center; }
.report-desc { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 16px; }
.report-loading { margin-top: 12px; font-size: 0.8rem; color: var(--blue-500); font-weight: 600; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.report-card { padding: 18px; margin-bottom: 12px; animation: view-in var(--dur-med) var(--ease-spring); }
.report-period { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; color: var(--blue-500); margin-bottom: 8px; }
.report-body { font-size: 0.88rem; line-height: 1.7; white-space: pre-wrap; }

/* ---------- タブバー ---------- */
.tabbar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow-bar);
}
.tab {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 7px;
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: color var(--dur-fast) var(--ease-spring);
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--blue-600); }
.tab-indicator {
  position: absolute;
  top: 6px; bottom: 6px; left: 6px;
  width: calc((100% - 12px) / 3);
  background: rgba(255,255,255,0.85);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(87,171,223,0.22);
  transition: transform var(--dur-med) var(--ease-spring);
}

/* ---------- ボトムシート ---------- */
.scrim {
  position: fixed; inset: 0;
  z-index: 30;
  background: rgba(61, 90, 118, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in var(--dur-fast) ease;
}
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 31;
  max-width: 680px;
  max-height: 86svh;
  margin: 0 auto;
  padding: 10px 22px calc(22px + env(safe-area-inset-bottom));
  background: rgba(250, 253, 255, 0.92);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255,255,255,0.7);
  border-bottom: none;
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -10px 40px rgba(87,171,223,0.25);
  overflow-y: auto;
  animation: sheet-in var(--dur-med) var(--ease-spring);
}
.sheet.closing { animation: sheet-out var(--dur-fast) var(--ease-spring) forwards; }
@keyframes sheet-in  { from { transform: translateY(100%); } }
@keyframes sheet-out { to   { transform: translateY(100%); } }

.sheet-grab { width: 40px; height: 5px; margin: 2px auto 12px; border-radius: 999px; background: var(--blue-200); }
.sheet-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 14px; }
.sheet-section { margin-bottom: 18px; }
.sheet-label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; color: var(--ink-soft); margin-bottom: 8px; }

/* タスク追加フォーム (1タスク単位) */
.task-form { display: flex; flex-direction: column; gap: 10px; }

/* タスクリスト */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.task-empty {
  padding: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.55);
  border-radius: var(--r-md);
}
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.8);
  border-radius: var(--r-md);
  animation: view-in var(--dur-fast) var(--ease-spring);
}
.task-check {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--blue-300);
  display: grid; place-items: center;
  transition: background var(--dur-fast) var(--ease-spring), border-color var(--dur-fast) ease;
}
.task-check svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.5); transition: opacity var(--dur-fast) ease, transform var(--dur-fast) var(--ease-spring); }
.task-item.done .task-check { background: var(--blue-400); border-color: var(--blue-400); }
.task-item.done .task-check svg { opacity: 1; transform: scale(1); }
.task-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.task-title { font-size: 0.9rem; overflow-wrap: anywhere; }
.task-item.done .task-title { text-decoration: line-through; color: var(--ink-soft); }
.task-memo { font-size: 0.72rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.task-del { flex: none; color: var(--blue-300); font-size: 0.75rem; padding: 6px; border-radius: 8px; }
.task-del:hover { color: #d0698a; }

textarea { resize: none; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  padding: 11px 22px;
  border-radius: 999px;
  background: rgba(61, 90, 118, 0.88);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  animation: toast-in var(--dur-med) var(--ease-spring);
  white-space: nowrap;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- アクセシビリティ (Apple §14) ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .cloud { animation: none; }
  .sheet, .sheet.closing { animation-name: fade-in; transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .material-card, .material-bar, .sheet { background: #f6fbff; backdrop-filter: none; }
}

@media (max-width: 480px) {
  .cmp-value { font-size: 1.2rem; }
  .cal-grid { padding: 12px; gap: 4px; }
}
