/* Modeled on iOS Reminders: system font, inset hairlines, hollow circles, an accent title. */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.22);
  --grouped: #f2f2f7;
  --card: #ffffff;
  --fill: rgba(118, 118, 128, 0.12);
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, 0.12);
  --on-accent: #ffffff;
  --danger: #ff3b30;
  --scrim: rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --gutter: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #ffffff;
    --secondary: rgba(235, 235, 245, 0.6);
    --tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.55);
    --grouped: #000000;
    --card: #1c1c1e;
    --fill: rgba(118, 118, 128, 0.24);
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.2);
    --danger: #ff453a;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body.focusing { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; opacity: 0.35; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  color: var(--accent);
  border-radius: 22px;
}
.icon-btn svg circle { fill: currentColor; stroke: none; }
.icon-btn.accent svg circle { fill: none; stroke: currentColor; }
#menu-btn svg, #focus-close svg { stroke-width: 2.2; }

.link { color: var(--accent); padding: 10px 4px; }
.link.strong { font-weight: 600; }

.button {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 14px;
  min-width: 200px;
}

.hint { color: var(--secondary); font-size: 13px; margin: 8px var(--gutter); }

/* -- list ------------------------------------------------------------------------- */

#app { min-height: 100dvh; display: flex; flex-direction: column; }
#app.blocked { visibility: hidden; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 2px) calc(var(--safe-right) + 6px) 2px calc(var(--safe-left) + 6px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.pill {
  font-size: 13px; color: var(--secondary);
  background: var(--fill); border-radius: 999px; padding: 4px 10px;
}

#list-view {
  flex: 1;
  padding: 0 var(--safe-right) calc(96px + var(--safe-bottom)) var(--safe-left);
}

.title-wrap { position: relative; margin: 2px var(--gutter) 10px; }
.title-wrap h1 {
  margin: 0;
  font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: 0.01em;
  color: var(--accent);
}
/* An invisible native picker over the title: tapping the title opens the date-time wheel. */
#title-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; font-size: 16px;
  border: 0; margin: 0; padding: 0;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
}

.rows, .subs { list-style: none; margin: 0; padding: 0; }

.row {
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}
.row .swipe {
  position: relative; z-index: 1;
  display: flex; align-items: flex-start;
  background: var(--bg);
  transition: transform 0.25s ease;
  padding-left: var(--gutter);
}
.row.dragging .swipe { transition: none; }
.row.open .swipe { transform: translateX(-84px); }
.row .delete {
  position: absolute; z-index: 0; top: 0; right: 0; bottom: 0;
  width: 84px;
  background: var(--danger); color: #fff;
  font-size: 15px; font-weight: 500;
}

.check {
  flex: none;
  width: 24px; height: 24px; margin: 11px 12px 0 0;
  border-radius: 50%;
  border: 1.5px solid var(--tertiary);
  display: grid; place-items: center;
  transition: border-color 0.15s;
}
/* A bigger invisible tap target than the circle itself. */
.check::before { content: ""; position: absolute; width: 48px; height: 48px; margin-left: -12px; }
.check::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); transform: scale(0); transition: transform 0.18s ease;
}
.row.done > .swipe > .check { border-color: var(--accent); }
.row.done > .swipe > .check::after { transform: scale(1); }
.check.pop { animation: pop 0.3s ease; }
@keyframes pop { 40% { transform: scale(1.18); } }

.body {
  flex: 1; min-width: 0;
  padding: 11px var(--gutter) 9px 0;
  border-bottom: 0.5px solid var(--separator);
}

.tap {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; text-align: left;
  min-height: 24px;
}
.name { font-size: 17px; line-height: 24px; overflow-wrap: anywhere; }
.detail { font-size: 15px; color: var(--secondary); margin-top: 1px; }
.row.done .name { color: var(--secondary); }

textarea.notes {
  display: block;
  width: 100%;
  margin: 2px 0 0; padding: 0;
  border: 0; outline: 0; resize: none; overflow: hidden;
  background: transparent; color: var(--secondary);
  font: 15px/1.35 inherit;
  font-family: inherit;
  min-height: 20px;
}
textarea.notes::placeholder { color: var(--tertiary); opacity: 0.7; }
textarea.notes:not(:focus):placeholder-shown { font-size: 13px; }

/* Sets sit indented under their workout, like subtasks. */
.subs .row .swipe { padding-left: calc(var(--gutter) + 36px); }
.subs .check { width: 22px; height: 22px; margin-top: 10px; }
.subs .check::after { width: 12px; height: 12px; }
.subs .name { font-size: 16px; }
.item.multi > .row .body { border-bottom-color: transparent; }

.empty { color: var(--tertiary); text-align: center; margin: 48px var(--gutter); font-size: 17px; }

