/* ============================================================
   讀書計畫：日 / 週 / 月檢視、時間表、時段區塊、編輯表單
   ============================================================ */

.planner { gap: 14px; }
.pl-head { display: grid; gap: 12px; }
.pl-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pl-nav .seg { order: 0; }
.pl-range { font-size: 1.12rem; font-weight: 800; flex: 1 1 auto; min-width: 9em; text-align: center; }
.pl-range small { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-3); }
.pl-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.brush { display: grid; gap: 10px; padding: 12px 14px; overflow: hidden; }
.brush-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.brush-label { font-weight: 750; font-size: .92rem; display: flex; align-items: center; gap: 6px; }
.brush-label .ic { color: var(--brand); }
.brush-hint { font-size: .86rem; color: var(--ink-2); line-height: 1.6; min-height: 1.4em; }
.brush-hint b { color: var(--ink); }
.dur-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); }

/* ---------- 時間表 ---------- */
.tg { --hh: 56px; --axis-w: 52px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1); }
.tg.week { --hh: 46px; --colmin: 104px; }
.tg-scroll { position: relative; overflow: auto; max-height: calc(100dvh - 300px); min-height: 440px; overscroll-behavior: contain; }
.tg-inner { display: grid; grid-template-columns: var(--axis-w) repeat(var(--cols), minmax(var(--colmin, 0px), 1fr)); min-width: calc(var(--axis-w) + var(--cols) * var(--colmin, 0px)); }
.tg-corner { position: sticky; top: 0; left: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line); }
.tg-hcell {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); border-left: 1px solid var(--line-2);
  padding: 8px 6px 8px; text-align: center; line-height: 1.25; cursor: pointer; border-top: 0; border-right: 0; font: inherit; color: var(--ink);
}
.tg-hcell:hover { background: var(--bg-2); }
.tg-hcell.today { background: var(--brand-soft); }
.tg-hcell .wd { display: block; font-size: .78rem; color: var(--ink-2); font-weight: 650; }
.tg-hcell .dn { display: block; font-size: 1.1rem; font-weight: 800; }
.tg-hcell .ds { display: block; font-size: .7rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tg-ev { display: block; margin-top: 3px; padding: 0 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand-soft-ink); font-size: .68rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tg-axis { position: sticky; left: 0; z-index: 3; background: var(--surface); height: calc(var(--rows) * var(--hh)); }
.tg-axis span { position: absolute; right: 8px; transform: translateY(-50%); font-size: .72rem; color: var(--ink-3); font-variant-numeric: tabular-nums; background: var(--surface); padding: 0 2px; }
.tg-axis span:first-child { transform: translateY(0); }
.tg-col {
  position: relative; height: calc(var(--rows) * var(--hh)); border-left: 1px solid var(--line-2); cursor: cell;
  background-image: linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px), linear-gradient(to bottom, var(--line-2) 0, var(--line-2) 1px, transparent 1px);
  background-size: 100% var(--hh), 100% calc(var(--hh) / 2);
}
.tg-col.today { background-color: color-mix(in srgb, var(--brand-soft) 38%, transparent); }
.tg-col.brushing { cursor: copy; }

.blk {
  position: absolute; z-index: 1; display: flex; gap: 6px; align-items: flex-start; padding: 4px 6px 4px 7px; overflow: hidden;
  border-radius: 10px; background: var(--c-soft); border-left: 4px solid var(--c); cursor: pointer; font-size: .82rem; line-height: 1.3;
  outline-offset: -2px; touch-action: manipulation;
}
.blk:hover { filter: brightness(.96); z-index: 2; }
.blk.done { opacity: .6; }
.blk.done .blk-name { text-decoration: line-through; }
.blk-check {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--c); background: var(--surface); color: transparent;
  display: grid; place-items: center; padding: 0; cursor: pointer; touch-action: manipulation; margin-top: 1px;
}
.blk-check[aria-pressed="true"] { background: var(--c); color: #fff; }
.blk-check .ic { width: 13px; height: 13px; stroke-width: 3.4; }
.blk-main { min-width: 0; flex: 1; }
.blk-name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-note, .blk-time { color: var(--ink-2); font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.blk.short .blk-main { display: flex; align-items: baseline; gap: 6px; }
.blk.short .blk-time { display: none; }
.blk.tiny { padding-top: 1px; padding-bottom: 1px; }
.blk.tiny .blk-check { display: none; }
.blk.narrow .blk-check { width: 18px; height: 18px; }
.blk.narrow .blk-note, .blk.narrow .blk-time { display: none; }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--brand); z-index: 4; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }

