/* らくらく記帳 — 屋外でも読みやすい、大きな文字と押しやすいボタン */
:root {
  --paddy: #DDE7DA;        /* チャットの背景（田んぼの水の色） */
  --paper: #FFFFFF;        /* AIからの吹き出し */
  --seedling: #C6E6A8;     /* 自分が送った吹き出し */
  --ink: #1E2A22;          /* 文字 */
  --muted: #56645B;        /* 補足の文字 */
  --line: #C5D2C3;         /* 区切り線 */
  --leaf: #2D6A3E;         /* ボタン・強調 */
  --leaf-dark: #22512F;
  --leaf-soft: #E5F0E2;
  --ear: #E2A31B;          /* ⚠ お返事が必要（稲穂の色） */
  --ear-soft: #FDF3D8;
  --warn: #A3261C;         /* エラー */
  --bar: #F7FAF6;          /* 上下の帯 */
  --radius-bubble: 18px;
  --tap: 52px;             /* 押しやすいボタンの高さ */
  --font: 'BIZ UDPGothic', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Noto Sans CJK JP', Meiryo, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paddy);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ear); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; flex: none; }

.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
  background: var(--paddy);
}

/* ---------- 上の帯 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  min-height: 60px;
}
.topbar-icon { border-radius: 9px; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.topbar-title b { font-size: 18px; }
.topbar-title span { font-size: 14px; color: var(--muted); }
.topbar h2 { margin: 0; font-size: 19px; flex: 1; }
.icon-btn, .back-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: var(--tap); height: 48px; padding: 0 8px;
  border: 0; background: transparent; border-radius: 12px; color: var(--ink);
}
.back-btn { font-size: 16px; padding-left: 0; color: var(--leaf); font-weight: 700; }
.icon-btn svg { width: 28px; height: 28px; }

/* ---------- 今月の枚数などの帯 ---------- */
.strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 8px 14px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--muted);
}
.meter { display: flex; align-items: center; gap: 8px; }
.meter b { color: var(--ink); font-size: 15px; }
.meter-bar { width: 84px; height: 8px; border-radius: 4px; background: #D6E0D3; overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--leaf); border-radius: 4px; }
.meter.full .meter-bar i { background: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 6px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ear); animation: pulse 1.4s ease-in-out infinite; }
.pill-btn { border: 0; background: none; padding: 4px 0; color: var(--leaf); font-weight: 700; font-size: 14px; text-decoration: underline; }
@keyframes pulse { 50% { opacity: .3; } }

.ask-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 46px; border: 0;
  background: var(--ear); color: var(--ink); font-weight: 700; font-size: 16px;
}

