/* ============================================================
   外接大腦待辦系統｜樣式
   設計：近單色（黑／白／灰）＋ 深綠 #4a7c59 點綴
   字體：Noto Serif TC（標題）／ Noto Sans TC（內文）
   ============================================================ */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #555;
  --ink-faint: #9a9a9a;
  --line: #e6e6e6;
  --line-soft: #f0f0f0;
  --green: #4a7c59;
  --green-soft: #eef3ef;
  --danger: #b4453a;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 有 hidden 屬性就一定隱藏（避免被 .modal / .menu 的 display 蓋過） */
[hidden] { display: none !important; }

body {
  font-family: "Noto Sans TC", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { font-family: "Noto Serif TC", serif; font-weight: 700; }

/* ---------- 密碼鎖 ---------- */
.lock {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.lock-box {
  text-align: center; width: 280px;
  display: flex; flex-direction: column; gap: 12px;
}
.lock-title { font-family: "Noto Serif TC", serif; font-size: 28px; font-weight: 700; }
.lock-sub { color: var(--ink-faint); font-size: 14px; margin-bottom: 8px; }
.lock-box input {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 16px; text-align: center; background: var(--surface);
}
.lock-box button {
  padding: 12px; border: none; border-radius: 10px; background: var(--green);
  color: #fff; font-size: 16px; font-weight: 500; cursor: pointer;
}
.lock-err { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- 頂部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250,250,250,.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  padding-top: max(12px, env(safe-area-inset-top));
}
.quickadd {
  display: flex; gap: 8px; max-width: 1100px; margin: 0 auto;
}
.quickadd input {
  flex: 1; padding: 13px 16px; border: 1px solid var(--line);
  border-radius: 12px; font-size: 16px; background: var(--surface);
  box-shadow: var(--shadow);
}
.quickadd input:focus { outline: none; border-color: var(--green); }
.quickadd button {
  width: 50px; flex: none; border: none; border-radius: 12px;
  background: var(--green); color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: var(--shadow);
}
.topnav { display: none; gap: 6px; max-width: 1100px; margin: 10px auto 0; }
.topnav-btn {
  border: 1px solid var(--line); background: var(--surface);
  padding: 7px 16px; border-radius: 20px; font-size: 14px; cursor: pointer;
  color: var(--ink-soft); font-family: inherit;
}
.topnav-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- 舞台與分頁切換 ---------- */
.stage { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(150px + env(safe-area-inset-bottom)); }
.panel { display: none; }

body[data-view="board"] .panel-pools { display: block; }
body[data-view="today"] .panel-schedule { display: block; }
body[data-view="dump"]  .panel-dump { display: block; }
body[data-view="done"]  .panel-done { display: block; }

/* ---------- 待辦池 ---------- */
.pool { margin-bottom: 18px; }
.pool-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.pool-head h2 { font-size: 17px; }
.pool[data-bucket="must_do_today"] .pool-head h2 { color: var(--green); }
.pool-count {
  font-size: 12px; color: var(--ink-faint);
  background: var(--line-soft); padding: 1px 9px; border-radius: 10px;
}
.pool-warn {
  font-size: 13px; color: #8a6d3b; background: #fdf6e3;
  border: 1px solid #f0e3bf; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px;
}
.dump-note { font-size: 13px; color: var(--ink-faint); margin-bottom: 12px; }

/* ---------- 今日排程 ---------- */
.schedule-head { margin-bottom: 14px; }
.schedule-head h2 { font-size: 17px; }
.schedule-head .hint { font-size: 12px; color: var(--ink-faint); }
.block { margin-bottom: 16px; }
.block h3 {
  font-size: 14px; color: var(--ink-soft); margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.slot { min-height: 48px; }

/* ---------- 清單與空狀態 ---------- */
.list { display: flex; flex-direction: column; gap: 8px; min-height: 12px; }
.list.drag-over { background: var(--green-soft); border-radius: 10px; }
.empty {
  font-size: 13px; color: var(--ink-faint); font-style: normal;
  padding: 14px 4px; text-align: left;
}

/* ---------- 任務卡片 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 12px 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow); touch-action: manipulation;
}
.card.done-card { opacity: .7; }
.check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); cursor: pointer; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); transition: all .15s;
}
.check:hover { border-color: var(--green); }
.check.checked { background: var(--green); border-color: var(--green); color: #fff; }
.card-body { flex: 1; min-width: 0; }
.card-title { font-size: 15px; word-break: break-word; }
.card.done-card .card-title { text-decoration: line-through; color: var(--ink-faint); }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }
.tag {
  font-size: 11px; padding: 1px 8px; border-radius: 8px;
  background: var(--green-soft); color: var(--green);
}
.tag.due { background: #fbeeee; color: var(--danger); }
.card-link {
  font-size: 12px; color: var(--green); text-decoration: none;
  display: inline-flex; align-items: center; gap: 3px;
}
.card-link:hover { text-decoration: underline; }
.card-note { font-size: 12px; color: var(--ink-faint); margin-top: 3px; word-break: break-word; }
.card-actions { flex: none; display: flex; gap: 2px; }
.icon-btn {
  border: none; background: none; cursor: pointer; font-size: 16px;
  color: var(--ink-faint); width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.drag-handle { cursor: grab; color: var(--ink-faint); }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: 0 6px 20px rgba(0,0,0,.12); }

/* ---------- 已完成 ---------- */
.done-group { margin-bottom: 22px; }
.done-date { font-size: 13px; color: var(--ink-faint); margin-bottom: 8px; font-weight: 500; }

/* ---------- 浮動選單 ---------- */
.menu {
  position: fixed; z-index: 60; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; min-width: 168px;
}
.menu .mi {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
  font-family: inherit; color: var(--ink);
}
.menu .mi:hover { background: var(--line-soft); }
.menu .mi.danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .mlabel { font-size: 11px; color: var(--ink-faint); padding: 5px 12px 2px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center;
}
.modal-box {
  background: var(--surface); width: 100%; max-width: 460px;
  border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto;
}
.modal-head {
  position: sticky; top: 0; background: var(--surface);
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
  font-family: "Noto Serif TC", serif; font-weight: 700; font-size: 16px;
}
.modal-head button { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-faint); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-soft); }
.modal-body textarea, .modal-body input, .modal-body select {
  font-family: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  resize: vertical;
}
.modal-body textarea:focus, .modal-body input:focus, .modal-body select:focus { outline: none; border-color: var(--green); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.btn-solid { background: var(--green); color: #fff; border: none; padding: 11px 22px; border-radius: 10px; font-size: 15px; cursor: pointer; font-family: inherit; }
.btn-ghost { background: none; border: 1px solid var(--line); padding: 11px 18px; border-radius: 10px; font-size: 15px; cursor: pointer; font-family: inherit; color: var(--ink-soft); }
.btn-ghost.danger { color: var(--danger); border-color: #e7c9c5; }

/* ---------- 底部導覽（手機） ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 9px 0 8px; font-size: 11px; color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: inherit;
}
.bn-btn span { font-size: 19px; }
.bn-btn.active { color: var(--green); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 14px; z-index: 90; box-shadow: var(--shadow);
}

/* ============================================================
   桌機版（≥ 880px）：左池 ＋ 右排程 並排
   ============================================================ */
@media (min-width: 880px) {
  .bottomnav { display: none; }
  .topnav { display: flex; }
  .stage { padding-bottom: 40px; }

  body[data-view="board"] .stage,
  body[data-view="today"] .stage {
    display: grid; grid-template-columns: 1fr 380px; gap: 28px; align-items: start;
  }
  body[data-view="board"] .panel-pools,
  body[data-view="today"] .panel-pools { display: block; }
  body[data-view="board"] .panel-schedule,
  body[data-view="today"] .panel-schedule { display: block; }

  .panel-schedule {
    position: sticky; top: 132px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px;
  }
  .modal { align-items: center; }
  .modal-box { border-radius: 18px; }
}