.start-state { display: none; text-align: center; color: var(--secondary); margin: 30vh var(--gutter) 0; }
#list-view.no-sessions .start-state { display: block; }

.toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  height: calc(64px + var(--safe-bottom));
  padding: 0 calc(var(--safe-right) + var(--gutter)) var(--safe-bottom) calc(var(--safe-left) + var(--gutter));
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.toolbar .add {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-weight: 600; font-size: 17px;
  padding: 10px 0;
}
.toolbar .add svg { width: 24px; height: 24px; }
@media (max-width: 359px) { .toolbar .add { font-size: 0; } .toolbar .add svg { width: 30px; height: 30px; } }
.toolbar .add svg circle { fill: var(--accent); stroke: none; }
.toolbar .add svg path { stroke: var(--on-accent); stroke-width: 2.4; }

.play {
  position: absolute; left: 50%; top: 4px;
  width: 56px; height: 56px; margin-left: -28px;
  border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.play svg { width: 26px; height: 26px; fill: currentColor; stroke: none; margin-left: 3px; }
.play:disabled { opacity: 0.3; box-shadow: none; }

/* -- drawer ----------------------------------------------------------------------- */

.scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  opacity: 0; transition: opacity 0.25s ease;
}

.drawer { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.drawer.open { pointer-events: auto; }
.drawer.open .scrim { opacity: 1; }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(84vw, 330px);
  display: flex; flex-direction: column;
  background: var(--grouped);
  padding: calc(var(--safe-top) + 8px) 0 0 var(--safe-left);
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1), box-shadow 0.28s;
}
.drawer.open .drawer-panel { transform: none; box-shadow: var(--shadow); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 var(--gutter); }
.drawer-head h2 { font-size: 28px; font-weight: 700; margin: 6px 0; }

.sessions {
  list-style: none; margin: 8px 12px; padding: 0;
  flex: 1; overflow-y: auto;
}
.sessions li + li { margin-top: 2px; }
.session {
  width: 100%; text-align: left;
  display: flex; flex-direction: column;
  padding: 10px 12px; border-radius: 10px;
}
.session.current { background: var(--card); }
.session-title { font-size: 17px; }
.session.current .session-title { color: var(--accent); font-weight: 600; }
.session-sub { font-size: 13px; color: var(--secondary); margin-top: 2px; }

.account {
  display: flex; align-items: center; gap: 12px;
  padding: 12px var(--gutter) calc(12px + var(--safe-bottom));
  border-top: 0.5px solid var(--separator);
  background: var(--card);
}
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--fill); color: var(--secondary); font-weight: 600;
}
.acct-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acct-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.acct-sub { font-size: 13px; color: var(--secondary); }

/* -- details sheet ---------------------------------------------------------------- */

.sheet { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.sheet.open { pointer-events: auto; }
.sheet.open .scrim { opacity: 1; }
.sheet.instant .sheet-panel, .sheet.instant .scrim { transition: none; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  height: calc(100dvh - var(--safe-top) - 24px);
  background: var(--grouped);
  border-radius: 12px 12px 0 0;
  transform: translateY(102%);
  transition: transform 0.32s cubic-bezier(0.3, 0.7, 0.2, 1), box-shadow 0.32s;
  overflow: hidden;
}
.sheet.open .sheet-panel { transform: none; box-shadow: var(--shadow); }
.page { height: 100%; display: flex; flex-direction: column; }
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 6px 12px;
  border-bottom: 0.5px solid var(--separator);
  background: var(--grouped);
}
.sheet-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-head .back { display: inline-flex; align-items: center; margin-left: -8px; }
.sheet-head .back svg { stroke-width: 2.6; }
.sheet-body {
  flex: 1; overflow-y: auto;
  padding: 18px var(--gutter) calc(24px + var(--safe-bottom));
}

.group {
  list-style: none; margin: 0 0 22px; padding: 0;
  background: var(--card); border-radius: 10px; overflow: hidden;
}
.group-title {
  font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em;
  color: var(--secondary); margin: 0 var(--gutter) 6px;
}
.field {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 48px;
  padding: 6px var(--gutter);
  text-align: left;
  position: relative;
}
.group > .field + .field::before, .picks li + li::before {
  content: ""; position: absolute; top: 0; left: var(--gutter); right: 0;
  border-top: 0.5px solid var(--separator);
}
.picks li { position: relative; }
.field .label { flex: 1; }
.field .value { display: flex; align-items: center; gap: 6px; color: var(--secondary); }
.field .value.placeholder { color: var(--accent); }
.field.nav .chev svg { width: 18px; height: 18px; color: var(--tertiary); stroke-width: 2.4; }
.field.danger { color: var(--danger); justify-content: center; }

