/* ============================================================
   Journal：UX 重視の版（2026-11-17）。手帳の形（リング・ページ・縦のタブ）はやめた。
   手帳版は git の binder ブランチにある。
   ============================================================ */
:root {
  --font: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --font-title: var(--font);
  --nav-h: 62px;
}
[data-theme="cute"] {
  --font-title: "Zen Maru Gothic", var(--font);
  --bg: #FBF3F1; --card: #FFFFFF; --ink: #43302F; --sub: #9A8381; --line: #F1E3E1;
  --accent: #C8647C; --accent-ink: #FFFFFF; --soft: #F9E6EA; --field: #F6ECEA;
  --r-card: 18px; --r-ctl: 999px; --r-thumb: 14px;
  --shadow: 0 1px 2px rgb(120 60 70 / .06), 0 6px 16px -8px rgb(120 60 70 / .18);
}
[data-theme="chic"] {
  --bg: #F2EDE3; --card: #FFFCF6; --ink: #2B231D; --sub: #8B7F71; --line: #E6DDCC;
  --accent: #2B231D; --accent-ink: #F3E6C8; --soft: #E9E0CF; --field: #EAE3D5;
  --r-card: 10px; --r-ctl: 8px; --r-thumb: 6px;
  --shadow: 0 1px 2px rgb(60 40 20 / .07), 0 6px 16px -8px rgb(60 40 20 / .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  min-height: 100dvh; padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; font-feature-settings: "palt";
  overflow-x: clip;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
main, .top > * { max-width: 560px; margin-left: auto; margin-right: auto; }

/* ---------- 上：見出し・検索・絞り込み（スクロールしても残る） ---------- */
.top {
  position: sticky; top: 0; z-index: 5; padding: env(safe-area-inset-top) 16px 8px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.bar { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 0 10px; }
.today { margin: 0 0 2px; font-size: 12px; letter-spacing: .06em; color: var(--sub); }
.bar h1 { font-family: var(--font-title); font-size: 26px; font-weight: 700; margin: 0; letter-spacing: .04em; line-height: 1.2; }
.icon-btn { width: 44px; height: 44px; margin-right: -8px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 13px; width: 18px; height: 18px; color: var(--sub); }
#q { width: 100%; height: 44px; padding: 0 14px 0 40px; border: 0; border-radius: var(--r-ctl); background: var(--field); font-size: 16px; }
#q:focus, .field input:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.chips { display: flex; gap: 8px; margin: 10px -16px 0; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 36px; padding: 0 16px; border: 0; border-radius: var(--r-ctl); font-size: 14px; white-space: nowrap;
  background: var(--card); color: var(--sub); box-shadow: inset 0 0 0 1px var(--line); }
.chip[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: none; font-weight: 500; }
.chip small { font-size: 11px; opacity: .7; margin-left: 4px; }

/* ---------- 一覧 ---------- */
main { padding: 6px 16px 0; }
.items, .timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { position: relative; border-radius: var(--r-card); }
/* 横になぞると下から出てくる帯 */
.under { position: absolute; inset: 0; border-radius: var(--r-card); display: flex; align-items: center; gap: 8px; padding-left: 20px;
  background: var(--soft); color: var(--accent); font-size: 14px; font-weight: 500; }
[data-theme="chic"] .under { color: var(--ink); }
.under svg { width: 20px; height: 20px; stroke-width: 2.2; }
.item.armed .under { background: var(--accent); color: var(--accent-ink); }
.card {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px; min-height: 76px;
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
  touch-action: pan-y; transition: transform .22s cubic-bezier(.2, .9, .3, 1); user-select: none; -webkit-user-select: none;
}
.card.dragging { transition: none; }
.card:active:not(.dragging) { transform: scale(.985); }
.thumb { width: 60px; height: 60px; flex-shrink: 0; border-radius: var(--r-thumb); overflow: hidden; display: grid; place-items: center;
  background: var(--k-tint, var(--soft)); color: var(--ink); font-family: var(--font-title); font-size: 22px; font-weight: 700; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.body { flex: 1; min-width: 0; padding-top: 1px; }
.title { font-size: 16px; font-weight: 500; line-height: 1.45; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sub { font-size: 13px; color: var(--sub); line-height: 1.55; margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 12px; color: var(--sub); }
.kchip { display: inline-block; font-size: 11px; line-height: 20px; padding: 0 9px; border-radius: var(--r-ctl); white-space: nowrap;
  background: var(--k-tab, var(--soft)); color: var(--ink); }
.memline { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 13px; color: var(--accent); }
[data-theme="chic"] .memline { color: #8A4A2F; }
.memline svg { width: 14px; height: 14px; flex-shrink: 0; }
.memline span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* チェック：大きく押しやすく */
.check { flex-shrink: 0; align-self: center; width: 44px; height: 44px; margin-right: -4px; border: 0; background: none; padding: 0; display: grid; place-items: center; }
.check i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  border: 1.6px solid color-mix(in srgb, var(--sub) 55%, transparent); color: transparent; transition: background .15s, border-color .15s; }
.check svg { width: 17px; height: 17px; stroke-width: 2.6; }
.check[aria-pressed="true"] i { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); animation: pop .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); } }
.item.is-done .thumb, .item.is-done .body { opacity: .55; }
.done-head { margin-top: 8px; }
.done-head button { display: flex; align-items: center; gap: 6px; width: 100%; height: 40px; border: 0; background: none; padding: 0 4px; font-size: 13px; color: var(--sub); }
.done-head svg { width: 16px; height: 16px; transition: transform .2s; }
.done-head button[aria-expanded="true"] svg { transform: rotate(90deg); }
.empty { text-align: center; color: var(--sub); font-size: 14px; line-height: 1.9; padding: 56px 16px; }
.empty b { display: block; font-family: var(--font-title); font-size: 17px; color: var(--ink); margin-bottom: 6px; }
.empty .primary { margin-top: 18px; height: 46px; padding: 0 24px; border: 0; border-radius: var(--r-ctl); background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 500; }

/* ---------- 思い出（タイムライン） ---------- */
.mem-summary { font-size: 13px; color: var(--sub); padding: 2px 4px 0; }
.mem-month { font-family: var(--font-title); font-size: 17px; font-weight: 700; padding: 14px 4px 0; letter-spacing: .04em; }
.mem { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; }
.mem-photo { display: block; }
.mem-photo img { display: block; width: 100%; max-height: 260px; object-fit: cover; }
.mem-in { padding: 12px 14px 14px; }
.mem-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); }
.mem-title { font-size: 16px; font-weight: 500; line-height: 1.5; margin-top: 4px; overflow-wrap: anywhere; }
.mem-text { margin: 6px 0 0; font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.mem-add { margin-top: 8px; height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-ctl); background: var(--soft); font-size: 13px; }

