:root {
    /* ロゴ（クリーム地 × 杏色 × 墨茶のインク）由来のパレット */
    --bg: #fcf5ec;
    --card: #ffffff;
    --quiet: #f8f1e7;
    --ink: #46403a;
    --ink-mid: #6a6058;
    --ink-soft: #776b61;
    --placeholder: #a3937f;
    --line: #efe6da;
    --line-strong: #e3d7c8;
    --accent: #a35540;
    --accent-deep: #8c4a39;
    --accent-soft: #fbeee7;
    --apricot: #edb6a4;
    --danger: #a83c2c;
    /* 土曜に使う青（日曜の朱色と同じくらいの濃さで並べる） */
    --saturday: #1f62aa;
    --danger-soft: #faeae6;
    --danger-line: #f0cec5;
    --radius: 16px;
}

* {
    -webkit-tap-highlight-color: rgba(163, 85, 64, 0.10);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    -webkit-text-size-adjust: 100%;
    /* ダブルタップ拡大を切り、タップ反応の遅延をなくす */
    touch-action: manipulation;
}

#formArea {
    display: none;
    padding: 20px 16px 24px;
    /* 横向き時のノッチ・角丸を避ける */
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
}

.pageShell {
    max-width: 560px;
    margin: 0 auto;
}

/* ---------- ヘッダー ---------- */

.pageHead {
    padding: 0 4px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--accent);
}

h1 {
    font-size: 22px;
    line-height: 1.35;
    margin: 0 0 8px;
    letter-spacing: 0.01em;
}

.intro {
    margin: 0;
    color: var(--ink-mid);
    font-size: 13px;
    line-height: 1.7;
}

/* ---------- セクション ---------- */

.reserveForm {
    display: grid;
    gap: 12px;
}

.formSection {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 14px;
}

.sectionTitle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.sectionNum {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

/* ---------- フィールド共通 ---------- */

.field + .field,
.field + .fieldset,
.fieldset + .field {
    margin-top: 18px;
}

.fieldset {
    border: none;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.fieldLabel {
    display: block;
    padding: 0;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}

.subLabel {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-soft);
}

.badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    vertical-align: 2px;
}

.badgeRequired {
    background: var(--danger-soft);
    color: var(--danger);
}

.badgeOptional {
    background: var(--quiet);
    color: var(--ink-soft);
}

/* ---------- 入力欄 ---------- */

input[type="text"],
.dateTrigger,
textarea,
select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    min-height: 50px;
    padding: 13px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    /* 16px未満にするとiOSで拡大されるため下げない */
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    color: var(--ink);
    text-align: left;
}

input::placeholder {
    color: var(--placeholder);
}

textarea {
    min-height: 120px;
    line-height: 1.7;
    /* 高さだけ手動で伸ばせるようにする（横は伸ばさせない） */
    resize: vertical;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-mid) 50%), linear-gradient(135deg, var(--ink-mid) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

input:focus,
.dateTrigger:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(163, 85, 64, 0.14);
}

/* ---------- 補足メモ ---------- */

.note {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--accent-soft);
    font-size: 12px;
    line-height: 1.6;
    color: var(--ink-mid);
}

.note a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.noteQuiet {
    background: var(--quiet);
    color: var(--ink-soft);
}

/* ---------- 日時の候補 ---------- */

.candidate + .candidate {
    margin-top: 16px;
}

.candidateHead {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.candidateTitle {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}

.datetimeRow {
    display: grid;
    /* スマホ基準：常に縦積み。横並びは広い画面向けの上書きで行う */
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
}

.datetimeCol {
    min-width: 0;
}

/* ---------- 日付を選ぶボタン ---------- */

.dateTrigger {
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    -webkit-user-select: none;
    user-select: none;
}

.dateTrigger.isEmpty .dateTriggerText {
    font-weight: 400;
    color: var(--placeholder);
}

.dateTriggerText {
    /* 長い日付でも枠内に収める */
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.dateTrigger[aria-expanded="true"] {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(163, 85, 64, 0.14);
}

.dateTrigger.hasError {
    border-color: var(--danger-line);
    background: var(--danger-soft);
}

/* ---------- カレンダー ---------- */

/* カレンダーを開いている間は背面をスクロールさせない */
body.isPickerOpen {
    overflow: hidden;
}

.dpOverlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: rgba(70, 64, 58, 0.45);
}

.dpOverlay[hidden] {
    display: none;
}

.dpPanel {
    width: 100%;
    max-width: 340px;
    max-height: 100%;
    box-sizing: border-box;
    overflow: auto;
    padding: 14px 14px 12px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: 0 18px 44px rgba(70, 64, 58, 0.28);
}

.dpHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.dpMonth {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

.dpNav {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    font-size: 20px;
    line-height: 1;
    color: var(--ink-mid);
    cursor: pointer;
}

.dpNav:disabled {
    opacity: 0.35;
    cursor: default;
}

.dpWeek,
.dpGrid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.dpWeek {
    margin-bottom: 4px;
}

.dpWeek span {
    padding: 4px 0;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-soft);
}

.dpWeek .dpSun {
    color: var(--danger);
}

.dpWeek .dpSat {
    color: var(--saturday);
}

.dpDay {
    -webkit-appearance: none;
    appearance: none;
    min-height: 42px;
    padding: 0;
    /* 押せる日は白地＋枠線でボタンらしく見せ、選べない日は枠も地も消して沈める */
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(70, 64, 58, 0.05);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}

/* タップ・クリックの手応え */
.dpDay:active {
    background: var(--accent-soft);
    border-color: var(--apricot);
}

/* 曜日・祝日は選べるが、見て分かるように色を変える */
.dpDay.isSun,
.dpDay.isHoliday {
    color: var(--danger);
}

.dpDay.isSat {
    color: var(--saturday);
}

.dpDay:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.dpDay[aria-disabled="true"],
.dpDay[aria-disabled="true"].isSun,
.dpDay[aria-disabled="true"].isSat,
.dpDay[aria-disabled="true"].isHoliday,
.dpDay[aria-disabled="true"]:active {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    color: var(--placeholder);
    opacity: 0.55;
    cursor: default;
}

.dpDay.isToday {
    border-color: var(--apricot);
    box-shadow: inset 0 0 0 1px var(--apricot);
}

.dpDay.isSelected {
    box-shadow: none;
}

.dpDay.isSelected,
.dpDay.isSelected.isSun,
.dpDay.isSelected.isSat,
.dpDay.isSelected.isHoliday {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.dpNote {
    margin: 10px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--quiet);
    font-size: 11px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.dpFoot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}

.dpClear,
.dpClose {
    -webkit-appearance: none;
    appearance: none;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 10px;
    border: 1px solid var(--line-strong);
    background: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-mid);
    cursor: pointer;
}

