/* O U R S . — 海×山×爽やか×大人かわいい
   アイボリー地＋ブルー/アクア/セージのアクセント。装飾は曲線とグラデーションでさりげなく。 */

:root {
  --bg: #FAF8F3;
  --surface: #FFFFFF;
  --ink: #2B3A44;
  --ink-soft: #74838D;
  --ink-faint: #A9B4BB;
  --line: #EAE4D7;
  --accent: #2E6E9E;
  --accent-soft: #EAF3F8;
  --sky: #CFE6F2;
  --aqua: #E4F2F2;
  --sand: #F3EDDF;
  --sage: #8FBF9F;
  --danger: #C96F5E;

  /* 予定カラー（SETTINGSから上書きされる） */
  --c-eichi: #6FA8CF;
  --c-partner: #8FBF9F;
  --c-both: #2E6E9E;

  --radius: 18px;
  --nav-h: 60px;
  --shadow: 0 2px 14px rgba(60, 90, 110, 0.07);
  --font-brand: "Avenir Next", "Futura", -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}

/* ---------- ボトムナビ ---------- */
#nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  max-width: 480px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.88);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav button {
  flex: 1;
  height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-faint);
  transition: color 0.15s;
}
#nav button svg {
  width: 23px; height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#nav button svg circle[r="1.2"] { fill: currentColor; stroke: none; }
#nav button span {
  font-family: var(--font-brand);
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 600;
}
#nav button.active { color: var(--accent); }

/* ---------- 共通部品 ---------- */
.screen { padding: 0 18px; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0.4; } to { opacity: 1; } }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(234, 228, 215, 0.6);
}

.screen-title {
  font-family: var(--font-brand);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--ink);
  padding: 22px 2px 4px;
}
.screen-sub {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 0 2px 14px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
}
.btn-primary:active { opacity: 0.85; }
.btn-ghost {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
}
.btn-danger-text { color: var(--danger); }

/* ---------- HOME ---------- */
.home-hero {
  position: relative;
  margin: 0 -18px;
  padding: calc(env(safe-area-inset-top) + 46px) 18px 10px;
  text-align: center;
  background: linear-gradient(180deg, #C9E3F1 0%, #DDEEF2 42%, #F1F1E4 78%, var(--bg) 100%);
  overflow: hidden;
}
.home-hero .sun {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 18px);
  right: 40px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.95), rgba(255, 244, 214, 0));
}
.home-hero h1 {
  position: relative;
  font-family: var(--font-brand);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.38em;
  text-indent: 0.38em;
  color: #33546B;
}
.home-hero .tagline {
  position: relative;
  font-family: var(--font-brand);
  font-size: 11px;
  font-style: italic;
  letter-spacing: 0.14em;
  color: #6E8A9C;
  margin-top: 2px;
}
.home-hero svg.scape { display: block; width: calc(100% + 36px); margin: 14px -18px -10px; }

.home-section-label {
  font-family: var(--font-brand);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--accent);
  margin: 20px 4px 8px;
}

.next-card { padding: 20px 20px 18px; position: relative; overflow: hidden; }
.next-card .next-date {
  font-family: var(--font-brand);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}
.next-card .next-title {
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0 10px;
  line-height: 1.3;
}
.next-card .next-count {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--c-both);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.next-card .next-time { font-size: 13px; color: var(--ink-soft); margin-left: 10px; }
.next-card .next-wave {
  position: absolute;
  right: -16px; bottom: -22px;
  width: 130px;
  opacity: 0.5;
}
.next-empty { padding: 26px 20px; text-align: center; color: var(--ink-soft); font-size: 14px; }

