:root {
  --bg: #faf7f2;
  --ink: #4a3b33;
  --muted: #7a6a5f;
  --soft: #5f5047;
  --card: #ffffff;
  --line: #f1ebe2;
  --chip: #f2ece2;
  --green: #4f7f2b;
  --green-ink: #3f6a1f;
  --soon-ink: #a8461f;
  --soon-bg: #fbe9dc;
  --danger: #b3382c;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--green-ink); }
a:hover { color: #2c4d14; }

button, input { font: inherit; color: inherit; }

#app { max-width: 480px; margin: 0 auto; }

.view {
  padding: 24px 22px 28px;
  padding-left: max(22px, env(safe-area-inset-left));
  padding-right: max(22px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
}
.view.with-bar { padding-bottom: 0; }
.privacy { padding-bottom: 40px; }
.privacy ul { margin: 0; padding-left: 1.2em; }
.privacy p { margin: 0 0 6px; }

.dev-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #4a3b33;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
}

.loading { text-align: center; color: var(--muted); padding: 28px 12px; margin: 0; }
.loading.small { padding: 8px 12px; font-size: 12px; }

.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.kicker { font-size: 12px; font-weight: 700; color: var(--green); }
.title { margin: 4px 0 0; font-size: 26px; font-weight: 900; line-height: 1.3; }
.title.sm { font-size: 24px; margin: 0; }

.pill-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--chip);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.section-title { margin: 0; font-size: 15px; font-weight: 900; }

/* 味わいマップ */
.map-card { background: var(--card); border-radius: 22px; padding: 12px; }
.map { position: relative; width: 100%; aspect-ratio: 1 / 1; background: #f6f1e9; border-radius: 16px; overflow: hidden; }
.map-hint { margin: 2px 4px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.axis { position: absolute; background: #e6ddd0; }
.axis-v { left: 50%; top: 11%; bottom: 11%; width: 1.5px; }
.axis-h { top: 50%; left: 9%; right: 9%; height: 1.5px; }
.axis-label { position: absolute; font-size: 11px; font-weight: 900; color: var(--muted); pointer-events: none; }
.axis-label.top, .axis-label.bottom { left: 0; right: 0; text-align: center; }
.axis-label.top { top: 4px; }
.axis-label.bottom { bottom: 4px; }
.axis-label.left { left: 6px; top: 50%; margin-top: -18px; }
.axis-label.right { right: 8px; top: 50%; margin-top: -18px; }
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-lines line { stroke: #b9a898; stroke-width: 1; }
/* a は豆の中心の 1 点。豆と名前を子に持ち、どちらを押しても詳細へ */
.map-mark { position: absolute; width: 0; height: 0; color: var(--green-ink); text-decoration: none; }
.map-bean {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.map-label {
  position: absolute;
  display: block;
  width: max-content;
  padding: 2px 13px 2px 3px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 900;
  overflow-wrap: anywhere;
  visibility: hidden;
  text-shadow: -1.5px 0 #f6f1e9, 1.5px 0 #f6f1e9, 0 -1.5px #f6f1e9, 0 1.5px #f6f1e9,
    -1.5px -1.5px #f6f1e9, 1.5px -1.5px #f6f1e9, -1.5px 1.5px #f6f1e9, 1.5px 1.5px #f6f1e9;
}
.map-label.placed { visibility: visible; }
/* 見た目より縦に広い押せる範囲（高さ 44px 以上） */
.map-label::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
.map-chev { position: absolute; right: 3px; top: 2px; }
.map-label-out { display: block; font-size: 11px; color: var(--muted); }
.map-mark.dim .map-bean, .map-mark.dim .map-label { opacity: 0.5; }
.map-mark:focus-visible { outline: none; }
.map-mark:focus-visible .map-label, .map-mark:focus-visible .map-bean { outline: 2px solid var(--green-ink); border-radius: 6px; }

/* 豆の一覧 */
.bean-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bean-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  background: var(--card);
  border-radius: 18px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--ink);
}
.bean-card svg { flex-shrink: 0; }
.bean-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bean-name { font-size: 15px; font-weight: 900; overflow-wrap: anywhere; }
.bean-desc { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.badge {
  font-size: 11px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--chip);
  color: var(--soft);
}
.badge-soon { color: var(--soon-ink); background: var(--soon-bg); }
.badge-out { color: #fff; background: #8a7b70; }
.status-pending { color: var(--green-ink); background: #eef4e6; }
.status-cancelled { color: var(--muted); }

.card { background: var(--card); border-radius: 22px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.status-card { align-items: flex-start; font-size: 14px; }
.status-card p { margin: 0; }
.muted { color: var(--muted); }

/* ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn.wide { width: 100%; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { color: #fff; }
.btn-primary:disabled { background: #b9c4ae; cursor: not-allowed; }
.btn-ghost { background: var(--chip); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 2px var(--danger); }

.bottom-bar {
  position: sticky;
  bottom: 0;
  margin: auto -22px 0;
  padding: 12px 22px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--line);
}
.bottom-bar .btn { width: 100%; }

.top-row { min-height: 44px; display: flex; align-items: center; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

/* 詳細 */
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 0 8px; text-align: center; }
.hero-circle {
  width: 150px; height: 150px; border-radius: 50%;
  background: #f1e6dc;
  display: flex; align-items: center; justify-content: center;
}
.hero-kind { font-size: 12px; font-weight: 700; color: var(--muted); }
.hero-name { margin: 0; font-size: 28px; font-weight: 900; line-height: 1.3; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.plain-section { display: flex; flex-direction: column; gap: 8px; }
.about { margin: 0; font-size: 14px; line-height: 1.9; color: var(--soft); white-space: pre-line; overflow-wrap: anywhere; }
.taste-row { display: flex; justify-content: space-between; align-items: center; min-height: 28px; font-size: 15px; font-weight: 700; gap: 8px; }
.taste-strength { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.pips { display: flex; gap: 3px; }
.pip { width: 10px; height: 10px; border-radius: 3px; }

.qty-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qty-btn {
  min-height: 56px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 16px;
  border: none;
  background: var(--card);
  cursor: pointer;
}
.qty-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--green); }
.qty-main { display: block; font-size: 14px; font-weight: 900; }
.qty-sub { font-size: 13px; color: var(--muted); }
.qty-total { margin: 4px 0 0; font-size: 13px; font-weight: 700; color: var(--soft); }

/* 入力 */
.summary { flex-direction: row; align-items: center; gap: 12px; padding: 14px; border-radius: 20px; }
.summary svg { flex-shrink: 0; }
.summary-text { flex: 1; min-width: 0; }
.summary-sub { font-size: 13px; color: #5a4c43; }
.form { display: flex; flex-direction: column; gap: 14px; padding: 6px 0 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 700; }
.input {
  width: 100%;
  min-height: 48px;
  font-size: 16px; /* 16px 未満だと iOS が入力時に拡大する */
  padding: 11px 12px;
  border: none;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}
.input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--danger); }
.static-box { font-size: 15px; font-weight: 700; background: #fff; border-radius: 10px; padding: 12px; }
.note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.note.center { text-align: center; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.field-error, .form-error { margin: 0; font-size: 13px; font-weight: 700; color: var(--danger); }
.field-error:empty, .form-error:empty { display: none; }
.info-msg { margin: 0; font-size: 13px; font-weight: 700; color: var(--green-ink); }
.info-msg:empty { display: none; }
.consent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
}
.consent input { width: 24px; height: 24px; flex-shrink: 0; accent-color: var(--green); }

/* 完了 */
.done { align-items: center; justify-content: center; text-align: center; gap: 18px; }
.done .title { margin: 0; }
.done-check { width: 76px; height: 76px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; }
.done-card { width: 100%; text-align: left; gap: 8px; font-size: 14px; padding: 16px; border-radius: 20px; }
.done-row { display: flex; justify-content: space-between; gap: 12px; }
.done-row b { text-align: right; overflow-wrap: anywhere; }

/* 履歴 */
.order { gap: 6px; padding: 16px; border-radius: 20px; }
.order-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order .btn { margin-top: 6px; align-self: flex-start; }
.erase { margin-top: 18px; padding-top: 18px; border-top: 1px solid #ece4d8; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; font-weight: 700; }

/* 確認ダイアログ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(74, 59, 51, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
}
.dialog { width: 100%; max-width: 380px; background: #fff; border-radius: 22px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.dialog-title { margin: 0; font-size: 17px; font-weight: 900; }
.dialog-body { margin: 0; font-size: 14px; line-height: 1.8; color: var(--soft); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* 商品画像（サイズは先に確保して、読み込み中もガタつかせない） */
.pimg { display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: #f1e6dc; overflow: hidden; }
.pimg img { display: block; width: 100%; height: 100%; }
.pimg-list { width: 56px; height: 56px; border-radius: 14px; }
.pimg-list img { object-fit: cover; }
.pimg-thumb { width: 48px; height: 48px; border-radius: 12px; }
.pimg-thumb img { object-fit: cover; }
.pimg-hero { width: 100%; max-width: 360px; height: 280px; border-radius: 20px; background: #f6f1e9; }
.pimg-hero img { object-fit: contain; }
.order-bean { display: flex; align-items: center; gap: 10px; }
.done-card > .pimg { align-self: center; margin-bottom: 4px; }

[hidden] { display: none !important; }

/* ラインナップ上部のリンク・タブ */
.page-head { display: flex; flex-direction: column; gap: 10px; }
.head-links { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; background: var(--chip); border-radius: 999px; padding: 4px; }
.tab { min-height: 44px; border: none; border-radius: 999px; background: transparent; font-size: 14px; font-weight: 900; color: var(--soft); cursor: pointer; }
.tab[aria-selected="true"] { background: #fff; color: var(--green-ink); box-shadow: 0 1px 3px rgba(74, 59, 51, 0.15); }
.map-mark.faint .map-bean, .map-mark.faint .map-label { opacity: 0.3; }
.bean-why { font-size: 12px; color: var(--soft); line-height: 1.5; overflow-wrap: anywhere; }
.how-box { background: var(--chip); border-radius: 18px; padding: 14px 16px; font-size: 12px; color: var(--soft); line-height: 1.8; }
.how-box p { margin: 0; }
.how-box b { color: var(--ink); }
.text-btn { min-height: 44px; border: none; background: none; font-size: 13px; font-weight: 700; color: var(--green-ink); cursor: pointer; }
.invite { align-items: flex-start; font-size: 14px; }
.invite p { margin: 0; }
.overlap-band { margin: 2px 0 0; font-size: 12px; font-weight: 700; color: var(--green-ink); background: #eef4e6; border-radius: 12px; padding: 9px 12px; }

/* 味の記録 */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 700; color: var(--soft); }
.chip-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chip-btn { min-height: 44px; border: none; background: #fff; color: var(--ink); font-size: 14px; font-weight: 900; cursor: pointer; box-shadow: inset 0 0 0 1.5px #e6ddd0; }
.chip-btn[aria-pressed="true"] { box-shadow: none; }
.rating-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.seg { min-height: 48px; padding: 8px 10px; border: none; border-radius: 14px; background: #fff; font-size: 14px; font-weight: 900; color: var(--ink); cursor: pointer; box-shadow: inset 0 0 0 1.5px #e6ddd0; }
.seg[aria-pressed="true"] { background: #eef4e6; color: var(--green-ink); box-shadow: inset 0 0 0 2px var(--green); }
.field-group { display: flex; flex-direction: column; gap: 14px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px; border: none; border-radius: 16px; background: #fff; text-align: left; cursor: pointer; }
.pick[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--green); background: #f5f9ef; }
.pick .bean-name { flex: 1; min-width: 0; }
.rating-1 { color: var(--soft); }
.rating-2 { color: var(--soft); }
.rating-3 { color: var(--green-ink); background: #eef4e6; }
.rec .btn { margin-top: 6px; align-self: flex-start; }
.bean-card-text .badges { flex-direction: row; flex-wrap: wrap; align-items: flex-start; margin-top: 4px; }

/* ---- 楽しんでもらう追加（自分のマップ・新着・終売・味のことば） ---- */
.badge-new { color: #fff; background: var(--green); }
.badge-liked { color: var(--green-ink); background: #eef4e6; box-shadow: inset 0 0 0 1.5px var(--green); }
.badge-drank { color: var(--soft); background: var(--chip); box-shadow: inset 0 0 0 1.5px #cdbfae; }
.hero .badge-new { margin-top: -2px; }
.map-new { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 999px; font-size: 10px; color: #fff; background: var(--green); text-shadow: none; vertical-align: 1px; }
.drink-progress { margin: -4px 0 0; font-size: 13px; font-weight: 700; color: var(--soft); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.alert-cards { display: flex; flex-direction: column; gap: 8px; }
.alert-card { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 14px; border-radius: 18px; background: var(--soon-bg); color: var(--ink); text-decoration: none; }
.alert-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 14px; font-weight: 900; line-height: 1.5; overflow-wrap: anywhere; }
.new-card { gap: 6px; }
.new-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; color: var(--ink); text-decoration: none; }
.new-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.new-text .badge { margin-left: 8px; vertical-align: 2px; }

.my-map-section { display: flex; flex-direction: column; gap: 10px; }
.pref-line { margin: 0; font-size: 15px; font-weight: 900; color: var(--green-ink); background: #eef4e6; border-radius: 14px; padding: 10px 14px; overflow-wrap: anywhere; }
.my-dot { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0; border: none; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.my-dot-mark { display: flex; align-items: center; justify-content: center; padding: 3px; border-radius: 50%; }
.my-dot[aria-pressed="true"] .my-dot-mark { box-shadow: 0 0 0 2px var(--green), 0 0 0 4px #fff; }
.my-dot:focus-visible .my-dot-mark { outline: 2px solid var(--green-ink); }
.my-circle { display: block; border: 1.5px solid; border-radius: 50%; }
.my-detail { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; min-height: 52px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--soft); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.legend-mark { display: inline-flex; align-items: center; justify-content: center; width: 24px; }

.taste-pick-list { display: flex; flex-direction: column; gap: 8px; }
.taste-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.taste-eg { margin: 0 0 0 6px; font-size: 12px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }

.guide-intro { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.8; color: var(--soft); }
.guide-intro p { margin: 0; }
.wheel-box { display: flex; justify-content: center; }
.wheel { width: 100%; max-width: 340px; height: auto; }
.wheel-sector { cursor: pointer; outline: none; }
.wheel-sector path { stroke: #fff; stroke-width: 2; }
.wheel-sector.on path { stroke: var(--ink); stroke-width: 3.5; }
.wheel-sector:focus-visible path { stroke: var(--ink); stroke-width: 3.5; stroke-dasharray: 6 3; }
.guide-chips { justify-content: center; }
.guide-detail { gap: 8px; }
.guide-cat { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.guide-eg { margin: 0; font-size: 14px; line-height: 1.8; color: var(--soft); overflow-wrap: anywhere; }
.guide-sub { margin: 4px 0 0; font-size: 13px; font-weight: 900; }
.guide-bean { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 8px 14px; border-radius: 14px; background: var(--chip); color: var(--ink); text-decoration: none; }
.guide-chips .chip-btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2.5px var(--ink); }

/* ひとこと（励まし）。下から出て数秒で消える。動きを減らす設定のときは動かさない */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: calc(100% - 32px);
  max-width: 440px;
  min-height: 44px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 20px rgba(74, 59, 51, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
