/* ============================================================
   デザイントークン
   - bg   : あたたかいクリームピンク
   - primary : ビビッドピンク(CTA・見出し)
   - accent  : 紙吹雪イエロー(バッジ・アクセント)
   - mint    : 補色のミント(成功状態などに控えめに)
   - ink     : 深いプラム系の黒(本文)
   ============================================================ */
:root {
  --bg: #fff6f2;
  --card: #ffffff;
  --ink: #2b2140;
  --muted: #8a8296;
  --primary: #ff6f91;
  --primary-dark: #e6537a;
  --accent: #ffc93c;
  --mint: #6fe7b8;
  --line: #f0dfe3;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 24px -12px rgba(43, 33, 64, 0.25);
  --font-display: "Zen Maru Gothic", sans-serif;
  --font-body: "Zen Kaku Gothic New", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── ヘッダー / ポイントゲージ(シグネチャー要素) ─────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 246, 242, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  background: none;
  font-size: 20px;
  color: var(--ink);
  width: 32px;
  flex-shrink: 0;
}

.gauge {
  flex: 1;
  min-width: 0;
}

.gauge-track {
  height: 10px;
  border-radius: 999px;
  background: #f4e4e9;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 4px;
}

.gauge-remaining {
  font-weight: 700;
  color: var(--primary-dark);
}

.cart-btn {
  position: relative;
  background: var(--card);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ── 共通ビュー ─────────────────────────────────────────── */
.view {
  padding: 20px 16px 100px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  margin: 28px 0 12px;
}

/* ── ローディング / エラー ──────────────────────────────── */
#view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  gap: 14px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 4px solid var(--line);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

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

.loading-text,
.error-box {
  color: var(--muted);
  font-size: 14px;
}

.error-box {
  margin-top: 40vh;
  text-align: center;
}

/* ── ホーム / ヒーロー ──────────────────────────────────── */
.hero {
  padding: 30px 4px 10px;
  position: relative;
}

.hero::before {
  content: "🎈 🎊 ✨";
  position: absolute;
  top: -6px;
  right: 0;
  font-size: 20px;
  letter-spacing: 6px;
  opacity: 0.85;
}

.hero-eyebrow {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 6px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.3;
  font-weight: 900;
  margin: 0 0 12px;
  color: var(--ink);
}

.hero-copy {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

/* ── カテゴリグリッド ───────────────────────────────────── */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.category-card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-align: left;
  display: flex;
  flex-direction: column;
}

.category-card-image {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ffe1ea, #ffd9a0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.category-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-card-name {
  padding: 10px 12px 12px;
  font-size: 13px;
  font-weight: 700;
}

/* ── リクエスト欄 ───────────────────────────────────────── */
.request-block {
  margin-top: 32px;
  border-top: 1px dashed var(--line);
  padding-top: 18px;
}

.request-toggle {
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.request-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.request-form textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  min-height: 70px;
  resize: vertical;
  background: var(--card);
}

.request-feedback {
  color: var(--mint);
  font-weight: 700;
  font-size: 13px;
  margin: 0;
}

/* ── カテゴリページ / 商品グリッド ──────────────────────── */
.category-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  margin: 10px 0 18px;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.product-card {
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-card-image {
  aspect-ratio: 1 / 1;
  background: #f4e9e5;
}

.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.product-card-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.product-card-cost {
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 700;
}

.product-card-btn {
  margin-top: auto;
  background: var(--primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 8px 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.product-card-btn:active {
  transform: scale(0.96);
}

.product-card-btn[data-state="added"] {
  background: var(--mint);
  color: var(--ink);
}

.product-card-btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

/* ── 商品詳細ビュー ─────────────────────────────────────── */
.view#view-product {
  padding: 0 0 100px;
}

.product-detail-image {
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #ffe1ea, #ffd9a0);
  width: 100%;
}

.product-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-detail-body {
  padding: 20px 16px 0;
}

.product-detail-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 900;
  margin: 0 0 8px;
  line-height: 1.4;
}

.product-detail-cost {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 16px;
}

.product-detail-description {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  white-space: pre-wrap;
  margin: 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.product-detail-body .btn {
  margin-top: 18px;
}

.product-detail-body .btn[data-state="added"] {
  background: var(--mint);
  color: var(--ink);
}

/* ── ボトムシート(カート) ──────────────────────────────── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 64, 0.4);
  z-index: 30;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 30px rgba(43, 33, 64, 0.25);
  z-index: 31;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 4px auto 12px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 12px;
}

.cart-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-item-image {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: #f4e9e5;
  overflow: hidden;
  flex-shrink: 0;
}

.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-cost {
  font-size: 12px;
  color: var(--primary-dark);
}

.cart-item-remove {
  background: none;
  color: var(--muted);
  font-size: 18px;
  padding: 4px 8px;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
  font-size: 14px;
}

.cart-summary strong {
  font-size: 18px;
  color: var(--primary-dark);
}

/* ── ボタン共通 ─────────────────────────────────────────── */
.btn {
  width: 100%;
  border-radius: 999px;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 700;
  margin-top: 14px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--accent);
  color: var(--ink);
}

.btn-ghost {
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
}

/* ── 確定ダイアログ ─────────────────────────────────────── */
.dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 48px);
  max-width: 340px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  z-index: 41;
  text-align: center;
}

.dialog-title {
  font-weight: 700;
  margin: 0 0 4px;
}

.dialog-body {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.dialog-actions .btn {
  margin-top: 0;
}

/* ── 完了画面 ───────────────────────────────────────────── */
#view-complete {
  min-height: 90vh;
  display: flex;
  align-items: center;
}

.complete-box {
  width: 100%;
  text-align: center;
}

.complete-emoji {
  font-size: 40px;
  margin: 0 0 6px;
}

.complete-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  margin: 0 0 24px;
}

.complete-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.complete-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

.complete-item:last-child {
  border-bottom: none;
}

.complete-total {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 14px;
  padding: 0 4px;
}

.complete-total strong {
  color: var(--primary-dark);
  font-size: 18px;
}