.num {
  width: 90px; text-align: right;
  font: inherit; font-size: 17px;
  color: var(--fg); background: none; border: 0; outline: 0; padding: 6px 0;
}
.num::placeholder { color: var(--tertiary); }
.num.invalid { color: var(--danger); }
.unit { color: var(--secondary); }

.stepper {
  display: inline-flex; align-items: center;
  background: var(--fill); border-radius: 9px; overflow: hidden;
}
.stepper button { width: 46px; height: 34px; font-size: 22px; line-height: 1; color: var(--fg); }
.stepper .count { min-width: 34px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.segmented {
  display: inline-flex; padding: 2px;
  background: var(--fill); border-radius: 9px;
}
.segmented button { padding: 6px 14px; border-radius: 7px; font-size: 15px; font-weight: 500; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14); }
@media (prefers-color-scheme: dark) { .segmented button.on { background: #636366; } }

.search {
  width: 100%; margin: 0 0 18px;
  padding: 9px 12px;
  border: 0; border-radius: 10px;
  background: var(--fill); color: var(--fg);
  font: inherit; font-size: 17px;
  -webkit-appearance: none; appearance: none;
}
.pick {
  width: 100%; min-height: 48px;
  display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px;
  padding: 8px var(--gutter); text-align: left;
}
.pick-name { flex: 1; }
.pick-sub { flex-basis: 100%; order: 3; font-size: 13px; color: var(--secondary); }
.pick.on .pick-name { color: var(--accent); }
.pick .tick svg { color: var(--accent); width: 20px; height: 20px; stroke-width: 2.6; }
.pick.add { color: var(--accent); }
.pick.add .plus svg { width: 24px; height: 24px; display: block; }
.pick.add .plus svg circle { fill: var(--accent); stroke: none; }
.pick.add .plus svg path { stroke: var(--on-accent); }
.adder { display: flex; align-items: center; gap: 8px; padding: 4px var(--gutter); }
.add-input {
  flex: 1; min-width: 0; padding: 10px 0;
  border: 0; outline: 0; background: none; color: var(--fg);
  font: inherit; font-size: 17px;
}

/* -- focus view ------------------------------------------------------------------- */

.focus {
  position: fixed; inset: 0; z-index: 15;
  display: flex; flex-direction: column;
  background: var(--bg);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.focus.flash { animation: flash 0.45s ease; }
@keyframes flash { 0% { background: var(--accent-soft); } }

.focus-head { display: flex; align-items: center; gap: 10px; padding: 4px 16px 4px 6px; }
.focus-head .icon-btn svg { width: 28px; height: 28px; }
.focus-progress { flex: 1; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.focus-bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.35s ease; }
.focus-count { font-size: 13px; color: var(--secondary); font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }

.focus-main {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: 4vh 24px 12px;
}
.focus-step {
  margin: 0 0 8px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent);
}
.focus-name { margin: 0; font-size: clamp(34px, 10vw, 52px); line-height: 1.05; font-weight: 800; letter-spacing: -0.01em; }
.focus-stats { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 16px 0 0; color: var(--secondary); font-size: 20px; }
.focus-stats b { color: var(--fg); font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.focus-dots { display: flex; gap: 8px; margin: 18px 0 0; }
.focus-dots:empty { display: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--tertiary); }
.dot.on { background: var(--accent); border-color: var(--accent); }
.dot.now { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.focus-ex-notes {
  margin: 18px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--fill); color: var(--secondary); font-size: 15px;
  white-space: pre-wrap; max-height: 20vh; overflow-y: auto;
}
textarea.focus-notes {
  flex: 1; min-height: 120px;
  margin-top: 20px; padding: 14px 16px;
  border-radius: 14px;
  background: var(--fill); color: var(--fg);
  font-size: 18px; line-height: 1.4;
  overflow-y: auto;
}
textarea.focus-notes::placeholder { font-size: 18px; }

.focus-actions {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 24px 18px;
}
.complete {
  width: 100%; max-width: 520px; height: 64px;
  border-radius: 18px;
  background: var(--accent); color: var(--on-accent);
  font-size: 20px; font-weight: 700;
}
.complete:active { transform: scale(0.98); }

.focus-finished { display: none; }
.focus.finished .focus-main, .focus.finished .focus-actions { display: none; }
.focus.finished .focus-finished {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 4px;
}
.focus-finished h1 { margin: 18px 0 0; font-size: 30px; }
.focus-finished p { margin: 0 0 28px; color: var(--secondary); }
.big-check {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
}
.big-check svg { width: 54px; height: 54px; stroke-width: 2.6; }

/* -- sign-in ---------------------------------------------------------------------- */

.signin {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: var(--grouped);
  padding: var(--gutter);
}
.signin-card { text-align: center; }
.signin-card img { border-radius: 16px; }
.signin-card h1 { margin: 16px 0 4px; font-size: 28px; }
.signin-card p { margin: 0 0 28px; color: var(--secondary); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