/* ---------- 下のナビ ---------- */
.nav {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: 1fr 84px 1fr; align-items: center; justify-items: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 -1px 0 var(--line);
}
.nav-btn { width: 100%; height: 100%; border: 0; background: none; display: grid; place-items: center; align-content: center; gap: 2px; font-size: 11px; color: var(--sub); }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn[aria-current="page"] { color: var(--accent); font-weight: 700; }
[data-theme="chic"] .nav-btn[aria-current="page"] { color: var(--ink); }
.nav-add { width: 60px; height: 60px; margin-top: -26px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -6px color-mix(in srgb, var(--accent) 75%, transparent), 0 0 0 5px var(--bg); }
[data-theme="chic"] .nav-add { border-radius: 18px; }
.nav-add svg { width: 28px; height: 28px; stroke-width: 2.2; }
.nav-add:active { transform: scale(.94); }

/* ---------- 下から出る画面 ---------- */
.sheet-dlg {
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; padding: 8px 20px 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--card); color: var(--ink); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
[data-theme="chic"] .sheet-dlg { border-radius: 14px 14px 0 0; }
.sheet-dlg[open] { animation: up .28s cubic-bezier(.2, .9, .3, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-dlg::backdrop, .ask-dlg::backdrop { background: rgb(40 25 25 / .34); }
.dlg-grip { width: 38px; height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 18%, transparent); margin: 2px auto 14px; }
.sheet-dlg h2 { font-family: var(--font-title); font-size: 19px; font-weight: 700; margin: 0 0 6px; letter-spacing: .04em; }
.label { font-size: 12px; color: var(--sub); letter-spacing: .06em; margin: 18px 0 8px; }
.hint { font-size: 12px; color: var(--sub); margin: 6px 0 0; }
.field { display: block; font-size: 12px; color: var(--sub); letter-spacing: .06em; margin-top: 14px; }
.field input, .field textarea { display: block; width: 100%; min-width: 0; margin-top: 6px; padding: 0 14px; height: 46px; border: 0; border-radius: 12px; background: var(--field); font-size: 16px; }
[data-theme="chic"] .field input, [data-theme="chic"] .field textarea { border-radius: 8px; }
.field textarea { height: auto; padding: 11px 14px; line-height: 1.6; resize: none; }
.field input::placeholder, .field textarea::placeholder, #q::placeholder { color: color-mix(in srgb, var(--sub) 75%, transparent); }
.err { color: #B23A48; font-size: 12px; margin: 6px 0 0; }
.fetch-status { min-height: 18px; margin: 6px 0 0; font-size: 12px; color: var(--sub); }
.fetch-status.ok { color: #3E7A5C; }
.fetch-status.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px;
  border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.paste-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; margin-top: 8px; border: 0; border-radius: 12px;
  background: var(--soft); font-size: 15px; font-weight: 500; }
.paste-btn svg { width: 19px; height: 19px; }
.preview { display: flex; align-items: flex-end; gap: 10px; margin-top: 8px; }
.preview img { width: 104px; height: 78px; object-fit: cover; border-radius: 10px; background: var(--line); }
.link-btn { border: 0; background: none; padding: 4px 0; font-size: 12px; color: var(--sub); text-decoration: underline; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.seg button { flex: 1 1 auto; min-width: 4.5em; height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-ctl); font-size: 14px; white-space: nowrap;
  background: var(--field); color: var(--sub); }
.seg button[aria-checked="true"] { background: var(--k-tab, var(--accent)); color: var(--ink); font-weight: 700; }
#typeSeg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--k-tab); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .08); }
.swatch-btn[aria-checked="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
/* 下のボタンはいつも見える位置に */
.dlg-btns { position: sticky; bottom: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin: 20px -20px 0; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--card); box-shadow: 0 -1px 0 var(--line); }
.grow { flex: 1; }
.dlg-btns button { height: 46px; padding: 0 18px; border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--sub); font-size: 15px; white-space: nowrap; }
.dlg-btns .primary { background: var(--accent); color: var(--accent-ink); padding: 0 28px; font-weight: 500; }
.dlg-btns .danger { color: #B23A48; flex-basis: 100%; order: -1; text-align: left; padding-left: 0; height: 32px; font-size: 14px; }

/* ---------- 詳細 ---------- */
.detail-img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 14px; margin-bottom: 14px; }
.detail-kind { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--sub); }
.detail-title { font-size: 21px !important; line-height: 1.45; margin: 8px 0 4px !important; overflow-wrap: anywhere; }
.detail-note { font-size: 15px; line-height: 1.8; margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-rows { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 14px 0 0; font-size: 14px; }
.detail-rows dt { color: var(--sub); font-size: 12px; padding-top: 2px; }
.detail-rows dd { margin: 0; overflow-wrap: anywhere; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.acts > * { display: flex; align-items: center; justify-content: center; gap: 6px; height: 48px; border: 0; border-radius: 12px; background: var(--field);
  font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none; white-space: nowrap; }
.acts svg { width: 18px; height: 18px; }
.acts .main { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); }
.detail-mem { margin-top: 18px; padding: 14px; border-radius: 14px; background: var(--soft); }
.detail-mem h3 { font-family: var(--font-title); font-size: 14px; margin: 0 0 6px; }
.detail-mem p { margin: 0; font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-mem .mem-photo img { border-radius: 10px; margin-bottom: 8px; }

/* ---------- 思い出を書く ---------- */
.mem-for { margin: 0 0 10px; font-size: 13px; color: var(--sub); }
.mem-photo-pick { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.mem-photo-pick img { width: 128px; height: 96px; object-fit: cover; border-radius: 10px; }
.photo-btn { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px; border-radius: var(--r-ctl); cursor: pointer; font-size: 14px; background: var(--soft); color: var(--ink); }
.photo-btn svg { width: 18px; height: 18px; }

/* ---------- 設定 ---------- */
.theme-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px; border: 0; border-radius: 14px; background: var(--field); font-size: 14px; }
.theme-opt[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.theme-opt i { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
.kind-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kind-list li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border-radius: 12px; background: var(--field); font-size: 14px; }
.kind-list small { color: var(--sub); font-size: 12px; }
.kind-list button { margin-left: auto; height: 34px; padding: 0 14px; border: 0; border-radius: var(--r-ctl); background: var(--card); font-size: 13px; }
.kind-list .add { justify-content: center; background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--sub); width: 100%; border: 0; min-height: 48px; border-radius: 12px; }

/* ---------- 確かめる ---------- */
.ask-dlg { width: min(320px, calc(100vw - 48px)); padding: 26px 22px 18px; border: 0; border-radius: 26px; text-align: center; background: var(--card); color: var(--ink);
  box-shadow: 0 24px 60px -18px rgb(60 20 30 / .45); }
[data-theme="chic"] .ask-dlg { border-radius: 14px; }
.ask-dlg[open] { animation: askPop .32s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes askPop { from { transform: scale(.8) translateY(10px); opacity: 0; } }
.ask-icon { width: 64px; height: 64px; margin: -4px auto 10px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); }
.ask-icon svg { width: 46px; height: 46px; }
.ai-paper { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.ai-fold { fill: var(--soft); stroke: var(--accent); stroke-width: 2; }
.ai-eye { fill: var(--ink); stroke: none; }
.ai-mouth { stroke: var(--ink); stroke-width: 1.8; }
.ai-cheek { fill: #F4A6B8; stroke: none; opacity: .75; }
[data-theme="chic"] .ai-cheek { display: none; }
.ask-dlg h2 { font-family: var(--font-title); font-size: 16px; font-weight: 700; line-height: 1.6; margin: 0 0 6px; overflow-wrap: anywhere; }
.ask-dlg p { font-size: 13px; line-height: 1.8; color: var(--sub); margin: 0; }
.ask-btns { display: flex; gap: 10px; margin-top: 20px; }
.ask-btns button { flex: 1; height: 46px; border-radius: var(--r-ctl); border: 0; font-size: 14px; white-space: nowrap; background: var(--field); color: var(--ink); }
.ask-btns .primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.ask-btns .primary.danger { background: #C9566C; color: #fff; }

/* ---------- お知らせ ---------- */
.toast { position: fixed; z-index: 20; left: 0; right: 0; margin: 0 auto; bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; width: fit-content; max-width: min(440px, calc(100vw - 32px)); padding: 10px 10px 10px 18px;
  border-radius: 26px; background: var(--ink); color: var(--card); font-size: 13.5px; line-height: 1.5; box-shadow: 0 10px 28px -10px rgb(0 0 0 / .5); animation: up .25s ease-out; }
.toast span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast button { flex-shrink: 0; height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--card); color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap; }

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

/* 狭い画面でも、下から出る画面の中身が横にはみ出さないように */
.sheet-dlg { max-width: min(560px, 100vw); }
.acts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.acts > * { min-width: 0; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; }
#detailBody, .detail-mem, .detail-rows dd { min-width: 0; max-width: 100%; }
/* 一覧の列は画面の幅より広がらない（長い 1 行の思い出があると、カードごと横に伸びていた） */
.items, .timeline { grid-template-columns: minmax(0, 1fr); }
.card, .mem { min-width: 0; }
