/* Apple Human Interface Guidelines 風のシステムカラー / マテリアル */
:root {
  color-scheme: light dark;
  --blue: #007aff;
  --red: #ff3b30;
  --green: #34c759;
  --label: #000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --separator: rgba(60, 60, 67, .29);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .2);
  --bg: #f2f2f7;             /* systemGroupedBackground */
  --bg-2: #fff;              /* secondarySystemGroupedBackground */
  --bar: rgba(242, 242, 247, .8);
  --tint-bg: rgba(0, 122, 255, .12);
  --thumb: #fff;
  --sheet-bg: #f2f2f7;
  --sheet-card: #fff;
  --shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04);
  --radius: 12px;
  --ease: cubic-bezier(.32, .72, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue: #0a84ff;
    --red: #ff453a;
    --green: #30d158;
    --label: #fff;
    --label-2: rgba(235, 235, 245, .6);
    --label-3: rgba(235, 235, 245, .3);
    --separator: rgba(84, 84, 88, .6);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .32);
    --bg: #000;
    --bg-2: #1c1c1e;
    --bar: rgba(22, 22, 24, .72);
    --tint-bg: rgba(10, 132, 255, .18);
    --thumb: #636366;
    --sheet-bg: #1c1c1e;
    --sheet-card: #2c2c2e;
    --shadow: 0 3px 8px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 55%, transparent); outline-offset: 2px; }

/* ---------- ナビバー（スクロールでLarge Titleが格納される） ---------- */
.navbar {
  position: fixed; inset: 0 0 auto; z-index: 10;
  height: calc(44px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 104px 0;
  display: grid; place-items: center;
  background: transparent;
  border-bottom: .5px solid transparent;
  transition: background .25s, border-color .25s;
}
.navbar-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
.navbar.scrolled {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--separator);
}
.navbar.scrolled .navbar-title { opacity: 1; transform: none; }

