/* くちろぐ（口内炎トラッカー）— Claude Design 成果物に忠実なスタイル
   トーン: 温かみのあるクリーム + テラコッタ。やわらかく清潔。スマホ縦・片手前提。 */

:root {
  --bg: #F4ECDE;
  --surface: #FFFDF8;
  --surface-warm: #FBF4E8;
  --primary: #C2674A;
  --primary-d: #A8543A;
  --primary-soft: #F6E6DD;
  --ink: #3B342B;
  --muted: #8A7C68;
  --muted-2: #A2937C;
  --muted-3: #B0A188;
  --line: #EFE5D3;
  --line-2: #E7DBC4;
  --line-3: #EADDC6;
  --track: #F0E7D6;
  --chip: #F2EADB;
  --tab-track: #EFE3CF;
  --heal: #5E7E62;
  --heal-bg: #EAF1E5;
  --heal-bd: #CFE0C8;
  --disabled: #DCCBB2;
  --pain-grad: linear-gradient(90deg,#93B39A,#BBBE7E,#E1C16B,#DD9F5B,#C46B4A);
  --shadow: 0 2px 12px rgba(120,90,50,0.05);
  --shadow-primary: 0 6px 16px rgba(194,103,74,0.34);
  --font-round: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', system-ui, sans-serif;
  --font-body: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #E9DEC9;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
button, input, textarea { font-family: var(--font-body); }

@keyframes screenIn { from { transform: translateY(10px); } to { transform: none; } }
@keyframes cardIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes mm-pin-pop { 0% { transform: translateY(-8px) scale(0.4); opacity: 0; } 60% { transform: translateY(0) scale(1.12); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes mm-dot-in { from { opacity: 0; transform: scale(0.2); } to { opacity: 1; transform: scale(1); } }

#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.screen { display: flex; flex-direction: column; height: 100%; animation: screenIn .32s ease both; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px; }
.scroll::-webkit-scrollbar { width: 0; }
.center { text-align: center; }

/* ───── ヘッダー ───── */
.home-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 12px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-icon { width: 40px; height: 40px; border-radius: 13px; background: var(--primary); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 10px rgba(194,103,74,0.32); }
.brand-name { font-family: var(--font-round); font-weight: 700; font-size: 20px; line-height: 1; }
.brand-tag { font-size: 11px; color: var(--muted-2); margin-top: 4px; }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line-2); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.icon-btn:active { background: var(--chip); }

.topbar { display: flex; align-items: center; gap: 13px; padding: 18px 16px 8px; flex-shrink: 0; }
.topbar-title { font-family: var(--font-round); font-weight: 700; font-size: 17px; }
.topbar-title.big { font-size: 19px; }
.topbar-step { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.hint.center { text-align: center; margin: 8px 0 12px; }

/* ───── サマリカード ───── */
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 14px 16px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow); margin: 8px 0 18px; }
.stat-thumb { width: 96px; flex-shrink: 0; }
.stat-cap { font-size: 12.5px; color: var(--muted); }
.stat-num-row { font-family: var(--font-round); font-weight: 700; margin: 2px 0; display: flex; align-items: baseline; }
.stat-num { font-size: 38px; color: var(--primary); line-height: 1; }
.stat-unit { font-size: 15px; color: var(--muted); margin-left: 5px; }
.stat-sub { font-size: 11.5px; color: var(--muted-3); }

.section-label { font-family: var(--font-round); font-weight: 700; font-size: 13px; color: var(--muted); margin: 0 4px 12px; letter-spacing: 0.04em; }

/* ───── エピソードカード ───── */
.ep-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 17px; margin-bottom: 14px; box-shadow: var(--shadow); animation: cardIn .35s ease both; }
.ep-card.is-sel { box-shadow: 0 0 0 2.5px var(--primary), var(--shadow); }
.sel-overlay { position: absolute; inset: 0; border-radius: 24px; cursor: pointer; z-index: 5; }
.sel-check { position: absolute; top: 15px; right: 15px; z-index: 6; width: 27px; height: 27px; border-radius: 50%; background: var(--surface); border: 2px solid #D8CCB6; display: flex; align-items: center; justify-content: center; color: var(--surface); font-size: 15px; }
.sel-check.on { background: var(--primary); border-color: var(--primary); }
.ep-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ep-head-l { display: flex; gap: 13px; align-items: center; }
.ep-thumb { width: 58px; flex-shrink: 0; background: var(--surface-warm); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.ep-painrow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ep-painlabel { font-size: 12px; color: var(--muted); }
.pain-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.ep-zone { font-family: var(--font-round); font-weight: 700; font-size: 16.5px; }
.ep-onset { font-size: 12px; color: var(--muted-2); margin-top: 3px; }
.ep-days { color: var(--primary); font-weight: 500; margin-left: 6px; }
.badge-merged { font-size: 10.5px; color: var(--muted); background: var(--chip); border: 1px solid var(--line-2); padding: 4px 9px; border-radius: 20px; white-space: nowrap; }

.pain-block { margin-top: 15px; }
.pain-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.mini-label { font-size: 13px; color: var(--muted); }
.pain-badge { font-family: var(--font-round); font-weight: 700; font-size: 13px; color: var(--surface); min-width: 30px; text-align: center; padding: 3px 10px; border-radius: 20px; }

.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 6px; outline: none; cursor: pointer; background: var(--pain-grad); }
.slider::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; }
.slider::-moz-range-track { height: 8px; border-radius: 6px; background: transparent; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); box-shadow: 0 2px 6px rgba(120,70,40,.28); cursor: pointer; }
.slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); box-shadow: 0 2px 6px rgba(120,70,40,.28); cursor: pointer; }

