/* MITONOA フロントエンド — 明るい近未来（確定デザイン v2・明るめ）
   地: 明るい銀〜淡い青 / 面: 白ガラス / 文字: 墨 / 差し色: 朱 #E8401E（発光）/ 補助: シアン #0098D6 */
:root {
  --ink: #17233a;
  --ink-soft: #3c4c66;
  --ink-faint: #8494ad;
  --accent: #e8401e;
  --accent-deep: #c93312;
  --cyan: #0098d6;
  --amber: #e8930c;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --line: rgba(120, 150, 190, 0.35);
  --shadow: 0 10px 30px rgba(38, 68, 110, 0.14);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Noto Sans JP", -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #dce8f5 0%, #eef4fb 55%, #f4f8fc 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--ink-faint); }
.small { font-size: 0.82rem; }
.center { text-align: center; }

/* ---------- ロゴ ---------- */
.logo-lockup { text-align: center; color: var(--ink); }
.logo-word {
  display: flex; align-items: center; justify-content: center; gap: 0.55em;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 700; letter-spacing: 0.24em; text-indent: 0.24em;
}
.logo-bar { display: inline-block; width: 1.1em; height: 2px; background: var(--ink); }
.logo-kana { letter-spacing: 0.62em; text-indent: 0.62em; color: var(--ink-soft); }
.logo-lockup--lg .logo-word { font-size: 1.55rem; }
.logo-lockup--lg .logo-kana { font-size: 0.72rem; margin-top: 0.45em; }
.logo-lockup--header .logo-word { font-size: 0.92rem; }
.logo-lockup--header .logo-kana { font-size: 0.5rem; margin-top: 0.15em; }
.logo-lockup--drawer { text-align: left; padding: 0.4rem 0.2rem 1rem; }
.logo-lockup--drawer .logo-word { justify-content: flex-start; font-size: 1.05rem; }
.logo-lockup--drawer .logo-kana { font-size: 0.58rem; margin-top: 0.3em; text-align: left; text-indent: 0.62em; }

/* ---------- アプリバー ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 0.5rem;
  padding: calc(env(safe-area-inset-top) + 0.45rem) 0.9rem 0.45rem;
  background: rgba(244, 248, 252, 0.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.appbar .logo-lockup { flex: 1; }
.appbar-spacer { width: 2.4rem; }
.icon-btn {
  width: 2.4rem; height: 2.4rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--glass);
  display: grid; place-items: center; cursor: pointer;
}
.burger { display: grid; gap: 4px; }
.burger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; }

/* ---------- ドロワー ---------- */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(23, 35, 58, 0.32);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
  width: min(78vw, 300px);
  padding: calc(env(safe-area-inset-top) + 1rem) 1.1rem 1rem;
  background: var(--glass-strong);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(-105%); transition: transform 0.28s ease;
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.drawer-item {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 0.55rem 0.6rem; border-radius: 12px; cursor: pointer; color: var(--ink);
}
.drawer-item:active, .drawer-item.current { background: rgba(0, 152, 214, 0.10); }
.drawer-name { display: block; font-size: 1.02rem; font-weight: 600; }
.drawer-desc { display: block; font-size: 0.74rem; color: var(--ink-faint); margin-top: 0.12rem; }
.drawer-rule { border: 0; border-top: 1px solid var(--line); margin: 0.9rem 0; }
#swipe-edge { position: fixed; left: 0; top: 0; bottom: 0; width: 22px; z-index: 45; }

/* ---------- 画面共通 ---------- */
#main { max-width: 560px; margin: 0 auto; padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 2rem); }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.screen-title { font-size: 1.25rem; margin: 0.4rem 0; letter-spacing: 0.06em; }
.section-label { font-size: 0.95rem; margin: 1.3rem 0 0.5rem; color: var(--ink-soft); }
.center-box { padding-top: 22dvh; display: grid; justify-items: center; gap: 1rem; }

.card {
  background: var(--glass);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem; margin-top: 1rem;
}
.card-title { margin: 0 0 0.6rem; font-size: 1.02rem; }
.field-label { display: block; font-size: 0.8rem; color: var(--ink-soft); margin: 0.85rem 0 0.35rem; }
.prev-note { float: right; color: var(--cyan); font-size: 0.72rem; }
input, select {
  width: 100%; padding: 0.72rem 0.8rem; font-size: 1rem; color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0, 152, 214, 0.18); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.form-msg { min-height: 1.2em; font-size: 0.85rem; color: var(--accent-deep); margin: 0.6rem 0 0; }
.form-msg.ok { color: #1d8a4e; }

/* ---------- ボタン ---------- */
.btn-primary {
  width: 100%; margin-top: 1rem; padding: 0.85rem;
  font-size: 1rem; font-weight: 700; color: #fff;
  background: linear-gradient(160deg, #2aa9e0, var(--cyan));
  border: 0; border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 152, 214, 0.35);
}
.btn-primary:active { transform: translateY(1px); }
.btn-block { display: block; text-align: center; text-decoration: none; }
.btn-accent {
  width: 100%; margin-top: 1rem; padding: 0.9rem;
  font-size: 1.05rem; font-weight: 700; color: #fff;
  background: linear-gradient(160deg, #ff6a4d, var(--accent));
  border: 0; border-radius: 14px; cursor: pointer;
  box-shadow: 0 8px 22px rgba(232, 64, 30, 0.42);
}
.btn-accent:active { transform: translateY(1px); }
.btn-sub {
  padding: 0.6rem 0.8rem; font-size: 0.85rem; color: var(--ink-soft);
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer;
}
.btn-small {
  padding: 0.45rem 0.8rem; font-size: 0.82rem; color: var(--ink-soft);
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.btn-link { background: none; border: 0; color: var(--cyan); font-size: 0.85rem; cursor: pointer; padding: 0.4rem 0; }
.btn-row { display: flex; gap: 0.7rem; }
.btn-half { flex: 1; margin-top: 0.4rem; }
button:disabled { opacity: 0.55; }

/* ---------- セグメント / チップ ---------- */
.segmented {
  display: flex; background: rgba(120, 150, 190, 0.16);
  border-radius: 12px; padding: 3px; gap: 3px;
}
.segmented button {
  flex: 1; padding: 0.55rem 0.3rem; font-size: 0.9rem; color: var(--ink-soft);
  background: transparent; border: 0; border-radius: 9px; cursor: pointer;
}
.segmented button.on {
  background: #fff; color: var(--ink); font-weight: 700;
  box-shadow: 0 2px 8px rgba(38, 68, 110, 0.18);
}
.segmented--lg button { padding: 0.85rem 0.3rem; font-size: 1.02rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  padding: 0.55rem 0.95rem; font-size: 0.92rem; color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer;
}
.chip.on {
  color: #fff; font-weight: 700; border-color: transparent;
  background: linear-gradient(160deg, #2aa9e0, var(--cyan));
  box-shadow: 0 4px 12px rgba(0, 152, 214, 0.35);
}

/* ---------- 入口 ---------- */
.entry-box { padding-top: 6dvh; }
.copy-main { text-align: center; font-size: 1.9rem; margin: 1.6rem 0 0.3rem; letter-spacing: 0.08em; }
.copy-sub { text-align: center; color: var(--ink-faint); font-weight: 300; margin: 0 0 0.6rem; letter-spacing: 0.06em; }
.once-note {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin: 1.2rem auto 0; padding: 0.5rem 0.9rem; width: fit-content;
  font-size: 0.8rem; color: var(--ink-soft);
  background: var(--glass); border: 1px solid var(--line); border-radius: 999px;
}
.once-note .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

/* ---------- カメラ ---------- */
.finder {
  position: relative; margin-top: 0.6rem; border-radius: 24px; overflow: hidden;
  aspect-ratio: 3 / 3.4; max-height: 52dvh; width: 100%;
  background: linear-gradient(165deg, #c9dcf2, #e8f1fa);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.camera-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.finder-corners { position: absolute; inset: 14px; pointer-events: none; }
.fc { position: absolute; width: 30px; height: 30px; border: 3px solid var(--cyan); opacity: 0.9; }
.fc-tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.fc-tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.fc-bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.fc-br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.scanline {
  position: absolute; left: 4%; right: 4%; top: 12%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  box-shadow: 0 0 12px var(--cyan); opacity: 0.75;
  animation: scan 3.2s ease-in-out infinite alternate;
}
@keyframes scan { from { top: 10%; } to { top: 88%; } }
@media (prefers-reduced-motion: reduce) { .scanline { animation: none; } }
.finder-hint {
  position: relative; z-index: 1; color: var(--ink-soft); font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.65); padding: 0.4rem 0.8rem; border-radius: 999px;
}
.shutter-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin-top: 1rem;
}
.shutter {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; flex: none;
}
.shutter-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 4px solid var(--accent);
  box-shadow: 0 0 18px rgba(232, 64, 30, 0.55), inset 0 0 10px rgba(232, 64, 30, 0.3);
}
.shutter-core {
  position: absolute; inset: 13px; border-radius: 50%;
  background: linear-gradient(160deg, #ff7357, var(--accent));
  box-shadow: 0 6px 16px rgba(232, 64, 30, 0.45);
}
.shutter:active .shutter-core { transform: scale(0.93); }
.shutter.busy { opacity: 0.5; pointer-events: none; }
.preselect { margin-top: 1.1rem; }

/* ---------- トレイ ---------- */
.tray-date {
  margin: 1.2rem 0 0.5rem; font-size: 0.9rem; font-weight: 700; color: var(--cyan);
  letter-spacing: 0.08em;
}
.tray-item {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  text-align: left; cursor: pointer; color: var(--ink);
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 6px 16px rgba(38, 68, 110, 0.10);
  padding: 0.85rem 0.95rem; margin-bottom: 0.55rem;
}
.tray-item.static { cursor: default; }
.tray-main { flex: 1; min-width: 0; }
.tray-merchant { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray-meta { font-size: 0.76rem; color: var(--ink-faint); margin-top: 0.15rem; }
.tray-amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.tag {
  display: inline-block; font-size: 0.68rem; padding: 0.14rem 0.5rem;
  border-radius: 999px; background: rgba(0, 152, 214, 0.12); color: #0077ad;
  margin-right: 0.35rem; vertical-align: 1px;
}
.status { font-size: 0.76rem; white-space: nowrap; }
.status.reading { color: var(--cyan); }
.status.candidate { color: var(--accent-deep); font-weight: 700; }
.status.confirmed { color: #1d8a4e; }
.status.duplicate, .status.error { color: var(--ink-faint); }
.sticky-note {
  display: inline-block; margin-top: 0.4rem; padding: 0.3rem 0.6rem;
  font-size: 0.78rem; color: #8a5a00;
  background: #fff3cf; border: 1px solid rgba(232, 147, 12, 0.45);
  border-radius: 6px; transform: rotate(-1.2deg);
  box-shadow: 0 3px 8px rgba(232, 147, 12, 0.25);
}

/* ---------- 候補カード: 確定シール ---------- */
.seal-btn {
  position: relative; display: block; margin: 1.4rem auto 0;
  width: 104px; height: 104px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer;
}
.seal-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 5px solid var(--accent);
  box-shadow: 0 0 22px rgba(232, 64, 30, 0.55), inset 0 0 14px rgba(232, 64, 30, 0.28);
}
.seal-ring::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%;
  border: 2px solid rgba(232, 64, 30, 0.65);
}
.seal-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 700; color: var(--accent); letter-spacing: 0.2em; text-indent: 0.2em;
}
.seal-btn:active .seal-ring { transform: scale(0.95); }
.seal-btn:disabled { opacity: 0.5; }
.seal-caption { text-align: center; color: var(--ink-soft); font-size: 0.85rem; margin-top: 0.5rem; }

/* ---------- 明細 ---------- */
.stmt-line {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  padding: 0.7rem 0.9rem; margin-bottom: 0.5rem;
}
.stmt-line .tray-main { flex: 1; }
.match-yes { color: #1d8a4e; font-size: 0.78rem; white-space: nowrap; }
.match-no { color: var(--amber); font-size: 0.78rem; white-space: nowrap; }

/* ---------- 月次帳面 ---------- */
#input-month { width: auto; padding: 0.45rem 0.6rem; font-size: 0.92rem; }
.summary-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0.45rem 0; border-bottom: 1px dashed var(--line);
}
.summary-row:last-child { border-bottom: 0; }
.summary-row strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.summary-row.small { font-size: 0.88rem; color: var(--ink-soft); }
.summary-row.small span:last-child { font-weight: 700; color: var(--ink); }
.recurring-row {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0;
  border-bottom: 1px dashed var(--line); font-size: 0.92rem;
}
.recurring-row:last-of-type { border-bottom: 0; }
.recurring-row .r-name { flex: 1; }
.recurring-form { display: flex; gap: 0.45rem; margin-top: 0.8rem; }
.recurring-form input { padding: 0.55rem 0.6rem; font-size: 0.9rem; }
.recurring-form #rec-name { flex: 2; }
.recurring-form #rec-day { flex: 1; }

/* ---------- プロフィール ---------- */
.profile-list { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem 1.1rem; margin: 0 0 1rem; }
.profile-list dt { color: var(--ink-faint); font-size: 0.85rem; }
.profile-list dd { margin: 0; font-weight: 600; word-break: break-all; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  transform: translateX(-50%); z-index: 80;
  max-width: min(92vw, 480px);
  background: rgba(23, 35, 58, 0.92); color: #fff;
  padding: 0.8rem 1.1rem; border-radius: 14px; font-size: 0.9rem;
  box-shadow: var(--shadow); text-align: center;
}
.toast button {
  margin-left: 0.7rem; color: #7fd4ff; background: none; border: 0;
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
}

/* ===== プランと料金・上限ボトムシート ===== */
.plan-current { font-size: 1.15rem; font-weight: 700; margin: 0.2rem 0; }
.plan-featured { border: 1px solid rgba(188, 63, 46, 0.45); box-shadow: 0 0 18px rgba(188, 63, 46, 0.18); }
.plan-badge {
  display: inline-block; margin: 0 0 0.4rem; padding: 0.1rem 0.6rem;
  border-radius: 999px; background: #bc3f2e; color: #fff;
  font-size: 0.78rem; font-weight: 700;
}
.plan-price { font-size: 1.5rem; font-weight: 800; margin: 0.3rem 0; }
.plan-per { font-size: 0.85rem; font-weight: 600; }
.btn-text {
  display: block; width: 100%; margin-top: 0.6rem; padding: 0.6rem;
  background: none; border: 0; color: inherit; font-size: 1rem; cursor: pointer;
  text-decoration: underline;
}
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 35, 0.45); z-index: 60;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: #fff; color: #1f2430;
  border-radius: 16px 16px 0 0; padding: 1.2rem 1.2rem 1.6rem;
  max-width: 560px; margin: 0 auto;
  box-shadow: 0 -8px 30px rgba(20, 24, 35, 0.25);
}
.sheet h3 { margin: 0 0 0.6rem; font-size: 1.1rem; }
.sheet-plan {
  border: 1px solid rgba(188, 63, 46, 0.4); border-radius: 10px;
  padding: 0.7rem 0.9rem; margin: 0.8rem 0;
}