/* ---------- チャット ---------- */
.feed {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 12px 12px 24px;
}
.day {
  display: flex; justify-content: center; margin: 18px 0 10px;
}
.day span {
  font-size: 13px; color: var(--paper); background: rgba(30, 42, 34, .45);
  padding: 2px 12px; border-radius: 999px;
}
.msg { display: flex; gap: 8px; margin: 8px 0; align-items: flex-end; }
.msg.me { justify-content: flex-end; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--leaf); color: #fff; display: grid; place-items: center; align-self: flex-start;
}
.avatar svg { width: 22px; height: 22px; }
.bubble {
  max-width: 84%;
  background: var(--paper);
  border-radius: 4px var(--radius-bubble) var(--radius-bubble) var(--radius-bubble);
  padding: 10px 14px;
  overflow-wrap: anywhere;
}
.msg.me .bubble {
  background: var(--seedling);
  border-radius: var(--radius-bubble) 4px var(--radius-bubble) var(--radius-bubble);
}
.bubble p { margin: 0; }
.bubble p + p { margin-top: 6px; }
.time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bubble-title { font-weight: 700; margin-bottom: 4px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 72px); gap: 4px; margin-top: 6px; }
.thumbs img, .thumbs .pdf { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #fff; }
.thumbs .pdf { display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }

/* 1日分の記帳の一覧（吹き出しの中） */
.entries { list-style: none; margin: 6px 0 0; padding: 0; }
.entry {
  display: grid; grid-template-columns: 1fr auto; gap: 0 10px;
  padding: 8px 0; border-top: 1px solid #E7ECE5;
  cursor: pointer;
}
.entry:first-child { border-top: 0; }
.entry-main { min-width: 0; }
.entry-vendor { font-weight: 700; }
.entry-sub { font-size: 14px; color: var(--muted); }
.entry-amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip {
  display: inline-block; font-size: 13px; line-height: 1.5; padding: 0 8px; border-radius: 999px;
  background: var(--leaf-soft); color: var(--leaf-dark); margin-right: 4px;
}
.chip.gray { background: #EEF0ED; color: var(--muted); }
.chip.warn { background: #FBE3E0; color: var(--warn); }
.chip.ear { background: var(--ear-soft); color: #6B4A00; }

/* ⚠ お返事が必要な記帳（この画面でいちばん目立たせるもの） */
.ask {
  margin: 8px 0 8px 44px;
  background: var(--paper);
  border: 3px solid var(--ear);
  border-radius: 16px;
  overflow: hidden;
}
.ask-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  background: var(--ear); color: var(--ink);
  padding: 6px 12px; font-weight: 700;
}
.ask-head small { font-weight: 400; font-size: 13px; }
.ask-body { padding: 10px 14px 4px; }
.ask-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ask-vendor { font-size: 18px; font-weight: 700; }
.ask-amount { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ask-desc { color: var(--muted); }
.ask-ai { margin-top: 4px; }
.ask-reason { font-size: 14px; color: var(--muted); margin-top: 2px; }
.ask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px 12px; }
.ask-actions .btn { min-height: var(--tap); }
.ask-actions .span2 { grid-column: 1 / -1; }
.ask-foot { display: flex; justify-content: flex-end; padding: 0 12px 10px; }
.ask.done { border-color: var(--line); }
.ask.done .ask-head { background: var(--leaf-soft); color: var(--leaf-dark); }
.ask-result { padding: 12px 14px; font-weight: 700; color: var(--leaf-dark); }
.collapse { animation: settle .35s ease-out; }
@keyframes settle { from { transform: scale(.98); opacity: .6; } to { transform: none; opacity: 1; } }

.limit-card { border-color: var(--warn); }
.limit-card .ask-head { background: var(--warn); color: #fff; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 8px 16px;
  border: 2px solid var(--leaf); border-radius: 12px;
  background: var(--paper); color: var(--leaf-dark); font-weight: 700; font-size: 16px;
  text-align: center; line-height: 1.3;
}
.btn.primary { background: var(--leaf); color: #fff; }
.btn.primary:active { background: var(--leaf-dark); }
.btn.quiet { border-color: var(--line); color: var(--ink); }
.btn.danger { border-color: var(--warn); color: var(--warn); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.link-btn { border: 0; background: none; color: var(--leaf); text-decoration: underline; padding: 8px 0; font-size: 15px; }

/* ---------- 下の送信欄 ---------- */
.composer {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 10px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--bar); border-top: 1px solid var(--line);
}
.compose-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 60px; border-radius: 16px;
  border: 2px solid var(--leaf); background: var(--paper); color: var(--leaf-dark);
  font-weight: 700; font-size: 18px; cursor: pointer;
}
.compose-btn.primary { background: var(--leaf); color: #fff; }
.compose-btn svg { width: 28px; height: 28px; }
.compose-btn:focus-within { outline: 3px solid var(--ear); outline-offset: 2px; }
.tray { background: var(--bar); border-top: 1px solid var(--line); padding: 10px 12px; }
.tray-thumbs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.tray-thumbs img, .tray-thumbs .pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; background: #fff; }
.tray-thumbs .pdf { display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.tray-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* ---------- メニュー・各画面 ---------- */
.panel { z-index: 5; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 14px 32px; background: var(--bar); }
.panel-body h3 { font-size: 18px; margin: 22px 0 8px; }
.panel-body h3:first-child { margin-top: 0; }
.panel-body p { margin: 0 0 10px; }
.note { font-size: 15px; color: var(--muted); }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list button {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  min-height: 62px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; text-align: left; font-size: 18px;
}
.menu-list button small { display: block; font-size: 14px; color: var(--muted); }
.menu-list button::after { content: ''; width: 10px; height: 10px; border-right: 2.5px solid var(--muted); border-top: 2.5px solid var(--muted); transform: rotate(45deg); flex: none; margin-right: 6px; }
.menu-list .danger-item { color: var(--warn); }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.month-nav b { font-size: 19px; }
.list-total { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 2px solid var(--ink); font-weight: 700; }
.list-group { font-size: 14px; color: var(--muted); margin: 14px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.plan-meter { background: var(--paper); border-radius: 14px; padding: 14px; margin-bottom: 14px; border: 1px solid var(--line); }
.plan-meter .big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-meter .meter-bar { width: 100%; height: 12px; margin-top: 8px; border-radius: 6px; }
.plan-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  padding: 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--paper); margin-bottom: 10px;
}
.plan-row.current { border-color: var(--leaf); }
.plan-row b { font-size: 19px; }
.plan-row .price { color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; background: var(--paper); border-radius: 14px; border: 1px solid var(--line); }
.switch-row b { font-size: 18px; }
.switch {
  position: relative; width: 66px; height: 38px; flex: none;
  border-radius: 999px; border: 0; background: #B9C6B6;
  transition: background .2s;
}
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--leaf); }
.switch[aria-checked="true"]::after { transform: translateX(28px); }
.help-steps { margin: 0; padding-left: 1.4em; }
.help-steps li { margin-bottom: 8px; }
.callout { background: var(--ear-soft); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }

/* ---------- 下から出るシート ---------- */
.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(30, 42, 34, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--bar); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-card h3 { margin: 0 0 10px; font-size: 19px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 14px; }
.detail { display: grid; grid-template-columns: 6em 1fr; gap: 6px 10px; margin: 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 700; }
.acc-group { font-size: 15px; color: var(--muted); margin: 16px 0 6px; }
.acc-list { display: grid; gap: 8px; }
.acc-btn {
  display: grid; grid-template-columns: 7.5em 1fr; gap: 10px; align-items: center; text-align: left;
  min-height: 54px; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--paper);
}
.acc-btn b { font-size: 17px; }
.acc-btn small { font-size: 13px; color: var(--muted); line-height: 1.4; }
.acc-btn.current { border-color: var(--leaf); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .btn { min-height: 46px; padding: 6px 14px; }
.photo-view { width: 100%; border-radius: 12px; background: #fff; }

/* ---------- 登録画面 ---------- */
.register { overflow-y: auto; }
.register-inner { padding: calc(env(safe-area-inset-top) + 36px) 20px 40px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand img { border-radius: 16px; }
.brand h1 { font-size: 28px; margin: 0; }
.lead { font-size: 18px; margin: 18px 0 24px; }
.register-form label { display: block; margin-bottom: 8px; }
.register-form input {
  width: 100%; height: 64px; padding: 0 16px;
  font-size: 30px; letter-spacing: .2em; text-align: center; font-variant-numeric: tabular-nums;
  border: 2px solid var(--line); border-radius: 14px; background: var(--paper);
}
.register-form input:focus { border-color: var(--leaf); outline: none; }
.register-form .btn { margin-top: 14px; min-height: 58px; font-size: 19px; }
.form-error { color: var(--warn); font-weight: 700; min-height: 1.6em; margin: 10px 0 0; }
.install-card { background: var(--paper); border: 3px solid var(--ear); border-radius: 16px; padding: 16px; margin-bottom: 22px; }
.install-card h2 { font-size: 19px; margin: 0 0 10px; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin-bottom: 6px; }
.code-show { font-size: 34px; font-weight: 700; letter-spacing: .15em; text-align: center; margin: 14px 0 4px; font-variant-numeric: tabular-nums; }

/* ---------- お知らせ ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  z-index: 20; max-width: min(92vw, 520px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 16px;
  box-shadow: 0 6px 20px rgba(30, 42, 34, .25);
}
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.loading { text-align: center; color: var(--muted); padding: 24px; }

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