/* かいもの — 共通スタイル（モバイルファースト） */
:root {
  --bg: #f6f7f5; --panel: #ffffff; --fg: #1d2420; --muted: #6b746f; --line: #e3e7e2;
  --accent: #1f9d55; --accent-fg: #ffffff; --accent-soft: #e6f5ec; --danger: #c9442e;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131715; --panel: #1c2220; --fg: #eef2ee; --muted: #93a098; --line: #2b3330;
          --accent: #35c477; --accent-fg: #0d1a12; --accent-soft: #1d3327; --danger: #f07560; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
       padding-top: env(safe-area-inset-top, 0px); min-height: 100dvh; }
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; border: 1px solid var(--line); background: var(--panel);
       border-radius: 999px; padding: 10px 18px; font-weight: 600; text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.big { font-size: 18px; padding: 14px 28px; min-height: 56px; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; font-weight: 500; }
.btn:active { transform: translateY(1px); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: transparent;
           border-radius: 50%; font-size: 22px; text-decoration: none; color: var(--fg); }
.iconbtn:hover { background: var(--accent-soft); }
.hint { color: var(--muted); font-size: 13px; }

/* ホーム */
.hero { text-align: center; padding: 48px 0 24px; }
.hero .logo { font-size: 64px; line-height: 1; }
.hero h1 { font-size: 32px; margin: 8px 0 4px; letter-spacing: .04em; }
.hero .lead { color: var(--muted); margin: 0 auto 28px; max-width: 32em; }
.recent h2 { font-size: 15px; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }
.recent-list { list-style: none; margin: 0; padding: 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.recent-list li { display: flex; align-items: center; border-top: 1px solid var(--line); }
.recent-list li:first-child { border-top: 0; }
.recent-list a { flex: 1; padding: 14px 16px; color: var(--fg); text-decoration: none; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-list a strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list a span { font-size: 12px; color: var(--muted); }
.recent-list .rm { border: 0; background: none; color: var(--muted); width: 44px; height: 44px; font-size: 20px; }

/* リスト画面 */
body.list { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 2px; padding: 6px 8px;
          background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar .title { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; font-size: 18px; font-weight: 700; padding: 8px 10px;
                 border-radius: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .title:hover { background: var(--accent-soft); }
.topbar .title.untitled { color: var(--muted); font-weight: 500; }
.title-input { flex: 1; min-width: 0; font-size: 18px; font-weight: 700; padding: 7px 10px; border: 2px solid var(--accent); border-radius: 10px; background: var(--panel); outline: 0; }
.status { text-align: center; font-size: 13px; padding: 6px; background: #fff3cd; color: #6b4e00; }
@media (prefers-color-scheme: dark) { .status { background: #3a2f0b; color: #ffd866; } }

.items { list-style: none; margin: 0; padding: 0; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.items:empty { display: none; }
.item { display: flex; align-items: center; border-top: 1px solid var(--line); min-height: 52px; }
.item:first-child { border-top: 0; }
.item .check { flex: none; width: 52px; height: 52px; border: 0; background: none; display: grid; place-items: center; }
.item .check span { width: 24px; height: 24px; border: 2px solid var(--muted); border-radius: 50%; display: grid; place-items: center; transition: background .15s, border-color .15s; }
.item .check span svg { opacity: 0; width: 14px; height: 14px; }
.item.checked .check span { background: var(--accent); border-color: var(--accent); }
.item.checked .check span svg { opacity: 1; }
.item .text { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 12px 4px 12px 0; overflow-wrap: anywhere; line-height: 1.4; }
.item.checked .text { color: var(--muted); text-decoration: line-through; }
.item .edit { flex: 1; min-width: 0; margin: 6px 4px 6px 0; padding: 7px 8px; border: 2px solid var(--accent); border-radius: 8px; background: var(--panel); outline: 0; }
.item .del { flex: none; width: 44px; height: 52px; border: 0; background: none; color: var(--muted); font-size: 20px; }
.item .del:hover { color: var(--danger); }
.item.pending { opacity: .55; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .btn { margin-top: 16px; }
.done { margin-top: 20px; }
.done-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.done-head h2 { font-size: 14px; color: var(--muted); margin: 0; font-weight: 600; }

.addbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
          background: var(--bg); border-top: 1px solid var(--line); }
.addbar input { flex: 1; min-width: 0; min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); outline: 0; font-size: 16px; }
.addbar input:focus { border-color: var(--accent); }

/* メニュー */
.backdrop { position: fixed; inset: 0; z-index: 9; background: rgba(0,0,0,.25); }
.menu { position: fixed; z-index: 10; top: calc(56px + env(safe-area-inset-top, 0px)); right: 8px; min-width: 240px; background: var(--panel); border-radius: var(--radius);
        box-shadow: 0 8px 32px rgba(0,0,0,.2); padding: 6px; display: flex; flex-direction: column; }
.menu button { border: 0; background: none; text-align: left; padding: 12px 14px; border-radius: 10px; font-size: 15px; }
.menu button:hover { background: var(--accent-soft); }
.menu button.danger { color: var(--danger); }

/* 共有ダイアログ */
.share-dlg { border: 0; border-radius: var(--radius); padding: 20px; max-width: min(92vw, 380px); background: var(--panel); color: var(--fg); box-shadow: 0 12px 48px rgba(0,0,0,.3); }
.share-dlg::backdrop { background: rgba(0,0,0,.35); }
.share-dlg h2 { margin: 0 0 4px; font-size: 18px; }
.share-dlg .qr { display: grid; place-items: center; margin: 12px 0; }
.share-dlg .qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }
.share-dlg .urlrow { display: flex; gap: 8px; }
.share-dlg .urlrow input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13px; }
.share-dlg .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); z-index: 20;
         background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; white-space: nowrap; }
body.home .toast { bottom: 32px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