/* ---------- 月曆 ---------- */
.month { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow-1); }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--bg-2); text-align: center; font-weight: 700; font-size: .82rem; color: var(--ink-2); padding: 8px 0; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mcell {
  position: relative; min-height: 84px; padding: 6px 6px 8px; border: 0; border-top: 1px solid var(--line-2); border-left: 1px solid var(--line-2);
  background: var(--surface); text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 5px; color: var(--ink); overflow: hidden;
}
.mcell:nth-child(7n + 1) { border-left: 0; }
.mcell:hover { background: var(--bg-2); }
.mcell.out { background: var(--surface-2); color: var(--ink-3); }
.mcell.out .mc-day { color: var(--ink-3); }
.mc-day { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-weight: 750; font-size: .88rem; }
.mcell.today .mc-day { background: var(--brand); color: var(--brand-ink); }
.mc-bar { display: flex; height: 7px; border-radius: 99px; overflow: hidden; background: transparent; }
.mc-bar i { display: block; height: 100%; background: var(--c); }
.mc-hours { font-size: .74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; line-height: 1.2; }
.mc-ev { font-size: .68rem; font-weight: 700; color: var(--brand-soft-ink); background: var(--brand-soft); border-radius: 6px; padding: 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-ok { position: absolute; right: 6px; top: 6px; color: var(--leaf); }
.mc-ok .ic { width: 1.1rem; height: 1.1rem; stroke-width: 3; }
@media (max-width: 560px) {
  .mcell { min-height: 68px; padding: 4px; gap: 4px; }
  .mc-hours { font-size: .66rem; }
  .mc-ev { font-size: .6rem; padding: 0 3px; }
}

/* ---------- 統計 / 回顧 ---------- */
.sum-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.sum-nums { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 22px; }
.sum-nums div { display: grid; }
.sum-nums b { font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.sum-nums small { color: var(--ink-3); font-size: .78rem; }
.sum-list { display: grid; gap: 8px; margin-top: 14px; }
.sum-row { display: grid; grid-template-columns: 6em 1fr 5.5em; gap: 10px; align-items: center; font-size: .9rem; }
.sum-row .nm { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sum-row .nm::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.sum-row .vl { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .84rem; }
.sum-bar { position: relative; height: 12px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.sum-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.sum-bar i.plan { background: var(--c-soft); }
.sum-bar i.fin { background: var(--c); }
.review-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.review-grid textarea { min-height: 84px; }

/* ---------- 時段編輯表單 ---------- */
.block-form { display: grid; gap: 18px; }
.block-form .chips .chip { min-height: 42px; }
.topic-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.topic-row small { color: var(--ink-3); }
.dur-keys { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dur-show { font-size: .85rem; color: var(--ink-2); margin-left: auto; font-variant-numeric: tabular-nums; }
.rep-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.wd-toggles { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.wd-btn { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); font-weight: 750; cursor: pointer; }
.wd-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.rep-until { margin-top: 12px; }
.custom-subject { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.custom-subject .row { gap: 8px; }

.tpl-list { display: grid; gap: 10px; }
.tpl-card { display: grid; gap: 4px; text-align: left; padding: 12px 14px; border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; width: 100%; }
.tpl-card:hover { background: var(--bg-2); }
.tpl-card[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tpl-card b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-card span { color: var(--ink-2); font-size: .9rem; line-height: 1.6; }

@media (max-width: 600px) {
  .tg-scroll { max-height: calc(100dvh - 300px); min-height: 380px; }
  .pl-range { order: 3; flex-basis: 100%; }
  .brush { padding: 10px 12px; gap: 8px; }
  .brush-label { font-size: .86rem; }
  .brush .chips, .dur-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 4px; }
  .brush .chips::-webkit-scrollbar, .dur-chips::-webkit-scrollbar { display: none; }
  .brush .chips .chip, .dur-chips .chip { flex: none; }
  .dur-chips { white-space: nowrap; }
  .brush-hint.idle { display: none; }
}
