/* Planner: white cards over the same sky as the home page */
:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --muted: #56606a;
  --line: rgba(40, 60, 80, .16);
  --card: rgba(255, 255, 255, .88);
  --accent: #3f7f86;
  --accent-ink: #fff;
  --danger: #b4492f;
  --today: #e8b04a;
  --climbing: #3f7f86;
  --general: #d9915f;
  --focus-base: #7fa98a;
  --focus-strength: #c4553f;
  --focus-power: #d9663a;
  --focus-power_endurance: #e8b04a;
  --focus-performance: #5f6fa8;
  --focus-recovery: #9aa5ad;
}
* { box-sizing: border-box; }
html { background: #dce7ef; }
body {
  margin: 0; min-height: 100vh;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  background: linear-gradient(to bottom, #7fb0d8 0%, #a5c8e3 30%, #c9dcea 65%, #dce7ef 100%) fixed;
}
/* the gradient above is the daytime fallback; sky.js sets it from the time of day. At night the
   text that sits right on the sky (top bar, breadcrumbs above the cards) turns light; cards stay white. */
body.night .brand, body.night .topbar nav a:not([aria-current]), body.night main > .crumbs,
body.night main > .crumbs a { color: #eef2f7; }
body.night main > .crumbs .sep { color: #b4c0cd; }
body.night .topbar nav a:hover { background: rgba(255, 255, 255, .14); }
a { color: var(--accent); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1100px; margin: 0 auto; padding: 18px 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 1.15rem; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
}
.brand svg { width: 22px; height: 22px; fill: currentColor; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.topbar nav a {
  padding: 6px 12px; border-radius: 999px;
  color: var(--ink); text-decoration: none; font-size: .95rem;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .5); }
.topbar nav a[aria-current] { background: var(--card); font-weight: 600; }
/* account: login link, or the user and logout (only when login is configured) */
.account { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: .9rem; }
.account-name { font-weight: 600; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.login, .link-button {
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--card); color: var(--accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
a.login:hover, .link-button:hover { background: var(--accent); color: #fff; filter: none; }
body.night .account-name { color: #eef2f7; }

main { max-width: 1100px; margin: 0 auto; padding: 0 16px 64px; }
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px 22px;
  margin: 0 0 16px;
  box-shadow: 0 1px 2px rgba(30, 50, 70, .08);
}
h1, h2, h3 { margin: 0 0 8px; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.2rem; font-weight: 600; }
h2 a { color: inherit; text-decoration: none; }
h2 a:hover { text-decoration: underline; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.notes, .goal { white-space: pre-line; }
.heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.heading h1, .heading h2 { margin: 0; }
.heading + * { margin-top: 10px; }
.notice { background: #fbeee0; border: 1px solid #e8b04a; border-radius: 10px; padding: 10px 14px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; font-size: .95rem; }
.card .crumbs { margin: 0; }
.crumbs .sep { color: var(--muted); }
.context { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.context .muted { margin: 0; }

.pager { display: flex; gap: 6px; }
.pager a {
  min-width: 40px; padding: 4px 12px; text-align: center;
  border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); text-decoration: none; background: #fff;
}
.pager a:hover { border-color: var(--accent); }

.totals { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); margin: 0; }
.totals span:first-child { color: var(--ink); }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; color: #fff; background: var(--muted);
  vertical-align: middle;
}
.focus-base { background: var(--focus-base); }
.focus-strength { background: var(--focus-strength); }
.focus-power { background: var(--focus-power); }
.focus-power_endurance { background: var(--focus-power_endurance); color: var(--ink); }
.focus-performance { background: var(--focus-performance); }
.focus-recovery { background: var(--focus-recovery); }

/* Days of a week or microcycle: one under another, the date on the left, sessions on the right */
.days { display: flex; flex-direction: column; gap: 8px; margin: 0 0 24px; }
.day {
  background: var(--card); border-radius: 12px; padding: 10px 14px;
  display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 6px 12px; align-items: start;
  border-left: 4px solid transparent;
}
.day.today { border-left-color: var(--today); }
.day h3 { grid-column: 1; grid-row: 1 / span 2; font-size: .95rem; margin: 0; padding-top: 6px; text-transform: capitalize; }
.day .sessions, .day .add { grid-column: 2; }
.day .add { justify-self: start; padding: 5px 0; font-size: .9rem; color: var(--muted); text-decoration: none; }
.day .add:hover { color: var(--accent); }
/* on wide screens the sessions of one day sit side by side */
@media (min-width: 760px) {
  .day .sessions { flex-direction: row; flex-wrap: wrap; }
  .day .session { flex: 1 1 260px; max-width: 420px; }
}
/* phone: the date above its sessions, so they get the full width */
@media (max-width: 560px) {
  .day { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 12px; }
  .day h3, .day .sessions, .day .add { grid-column: 1; grid-row: auto; }
  .day h3 { padding-top: 0; }
  .day .add { padding: 2px 0; }
}

.sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.session {
  display: flex; gap: 8px; align-items: flex-start;
  background: #fff; border-radius: 8px; padding: 7px 8px;
  border-left: 4px solid var(--muted);
}
.session.kind-climbing { border-left-color: var(--climbing); }
.session.kind-general { border-left-color: var(--general); }
.session a { display: flex; flex-direction: column; min-width: 0; color: var(--ink); text-decoration: none; }
.session a:hover .title { text-decoration: underline; }
.session .title { font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.session .meta { font-size: .8rem; color: var(--muted); }
.session.done .title { text-decoration: line-through; color: var(--muted); }
.check {
  flex: none; width: 22px; height: 22px; padding: 0; margin-top: 1px;
  border: 1.5px solid var(--line); border-radius: 6px; background: #fff;
  color: transparent; font-size: .8rem; line-height: 1; cursor: pointer;
}
.check:hover { border-color: var(--accent); color: var(--line); }
.check[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Proportional timeline of child cycles */
.timeline {
  position: relative; height: 34px; margin: 14px 0 4px;
  background: rgba(40, 60, 80, .07); border-radius: 8px; overflow: hidden;
}
.timeline .seg {
  position: absolute; top: 0; bottom: 0;
  display: flex; align-items: center; padding: 0 8px;
  color: #fff; font-size: .8rem; font-weight: 600; text-decoration: none;
  border-right: 2px solid #fff; overflow: hidden;
}
.timeline .seg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline .seg.focus-power_endurance { color: var(--ink); }
.timeline .seg:hover { filter: brightness(1.08); }
.timeline .now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); pointer-events: none; }
.timeline-scale { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: 10px; }

.cycles { list-style: none; margin: 0; padding: 0; }
.cycles li {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.cycles li:first-child { border-top: 0; }
.cycles a { font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 20px; padding: 0; list-style: none; color: var(--muted); }

/* Forms */
form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field .label { font-size: .85rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .8rem; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row .field { min-width: 150px; }
input, select, textarea {
  font: inherit; color: inherit;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
/* Same look and height for selects, dates and numbers everywhere: phones (iOS above all) draw them
   their own way, with widths from the longest option or the date, which broke the rows. */
input, select, textarea { min-width: 0; max-width: 100%; }
select, input[type="date"], input[type="number"] {
  -webkit-appearance: none; appearance: none;
  min-height: 40px; line-height: 1.3;
}
select {
  padding-right: 32px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2356606a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 11px center / 12px 8px;
}
input[type="date"] { display: block; width: 100%; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
textarea { resize: vertical; }
.check-field { display: flex; align-items: center; gap: 8px; }
.check-field input { width: auto; }
.form-error { color: var(--danger); margin: 0; min-height: 0; }
.form-error:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 4px; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button:hover, .button:hover { filter: brightness(1.08); }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
/* "Edit …" sections: folded, they are a slim bar set apart from the content cards above */
details.card:not([open]) { padding: 10px 22px; background: rgba(255, 255, 255, .7); box-shadow: none; border: 1px dashed var(--line); }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 4px; }
details.card > .actions { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }

@media (max-width: 560px) {
  /* phone: brand and account on the first line, the menu under them */
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .topbar nav { gap: 2px; margin-left: -8px; }
  .topbar nav a { padding: 6px 8px; }
  .card { padding: 16px; }
  h1 { font-size: 1.35rem; }
}

/* Exercises of a session (editor) */
fieldset.exercises { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; min-width: 0; }
fieldset.exercises legend { font-size: .85rem; font-weight: 600; padding: 0 4px; }
.exercise-list { display: flex; flex-direction: column; gap: 10px; }
.exercise-list:empty::before { content: "Brak ćwiczeń – dodaj z biblioteki lub własne."; color: var(--muted); font-size: .9rem; }
.exercise-row {
  display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.ex-head { display: flex; gap: 6px; align-items: flex-start; }
.ex-head textarea { font-weight: 600; flex: 1; min-width: 0; }
textarea[data-autosize] { resize: none; overflow: hidden; line-height: 1.35; field-sizing: content; }
.ex-info {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); text-decoration: none; font-weight: 600;
}
.ex-dose { display: grid; gap: 6px; grid-template-columns: 70px repeat(3, minmax(0, 1fr)); }
.ex-dose label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ex-dose span { font-size: .75rem; color: var(--muted); }
.ex-dose input, .ex-dose textarea, .exercise-row > textarea { padding: 6px 8px; font-size: .92rem; }
.ex-dose input, .ex-dose textarea { min-height: 36px; }
@media (max-width: 560px) {
  .ex-dose { grid-template-columns: 1fr 1fr; }
  .ex-dose label:nth-child(3) { grid-column: 1 / -1; } /* load: usually the longest text */
}
.add-exercise { display: flex; gap: 8px; margin-top: 10px; }
.add-exercise select { flex: 1; min-width: 0; }
button.icon { flex: none; width: 32px; height: 32px; padding: 0; background: #fff; color: var(--ink); border-color: var(--line); }
button.icon.danger { color: var(--danger); }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
a.button { display: inline-block; text-decoration: none; }

/* Generator preview and exercise library */
.preview-sessions { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.preview-sessions li { display: flex; flex-direction: column; }
.principles { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.exercise-card { padding: 12px 0; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.exercise-card:first-of-type { border-top: 0; }
.exercise-card:target, .exercise-card:focus-within { background: none; }
.exercise-card h3 { font-size: 1rem; }
.exercise-card h3 .muted { font-weight: 400; font-size: .85rem; }
.exercise-anim { margin: 8px 0 10px; text-align: center; }
/* the colour is the caption's and the countdown's drawn on the canvas (figure3d.js) */
.exercise-3d {
  display: block; width: 100%; max-width: 280px; aspect-ratio: 1; margin: 0 auto; color: var(--muted);
  cursor: grab; touch-action: pan-y; border-radius: 10px; background: #f6f8f5;
}
.exercise-3d:active { cursor: grabbing; }
.exercise-anim figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.doses { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 6px; font-size: .9rem; }
.doses dt { font-weight: 600; }
.doses dd { margin: 0; color: var(--muted); }
fieldset.weekdays { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
fieldset.weekdays legend { font-size: .85rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
fieldset.weekdays small { color: var(--muted); font-size: .8rem; }
.day-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.day-choice {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.day-choice input { width: auto; }
.day-choice:has(input:checked) { border-color: var(--accent); background: #e6f1f2; font-weight: 600; }
.bibliography { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.bibliography a { overflow-wrap: anywhere; }

/* Session read view */
.exercise-read { margin: 12px 0 4px; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.exercise-read li { display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.exercise-read .dose { color: var(--ink); }
.exercise-read .ex-notes { color: var(--muted); font-style: italic; }
.exercise-read details { color: var(--muted); font-size: .92rem; }
.exercise-read summary { cursor: pointer; color: var(--accent); width: fit-content; }
.exercise-read details p { margin: 4px 0 0; }
.done-badge { background: var(--accent); }

/* Unfoldable hint next to a field label (RPE) */
.field .label { display: inline-flex; align-items: center; gap: 6px; }
.hint-toggle {
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  background: #fff; color: var(--accent); border: 1px solid var(--accent);
  font-size: .8rem; line-height: 1;
}
.hint-toggle[aria-expanded="true"] { background: var(--accent); color: #fff; }
.hint {
  background: #f3f7f8; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: .9rem; color: var(--ink);
}
.hint p { margin: 0 0 8px; }
.hint p:last-child { margin: 8px 0 0; color: var(--muted); }
.rpe-scale { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
.rpe-scale dt { font-weight: 600; text-align: right; }
.rpe-scale dd { margin: 0; }

.title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card > .title-row { margin-bottom: 8px; }
.title-row h1 { margin: 0; }
.title-row h1 { overflow-wrap: anywhere; }
.back-arrow {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 1.2rem; text-decoration: none;
}
.back-arrow:hover { border-color: var(--accent); color: var(--accent); }
.actions.end { justify-content: flex-end; }

/* Campsite from the home page (templates/partials/camp.html) as the footer: at the bottom of the
   page on the right, after the content, so it never sits behind the cards. The body is a column
   so the footer stays at the bottom of the window on short pages too. */
body { display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
/* safety net: nothing too wide may make the page scroll sideways (iOS shows it as a wobble) */
body { overflow-x: clip; }
.camp-footer {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  margin-top: -24px; padding-left: 16px;
}
.camp-footer .camp { pointer-events: none; }
.footer-links { padding-bottom: 14px; font-size: .9rem; }
.footer-links a { color: var(--muted); }
.footer-links a[aria-current] { color: var(--ink); font-weight: 600; }
body.night .footer-links a { color: #b4c0cd; }
body.night .footer-links a[aria-current] { color: #eef2f7; }
.camp-footer .camp { display: block; width: min(46vw, 560px); height: auto; }
@media (max-width: 560px) {
  /* phone: the links above the campsite, which takes the full width */
  .camp-footer { flex-direction: column; align-items: stretch; padding-left: 0; }
  .footer-links { padding: 0 16px 4px; }
  .camp-footer .camp { width: 92vw; align-self: flex-end; }
}
body.night .camp .scene { filter: brightness(.42) saturate(.75); }
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite; }
.flame.inner { animation-duration: 1.1s; animation-delay: -.4s; }
@keyframes flicker {
  0%, 100% { transform: scale(1, 1); }
  30% { transform: scale(.92, 1.08) skewX(-3deg); }
  60% { transform: scale(1.05, .94) skewX(2deg); }
}
.smoke { animation: rise 6s linear infinite; opacity: 0; }
.smoke.s2 { animation-delay: -3s; }
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: .35; }
  100% { transform: translate(-14px, -70px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .flame, .smoke { animation: none; } }

/* Account copy of the plan (sync.js) */
#sync-prompt { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
#sync-prompt:empty { display: none; }
.sync-card { border-left: 4px solid var(--accent); }
.sync-status { display: block; margin-top: 4px; color: var(--muted); font-size: .85rem; }
.sync-status[data-status="offline"], .sync-status[data-status="login"], .sync-status[data-status="outdated"],
.sync-status[data-status="unavailable"] { color: var(--danger); }
body.night .sync-status { color: #b4c0cd; }

/* iOS zooms into any field under 16px when it gets focus (and the page stays zoomed): not on phones */
@media (max-width: 560px) {
  input, select, textarea, .ex-dose input, .ex-dose textarea, .exercise-row > textarea { font-size: 16px; }
}

/* Moving a session: drag in the week view, or the "Przenieś" card of a session */
.session[draggable="true"] { cursor: grab; }
.session.dragging { opacity: .45; }
.day.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: #eef6f6; }
.move-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
/* Touch dragging (app.js): no link preview, callout or text selection on a long press of a session,
   and the copy that follows the finger */
.session { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.session a { -webkit-touch-callout: none; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 10; margin: 0; pointer-events: none;
  list-style: none; opacity: .92; box-shadow: 0 8px 20px rgba(20, 40, 60, .28);
  transform-origin: center; will-change: transform;
}
.pager a.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; background: #eef6f6; }
/* "Only this one or all of them?" when moving a session of a plan to another weekday */
.move-dialog {
  max-width: min(440px, calc(100vw - 32px)); padding: 18px 20px; border: 0; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(20, 40, 60, .3); color: var(--ink);
}
.move-dialog::backdrop { background: rgba(20, 30, 40, .35); }
.move-dialog p { margin: 0 0 10px; }