.dpClose {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

/* ---------- 第二・第三候補の折りたたみ ---------- */

.optionalCandidates {
    margin-top: 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    padding: 0 12px;
}

.optionalCandidates summary {
    display: flex;
    -webkit-user-select: none;
    user-select: none;
    align-items: center;
    gap: 4px;
    min-height: 48px;
    list-style: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.optionalCandidates summary::-webkit-details-marker {
    display: none;
}

.summaryText::before {
    content: "＋";
    margin-right: 6px;
    font-weight: 700;
}

.optionalCandidates[open] .summaryText::before {
    content: "−";
}

.optionalCandidates[open] {
    padding-bottom: 16px;
    border-style: solid;
    background: #fdfaf5;
}

/* ---------- メニュー選択カード ---------- */

.choiceGroup {
    display: grid;
    gap: 8px;
}

.choiceCard {
    display: flex;
    -webkit-user-select: none;
    user-select: none;
    align-items: flex-start;
    gap: 12px;
    min-height: 48px;
    padding: 13px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}

.choiceCard input[type="radio"] {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    accent-color: var(--accent);
}

.choiceBody {
    display: block;
    min-width: 0;
}

.choiceName {
    display: block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--ink);
}

.choicePrice {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-soft);
}

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    vertical-align: 1px;
}

/* 選択状態（:has 非対応環境向けに .isSelected も併用） */
.choiceCard:has(input:checked),
.choiceCard.isSelected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent) inset;
}

/* ---------- チップ選択 ---------- */

.chipGroup {
    /* 1行につき1つ、横幅いっぱいに並べる */
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.chip {
    position: relative;
    display: flex;
    -webkit-user-select: none;
    user-select: none;
    align-items: center;
    justify-content: center;
    /* label は既定が content-box のため、padding が幅に加算されないようにする */
    box-sizing: border-box;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-mid);
    cursor: pointer;
}

.chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    inset: 0;
}

.chip:has(input:checked),
.chip.isSelected {
    border-color: var(--accent);
    background: var(--apricot);
    color: var(--ink);
}

.chip:has(input:focus-visible) {
    box-shadow: 0 0 0 3px rgba(163, 85, 64, 0.22);
}

/* ---------- エラー ---------- */

.formError {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--danger-line);
    border-radius: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;
}

.formError[hidden] {
    display: none;
}

/* ---------- 送信 ---------- */

.submitBar {
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    background: var(--bg);
}

button {
    width: 100%;
    min-height: 54px;
    padding: 15px 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 12px rgba(163, 85, 64, 0.22);
}

button:active:not(:disabled) {
    background: var(--accent-deep);
    box-shadow: 0 2px 6px rgba(163, 85, 64, 0.22);
}

button:disabled {
    background: var(--line-strong);
    color: var(--ink-soft);
    box-shadow: none;
}

.submitNote {
    margin: 8px 0 0;
    text-align: center;
    font-size: 11px;
    color: var(--ink-soft);
}

/* ---------- 読み込み・エラー画面 ---------- */

.center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* dvh 非対応環境向けに vh を先に置く */
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
    text-align: center;
    color: var(--ink-mid);
    font-size: 14px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error {
    color: var(--danger);
    font-weight: 600;
    line-height: 1.7;
}

#doneArea {
    display: none;
    text-align: center;
    padding: 40px 0;
}

/* ---------- テストモード（ローカル確認時のみ表示される） ---------- */

.testBanner {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px dashed var(--danger-line);
    border-radius: 10px;
    background: var(--danger-soft);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.6;
    color: var(--danger);
    text-align: center;
}

.testPreview {
    margin: 14px 0 0;
    padding: 12px;
    border-radius: 10px;
    background: var(--ink);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.7;
    color: #fdf6ec;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ------------------------------------------------------------------
   ここまでがスマホ用の基準スタイル。
   以下はタブレット・PCで開かれた場合のフォールバックのみ。
   ------------------------------------------------------------------ */

@media (min-width: 600px) {
    #formArea {
        padding-top: 40px;
        padding-bottom: 40px;
    }

    /* 画面に余裕があるときだけ日付と時間を横並びにする */
    .datetimeRow {
        grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    }

    /* 指で押す前提の大きさは不要になるため、少し詰める */
    .chipGroup {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2s;
    }
}