.upcoming-list { margin-top: 8px; }
.upcoming-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.upcoming-row:last-child { border-bottom: none; }
.upcoming-row .u-date {
  font-family: var(--font-brand);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  min-width: 62px;
}
.upcoming-row .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.upcoming-row .u-title { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.home-cards { display: flex; gap: 12px; margin-top: 20px; }
.home-cards .mini-card {
  flex: 1;
  padding: 16px;
  text-align: left;
}
.mini-card .mc-label {
  font-family: var(--font-brand);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--accent);
}
.mini-card .mc-value { font-size: 21px; font-weight: 700; margin-top: 6px; }
.mini-card .mc-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.mini-card.mc-list { background: linear-gradient(160deg, #FFFFFF 30%, var(--aqua) 100%); }
.mini-card.mc-cal { background: linear-gradient(160deg, #FFFFFF 30%, var(--accent-soft) 100%); }

/* ---------- CALENDAR ---------- */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 2px 10px;
}
.cal-head .cal-month {
  font-family: var(--font-brand);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.06em;
}
.cal-head .cal-month small { font-size: 12px; color: var(--ink-soft); font-weight: 500; margin-left: 6px; letter-spacing: 0.1em; }
.cal-nav { display: flex; align-items: center; gap: 4px; }
.cal-nav button {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 17px;
}
.cal-nav button:active { background: var(--accent-soft); }
.cal-nav .today-btn { width: auto; padding: 0 12px; font-size: 12.5px; font-weight: 600; }

.cal-legend { display: flex; gap: 14px; padding: 0 4px 10px; }
.cal-legend span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-soft); }
.cal-legend i { width: 8px; height: 8px; border-radius: 50%; }

.cal-grid-wrap { padding: 12px 8px 10px; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-family: var(--font-brand);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  padding-bottom: 6px;
}
.cal-weekdays .wd-sun { color: #CC8B7E; }
.cal-weekdays .wd-sat { color: #7EA6CC; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell {
  aspect-ratio: 1 / 1.06;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 5px;
  border-radius: 12px;
  position: relative;
}
.cal-cell .d {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 13.5px;
  font-weight: 500;
}
.cal-cell.other .d { color: var(--ink-faint); opacity: 0.55; }
.cal-cell.today .d { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); font-weight: 700; }
.cal-cell.selected { background: var(--accent-soft); }
.cal-cell.selected .d { background: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.cal-cell .dots { display: flex; gap: 3px; margin-top: 3px; height: 6px; align-items: center; }
.cal-cell .dots i { width: 5.5px; height: 5.5px; border-radius: 50%; }
.cal-cell .dots .more { font-size: 8px; color: var(--ink-soft); line-height: 1; }

.day-panel { margin-top: 14px; }
.day-panel .dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px;
}
.day-panel .dp-date { font-size: 14px; font-weight: 700; }
.day-panel .dp-date small { color: var(--ink-soft); font-weight: 500; margin-left: 6px; }
.dp-add {
  display: flex; align-items: center; gap: 4px;
  color: var(--accent);
  font-size: 13px; font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
}
.dp-add:active { background: var(--accent-soft); }
.event-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.event-row:last-child { border-bottom: none; }
.event-row .bar { width: 4px; height: 36px; border-radius: 2px; flex: none; }
.event-row .ev-main { flex: 1; min-width: 0; }
.event-row .ev-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-row .ev-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.event-row .ev-who { font-size: 11px; color: var(--ink-faint); flex: none; }
.dp-empty { padding: 22px 16px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---------- OUR LIST ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.seg {
  display: flex;
  background: #EFEBE0;
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 14px;
}
.seg button {
  flex: 1;
  padding: 8px 0;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(60,90,110,0.1); }

.item-card {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  margin-bottom: 10px;
}
.item-card .cat-icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex: none;
}
.cat-place { background: var(--accent-soft); }
.cat-food { background: var(--sand); }
.cat-todo { background: var(--aqua); }
.cat-want { background: #F5EBE9; }
.item-card .it-main { flex: 1; min-width: 0; }
.item-card .it-title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.item-card .it-title.done { color: var(--ink-faint); text-decoration: line-through; }
.item-card .it-memo { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .it-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.status-badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
}
.st-wish { background: var(--sand); color: #8A7A55; }
.st-planned { background: var(--accent-soft); color: var(--accent); }
.st-done { background: #EAF2EA; color: #5E8A68; }
.it-link { font-size: 12px; }
.list-empty { padding: 44px 16px; text-align: center; color: var(--ink-faint); font-size: 13.5px; line-height: 2; }

.fab {
  position: fixed;
  right: max(18px, calc(50% - 222px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  z-index: 30;
  width: 54px; height: 54px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  font-weight: 300;
  box-shadow: 0 6px 18px rgba(46, 110, 158, 0.35);
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(0.94); }

/* ---------- SETTINGS ---------- */
.set-section { margin-bottom: 22px; }
.set-label {
  font-family: var(--font-brand);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--accent);
  margin: 0 4px 8px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.set-row:last-child { border-bottom: none; }
.set-row .grow { flex: 1; }
.set-row .swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.set-row .chev { color: var(--ink-faint); font-size: 15px; }
.set-row .sub-val { color: var(--ink-soft); font-size: 13.5px; }
.set-note { font-size: 11.5px; color: var(--ink-faint); margin: 8px 6px 0; line-height: 1.7; }

/* ---------- シート（下からのパネル） ---------- */
#sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(43, 58, 68, 0.32);
  z-index: 50;
  animation: fadein 0.2s ease;
}
#sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 51;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 18px);
  max-height: 88dvh;
  overflow-y: auto;
  animation: slideup 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideup { from { transform: translateY(40%); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 12px; }
.sheet-title { font-size: 16.5px; font-weight: 700; margin-bottom: 14px; }

.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.form-field input[type="text"], .form-field input[type="url"],
.form-field input[type="date"], .form-field input[type="time"],
.form-field textarea, .form-field select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 16px; /* iOSの自動ズーム防止に16px以上 */
  -webkit-appearance: none;
  min-height: 46px;
}
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-field textarea { resize: none; height: 84px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-field { flex: 1; }

.type-picker { display: flex; gap: 8px; }
.type-picker button {
  flex: 1;
  padding: 11px 0;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.type-picker button i { width: 10px; height: 10px; border-radius: 50%; }
.type-picker button.active { border-color: var(--tp-color); background: color-mix(in srgb, var(--tp-color) 10%, #fff); font-weight: 700; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
  margin-bottom: 14px;
}
.switch-row label { font-size: 14px; font-weight: 600; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; z-index: 2; margin: 0; }
.switch .knob {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: #E0DACB;
  transition: background 0.18s;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  transition: transform 0.18s;
}
.switch input:checked + .knob { background: var(--sage); }
.switch input:checked + .knob::after { transform: translateX(20px); }

.cat-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-picker button {
  padding: 10px 0 8px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-soft);
}
.cat-picker button .ci { font-size: 20px; }
.cat-picker button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.preset-colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 9px; margin-bottom: 14px; }
.preset-colors button {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.5px solid transparent;
  position: relative;
}
.preset-colors button.active { border-color: var(--ink); }
.custom-color-row { display: flex; align-items: center; gap: 10px; }
.custom-color-row input[type="color"] {
  width: 46px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 3px;
}
.custom-color-row span { font-size: 13px; color: var(--ink-soft); }

.sheet-actions { margin-top: 18px; }
.sheet-actions .btn-primary { margin-bottom: 4px; }

.schedule-origin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--aqua);
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------- トースト・オフライン ---------- */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(43, 58, 68, 0.92);
  color: #fff;
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 999px;
  white-space: nowrap;
  animation: fadein 0.2s ease;
}
#offline-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 45;
  background: #C9A96A;
  color: #fff;
  font-size: 12px;
  text-align: center;
  padding: calc(env(safe-area-inset-top) + 5px) 10px 5px;
}

/* トークン未設定の案内画面 */
.gate {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 10px;
}
.gate h1 { font-family: var(--font-brand); letter-spacing: 0.35em; text-indent: 0.35em; font-size: 24px; font-weight: 500; color: #33546B; }
.gate p { font-size: 13.5px; color: var(--ink-soft); line-height: 2; }
.gate input {
  width: 100%;
  max-width: 260px;
  padding: 12px 13px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 16px;
}
.gate input:focus { outline: none; border-color: var(--accent); }
