:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1f2328; --muted: #656d76; --line: #e3e6ea;
  --accent: #2563eb; --accent-text: #ffffff;
  --red: #d1242f; --red-bg: #fdecec; --yellow: #b7791f; --yellow-bg: #fff6dc;
  --green: #1a7f37; --green-bg: #e6f4ea; --gray: #8c959f; --gray-bg: #f0f1f3;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --card: #161b22; --text: #e6edf3; --muted: #9198a1; --line: #30363d;
    --accent: #4c8dff; --accent-text: #ffffff;
    --red: #ff7b72; --red-bg: #3a1d1f; --yellow: #e3b341; --yellow-bg: #362b12;
    --green: #56d364; --green-bg: #12301b; --gray: #8b949e; --gray-bg: #21262d;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --card: #161b22; --text: #e6edf3; --muted: #9198a1; --line: #30363d;
  --accent: #4c8dff; --accent-text: #ffffff;
  --red: #ff7b72; --red-bg: #3a1d1f; --yellow: #e3b341; --yellow-bg: #362b12;
  --green: #56d364; --green-bg: #12301b; --gray: #8b949e; --gray-bg: #21262d;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top); }
.top-in { max-width: 920px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 8px 16px; }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tabs a.on { background: var(--gray-bg); color: var(--text); }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.wrap { max-width: 920px; margin: 0 auto; padding: 12px 16px 80px; }
.pad { padding: 24px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .7; margin-left: 4px; }
.search { flex: 1 1 200px; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; }

.list { display: grid; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 5px solid var(--gray); padding: 10px 12px; display: block; color: var(--text); }
a.card:hover { border-color: var(--accent); border-left-color: inherit; }
.s-open { border-left-color: var(--red); }
.s-wip { border-left-color: var(--yellow); }
.s-done { border-left-color: var(--green); }
.s-na { border-left-color: var(--gray); }
.card .t { font-weight: 650; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.b-open { color: var(--red); background: var(--red-bg); }
.b-wip { color: var(--yellow); background: var(--yellow-bg); }
.b-done { color: var(--green); background: var(--green-bg); }
.b-na { color: var(--gray); background: var(--gray-bg); }
.due-over { color: var(--red); font-weight: 700; }
.due-today { color: var(--yellow); font-weight: 700; }

h1.title { font-size: 19px; line-height: 1.4; margin: 6px 0 4px; overflow-wrap: anywhere; }
h2 { font-size: 15px; margin: 22px 0 8px; }
.back { display: inline-block; margin: 2px 0 6px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.field { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 6px 10px; min-width: 0; }
textarea.field { width: 100%; min-height: 70px; }
.kv { display: grid; grid-template-columns: 5.5em 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.summary { white-space: pre-wrap; margin: 0; }
.note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.todo { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: 0; }
.todo input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--green); }
.todo .body { flex: 1; min-width: 0; }
.todo.done .txt { text-decoration: line-through; color: var(--muted); }
.todo .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px; }
.addtodo { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-top: 10px; }
.addtodo .field:first-child { grid-column: 1 / -1; }

.msg { border-top: 1px solid var(--line); padding: 10px 0; }
.msg:first-child { border-top: 0; }
.msg pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; font: inherit; font-size: 14px; }
.msg.clip pre { max-height: 220px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.group-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: calc(100% - 32px); z-index: 10; }
.toast.err { background: var(--red); color: #fff; }

@media (max-width: 600px) {
  .brand { display: none; }
  .wrap { padding: 10px 16px 80px; }
  .addtodo { grid-template-columns: 1fr 1fr; }
  .addtodo .btn { grid-column: 1 / -1; }
}
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt16 { margin-top: 16px; }
.m0 { margin: 0; } .m0t { margin-top: 0; } .mb8 { margin-bottom: 8px; }