.size-row { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; }
.seg { display: flex; gap: 7px; }
.seg-btn { width: 48px; height: 36px; border-radius: 12px; border: 1.5px solid #EBE0CE; background: var(--surface-warm); color: var(--muted); font-family: var(--font-round); font-weight: 700; font-size: 14px; cursor: pointer; transition: all .15s; }
.seg-btn.on { background: var(--primary); color: var(--surface); border-color: var(--primary); }

.expand-btn { margin-top: 14px; width: 100%; background: none; border: none; border-top: 1px solid var(--track); padding-top: 11px; display: flex; justify-content: center; align-items: center; gap: 6px; color: var(--muted-2); font-size: 12px; cursor: pointer; }
.ep-detail { margin-top: 8px; display: flex; flex-direction: column; gap: 11px; }
.detail-row { display: flex; gap: 10px; font-size: 13px; align-items: flex-start; }
.detail-k { color: var(--muted-2); width: 52px; flex-shrink: 0; }
.detail-photo { width: 120px; height: 90px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line-2); }
.detail-btn-row { display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.heal-btn { background: var(--heal-bg); color: var(--heal); border: 1px solid var(--heal-bd); border-radius: 15px; padding: 10px 20px; font-family: var(--font-round); font-weight: 700; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.edit-btn { background: var(--surface-warm); color: var(--muted); border: 1px solid var(--line-2); border-radius: 15px; padding: 10px 20px; font-family: var(--font-round); font-weight: 700; font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.edit-btn:active { background: var(--chip); }

/* ───── 空状態 ───── */
.empty { text-align: center; padding: 34px 24px 20px; }
.empty-map { width: 120px; margin: 0 auto 18px; opacity: 0.85; }
.empty-title { font-family: var(--font-round); font-weight: 700; font-size: 17px; color: #7A6A52; }
.empty-sub { font-size: 13px; color: var(--muted-2); margin-top: 8px; line-height: 1.7; }

/* ───── アクションバー ───── */
.actionbar { flex-shrink: 0; padding: 14px 16px 18px; display: flex; gap: 10px; background: linear-gradient(to top, var(--bg) 78%, rgba(244,236,222,0)); }
.actionbar.merge { flex-direction: column; background: var(--bg); border-top: 1px solid var(--line-3); }
.merge-hint { text-align: center; font-size: 12px; color: var(--muted); }
.action-row { display: flex; gap: 10px; }
.btn { height: 54px; border-radius: 18px; border: none; font-family: var(--font-round); font-weight: 700; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-grow { flex: 1; }
.btn-primary { background: var(--primary); color: var(--surface); box-shadow: var(--shadow-primary); }
.btn-primary:active { background: var(--primary-d); }
.btn-primary.is-disabled { background: var(--disabled); box-shadow: none; cursor: default; }
.btn-ghost { padding: 0 22px; background: var(--surface); border: 1.5px solid var(--line-2); color: var(--muted); font-size: 15px; }
.btn-merge { flex: 0 0 auto; padding: 0 20px; }
.btn-merge:disabled { opacity: .5; cursor: default; }
.action-row .btn { flex: 1; }
.action-row .btn-ghost { flex: 0 0 auto; }
.plus { font-size: 22px; line-height: 1; }

/* ───── マップ ───── */
.map-frame { width: 100%; }
.mm-wrap { width: 100%; }
.mm-label { font-family: var(--font-round); font-weight: 700; letter-spacing: 0.02em; paint-order: stroke; stroke: rgba(255,250,243,0.82); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.mm-zone { transition: fill .15s ease, stroke .15s ease; }
.mm-dot { transform-origin: center; animation: mm-dot-in .4s ease both; pointer-events: none; }
.mm-pin { animation: mm-pin-pop .35s cubic-bezier(.34,1.56,.64,1) both; pointer-events: none; }

.map-under { margin-top: 8px; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 12px; }
.zone-pill { display: flex; align-items: center; gap: 9px; background: var(--primary-soft); border: 1.5px solid #E3B9A6; padding: 9px 18px; border-radius: 30px; }
.zone-pill-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.zone-pill span:last-child { font-family: var(--font-round); font-weight: 700; font-size: 15px; color: var(--primary-d); }
.zone-none { font-size: 13px; color: var(--muted-3); }

/* ───── 原因・メモ ───── */
.loc-preview { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px; margin: 6px 0 18px; }
.loc-thumb { width: 74px; flex-shrink: 0; }
.loc-zone { font-family: var(--font-round); font-weight: 700; font-size: 17px; margin: 3px 0 6px; }
.link { background: none; border: none; color: var(--primary); font-size: 12.5px; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.merge-info { background: var(--chip); border: 1px solid var(--line-3); border-radius: 18px; padding: 14px 16px; margin-bottom: 18px; display: flex; gap: 11px; font-size: 13px; color: #7A6A52; line-height: 1.7; }
.merge-info-ic { flex-shrink: 0; margin-top: 1px; }
.merge-info b { color: var(--primary-d); font-weight: 500; }

.field-label { font-family: var(--font-round); font-weight: 700; font-size: 13px; color: var(--muted); margin: 0 2px 11px; }
.input { width: 100%; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 15px; padding: 14px 16px; font-size: 15px; color: var(--ink); margin-bottom: 22px; }
.input:focus { outline: none; border-color: var(--primary); }
.textarea { min-height: 74px; resize: none; font-size: 14px; line-height: 1.6; }
input[type=date].input { font-family: var(--font-round); }

.cause-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.cause-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 15px 6px; border-radius: 17px; border: 1.5px solid #EBE0CE; background: var(--surface); cursor: pointer; transition: all .15s; }
.cause-card.on { background: var(--primary-soft); border-color: var(--primary); }
.cause-name { font-size: 12.5px; color: var(--ink); font-weight: 500; }

.photo-label { display: block; cursor: pointer; margin-bottom: 8px; }
.photo-empty { width: 100%; height: 88px; border: 1.5px dashed #D6C7A8; border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted-2); font-size: 14px; }
.photo-filled { width: 100%; height: 150px; border-radius: 16px; background-size: cover; background-position: center; border: 1.5px solid var(--line-2); }

/* ───── ダッシュボード ───── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-title { font-family: var(--font-round); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.card-sub { font-size: 12px; color: var(--muted-2); margin-bottom: 12px; }
.heat-map { width: 74%; max-width: 260px; margin: 0 auto; }
.zone-bars { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.zbar-row { display: flex; align-items: center; gap: 11px; }
.zbar-name { width: 96px; flex-shrink: 0; font-size: 12.5px; }
.zbar-track { flex: 1; height: 9px; background: var(--track); border-radius: 6px; overflow: hidden; }
.zbar-fill { display: block; height: 100%; background: #D98E6E; border-radius: 6px; }
.zbar-num { width: 18px; text-align: right; font-size: 12px; color: var(--muted); }

.stat-duo { display: flex; gap: 12px; margin-bottom: 14px; }
.hero-card { flex: 1.4; background: var(--primary); border-radius: 24px; padding: 18px; box-shadow: 0 4px 14px rgba(194,103,74,0.26); }
.hero-cap { font-size: 12.5px; color: #F4D9CE; }
.hero-num-row { font-family: var(--font-round); font-weight: 700; display: flex; align-items: baseline; margin-top: 4px; }
.hero-num { font-size: 46px; color: var(--surface); line-height: 1; }
.hero-unit { font-size: 17px; color: #F4D9CE; margin-left: 5px; }
.hero-sub { font-size: 11.5px; color: #F0CBBC; margin-top: 8px; }
.mini-card { flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; display: flex; flex-direction: column; justify-content: center; box-shadow: var(--shadow); }
.mini-num-row { font-family: var(--font-round); font-weight: 700; }
.mini-num { font-size: 34px; }

.month-bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; }
.mbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 7px; height: 100%; }
.mbar-num { font-family: var(--font-round); font-weight: 700; font-size: 12px; color: var(--muted); }
.mbar { width: 64%; min-height: 4px; background: linear-gradient(to top, var(--primary), #D98E6E); border-radius: 7px 7px 3px 3px; }
.mbar-label { font-size: 11px; color: var(--muted-2); }

.cbar-row { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.cbar-name { width: 74px; flex-shrink: 0; font-size: 12.5px; }
.cbar-track { flex: 1; height: 13px; background: var(--track); border-radius: 7px; overflow: hidden; }
.cbar-fill { display: block; height: 100%; border-radius: 7px; transition: width .4s; }
.cbar-num { width: 18px; text-align: right; font-size: 12px; color: var(--muted); }

.ep-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.ep-chips::-webkit-scrollbar { height: 0; }
.ep-chip { flex-shrink: 0; padding: 8px 14px; border-radius: 13px; border: 1.5px solid #EBE0CE; background: var(--surface); color: var(--muted); font-size: 12.5px; font-family: var(--font-round); font-weight: 700; cursor: pointer; }
.ep-chip.on { background: var(--primary); color: var(--surface); border-color: var(--primary); }
.ep-chip-sub { font-weight: 400; font-size: 11px; margin-left: 5px; opacity: 0.8; }

.curve { width: 100%; height: auto; }
.curve-grid { stroke: var(--track); stroke-width: 1; }
.curve-axis { fill: #B6A88F; font-size: 10px; font-family: var(--font-round); }
.curve-line { stroke: #D98E6E; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.curve-empty { fill: var(--muted-3); font-size: 12px; font-family: var(--font-round); }
.curve-legend { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 10px; font-size: 11px; color: var(--muted-2); }
.lg { display: flex; align-items: center; gap: 6px; }
.lg-dot { border-radius: 50%; background: var(--muted-2); display: inline-block; }
.lg-dot.sm { width: 7px; height: 7px; }
.lg-dot.lg-big { width: 11px; height: 11px; }
.lg-grad { width: 38px; height: 7px; border-radius: 4px; background: linear-gradient(90deg,#93B39A,#E1C16B,#C46B4A); display: inline-block; }
.reset-btn { background: none; border: none; color: #C6B79D; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 11px 16px; border-radius: 13px; border: 1.5px solid var(--line-2); background: var(--surface); color: var(--muted); font-family: var(--font-round); font-weight: 700; font-size: 13px; cursor: pointer; }
.chip-btn:active { background: var(--chip); }

/* ───── トースト ───── */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--surface-warm); padding: 12px 22px; border-radius: 30px; font-family: var(--font-round); font-weight: 700; font-size: 14px; box-shadow: 0 8px 22px rgba(0,0,0,0.22); z-index: 50; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .25s; }
.toast.show { opacity: 1; animation: toastIn .3s ease; }
