@charset "UTF-8";

/* ---------- 色とベース ---------- */
:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --border: #e6e1d8;
  --text: #2f2b26;
  --text-sub: #7d766c;
  --accent: #3a8f7e;
  --accent-soft: #d9ece7;
  --mood: #d99a3e;
  --up: #cc5f52;
  --down: #3a8f7e;
  --danger: #c0524a;
  --line: #06c755;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(47, 43, 38, .06), 0 6px 16px rgba(47, 43, 38, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --surface: #262421;
    --border: #3a3733;
    --text: #ece8e1;
    --text-sub: #9d968b;
    --accent: #5cb5a1;
    --accent-soft: #24403a;
    --mood: #e0ab5c;
    --up: #e07a6c;
    --down: #5cb5a1;
    --danger: #d9736a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 16px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 84px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

h1, h2 { font-weight: 700; line-height: 1.4; }

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
}
.brand-mark { color: var(--accent); font-size: 20px; }

.avatar { display: block; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--accent-soft); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fallback { display: grid; place-items: center; width: 100%; height: 100%; color: var(--accent); font-weight: 700; }

.container { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- お知らせ ---------- */
.flash {
  max-width: 640px;
  margin: 12px auto 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.flash-success { background: var(--accent-soft); color: var(--accent); }
.flash-error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* ---------- カード ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 15px; }

/* ---------- 日付ナビ ---------- */
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.date-nav-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
}
.date-nav-btn.is-disabled { opacity: .3; }
.date-nav-current { text-align: center; }
.date-main { font-size: 20px; font-weight: 700; }
.date-sub { font-size: 12px; color: var(--text-sub); }

/* ---------- フォーム ---------- */
.field { margin-bottom: 22px; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--text-sub); margin-bottom: 8px; }
.field-note { margin: 8px 0 0; font-size: 12px; color: var(--text-sub); line-height: 1.6; }

.weight-input { display: flex; align-items: baseline; gap: 8px; }
.weight-input input {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.weight-input input:focus { outline: none; border-bottom-color: var(--accent); }
.weight-input .unit { font-size: 16px; color: var(--text-sub); font-weight: 700; }

.mood-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mood-picker input { position: absolute; opacity: 0; pointer-events: none; }
.mood-picker label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.mood-picker label:active { transform: scale(.96); }
.mood-emoji { font-size: 26px; line-height: 1; }
.mood-label { font-size: 10px; color: var(--text-sub); text-align: center; }
.mood-picker input:checked + label { background: var(--accent-soft); border-color: var(--accent); }
.mood-picker input:checked + label .mood-label { color: var(--accent); font-weight: 700; }
.mood-picker input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- ボタン ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: transparent; border: 1px solid var(--border); color: var(--text); margin-bottom: 8px; }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
.link-btn-danger { color: var(--danger); }

.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- 数値カード ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.stat-label { font-size: 12px; color: var(--text-sub); }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat-unit { font-size: 13px; font-weight: 700; color: var(--text-sub); margin-left: 3px; }
.is-up { color: var(--up); }
.is-down { color: var(--down); }

/* ---------- グラフ ---------- */
.chart-box { position: relative; height: 320px; }
.chart-box-sm { height: 180px; }
.chart-legend-note { margin: 12px 0 0; font-size: 12px; color: var(--text-sub); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legend-weight { background: var(--accent); }
.legend-average { background: color-mix(in srgb, var(--accent) 40%, transparent); }
.legend-mood { background: var(--mood); }

.range-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.range-tabs-scroll { overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.range-tab {
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-sub);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.range-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

/* ---------- 履歴 ---------- */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.history-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.history-date { font-size: 14px; font-weight: 700; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; }
.history-values { display: flex; align-items: baseline; gap: 10px; }
.history-weight { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.history-delta { font-size: 12px; font-variant-numeric: tabular-nums; }
.history-mood { font-size: 20px; }
.history-memo {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.history-actions { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.history-actions form { margin: 0; }

.empty-card { text-align: center; }
.empty-card p { color: var(--text-sub); }

/* ---------- ログイン画面 ---------- */
.welcome { text-align: center; padding: 24px 4px 40px; }
.welcome-mark { font-size: 52px; color: var(--accent); line-height: 1; }
.welcome h1 { font-size: 22px; margin: 14px 0 18px; }
.welcome-lead { color: var(--text-sub); font-size: 15px; margin-bottom: 26px; }
.welcome-points { list-style: none; margin: 0 0 30px; padding: 0; text-align: left; display: inline-block; }
.welcome-points li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; }
.welcome-points span {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 auto;
}
.btn-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  border-radius: 12px;
  background: var(--line);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}
.btn-line-icon {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .22);
  font-size: 12px;
  letter-spacing: .04em;
}
.liff-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 15px;
  font-size: 15px;
  color: var(--text-sub);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.welcome-note { margin-top: 18px; font-size: 12px; color: var(--text-sub); line-height: 1.8; }
.welcome-note-error { color: var(--danger); }
.welcome-note code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }

.error-card h1 { font-size: 18px; margin: 0 0 10px; }
.error-detail { font-size: 13px; color: var(--text-sub); }

/* ---------- 設定 ---------- */
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-pic { border-radius: 50%; object-fit: cover; }
.profile-name { font-weight: 700; }
.profile-sub { font-size: 12px; color: var(--text-sub); }

/* ---------- ホーム画面追加の案内 ---------- */
.install-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 616px;
  margin: 0 auto;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(47, 43, 38, .18);
  transform: translateY(16px);
  opacity: 0;
  transition: transform .25s ease, opacity .25s ease;
}
.install-sheet.is-open { transform: translateY(0); opacity: 1; }
.install-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.install-body { margin: 0 0 14px; font-size: 13px; color: var(--text-sub); line-height: 1.7; }
.install-actions { display: flex; align-items: center; gap: 8px; }
.install-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.install-later {
  padding: 11px 14px;
  border: none;
  background: none;
  color: var(--text-sub);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* ---------- 下部タブ ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 7px;
  color: var(--text-sub);
  text-decoration: none;
}
.tab-icon { font-size: 18px; line-height: 1; }
.tab-label { font-size: 10px; }
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-label { font-weight: 700; }
