/* Version 3.5: plans, calendar, exercise preview and Skill progress. Uses the shared tokens in styles.css (light + dark). */

.plan-head { display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.plan-head h2 { margin: 0 0 4px; font-size: 18px; }
.plan-head .row-actions { margin: 0; }
.plan-dates { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0; font-weight: 600; }
.plan-dates .ic { width: 18px; height: 18px; flex: none; }
.plan-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-title-row h1 { margin-bottom: 4px; }
.plan-empty p { margin-top: 0; }

.plan-cards { display: grid; gap: 10px; margin: 10px 0 18px; }
.plan-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: inherit; text-decoration: none; min-height: 64px; }
.plan-card .plan-card-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.plan-card strong { overflow-wrap: anywhere; }
.plan-card > .ic { flex: none; color: var(--text-2); }
.plan-cover { width: 52px; height: 52px; flex: none; border-radius: var(--radius); background: var(--light-gray); display: grid; place-items: center; overflow: hidden; color: var(--text-2); }
.plan-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plan-cover.sm { width: 40px; height: 40px; }
.plan-cover .media-missing { font-size: 9px; text-align: center; padding: 2px; }

.plan-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.plan-tabs a { flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.plan-tabs a.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.plan-tabs a:focus-visible, .cal-day:focus-visible, .plan-card:focus-visible, .day-entry:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.plan-manage { position: relative; }
.plan-manage-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.plan-manage h2 { margin: 0 0 4px; font-size: 18px; }
.plan-manage .section-menu { position: absolute; right: 8px; bottom: 8px; }
.plan-manage .row-actions { padding-right: 44px; }
.plan-steps { margin: 6px 0 0; padding-left: 20px; }
.plan-steps li { margin: 4px 0; }
.plan-row h3 { margin: 0; font-size: 15px; }

/* status chips always carry text, never colour alone */
.status-chip { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--light-gray); color: var(--text); width: fit-content; }
.status-chip .ic { width: 14px; height: 14px; }
.status-chip.st-completed, .status-chip.st-ended_early, .status-chip.st-extra { background: var(--success-soft); color: var(--success); }
.status-chip.st-in_progress { background: var(--info-soft); color: var(--info); }
.status-chip.st-not_recorded { background: var(--warning-soft); color: var(--warning-text); }
.status-chip.st-skipped, .status-chip.st-removed { background: var(--light-gray); color: var(--text-2); }

/* calendar */
.cal-card { padding: 12px; }
.cal-head { margin: 0 0 8px; font-size: 17px; }
.cal-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-toolbar .btn { margin: 0; }
.cal-mode { display: flex; gap: 6px; margin-left: auto; }
.chip-btn.is-on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-2); padding-bottom: 2px; }
.cal-day { font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); min-height: 44px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; cursor: pointer; min-width: 0; }
.cal-day.strip { min-height: 64px; }
.cal-day .dow { font-size: 11px; color: var(--text-2); }
.cal-day .num { font-weight: 700; font-size: 15px; line-height: 1.2; }
.cal-day.is-dim { opacity: .45; }
.cal-day:not(.in-plan) { background: transparent; }
.cal-day.is-today .num { text-decoration: underline; text-underline-offset: 3px; }
.cal-day.is-selected { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day .marker { min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.cal-day .marker.none { visibility: hidden; }
.marker.m-planned { background: var(--info-soft); color: var(--info); }
.marker.m-done { background: var(--success-soft); color: var(--success); }
.marker.m-progress { background: var(--primary); color: var(--on-primary); }
.marker.m-missed { background: var(--warning-soft); color: var(--warning-text); }
.marker.m-skipped { background: var(--light-gray); color: var(--text-2); }
.cal-legend { margin: 8px 0 0; }
.day-head { font-size: 17px; margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.day-list { display: grid; gap: 8px; }
.day-entry { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: inherit; text-decoration: none; }
.day-entry > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.day-entry strong { overflow-wrap: anywhere; }
.day-entry .btn { margin: 0; flex: none; }

/* exercise preview */
.pv-head { display: flex; gap: 12px; align-items: flex-start; }
.pv-head h1 { margin: 0 0 4px; }
.pv-cover { width: 72px; height: 72px; flex: none; }
.pv-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pv-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.pv-text { min-width: 0; flex: 1; }
.pv-text h3 { margin: 0 0 2px; font-size: 15px; overflow-wrap: anywhere; }
.pv-text p { margin: 2px 0; }
.pv-note { color: var(--text-2); font-size: 13px; }
.pv-notes summary { cursor: pointer; color: var(--text-2); font-size: 13px; }
.pv-notes p { font-size: 13px; color: var(--text-2); }
.pv-section { margin-bottom: 14px; }
.date-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.date-actions .btn { margin: 0; }
.start-bar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; padding-top: 8px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); margin-top: 8px; padding-bottom: 4px; }
.start-bar .btn-block { margin: 6px 0; }
.start-now .ic { margin-right: 6px; }

/* import preview */
.import-preview h3 { margin: 14px 0 6px; font-size: 15px; }
.plain-list { margin: 4px 0; padding-left: 18px; }
.plain-list li { margin: 3px 0; overflow-wrap: anywhere; }
.change-list li { font-size: 14px; }
.ex-match { display: grid; gap: 8px; }
.ex-match-row { border-top: 1px solid var(--line); padding-top: 8px; }
.ex-match-row p { margin: 2px 0; }
.check-row { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 14px; }
.check-row input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--primary); }
.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.paste-fallback summary { cursor: pointer; margin-top: 10px; }
.link-btn.inline { padding: 0; min-height: 0; display: inline; font-size: inherit; }

