/* はこぶんで — 明るいパステルと、丸くてぷくっとした形
   文字の大きさ・コントラスト・フォーカス表示はデジタル庁デザインシステムの基準
   （本文16px以上・文字4.5:1以上・線やアイコン3:1以上）、動きはMaterial 3のスプリング換算値 */
:root {
  color-scheme: light;
  --bg: #FFF7EC;
  --surface: #FFFFFF;
  --ink: #3B3355;        /* 文字。背景(#FFF7EC)に対して約12:1 */
  --ink-sub: #5F5779;    /* 補足の文字。白に対して約6.6:1 */
  --line: #3B3355;
  --pink: #FF9FB8;
  --pink-soft: #FFE3EA;
  --mint: #8ED9B5;
  --mint-soft: #DDF5EA;
  --sky: #8CC7FF;
  --sky-soft: #E1F0FF;
  --lemon: #FFD66E;
  --lemon-soft: #FFF3C9;
  --lilac: #C7B2FF;
  --lilac-soft: #EEE7FF;
  --peach: #FFB38A;
  --danger: #B3261E;     /* エラー（赤）。白に対して約6.5:1 */
  --success: #1E6B45;    /* うまくいった（緑）。白に対して約6.6:1 */
  --radius: 20px;
  --pop: 0 4px 0 rgba(59, 51, 85, .9);
  --spatial: cubic-bezier(.38, 1.21, .22, 1);   /* M3 Expressive default spatial */
  --effects: cubic-bezier(.34, .8, .34, 1);     /* M3 Expressive default effects */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(#FFE3C4 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.4; margin: 0; font-weight: 900; }
.ic { flex: none; vertical-align: -0.2em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* デジタル庁デザインシステムのフォーカス表示：黄色と黒の2重 */
:focus-visible {
  outline: 3px solid #000;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px #FFD43D;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 104px);
}

/* 見出しの帯 */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 4px 0 16px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 900; letter-spacing: .02em; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  background: var(--lemon); border: 2.5px solid var(--line); box-shadow: 0 3px 0 var(--line);
}
.top h1 { font-size: 22px; }

/* カード */
.card {
  background: var(--surface);
  border: 2.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--pop);
  padding: 16px;
  margin-bottom: 20px;
}
.card h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.card .sub { color: var(--ink-sub); font-size: 15px; margin: 0; }
.tint-pink { background: var(--pink-soft); }
.tint-mint { background: var(--mint-soft); }
.tint-sky { background: var(--sky-soft); }
.tint-lemon { background: var(--lemon-soft); }
.tint-lilac { background: var(--lilac-soft); }

/* キャラとふきだし */
.stage { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 20px; }
.avatar-btn {
  border: 0; background: none; padding: 0; cursor: pointer; flex: none;
  animation: bob 2.4s var(--effects) infinite;
  border-radius: 24px;
}
.avatar-btn:active .avatar-svg { transform: scale(.94) rotate(-4deg); }
.avatar-svg { display: block; transition: transform 350ms var(--spatial); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.bubble {
  position: relative; flex: 1;
  background: var(--surface); border: 2.5px solid var(--line); border-radius: 22px;
  box-shadow: var(--pop);
  padding: 14px 16px; margin-bottom: 40px; font-size: 17px; font-weight: 700; min-height: 64px;
}
.bubble::before {
  content: ""; position: absolute; left: -14px; bottom: 18px;
  border: 8px solid transparent; border-right: 14px solid var(--line); border-left: 0;
}
.bubble::after {
  content: ""; position: absolute; left: -9px; bottom: 20.5px;
  border: 5.5px solid transparent; border-right: 10px solid var(--surface); border-left: 0;
}
.bubble .who { display: block; font-size: 14px; color: var(--ink-sub); font-weight: 700; }
.bubble .hint { display: block; font-size: 14px; color: var(--ink-sub); font-weight: 500; margin-top: 4px; }
.bubble.say { animation: say 500ms var(--spatial); }
@keyframes say { from { transform: scale(.9); } to { transform: scale(1); } }

/* 部屋の絵 */
.room-svg { display: block; width: 100%; height: auto; border: 2.5px solid var(--line); border-radius: 16px; background: #fff; }
.room-svg .ghost * { fill: transparent !important; stroke-dasharray: 4 4; opacity: .55; }
.room-svg .ghost .glow { display: none; }
.room-svg .pop { animation: popin 650ms var(--spatial) both; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes popin { from { transform: scale(.6); } to { transform: scale(1); } }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 14px; color: var(--ink-sub); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 12px; border-radius: 4px; border: 2px solid var(--line); display: inline-block; }
.legend i.dash { border-style: dashed; opacity: .7; }

/* 数字のまとめ */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  border: 2.5px solid var(--line); border-radius: 18px; padding: 12px; background: var(--surface);
  box-shadow: 0 3px 0 var(--line);
}
.stat .k { font-size: 14px; color: var(--ink-sub); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 22px; font-weight: 900; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 700; }
.stat .n { font-size: 14px; color: var(--ink-sub); }
.stat.wide { grid-column: 1 / -1; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border: 2.5px solid var(--line); border-radius: 999px;
  background: var(--surface); box-shadow: var(--pop);
  font-weight: 900; font-size: 16px; cursor: pointer; text-decoration: none;
  transition: transform 150ms var(--effects), box-shadow 150ms var(--effects);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--pink); }
.btn.mint { background: var(--mint); }
.btn.sky { background: var(--sky); }
.btn.lemon { background: var(--lemon); }
a.btn { color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 48px; padding: 0; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row > .grow { flex: 1; }

/* 下のタブ */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: min(528px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 2.5px solid var(--line); border-radius: 26px;
  box-shadow: var(--pop); padding: 6px; z-index: 10;
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 18px; text-decoration: none; color: var(--ink);
  font-size: 13px; font-weight: 700; min-height: 52px; justify-content: center;
}
.tabs a[aria-current="page"] { background: var(--lemon); }

/* 切りかえ（セグメント） */
.seg { display: flex; gap: 6px; background: var(--surface); border: 2.5px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg button {
  flex: 1; border: 0; background: none; border-radius: 999px; min-height: 44px;
  font-weight: 900; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button[aria-pressed="true"] { background: var(--sky); box-shadow: inset 0 0 0 2px var(--line); }

/* リスト */
.list { display: grid; gap: 12px; margin-bottom: 20px; }
.item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 2.5px solid var(--line); border-radius: 18px;
  box-shadow: 0 3px 0 var(--line); padding: 12px 14px;
  width: 100%; text-align: left; cursor: pointer;
}
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 900; font-size: 17px; overflow-wrap: anywhere; }
.item .meta { font-size: 14px; color: var(--ink-sub); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.item .contents { font-size: 15px; margin-top: 4px; overflow-wrap: anywhere; }
.item .price { font-weight: 900; font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.item .price small { display: block; font-size: 13px; font-weight: 700; color: var(--ink-sub); }
.item.done { background: #F6F4FA; }
.item.done .title { text-decoration: line-through; text-decoration-thickness: 2px; }
.badge {
  width: 44px; height: 44px; border-radius: 14px; border: 2.5px solid var(--line);
  display: grid; place-items: center; flex: none; font-weight: 900; font-size: 15px;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  border: 2px solid var(--line); font-size: 13px; font-weight: 700; background: var(--surface); white-space: nowrap;
}
.chip.packing { background: var(--lemon-soft); }
.chip.sent { background: var(--sky-soft); }
.chip.arrived { background: var(--mint-soft); }
.chip.ordered { background: var(--sky-soft); }
.check {
  width: 44px; height: 44px; flex: none; border-radius: 14px; border: 2.5px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.check[aria-pressed="true"] { background: var(--mint); }
.group-title { font-size: 16px; font-weight: 900; display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.group-title .chip { margin-left: auto; }
.empty { text-align: center; color: var(--ink-sub); padding: 16px 8px; border: 2.5px dashed var(--ink-sub); border-radius: 18px; margin-bottom: 20px; }

/* 検索 */
.search { position: relative; margin-bottom: 16px; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); }
.search input[type="search"] { padding-left: 46px; }

/* 入力 */
label.f { display: block; font-weight: 900; font-size: 15px; margin-bottom: 14px; }
label.f > span.l { display: block; margin-bottom: 4px; }
.f .help { display: block; font-weight: 500; font-size: 14px; color: var(--ink-sub); margin-top: 4px; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2.5px solid var(--line); border-radius: 14px; background: var(--surface);
  font-size: 16px; font-weight: 500;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.6; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { font-weight: 900; font-size: 15px; margin-bottom: 6px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px;
  border: 2.5px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-weight: 700;
}
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choices label:has(input:checked) { background: var(--lemon); box-shadow: inset 0 0 0 1px var(--line); }
.choices label:has(input:focus-visible) { outline: 3px solid #000; outline-offset: 2px; box-shadow: 0 0 0 6px #FFD43D; }
.swatches label { width: 44px; height: 44px; padding: 0; justify-content: center; }
.swatches label:has(input:checked) { box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px var(--line); }
.toggle { display: flex; align-items: flex-start; gap: 10px; font-weight: 700; margin-bottom: 12px; cursor: pointer; }
.toggle input { width: 24px; height: 24px; accent-color: #E26D86; flex: none; margin-top: 2px; }
.toggle small { display: block; font-weight: 500; color: var(--ink-sub); font-size: 14px; }

/* 見積もり */
.quote { display: grid; gap: 8px; margin: 4px 0 16px; }
.quote .opt { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border: 2.5px solid var(--line); border-radius: 14px; background: var(--surface); }
.quote .opt.best { background: var(--mint-soft); }
.quote .opt b { font-size: 18px; font-variant-numeric: tabular-nums; }
.quote .opt small { color: var(--ink-sub); font-size: 13px; display: block; }
.note { font-size: 14px; color: var(--ink-sub); }
.note a { color: var(--ink); }

/* 下から出る入力シート */
dialog#sheet {
  border: 2.5px solid var(--line); border-radius: 26px 26px 0 0; padding: 0;
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0;
  background: var(--bg); color: var(--ink); box-shadow: 0 -4px 0 var(--line);
}
dialog#sheet[open] { animation: sheet-up 500ms var(--spatial); }
dialog#sheet::backdrop { background: rgba(59, 51, 85, .45); }
@keyframes sheet-up { from { transform: translateY(40%); } to { transform: translateY(0); } }
.sheet-in { padding: 16px 16px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; max-height: 92dvh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 20px; }

/* お知らせ */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity 200ms var(--effects), transform 350ms var(--spatial);
  z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); }

/* ログイン */
.login { min-height: 80dvh; display: grid; place-items: center; text-align: center; }
.login .card { width: 100%; text-align: left; }
.login .err { color: var(--danger); font-weight: 700; min-height: 1.6em; }

/* 予算のバー */
.bar { height: 18px; border: 2.5px solid var(--line); border-radius: 999px; background: var(--surface); overflow: hidden; margin: 8px 0 4px; }
.bar i { display: block; height: 100%; background: var(--mint); border-right: 2.5px solid var(--line); transition: width 500ms var(--spatial); }
.bar.over i { background: var(--pink); }

.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px 12px; scrollbar-width: thin; }
.suggest button { flex: none; }

table.cmp { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.cmp th, table.cmp td { padding: 8px 6px; border-bottom: 2px dashed #D9D3E6; text-align: right; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp tr.best td { font-weight: 900; background: var(--mint-soft); }

@media (max-width: 420px) {
  .seg button .ic { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
