/* 看板與編輯畫面 */
:root {
  --page: light-dark(#fff, #0d0d0d);
  --rule: light-dark(#e0e0e0, #303030);
  --soft: light-dark(#ededed, #2a2a2a);
  --field: light-dark(#cfe6ff, #0e2338);
  --field-ink: light-dark(#0b2f57, #cfe6ff);
}
/* place-items 要還原，不然登入頁的置中設定會讓看板無法佔滿畫面 */
body.board-mode { display: block; place-items: normal; padding: 0; background: var(--page); }
.board :is(h1, h2, h3, p, ol, ul), .editor :is(p, ul) { margin: 0; padding: 0; }
.board :is(ol, ul), .editor ul { list-style: none; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 max(16px, 4vw); }
.hint { font-size: 0.875rem; color: var(--mute); }
.banner {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  padding: 10px max(16px, 4vw); border-bottom: 2px solid var(--red); color: var(--red);
}

.top { padding: 28px 0; background: var(--field); color: var(--field-ink); }
.head { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; justify-content: space-between; }
.top .btn { border-color: var(--field-ink); background: var(--field-ink); color: var(--field); }
.board h1 { font-size: clamp(1.75rem, 5vw, 2.625rem); line-height: 1.15; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px !important; }
.stats li { padding-top: 8px; border-top: 3px solid currentColor; font-size: 0.875rem; }
.stats b { display: block; font-size: clamp(1.75rem, 4vw, 2.625rem); line-height: 1.1; }

.board h2 { margin: 28px 0 14px; font-size: 1.25rem; }
.timeline {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(190px, 1fr);
  overflow-x: auto; padding: 10px 4px 4px !important;
}
.timeline li { position: relative; padding: 18px 16px 0 0; border-top: 2px solid var(--rule); }
.timeline li::before {
  content: ""; position: absolute; top: -8px; left: 0;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--page);
}
.timeline li.soon::before { background: var(--red); }
.timeline time { font-weight: 700; }
.left { margin-left: 8px; font-size: 0.875rem; color: var(--mute); }
.soon .left, .late { color: var(--red); font-weight: 700; }
.timeline button {
  display: block; width: 100%; min-height: 44px; padding: 0; border: 0;
  background: none; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.timeline button:hover b, .open:hover { text-decoration: underline; }
.timeline button span { display: block; font-size: 0.875rem; color: var(--mute); }
#noDate { margin-top: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--rule);
  border-radius: 999px; background: var(--card); cursor: pointer;
}
.chip[aria-pressed=true] { border-color: var(--ink); background: var(--ink); color: var(--card); }
.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.tools input[type=search] { flex: 1 1 220px; }
.tools :is(input[type=search], select), .editor :is(input:not([type=checkbox]), select, textarea) {
  min-height: 46px; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card);
}
.check { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: 0.875rem; }
.board input[type=checkbox], .editor input[type=checkbox] {
  flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent);
}

.grid {
  display: grid; gap: 14px; align-items: start; padding: 16px 0 32px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 16px;
  border: 1px solid var(--rule); border-radius: 14px; background: var(--card);
}
.card:hover { border-color: var(--line); }
.row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  justify-content: space-between; font-size: 0.875rem; color: var(--mute);
}
.pill { padding: 1px 10px; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink); }
.pill.blocked { border-color: var(--red); color: var(--red); font-weight: 700; }
.card h3 { font-size: 1.125rem; line-height: 1.4; }
.open {
  padding: 0; border: 0; background: none; font-weight: 700; text-align: left;
  cursor: pointer; overflow-wrap: anywhere;
}
/* 讓整張卡片都能點 */
.open::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
.open:focus-visible { outline: none; }
.open:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 2px; }
.next {
  padding: 12px !important; border-radius: 10px; background: var(--field); color: var(--field-ink);
  font-size: 1.0625rem; font-weight: 700; white-space: pre-line; overflow-wrap: anywhere;
}
.next span { display: block; font-size: 0.8125rem; font-weight: 400; }
.next.none { border: 1px dashed var(--line); background: none; color: var(--mute); font-weight: 400; }
.meter { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.foot {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding-bottom: 32px; font-size: 0.875rem; color: var(--mute); overflow-wrap: anywhere;
}

.editor {
  width: min(600px, 100%); max-width: none; height: 100dvh; max-height: none;
  margin: 0 0 0 auto; padding: 0 20px 32px; border: 0; border-left: 1px solid var(--rule);
  background: var(--page); color: var(--ink); overflow-y: auto;
}
.editor::backdrop { background: #0008; }
.editor-head {
  position: sticky; top: 0; z-index: 1; display: flex; gap: 8px; align-items: center;
  padding: 12px 0; background: var(--page); border-bottom: 1px solid var(--rule);
}
#saveStatus { flex: 1; font-size: 0.875rem; color: var(--mute); overflow-wrap: anywhere; }
#saveStatus.error { color: var(--red); }
.editor label { display: block; margin: 16px 0 4px; font-size: 0.875rem; color: var(--mute); }
.editor :is([data-field], textarea) { width: 100%; }
.editor textarea { resize: vertical; }
#f-name { font-size: 1.25rem; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.editor h2 { margin: 28px 0 8px; font-size: 1.125rem; }
#taskCount { font-size: 0.875rem; font-weight: 400; color: var(--mute); }
.items li {
  display: flex; gap: 10px; align-items: center; min-height: 48px;
  border-bottom: 1px solid var(--rule);
}
.items label { flex: 1; display: flex; gap: 10px; align-items: center; margin: 0; padding: 10px 0; font-size: 1rem; color: var(--ink); cursor: pointer; }
.items .text { flex: 1; overflow-wrap: anywhere; }
.items .done .text { color: var(--mute); text-decoration: line-through; }
.items time { flex: none; font-size: 0.875rem; color: var(--mute); }
.remove { flex: none; min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--mute); cursor: pointer; }
.remove[data-armed] { color: var(--red); font-weight: 700; }
.add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.add [name=text] { flex: 1 1 180px; }
.editor .danger { margin-top: 36px; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .timeline { grid-auto-flow: row; overflow: visible; padding: 0 0 0 7px !important; }
  .timeline li { padding: 0 0 18px 20px; border-top: 0; border-left: 2px solid var(--rule); }
  .timeline li::before { top: 5px; left: -8px; }
  .editor { border-left: 0; padding: 0 16px 32px; }
}
