:root {
  --bg: #f7f5f0;
  --paper: #fffefb;
  --ink: #1d1c1a;
  --ink-2: #5f5b54;
  --ink-3: #9a958c;
  --rule: #e4e0d7;
  --accent: #c2410c;
  --accent-ink: #fff;
  --ok: #3f6b4a;
  --late: #b42318;
  --del: #c8352b;
  --shadow: 0 -1px 0 var(--rule);
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413; --paper: #1d1c1a; --ink: #f1eee8; --ink-2: #b9b3a8; --ink-3: #7d786f;
    --rule: #33302c; --accent: #f97316; --accent-ink: #1d1c1a; --ok: #86b393; --late: #f87171; --del: #dc4a3f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { max-width: 640px; margin: 0 auto; padding: env(safe-area-inset-top) 0 calc(140px + env(safe-area-inset-bottom)); }

/* 見出し */
.top { position: relative; padding: 18px 20px 6px; }
.top h1 { margin: 0; font-size: 34px; line-height: 1.15; letter-spacing: .02em; font-weight: 800; }
.top .sub { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.top .textbtn { position: absolute; right: 12px; top: 14px; }
.textbtn { background: none; border: 0; color: var(--accent); padding: 8px 10px; font-size: 16px; min-height: 44px; }
.textbtn.strong { font-weight: 700; }

/* タブ（下線式） */
.tabs { display: flex; gap: 22px; padding: 6px 20px 0; border-bottom: 1px solid var(--rule); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.tabs button { background: none; border: 0; padding: 10px 0 9px; font-size: 15px; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--ink); font-weight: 700; }

/* 区切り */
.group { margin-top: 18px; }
.group-h { display: flex; align-items: baseline; gap: 8px; padding: 0 20px 6px; font-size: 13px; color: var(--ink-2); letter-spacing: .04em; }
.group-h b { font-weight: 700; color: var(--ink); }
.group-h .n { font-family: var(--mono); color: var(--ink-3); }
.group.g-late .group-h b { color: var(--late); }
.rows { background: var(--paper); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 0; padding: 0; list-style: none; }

/* 1行 */
.row { position: relative; overflow: hidden; }
.row + .row::before { content: ""; position: absolute; left: 56px; right: 0; top: 0; border-top: 1px solid var(--rule); z-index: 2; }
.row .behind { position: absolute; inset: 0; background: var(--del); color: #fff; display: flex; align-items: center; justify-content: flex-end; padding-right: 22px; font-size: 15px; font-weight: 700; }
.row .front { position: relative; background: var(--paper); display: grid; grid-template-columns: 56px 1fr auto; align-items: start; min-height: 58px; touch-action: pan-y; transition: transform .22s cubic-bezier(.2,.8,.2,1); }
.row.dragging .front { transition: none; }
.check { width: 56px; height: 58px; border: 0; background: none; display: grid; place-items: center; padding: 0; }
.check i { width: 22px; height: 22px; border: 1.6px solid var(--ink-3); border-radius: 4px; display: block; position: relative; transition: background .15s, border-color .15s; }
.row.done .check i { background: var(--ok); border-color: var(--ok); }
.row.done .check i::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.body { padding: 15px 0 13px; min-width: 0; border: 0; background: none; text-align: left; }
.name { font-size: 17px; overflow-wrap: anywhere; }
.row.done .name { text-decoration: line-through; color: var(--ink-3); }
.meta { margin-top: 2px; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.meta span + span::before { content: "／"; color: var(--ink-3); margin: 0 4px; }
.side { padding: 15px 18px 0 12px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.side .q { font-size: 15px; }
.side .d { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.side .d.late { color: var(--late); font-weight: 700; }
.side .d.soon { color: var(--accent); font-weight: 700; }
.row.leaving { animation: leave .32s ease forwards; }
@keyframes leave { to { opacity: 0; transform: translateX(-24px); max-height: 0; } }
.row.entering .front { animation: enter .35s cubic-bezier(.2,.8,.2,1); }
@keyframes enter { from { background: color-mix(in srgb, var(--accent) 14%, var(--paper)); } }

/* 空・読み込み */
.empty { padding: 56px 28px; text-align: center; color: var(--ink-2); }
.empty h2 { color: var(--ink); font-size: 20px; margin: 0 0 8px; }
.empty p { margin: 0 0 18px; font-size: 15px; }
.empty .ex { font-family: var(--mono); font-size: 13px; color: var(--ink-2); line-height: 1.9; }
.skel { padding: 18px 20px; display: grid; gap: 14px; }
.skel div { height: 18px; border-radius: 3px; background: linear-gradient(90deg, var(--rule), color-mix(in srgb, var(--rule) 40%, var(--bg)), var(--rule)); background-size: 200% 100%; animation: sh 1.2s infinite linear; }
.skel div:nth-child(odd) { width: 72%; } .skel div:nth-child(even) { width: 46%; }
@keyframes sh { to { background-position: -200% 0; } }

/* 入力欄 */
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--rule); padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.composer[hidden] { display: none; }
.composer .bar { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.composer input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--rule); background: var(--paper); border-radius: 10px; padding: 0 14px; font-size: 17px; outline: none; }
.composer input:focus { border-color: var(--ink-2); }
.mic { width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); display: grid; place-items: center; flex: none; }
.mic.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); } }
.add { height: 46px; padding: 0 16px; border-radius: 10px; border: 0; background: var(--ink); color: var(--bg); font-weight: 700; flex: none; }
.add:disabled { opacity: .35; }
.preview { max-width: 640px; margin: 0 auto 6px; padding: 0 4px; font-size: 13px; color: var(--ink-2); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview b { color: var(--ink); font-family: var(--sans); }

/* トースト */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30; max-width: 616px; margin: 0 auto; background: var(--ink); color: var(--bg); border-radius: 10px; padding: 6px 6px 6px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; animation: up .2s ease; }
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 10px 12px; min-height: 44px; }
.toast button[hidden] { display: none; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* 編集シート */
.sheet { border: 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 14px 14px 0 0; background: var(--paper); color: var(--ink); max-height: 92vh; }
.sheet::backdrop { background: rgba(0,0,0,.35); }
.sheet[open] { animation: sheetIn .26s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.sheet form { padding: 0 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 -8px 6px; position: sticky; top: 0; background: var(--paper); }
.sheet-head h2 { font-size: 16px; margin: 0; }
.sheet-head .textbtn:last-child { justify-self: end; }
.sheet-head .textbtn:first-child { justify-self: start; }
.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--rule); background: var(--bg); border-radius: 8px; padding: 11px 12px; font-size: 17px; outline: none; min-height: 46px; }
.field input:focus, .field textarea:focus { border-color: var(--ink-2); }
.field textarea { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.datepick { display: grid; gap: 8px; }
.quick { display: flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.quick button { flex: 1; background: var(--bg); border: 0; padding: 9px 0; font-size: 14px; color: var(--ink); min-height: 40px; }
.quick button + button { border-left: 1px solid var(--rule); }
.quick button:active { background: var(--rule); }
.danger { display: block; width: 100%; margin-top: 26px; background: none; border: 1px solid var(--rule); color: var(--del); border-radius: 8px; padding: 13px; font-size: 16px; }

/* 予定 */
.day { margin-top: 18px; }
.day-h { padding: 0 20px 6px; display: flex; gap: 10px; align-items: baseline; }
.day-h .date { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.day-h .rel { font-size: 13px; color: var(--ink-2); }
.day.late .day-h .date { color: var(--late); }
.tag { display: inline-block; font-size: 11px; letter-spacing: .06em; color: var(--ink-2); border-bottom: 1px solid currentColor; margin-right: 8px; vertical-align: 2px; }
.tag.use { color: var(--ok); }
.tag.due { color: var(--accent); }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 18px 13px 20px; border: 0; background: var(--paper); width: 100%; text-align: left; min-height: 52px; }
.plan-row + .plan-row { border-top: 1px solid var(--rule); }
.plan-row .q { font-family: var(--mono); font-size: 14px; color: var(--ink-2); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); padding: 14px 12px 0; text-align: center; }
.week div { padding: 6px 0; font-size: 12px; color: var(--ink-2); }
.week b { display: block; font-family: var(--mono); font-size: 17px; color: var(--ink); font-weight: 600; }
.week .dots { display: flex; justify-content: center; gap: 3px; height: 6px; margin-top: 4px; }
.week .dots i { width: 5px; height: 5px; background: var(--accent); border-radius: 50%; }
.week .dots i.u { background: var(--ok); }
.week .today b { color: var(--accent); }

/* 履歴 */
.again { border: 1px solid var(--rule); background: var(--bg); border-radius: 8px; padding: 6px 12px; font-size: 14px; color: var(--ink); min-height: 36px; flex: none; }

/* 設定 */
.settings { padding: 4px 0 30px; }
.sec { margin-top: 22px; }
.sec h2 { font-size: 13px; letter-spacing: .04em; color: var(--ink-2); font-weight: 600; margin: 0; padding: 0 20px 6px; }
.box { background: var(--paper); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 16px 20px; }
.box p { margin: 0 0 10px; font-size: 15px; }
.box p:last-child { margin-bottom: 0; }
.steps { margin: 0; padding: 0 0 0 1.4em; font-size: 15px; }
.steps li { margin: 0 0 12px; }
.steps li:last-child { margin-bottom: 0; }
.steps em { font-style: normal; font-weight: 700; }
.copyline { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.copyline code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--rule); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; }
.btn { border: 1px solid var(--rule); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 8px 14px; font-size: 14px; min-height: 40px; flex: none; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
.tryline { display: flex; gap: 8px; margin-top: 8px; }
.tryline input { flex: 1; min-width: 0; border: 1px solid var(--rule); background: var(--bg); border-radius: 8px; padding: 9px 12px; font-size: 16px; }
.answer { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--bg); font-size: 15px; }
.answer[hidden] { display: none; }
.examples { font-family: var(--mono); font-size: 13px; line-height: 2; color: var(--ink-2); margin: 0; padding: 0; list-style: none; }
.examples li span { color: var(--ink); font-family: var(--sans); }
.muted { color: var(--ink-2); font-size: 13px; }
.back { margin: 8px 0 0 8px; }

@media (min-width: 700px) {
  .top { padding-top: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.pad { padding: 14px 20px; }
.mt6 { margin-top: 6px; }
.mt12 { margin-top: 12px; }
.pair { display: flex; gap: 8px; flex: none; }
.tryline.flush { margin: 0; flex-wrap: wrap; }
.sheet-head h2:focus { outline: none; }
.tabs[hidden], .preview[hidden] { display: none; }