main {
  max-width: 680px; margin: 0 auto;
  padding: calc(56px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---------- ヒーロー ---------- */
.hero { padding: 8px 4px 8px; }
.eyebrow { margin: 0 0 2px; color: var(--blue); font-size: 15px; font-weight: 600; }
.large-title { margin: 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: .01em; }
.hero-sub { margin: 6px 0 0; color: var(--label-2); }
.meta { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 0; padding: 0; color: var(--label-2); font-size: 15px; }
.meta li { display: inline-flex; align-items: center; gap: 6px; }
.tz-select {
  appearance: none; border: 0; margin: 0; padding: 2px 22px 2px 8px; border-radius: 7px; cursor: pointer;
  font: inherit; color: var(--blue); background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%23007aff' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 6px center / 10px;
}
.meta svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* ---------- セクション ---------- */
.section { margin-top: 28px; }
.section-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-header { margin: 0 0 8px 16px; font-size: 13px; font-weight: 400; color: var(--label-2); text-transform: uppercase; letter-spacing: .02em; }
.section-aside { margin-right: 16px; font-size: 13px; color: var(--label-2); }
.card { background: var(--bg-2); border-radius: var(--radius); }

/* ---------- ステッパー ---------- */
.stepper-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; min-height: 60px; }
.stepper-value { display: grid; gap: 1px; }
.stepper-num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stepper-num.bump { animation: bump .25s var(--ease); }
@keyframes bump { 40% { transform: scale(1.06); } }
.stepper-range { font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; height: 36px; border-radius: 9px; background: var(--fill); flex: 0 0 auto; }
.stepper button {
  width: 52px; height: 100%; border: 0; background: none; border-radius: 9px; cursor: pointer;
  display: grid; place-items: center; color: var(--label); transition: background .15s;
}
.stepper button:active:not(:disabled) { background: var(--fill-2); }
.stepper button:disabled { color: var(--label-3); cursor: default; }
.stepper svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.stepper-divider { width: .5px; height: 18px; background: var(--separator); }

/* ---------- 日付ストリップ ---------- */
.date-card { padding: 10px 6px; }
.dates {
  display: flex; gap: 2px; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.dates::-webkit-scrollbar { display: none; }
.date {
  flex: 0 0 auto; width: 52px; padding: 6px 0 8px; border: 0; background: none; border-radius: 12px;
  display: grid; justify-items: center; gap: 4px; cursor: pointer; scroll-snap-align: start;
}
.date-dow { font-size: 11px; font-weight: 600; color: var(--label-2); }
.date.sun .date-dow { color: var(--red); }
.date.sat .date-dow { color: var(--blue); }
.date-num {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
  font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background .2s, color .2s, transform .2s var(--ease);
}
.date-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }
.date.today .date-num { color: var(--red); font-weight: 600; }
.date:disabled { cursor: default; }
.date:disabled .date-num { color: var(--label-3); }
.date:disabled .date-dot { visibility: hidden; }
.date:not(:disabled):active .date-num { transform: scale(.92); }
.date[aria-selected="true"] .date-num { background: var(--blue); color: #fff; font-weight: 600; }
.date.today[aria-selected="true"] .date-num { background: var(--red); }

/* ---------- 時間スロット ---------- */
.slot-group + .slot-group { margin-top: 18px; }
.slot-group-title { margin: 0 0 8px 16px; font-size: 13px; color: var(--label-2); }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.slot {
  height: 44px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--tint-bg); color: var(--blue);
  font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: transform .15s var(--ease), background .15s, opacity .15s;
  animation: rise .35s var(--ease) both;
}
.slot:hover { background: color-mix(in srgb, var(--blue) 20%, transparent); }
.slot:active { transform: scale(.96); opacity: .8; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.skeleton { height: 44px; border-radius: 10px; background: var(--fill); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.empty { margin: 8px 0 0; padding: 28px 16px; text-align: center; color: var(--label-2); background: var(--bg-2); border-radius: var(--radius); }
.footer { margin-top: 36px; text-align: center; font-size: 13px; color: var(--label-2); }

/* ---------- シート ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .35s var(--ease);
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 21; left: 0; right: 0; bottom: 0;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--sheet-bg); border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .15);
  transform: translateY(100%); transition: transform .45s var(--ease);
}
.sheet.open { transform: none; }
@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 460px;
    border-radius: 16px; padding-bottom: 20px;
    transform: translate(-50%, -46%) scale(.96); opacity: 0;
    transition: transform .35s var(--ease), opacity .25s;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .grabber { visibility: hidden; }
}
.grabber { width: 36px; height: 5px; margin: 0 auto 4px; border-radius: 3px; background: var(--label-3); }
.sheet-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 44px; margin-bottom: 8px; }
.sheet-title { margin: 0; font-size: 17px; font-weight: 600; }
.bar-button { justify-self: start; border: 0; background: none; color: var(--blue); padding: 8px 0; cursor: pointer; }

.summary { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 20px; background: var(--sheet-card); border-radius: var(--radius); }
.summary-icon {
  flex: 0 0 auto; width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
  display: grid; grid-template-rows: 16px 1fr; text-align: center; background: var(--bg); box-shadow: inset 0 0 0 .5px var(--separator);
}
.summary-month { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; }
.summary-day { font-size: 24px; font-weight: 500; line-height: 34px; }
.summary-date { font-weight: 600; }
.summary-time { color: var(--label-2); font-size: 15px; font-variant-numeric: tabular-nums; }

/* iOS 設定アプリ風 Inset Grouped リスト */
.list { background: var(--sheet-card); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.list-row { position: relative; display: flex; align-items: center; min-height: 44px; padding: 0 16px; gap: 12px; }
.list-row + .list-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--separator); }
.list-label { flex: 0 0 5.5em; }
.list-row input, .list-row textarea {
  flex: 1; min-width: 0; border: 0; background: none; color: var(--label); font: inherit; padding: 11px 0; outline: none;
}
.list-row input::placeholder, .list-row textarea::placeholder { color: var(--label-3); }
.list-row-stack { flex-direction: column; align-items: stretch; gap: 0; padding-top: 11px; }
.list-row-stack .list-label { flex: none; font-size: 13px; color: var(--label-2); }
.list-row-stack textarea { resize: none; padding-top: 4px; }
.list-row.invalid .list-label { color: var(--red); }
.hp { position: absolute; left: -9999px; }

.form-error { min-height: 20px; margin: -8px 16px 12px; color: var(--red); font-size: 13px; }
.button-filled, .button-tinted {
  width: 100%; height: 50px; border: 0; border-radius: 12px; cursor: pointer;
  font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s var(--ease), opacity .15s;
}
.button-filled { background: var(--blue); color: #fff; }
.button-tinted { background: var(--tint-bg); color: var(--blue); }
.button-filled:active, .button-tinted:active { transform: scale(.98); opacity: .85; }
.button-filled:disabled { opacity: .6; cursor: default; }
.spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .8s linear infinite; }
.button-filled.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 完了 */
.done { text-align: center; padding: 28px 8px 4px; }
.done-check { width: 72px; height: 72px; margin-bottom: 12px; }
.done-check circle { fill: var(--green); transform-origin: center; animation: pop .45s var(--ease) both; }
.done-check path { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .35s .25s ease-out forwards; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.done-text { margin: 0 0 4px; font-weight: 600; line-height: 1.5; }
.done-text span { display: block; font-weight: 400; color: var(--label-2); }
.done-note { margin: 0 0 24px; color: var(--label-2); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .done-check path { stroke-dashoffset: 0; }
}

/* ---------- 言語切替 ---------- */
.lang {
  position: absolute; top: calc(6px + env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill);
}
.lang button {
  border: 0; background: transparent; padding: 3px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--label-2); cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--blue); color: #fff; }
