:root {
  --paper: #eef3f9;
  --paper-2: #e3ebf5;
  --line: #cfdbea;
  --card: #fbfdff;
  --ink: #0e1a2b;
  --ink-2: #4a5b72;
  --ink-3: #8090a6;
  --cobalt: #1f4fd8;
  --cobalt-2: #173da8;
  --ice: #8fd3ff;
  --ice-soft: #dff1ff;
  --warn: #fff1e6;
  --warn-ink: #9a4a12;
  --rest: #10a37f;
  --shadow: 0 1px 0 rgba(14,26,43,.04), 0 6px 18px rgba(14,26,43,.06);
  --head: 'Barlow Condensed', system-ui, sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: currentColor; }
[hidden] { display: none !important; }

.app {
  height: 100vh; min-height: 640px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0 20px;
  padding: 0 20px 16px;
}

/* header */
.top { grid-column: 1 / 3; position: relative; z-index: 1; pointer-events: none; display: flex; justify-content: space-between; align-items: center; padding: 18px 0 8px; }
.title h1 { font-family: var(--head); font-weight: 800; font-size: 34px; letter-spacing: .06em; margin: 0; line-height: 1; }
.title p { font-family: var(--head); font-weight: 500; letter-spacing: .32em; color: var(--ink-3); margin: 6px 0 0; font-size: 15px; }
.status { display: flex; gap: 22px; align-items: center; }
.progress-card {
  display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; box-shadow: var(--shadow);
}
.pc-icon { width: 24px; height: 24px; color: var(--cobalt); }
.pc-label { font-family: var(--head); font-weight: 700; letter-spacing: .08em; font-size: 14px; }
.pc-bar { width: 120px; height: 6px; background: var(--paper-2); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.pc-bar span { display: block; height: 100%; width: 0; background: var(--cobalt); border-radius: 4px; transition: width .4s; }
.pc-count { font-family: var(--head); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.clock { font-family: var(--head); font-weight: 500; letter-spacing: .12em; color: var(--ink-2); font-size: 15px; line-height: 1.35; text-align: right; font-variant-numeric: tabular-nums; }

/* stage */
.stage { position: relative; z-index: 0; grid-column: 1; grid-row: 2; min-height: 0; }
#view { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage-deco { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden; }
.stage-deco span {
  font-family: var(--head); font-weight: 800; font-size: clamp(120px, 22vw, 300px); letter-spacing: .02em;
  color: transparent; -webkit-text-stroke: 2px rgba(31,79,216,.10); transform: translateY(-6%);
  user-select: none;
}
.tag {
  z-index: 2;
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-family: var(--head); font-weight: 700; letter-spacing: .14em;
  padding: 6px 14px; border-radius: 8px; font-size: 15px; white-space: nowrap;
}
.overlay {
  z-index: 2;
  position: absolute; right: 18px; top: 18px; background: rgba(14,26,43,.92); color: #fff; border-radius: 16px;
  padding: 14px 20px; text-align: center; min-width: 150px; box-shadow: var(--shadow);
}
.overlay.rest { background: rgba(16,163,127,.95); }
.ov-phase { font-family: var(--head); font-weight: 700; letter-spacing: .2em; font-size: 14px; opacity: .85; }
.ov-time { font-family: var(--head); font-weight: 800; font-size: 56px; line-height: 1; font-variant-numeric: tabular-nums; }
.ov-next { font-size: 13px; opacity: .85; margin-top: 4px; }
.toolbar {
  z-index: 2;
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 5px; box-shadow: var(--shadow);
}
.toolbar button {
  border: 0; background: transparent; border-radius: 8px; height: 32px; min-width: 32px; padding: 0 9px;
  font-family: var(--head); font-weight: 600; letter-spacing: .08em; font-size: 13px; color: var(--ink-2);
  display: grid; place-items: center;
}
.toolbar button svg { width: 18px; height: 18px; }
.toolbar button:hover { background: var(--paper-2); }
.toolbar button.on { background: var(--ink); color: #fff; }
.toolbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* panel */
.panel {
  position: relative; z-index: 1; grid-column: 2; grid-row: 2; display: flex; flex-direction: column; min-height: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.tabs { display: flex; gap: 22px; padding: 14px 20px 0; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: none; padding: 6px 0 10px; font-family: var(--head); font-weight: 600; letter-spacing: .1em;
  color: var(--ink-3); font-size: 15px; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab { cursor: default; }
.tab.active { color: var(--ink); border-color: var(--ink); }
.panel-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.ex-head h2 { font-family: var(--head); font-weight: 800; font-size: 28px; letter-spacing: .03em; margin: 0; text-transform: uppercase; }
.chips { display: flex; gap: 6px; margin: 8px 0 10px; flex-wrap: wrap; }
.chip { font-family: var(--head); font-weight: 600; letter-spacing: .08em; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--cobalt); color: #fff; text-transform: uppercase; }
.chip.ghost { background: var(--ice-soft); color: var(--cobalt-2); }
.summary { color: var(--ink-2); margin: 0 0 14px; line-height: 1.45; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0 0 14px; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 36px; line-height: 1.45; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -1px; width: 24px; height: 24px; border-radius: 7px;
  background: var(--ice-soft); color: var(--cobalt-2); font-family: var(--head); font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.callout { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.callout h3, .sub { font-family: var(--head); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 14px; margin: 0 0 6px; }
.callout p { margin: 0; line-height: 1.45; color: var(--ink-2); }
.callout ul { margin: 0; padding-left: 18px; color: var(--ink-2); line-height: 1.5; }
.callout.warn { background: var(--warn); border-color: #f6d9c2; }
.callout.warn h3 { color: var(--warn-ink); }
.callout.cobalt { background: var(--ice-soft); border-color: #bfe2fb; }
.muscles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.muscles span { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 14px; background: #fff; }

/* timer */
.timer { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--paper); }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: var(--paper-2); }
.ring-fg { stroke: var(--cobalt); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear, stroke .3s; }
.timer.rest .ring-fg { stroke: var(--rest); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text b { font-family: var(--head); font-weight: 800; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-text small { font-family: var(--head); font-weight: 600; letter-spacing: .14em; font-size: 11px; color: var(--ink-3); }
.timer-side { flex: 1; min-width: 0; }
.timer-title { font-family: var(--head); font-weight: 700; letter-spacing: .06em; font-size: 17px; }
.timer-sub { color: var(--ink-3); font-size: 13px; margin: 2px 0 10px; }
.timer-btns { display: flex; gap: 8px; }
.play {
  flex: 1; height: 42px; border: 0; border-radius: 11px; background: var(--cobalt); color: #fff; display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--head); font-weight: 700; letter-spacing: .14em; font-size: 16px;
}
.play:hover { background: var(--cobalt-2); }
.play svg { width: 20px; height: 20px; }
.icon { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); display: grid; place-items: center; color: var(--ink-2); }
.icon svg { width: 18px; height: 18px; }

/* lessons */
.lessons { grid-column: 1 / 3; grid-row: 3; padding-top: 12px; position: relative; z-index: 1; }
.lesson-pick { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-family: var(--head); font-weight: 700; letter-spacing: .1em; }
.lesson-pick svg { width: 18px; height: 18px; color: var(--cobalt); }
.lesson-pick select {
  font-family: var(--head); font-weight: 700; letter-spacing: .08em; font-size: 16px; text-transform: uppercase;
  border: 0; background: transparent; color: var(--ink); padding: 2px 4px; cursor: pointer;
}
.cards-wrap { display: flex; gap: 10px; align-items: stretch; }
.cards { flex: 1; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding: 2px; }
.cards::-webkit-scrollbar { display: none; }
.card {
  flex: none; width: 196px; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 8px; position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-align: left; scroll-snap-align: start;
}
.card:hover { border-color: #a9bdd8; }
.card.active { border: 2px solid var(--cobalt); padding: 7px 9px 7px 7px; box-shadow: 0 0 0 4px rgba(31,79,216,.10); }
.card img { width: 74px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--paper); flex: none; }
.card .num { font-family: var(--head); font-weight: 700; color: var(--ink-3); font-size: 13px; }
.card .nm { font-family: var(--head); font-weight: 700; letter-spacing: .04em; font-size: 15px; line-height: 1.1; text-transform: uppercase; }
.card .done {
  position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; background: var(--rest); color: #fff;
  display: none; place-items: center; border: 2px solid var(--paper);
}
.card .done svg { width: 12px; height: 12px; }
.card.completed .done { display: grid; }
.nav-btn { flex: none; width: 46px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); }
.nav-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }

/* responsive */
@media (max-width: 1100px) { .app { grid-template-columns: minmax(0, 1fr) 330px; } }
@media (max-width: 860px) {
  .app { display: flex; flex-direction: column; height: auto; min-height: 100vh; padding: 0 16px 16px; gap: 12px; }
  .app > * { min-width: 0; max-width: 100%; }
  .cards-wrap, .cards { min-width: 0; }
  .tag { left: 12px; top: 12px; transform: none; font-size: 13px; }
  .overlay { top: 12px; right: 12px; }
  .top { padding: 14px 0 0; flex-wrap: wrap; gap: 10px; }
  .title h1 { font-size: 28px; }
  .clock { display: none; }
  .stage { height: 56vh; min-height: 340px; flex: none; }
  .lessons { order: 3; padding: 0; }
  .panel { order: 4; }
  .panel-body { overflow: visible; }
  .nav-btn { display: none; }
  .card { width: 168px; }
  .stage-deco span { font-size: 140px; }
  .overlay { padding: 10px 14px; min-width: 110px; }
  .ov-time { font-size: 40px; }
}
