:root {
  --bg: #ffffff; --fg: #2a3135; --muted: #868c90; --line: #e6e8ea; --accent: #49baf2; --bul: #4b5155; --mark: #fff2a8; --bar: #f5f6f7;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d2125; --fg: #dfe3e6; --muted: #8b9297; --line: #33393e; --accent: #5cc4f5; --bul: #b8bec2; --mark: #6b5d12; --bar: #262b30; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
a { color: var(--accent); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ログイン */
.login { max-width: 320px; margin: 18vh auto 0; padding: 0 16px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0 0 8px; font-size: 26px; }
.login input { font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
.login button { padding: 12px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; }
.err { color: #d9534f; }

/* ヘッダー */
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.home { font-size: 22px; text-decoration: none; color: var(--muted); }
#crumbs { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
#crumbs a { color: var(--muted); text-decoration: none; }
#crumbs a + a::before { content: " › "; }
#q { width: 140px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 16px; font: inherit; font-size: 14px; background: var(--bar); color: var(--fg); }
#menuBtn { font-size: 20px; padding: 0 6px; color: var(--muted); }
#menu { position: absolute; right: 16px; top: 48px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 0; box-shadow: 0 4px 16px rgba(0,0,0,.12); display: flex; flex-direction: column; min-width: 170px; }
#menu[hidden] { display: none; }
#menu > * { padding: 8px 16px; text-align: left; font-size: 14px; }

/* 本文 */
main { max-width: 760px; margin: 0 auto; padding: 20px 16px 120px; }
#title { margin: 4px 0 18px 4px; }
#title .ttl { font-size: 26px; font-weight: 700; line-height: 1.35; }
.tx, .nt { outline: none; min-height: 1.55em; word-break: break-word; }
.n { position: relative; }
.row { display: flex; align-items: flex-start; }
.tog { width: 18px; flex: none; text-align: center; color: var(--muted); font-size: 12px; line-height: 25px; cursor: pointer; user-select: none; opacity: .5; }
.row:hover .tog { opacity: 1; }
.bul { flex: none; width: 18px; height: 25px; position: relative; margin-right: 4px; }
.bul::after { content: ""; position: absolute; left: 5px; top: 8.5px; width: 8px; height: 8px; border-radius: 50%; background: var(--bul); }
.bul.closed::before { content: ""; position: absolute; left: 1px; top: 4.5px; width: 16px; height: 16px; border-radius: 50%; background: var(--line); }
.row .tx { flex: 1; min-width: 0; padding: 0 2px; }
.nt { margin-left: 44px; color: var(--muted); font-size: 14px; white-space: pre-wrap; padding: 0 2px 2px; }
.nt[hidden] { display: none; }
.ch { margin-left: 26px; border-left: 1px solid var(--line); padding-left: 0; }
.ch:empty { display: none; }
.done > .row .tx, .done > .nt { text-decoration: line-through; color: var(--muted); }
.done > .row .bul::after { opacity: .4; }
mark { background: var(--mark); color: inherit; }
#add { margin: 8px 0 0 22px; font-size: 22px; color: var(--muted); }
#add[hidden] { display: none; }

#status { position: fixed; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 6px; opacity: .9; }
#status.err { color: #fff; background: #d9534f; padding: 6px 10px; border-radius: 6px; }

/* スマホの操作ボタン（書いている時だけ出す） */
#bar { position: fixed; left: 0; right: 0; bottom: 0; display: none; justify-content: space-around; background: var(--bar); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); z-index: 6; }
#bar button { font-size: 20px; min-width: 44px; min-height: 44px; }
@media (hover: none), (max-width: 700px) { body.editing #bar { display: flex; } body.editing #status { bottom: 64px; } }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--fg); max-width: 420px; }
dialog ul { padding-left: 18px; font-size: 14px; }
dialog form button { padding: 8px 16px; border-radius: 6px; background: var(--accent); color: #fff; }
@media (max-width: 480px) { #q { width: 96px; } #title .ttl { font-size: 22px; } }
