.modes > .history-open-btn {
  order: 3; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  width: 100%; margin: 14px 0 0; padding: 12px 16px;
  background: transparent; border: 0; border-top: 1px solid var(--border2, #e5eaf0);
  border-radius: 0 0 10px 10px; font: inherit; font-size: 13px; font-weight: 500;
  color: var(--muted, #6e8098); text-align: left; cursor: pointer;
}
.modes > .history-open-btn::before { content: '↺'; font-size: 20px; font-weight: 400; line-height: 1; }
.modes > .history-open-btn:hover { background: var(--soft, rgba(255,255,255,.5)); color: var(--text); }
.history-overlay[hidden] { display: none; }
.history-overlay { position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; background: rgba(24,43,66,.23); backdrop-filter: blur(3px); }
.history-is-open { overflow: hidden; }
.history-drawer {
  width: min(460px, 100%); height: 100dvh; box-sizing: border-box; padding: 25px 24px 0;
  display: flex; flex-direction: column; gap: 16px;
  background: var(--panel, #f6f9fd); color: var(--text, #24344b);
  border-left: 1px solid var(--border, #d8e2ed); box-shadow: -12px 0 45px rgba(20,40,65,.1);
  font-variant-numeric: tabular-nums;
  animation: history-slide-in .18s ease-out;
}
@keyframes history-slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.history-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.history-drawer-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.history-drawer-head button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--soft, #edf2f8); color: var(--muted, #718099); font-size: 24px; line-height: 1; cursor: pointer; }
.history-search { width: 100%; box-sizing: border-box; min-height: 40px; border: 1px solid var(--border, #d8e2ed); border-radius: 10px; padding: 10px 14px; background: var(--card, #fff); color: var(--text); font: inherit; font-size: 13px; }
.history-search:focus-visible { outline: 2px solid var(--accent, #3c79cf); outline-offset: 2px; }
.history-tabs { display: flex; gap: 5px; padding: 4px; border-radius: 10px; background: var(--soft, #edf2f8); }
.history-tabs button { flex: 1; border: 0; border-radius: 7px; padding: 8px 6px; font: inherit; font-size: 13px; cursor: pointer; background: transparent; color: var(--muted, #718099); transition: background .15s, color .15s; }
.history-tabs button.active { background: var(--card, #fff); color: var(--accent, #3c79cf); font-weight: 600; box-shadow: 0 2px 6px rgba(30,60,90,.06); }
.history-entries { flex: 1; min-height: 0; overflow: auto; padding-bottom: 8px; }
.history-entry { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border2, #e4eaf1); padding: 14px 0; }
.history-entry-main { display: block; flex: 1; min-width: 0; border: 0; padding: 0; background: transparent; text-align: left; color: var(--text); font: inherit; cursor: pointer; }
.history-entry-main strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; font-size: 14px; font-weight: 500; line-height: 1.6; }
.history-entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--muted, #718099); }
.history-state { font-size: 11.5px; padding: 1px 7px; border-radius: 5px; font-weight: 500; }
.history-state.done { color: var(--green, #238269); background: rgba(35,130,105,.12); }
.history-state.error { color: var(--red, #b94c4c); background: var(--red-bg, rgba(185,76,76,.1)); }
.history-state.running { color: var(--amber, #aa7b32); background: var(--amber-bg, rgba(170,123,50,.12)); }
.history-entry-download { font-size: 12px; color: var(--accent, #3c79cf); text-decoration: none; padding: 6px 8px; border-radius: 6px; white-space: nowrap; }
.history-entry-download:hover { background: var(--soft); }
.history-entry-delete { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--faint, #8a9aab); font-size: 20px; cursor: pointer; }
.history-entry-delete:hover { background: var(--red-bg, #fff0f0); color: var(--red, #b94c4c); }
.history-drawer-empty { padding: 70px 20px; text-align: center; font-size: 13px; color: var(--muted, #718099); }
.history-drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 max(20px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border2, #e4eaf1); font-size: 12px; color: var(--muted, #718099); }
.history-drawer-foot button { border: 0; background: transparent; padding: 5px 0; font: inherit; font-size: 12px; color: var(--muted, #718099); cursor: pointer; }
.history-drawer-foot button:hover:not(:disabled) { color: var(--text); }
.history-drawer-foot button:disabled { opacity: .4; cursor: default; }
@media (max-width: 700px) {
  .modes > .history-open-btn { width: auto; margin: 0; padding: 9px 12px; justify-content: center; border: 0; border-radius: 9px; font-size: 12px; }
  .modes > .history-open-btn::before { display: none; }
  .history-drawer { padding: 20px 18px 0; gap: 14px; }
}
@media (prefers-reduced-motion: reduce) { .history-drawer { animation: none; } }

.modes > .todo-open-btn { order: 4; margin-top: 0; border-top: 0; border-radius: 10px; }
.modes > .todo-open-btn::before { content: '☑'; font-size: 17px; }
.todo-badge { margin-left: auto; display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 7px; background: var(--soft, #edf2f8); color: var(--accent, #3c79cf); font-size: 11px; font-weight: 600; box-sizing: border-box; }
.todo-badge[hidden] { display: none; }
.todo-form { display: grid; gap: 12px; }
.todo-form > input { width: 100%; box-sizing: border-box; min-height: 42px; border: 1px solid var(--border, #d8e2ed); border-radius: 10px; padding: 10px 14px; font: inherit; font-size: 14px; color: var(--text); background: var(--card, #fff); }
.todo-form-bottom { display: flex; align-items: center; gap: 10px; }
.todo-form-bottom label { font-size: 12px; color: var(--muted, #718099); white-space: nowrap; }
.todo-form-bottom label span { display: block; font-size: 11px; color: var(--faint, #8a9aab); }
.todo-form-bottom input { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid var(--border, #d8e2ed); border-radius: 8px; color: var(--text); background: var(--card, #fff); font: inherit; font-size: 13px; }
.todo-form-bottom button { font-size: 13px; padding: 9px 16px; }
.todo-form input:focus-visible { outline: 2px solid var(--accent, #3c79cf); outline-offset: 2px; }
.todo-entry { display: flex; align-items: center; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--border2, #e4eaf1); }
.todo-entry-label { display: flex; flex: 1; min-width: 0; align-items: flex-start; gap: 11px; cursor: pointer; }
.todo-entry-label > input { width: 16px; height: 16px; flex: none; margin: 4px 0 0; accent-color: var(--accent, #3c79cf); }
.todo-entry-content { display: grid; gap: 5px; min-width: 0; }
.todo-entry-title { font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.todo-due { font-size: 12px; color: var(--muted, #718099); }
.todo-due.overdue { color: var(--red, #b94c4c); font-weight: 500; }
.todo-entry.is-done .todo-entry-title { text-decoration: line-through; color: var(--muted, #718099); }
.todo-entry.is-done { opacity: .75; }
.todo-completed { margin-top: 20px; }
.todo-completed summary { font-size: 12px; color: var(--muted, #718099); cursor: pointer; padding: 8px 0; }
.todo-error { color: var(--red, #b94c4c); font-size: 13px; line-height: 1.65; margin: 0; }
.todo-error[hidden] { display: none; }
.todo-empty { padding: 55px 15px; }
@media (max-width: 700px) { .modes > .todo-open-btn { margin: 0; } .todo-badge { margin-left: 0; } }
