:root {
  --bg: #fafaf9;
  --card: #ffffff;
  --card-2: #f5f5f4;
  --media: #f1f0ee;
  --text: #18181b;
  --muted: #71717a;
  --line: #e7e5e4;
  --line-2: #d6d3d1;
  --accent: #0f766e;
  --done: #0f766e;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 12px rgba(0,0,0,.04);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0c0e;
    --card: #16181c;
    --card-2: #1e2126;
    --media: #f4f4f5;
    --text: #f4f4f5;
    --muted: #9ca3af;
    --line: #26282e;
    --line-2: #33363d;
    --accent: #2dd4bf;
    --done: #2dd4bf;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: 96px;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 10px; height: 26px; border-radius: 99px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 40%, transparent));
  flex: none;
}
h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--muted);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.days { display: flex; gap: 5px; padding-top: 12px; padding-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.day-btn {
  flex: 1 1 0; min-width: 0;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--card); color: var(--muted);
  padding: 7px 3px 8px; cursor: pointer;
  font-family: inherit; font-size: 12px; line-height: 1.25;
  white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: background .15s, color .15s, border-color .15s;
}
.day-btn b { font-weight: 600; font-size: 14px; }
.day-btn .dot { width: 5px; height: 5px; border-radius: 99px; background: transparent; }
.day-btn.has-progress .dot { background: var(--line-2); }
.day-btn.complete .dot { background: var(--done); }
.day-btn.today { border-color: var(--accent); color: var(--text); }
.day-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.day-btn.active .dot { background: var(--bg); opacity: .55; }
.day-btn.rest { opacity: .62; }

/* ---------- day head ---------- */
.day-head { padding: 20px 0 4px; }
.eyebrow { font-size: 12px; color: var(--accent); font-weight: 500; margin: 0 0 2px; }
.day-head h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.day-meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.progress { margin-top: 14px; }
.progress-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.progress-track { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s ease; }

/* ---------- small pill buttons ---------- */
.mini {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; font-size: 12.5px; line-height: 1;
  color: var(--muted); background: var(--card-2);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 11px; cursor: pointer;
}
.mini svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mini:hover { color: var(--text); border-color: var(--line-2); }
.mini.on { color: var(--accent); border-color: var(--accent); background: transparent; }
.note-btn { margin-top: 14px; }

.note {
  margin: 10px 0 0; padding: 11px 13px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; font-size: 13px; color: var(--muted);
}

/* ---------- exercise cards (image-led) ---------- */
.list { display: flex; flex-direction: column; gap: 16px; margin: 20px 0 10px; padding: 0; list-style: none; }
.ex {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; transition: opacity .2s, border-color .2s;
}
.ex.done { opacity: .48; }
.ex.done:hover { opacity: .8; }

.media { position: relative; background: var(--media); display: grid; place-items: center; padding: 8px 0; }
.media .gif {
  display: block; width: 100%; max-width: 340px; height: auto;
  aspect-ratio: 1 / 1; object-fit: contain;
}
.media .num {
  position: absolute; top: 10px; left: 12px;
  font-size: 12px; font-weight: 600; color: #57534e;
  background: rgba(255,255,255,.82); border-radius: 99px;
  min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px;
}
.media .tag {
  position: absolute; top: 10px; right: 12px;
  font-size: 11px; color: #57534e;
  background: rgba(255,255,255,.82); border-radius: 99px; padding: 2px 9px;
}
.ex.done .media { filter: grayscale(1); }

.body { padding: 14px 14px 15px; }
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.titles { min-width: 0; }
.ex-name { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; line-height: 1.4; }
.ex-en { font-size: 12px; color: var(--muted); margin: 1px 0 0; }
.ex.done .ex-name { text-decoration: line-through; text-decoration-thickness: 1px; }

.tick {
  width: 40px; height: 40px; flex: none; border-radius: 99px;
  border: 1.5px solid var(--line-2); background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: background .15s, border-color .15s;
}
.tick svg { width: 19px; height: 19px; fill: none; stroke: var(--line-2); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tick:hover { border-color: var(--accent); }
.ex.done .tick { background: var(--done); border-color: var(--done); }
.ex.done .tick svg { stroke: var(--card); }

.ex-dose { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.ex-dose b { color: var(--text); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.chip {
  font-size: 11.5px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 2px 9px;
}

.mini-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.cues { margin: 12px 0 0; padding: 12px 13px; list-style: none;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  font-size: 13px; color: var(--muted); }
.cues[hidden] { display: none; }
.cues li { position: relative; padding-inline-start: 15px; }
.cues li + li { margin-top: 6px; }
.cues li::before { content: ""; position: absolute; inset-inline-start: 3px; top: 10px; width: 4px; height: 4px; border-radius: 99px; background: var(--accent); }

/* ---------- actions / rest day ---------- */
.actions { display: flex; justify-content: center; padding: 8px 0 4px; }
.ghost-btn {
  font-family: inherit; font-size: 13px; color: var(--muted);
  background: none; border: 1px solid var(--line); border-radius: 99px;
  padding: 7px 16px; cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--line-2); }

.rest-card {
  margin: 26px 0; padding: 26px 20px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.rest-card .big { font-size: 30px; line-height: 1; margin: 0 0 10px; }
.rest-card h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.rest-card p.sub { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.rest-card ul { margin: 0; padding: 0; list-style: none; text-align: start; font-size: 13.5px; color: var(--muted); }
.rest-card li { position: relative; padding-inline-start: 16px; margin-bottom: 7px; }
.rest-card li::before { content: ""; position: absolute; inset-inline-start: 3px; top: 10px; width: 4px; height: 4px; border-radius: 99px; background: var(--accent); }

.week-summary { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.week-summary div { text-align: center; font-size: 11px; color: var(--muted); }
.week-summary .ring {
  width: 34px; height: 34px; border-radius: 99px; margin: 0 auto 4px;
  display: grid; place-items: center; font-size: 11px;
  border: 2px solid var(--line); color: var(--muted);
}
.week-summary .ring.full { border-color: var(--done); color: var(--done); }

/* ---------- footer ---------- */
.foot { padding: 22px 16px 8px; font-size: 11.5px; color: var(--muted); text-align: center; }
.foot p { margin: 0 0 4px; }
.foot-dim { opacity: .75; }
.foot a { color: var(--muted); }

/* ---------- rest timer ---------- */
.timer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.timer[hidden] { display: none; }
.timer-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.timer-label { font-size: 12.5px; color: var(--muted); }
.timer-time { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 54px; }
.timer-bar { flex: 1; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 99px; transition: width .25s linear; }
.timer-stop {
  font-family: inherit; font-size: 13px; color: var(--text);
  background: none; border: 1px solid var(--line-2); border-radius: 99px;
  padding: 5px 14px; cursor: pointer;
}

/* ---------- guide sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.42); }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px;
  max-height: 82vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding: 4px 18px calc(24px + env(safe-area-inset-bottom));
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } }
.sheet-head {
  position: sticky; top: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.sheet-body h3 { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
.sheet-body p { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.sheet-body .kit { font-size: 12.5px; }