/* revisions */
.rev-card p { margin: 4px 0; }

/* tables (accessible alternative to charts) */
.table-wrap { overflow-x: auto; margin: 10px 0 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table thead th { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: 0; }
.tiny.block { display: block; font-weight: 400; }
.chart .mark { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.sets-detail summary { cursor: pointer; font-weight: 600; }
.sets-detail .sum-row { color: inherit; text-decoration: none; }
.series-row h3 { margin: 0; }
.series-row .chip { margin-top: 4px; }

/* skill progress */
.range-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.range-row .field { flex: 1 1 130px; margin: 0; }
.obs-row { align-items: flex-start; }
.obs-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.obs-edit form { display: flex; gap: 6px; align-items: flex-end; margin-top: 6px; }
.obs-edit summary { list-style: none; cursor: pointer; }
.obs-edit .field { margin: 0; }
.is-dim { opacity: .65; }

/* setup recorded for a set (player + history) */
.setup-line { grid-column: 1 / -1; margin: 0; }
.setup-line:empty { display: none; }
.setup-chip { display: inline-block; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: var(--info-soft); color: var(--info); font-size: 12px; font-weight: 600; }
.set-setup { grid-column: 1 / -1; }
.setup-fields { display: grid; gap: 6px; padding: 8px; border: 1px dashed var(--line); border-radius: var(--radius); margin: 4px 0 6px; }
.setup-fields .field { margin: 0; font-size: 13px; }
.set-setup.hist { width: 100%; font-size: 13px; }
.set-setup.hist summary { cursor: pointer; color: var(--text-2); }
.sum-row.has-setup { flex-wrap: wrap; }
.sum-row.has-setup .sum-inputs { flex-wrap: wrap; }
.plan-prov { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.plan-prov .ic { width: 16px; height: 16px; }

/* four-option segmented control (Progress) */
.segmented .seg:first-child:nth-last-child(4), .segmented .seg:first-child:nth-last-child(4) ~ .seg { font-size: 12.5px; flex: 1 1 auto; padding: 0 6px; }
@media (max-width: 360px) {
  .segmented .seg:first-child:nth-last-child(4), .segmented .seg:first-child:nth-last-child(4) ~ .seg { font-size: 11.5px; padding: 0 4px; }
  .cal-day.strip { min-height: 58px; }
  .cal-day .num { font-size: 14px; }
}

.data-table th[scope="row"] { min-width: 92px; }
.data-table th, .data-table td { padding: 8px 6px; }
.data-table td:last-child { min-width: 96px; }
.plan-dates + .tiny, .plan-head .tiny { margin: 2px 0; }

.obs-actions .link-btn { white-space: nowrap; }
.obs-row > div:first-child { min-width: 0; }
