/* V0.13 layer: 工作導航（今天｜本週｜下週）, phone week agenda, readable quick index, project 進度與預算.
   Same palette and card system as V0.11/V0.12; no new fixed-height blocks. */

/* ---------- Work navigation ---------- */
.v13-worknav { margin-bottom: 22px; }
.v13-worknav-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.v13-seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(84px, auto); gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.v13-seg [role=tab] { min-height: 40px; padding: 0 18px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); font-weight: 650; white-space: nowrap; }
.v13-seg [role=tab][aria-selected="true"] { background: var(--brand); color: #fff; }
.v13-seg [role=tab]:not([aria-selected="true"]):hover { background: var(--brand-soft); color: var(--brand); }
.v13-range { margin: 0; }
.v13-worknav .daily-hero { margin-bottom: 0; }
.v13-back-today { margin: -4px 0 6px; }
.v13-loading { min-height: 120px; display: grid; place-items: center; }
.v13-row .pill { white-space: nowrap; }

/* drafts / completed inside a day */
.v13-drafts { margin-top: 12px; }
.v13-drafts .draft-nudge { width: 100%; margin: 0; }
.v13-drafts ul { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 13px; }
.v13-done { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 8px; }
.v13-done > summary { cursor: pointer; color: var(--muted); font-weight: 650; min-height: var(--tap); display: flex; align-items: center; }
.v13-done-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 6px 0; border-bottom: 1px solid #EEF2F6; }
.v13-done-row .title-button { color: var(--muted); text-align: left; overflow-wrap: anywhere; }
.v13-done-row small { grid-column: 1; color: var(--muted-2); font-size: 12px; }
.v13-done-row .text-button { grid-column: 2; grid-row: 1 / span 2; align-self: center; min-height: 36px; }

/* 24-hour strip */
.v13-strip { position: relative; height: 10px; margin: 10px 0 6px; border-radius: 999px; background: #EEF2F7; overflow: hidden; }
.v13-strip i { position: absolute; top: 0; bottom: 0; }
.v13-strip .v13-free { background: var(--sky-soft); }
.v13-strip .v13-busy { background: var(--brand-2); border-radius: 2px; }
.v13-strip .v13-pending { background: repeating-linear-gradient(135deg, #FF7A5966 0 4px, transparent 4px 8px); border: 1px dashed var(--action); box-sizing: border-box; }
.v13-strip .v13-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: #FFFFFFB3; }

/* ---------- Week (本週／下週, and the phone calendar) ---------- */
.v13-week .section-heading { align-items: flex-start; }
.v13-totals { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 14px; }
.v13-totals span { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.v13-totals b { color: var(--brand); margin-left: 2px; font-variant-numeric: tabular-nums; }
.v13-days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.v13-day { display: flex; flex-direction: column; min-width: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.v13-day.is-today { border-color: var(--sky); box-shadow: inset 0 3px 0 var(--sky); }
.v13-day.is-selected { border-color: var(--brand-2); }
.v13-day.is-past { background: #FAFBFC; }
.v13-day-hit { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 2px 0; border: 0; background: transparent; text-align: left; color: var(--ink); border-radius: 10px; }
.v13-day-hit:hover .v13-go { color: var(--brand); transform: translateX(2px); }
.v13-date { display: flex; align-items: baseline; gap: 6px; }
.v13-date strong { font-size: 24px; line-height: 1; color: var(--brand); font-variant-numeric: tabular-nums; }
.v13-day.is-past .v13-date strong { color: var(--muted-2); }
.v13-date span { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.v13-free-label { justify-self: end; font-size: 12px; color: var(--muted); white-space: nowrap; }
.v13-free-label b { margin-left: 4px; color: var(--ok-ink); font-size: 14px; }
.v13-go { color: var(--muted-2); font-size: 22px; line-height: 1; transition: transform .15s var(--ease); }
.v13-preview { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 2px; }
.v13-preview button { display: flex; gap: 8px; width: 100%; min-height: 36px; align-items: center; padding: 4px 6px; border: 0; border-radius: 8px; background: transparent; text-align: left; color: var(--ink); font-size: 13px; }
.v13-preview button:hover { background: var(--brand-soft); }
.v13-preview time { flex-shrink: 0; font-size: 12px; font-weight: 650; color: var(--brand-2); font-variant-numeric: tabular-nums; }
.v13-preview span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v13-li-event button { background: var(--brand-soft); }
.v13-li-task span:first-child { color: var(--muted-2); }
.v13-li-task.is-overdue span:last-child { color: var(--danger-ink); }
.v13-none { margin: 6px 0 0; color: var(--muted-2); font-size: 13px; }
.v13-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.v13-chip { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.v13-chip-event { background: var(--brand-soft); color: var(--brand); }
.v13-chip-task { background: var(--warn-bg); color: var(--warn-ink); }
.v13-chip-done { background: var(--ok-bg); color: var(--ok-ink); }
.v13-chip-draft { background: var(--action-soft); color: var(--action-ink); border: 1px dashed var(--action); }
.v13-goals { margin: 8px 0 0; font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.v13-goals > span:first-child { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.v13-more { margin-top: 8px; }
.v13-more > summary { cursor: pointer; color: var(--brand-2); font-size: 13px; font-weight: 650; min-height: 36px; display: flex; align-items: center; }
.v13-more .priority-row { padding: 10px 4px; gap: 10px; }
.v13-more .priority-row time { min-width: 0; font-size: 13px; }

/* Phone full-calendar week: vertical agenda replaces the 1580px horizontal grid */
.v13-week-agenda { margin: 10px 0 14px; }
.v13-cal-weekhead { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; gap: 8px; text-align: center; }
.v13-cal-weekhead button { min-height: var(--tap); padding: 0; font-size: 20px; }
.v13-cal-weekhead strong { color: var(--brand); }
.v13-cal-hint { text-align: center; margin: 4px 0 10px; }
.v13-days-cal { touch-action: pan-y; }
#schedule-content.v13-cal-agenda .cal-scroll.week-view,
#schedule-content.v13-cal-agenda .cal-toolbar > .row:first-child,
#schedule-content.v13-cal-agenda .cal-summary,
#schedule-content.v13-cal-agenda .cal-legend,
#schedule-content.v13-cal-agenda > p.micro { display: none; }   /* the agenda header carries week, totals and navigation */
.v13-cal-weekhead > div { display: grid; justify-items: center; gap: 2px; }
#schedule-content .v13-cal-weekhead .v13-cal-today, .v13-cal-now { min-height: 28px; padding: 0 8px; font-size: 12px; font-weight: 650; }
.v13-cal-now { color: var(--ok-ink); font-weight: 650; }
.v13-cal-sum { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 8px 0 2px; }
.v13-cal-sum span { padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.v13-cal-sum b { color: var(--brand); }
.v13-grid-toggle { margin-top: 10px; }
.v13-grid-toggle > summary { cursor: pointer; color: var(--muted); font-size: 13px; min-height: 36px; display: flex; align-items: center; }

/* ---------- Quick index: complete names, up to two lines, link entries marked ---------- */
.v12-qi button[data-qi] { white-space: normal; max-width: 9.5em; line-height: 1.3; overflow-wrap: anywhere; }
.v12-qi .v12-qi-link { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.v12-qi .v12-qi-link button { color: var(--brand-2); }

/* ---------- Projects: 進度與預算 ---------- */
.v13-project-line { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.project-summary .v13-project-line .project-percent { display: inline; margin: 0; font-size: 15px; line-height: inherit; color: var(--brand); }
.v13-pb-grid { margin-top: 4px; }
.v13-pb > summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--brand-2); font-weight: 650; }
.v13-pb-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.v13-meter { margin-bottom: 6px; }
.v13-meter-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.v13-meter-head strong { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.v13-meter .progress { margin-top: 6px; }
.v13-meter.is-warning .progress span { background: #E3A008; }
.v13-meter.is-over .progress span { background: var(--action); }
.v13-meter.is-over .v13-meter-head strong { color: var(--danger-ink); }
.v13-budget { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.v13-budget + .v13-budget { margin-top: 10px; }
.v13-budget.is-empty strong { color: var(--muted); }
.v13-money { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; margin: 8px 0 4px; }
.v13-money div { min-width: 0; }
.v13-money dt { font-size: 12px; color: var(--muted); }
.v13-money dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.v13-scope { margin: 2px 0 0; }
.v13-pb-extra { margin-top: 10px; }

@media (max-width: 900px) {
  .v13-worknav-head { flex-direction: column; align-items: stretch; }
  .v13-seg { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-flow: row; width: 100%; }
  .v13-seg [role=tab] { padding: 0 6px; min-height: var(--tap); }
  .v13-days { grid-template-columns: 1fr; gap: 10px; }
  .v13-day { padding: 10px 12px; }
  .v13-pb-grid { grid-template-columns: 1fr; }
  .v12-qi button[data-qi] { max-width: 12em; }
}
@media (max-width: 380px) {
  .v13-date strong { font-size: 20px; }
  .v13-money { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .v13-go, .v13-day-hit:hover .v13-go { transition: none; transform: none; } }

/* ---------- Day timeline alignment (V0.13 fix) ----------
   v04.css `button { min-height: 40px }` made the 48 half-hour slots 40px tall (1920px) inside a 1440px timeline,
   while events, the "now" line and the 24:00 label are positioned on the 1440px scale: an 11:00 event was drawn at
   ~08:15 and 24:00 appeared at ~18:00. Slots go back to the designed 30px so every layer shares one scale. */
.cal-timeline .cal-slot { min-height: 0; height: 30px; }
.cal-slot.is-busy { background: #EEF1FA; }
