:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --ink: #17211b;
  --muted: #5e675f;
  --panel: #fffdf7;
  --line: #d9d2c1;
  --green: #1f7a4d;
  --green-dark: #135b38;
  --blue: #245f93;
  --orange: #c05d28;
  --red: #b63d32;
  --shadow: 0 18px 40px rgba(23, 33, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100svh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(247, 244, 236, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 6vw, 2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.28rem;
  line-height: 1.15;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

main {
  flex: 1;
  padding: 16px;
}

.hero-panel,
.current-panel,
.info-panel,
.done-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 18px;
}

.hero-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 0;
}

.status-item {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ee;
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-value {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 900;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #e9e1d2;
  border-radius: 8px;
}

.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
}

.segmented button.is-active {
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(23, 33, 27, 0.12);
}

.current-panel {
  margin-top: 14px;
  overflow: hidden;
}

.step-head {
  padding: 16px;
  background: #17211b;
  color: #fffdf7;
}

.step-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 253, 247, 0.22);
  border-radius: 999px;
  color: #f2d18b;
  font-size: 0.82rem;
  font-weight: 900;
}

.exercise-title {
  margin: 12px 0 8px;
  color: #fffdf7;
  font-size: clamp(1.9rem, 11vw, 3.2rem);
  line-height: 0.98;
}

.focus-line {
  margin: 0;
  color: #e7dfce;
  font-size: 1.03rem;
  line-height: 1.4;
}

.step-body {
  padding: 16px;
}

.big-number {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ee;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.35rem, 8vw, 2rem);
  line-height: 1;
}

.set-row {
  display: grid;
  grid-template-columns: repeat(var(--set-count), minmax(0, 1fr));
  gap: 7px;
  margin: 14px 0;
}

.set-dot {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2eadb;
  color: var(--muted);
  font-weight: 900;
}

.set-dot.is-done {
  border-color: var(--green);
  background: #dff1e7;
  color: var(--green-dark);
}

.primary-button,
.secondary-button,
.danger-button,
.quiet-button,
.small-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.primary-button {
  width: 100%;
  min-height: 64px;
  padding: 15px 18px;
  background: var(--green);
  color: #fff;
  font-size: 1.18rem;
}

.primary-button:active,
.secondary-button:active,
.danger-button:active,
.quiet-button:active,
.small-button:active {
  transform: translateY(1px);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.wide-button {
  width: 100%;
  margin-top: 12px;
}

.preview-panel {
  margin-top: 14px;
}

.preview-head {
  background: #245f93;
}

.preview-actions {
  grid-template-columns: 0.8fr 1.1fr 1.1fr;
}

.secondary-button,
.danger-button,
.quiet-button {
  min-height: 54px;
  padding: 12px;
}

.secondary-button {
  background: #dfeaf3;
  color: var(--blue);
}

.danger-button {
  background: #f5dedb;
  color: var(--red);
}

.quiet-button {
  background: #ede6d8;
  color: var(--ink);
}

.small-button {
  min-height: 40px;
  padding: 8px 12px;
  background: #ede6d8;
  color: var(--ink);
}

.notice {
  margin: 12px 0 0;
  padding: 12px;
  border-left: 4px solid var(--orange);
  border-radius: 8px;
  background: #fff3dd;
  color: #503116;
  font-weight: 800;
}

details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

summary {
  min-height: 48px;
  padding: 14px 0 0;
  cursor: pointer;
  color: var(--blue);
  font-weight: 900;
}

.cue-list {
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--ink);
  line-height: 1.5;
}

.cue-list li + li {
  margin-top: 6px;
}

.timer-bar {
  position: sticky;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 9;
  display: none;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  padding: 12px;
  border: 1px solid #8fb79f;
  border-radius: 8px;
  background: #dff1e7;
}

.timer-bar.is-visible {
  display: grid;
}

.timer-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.65rem;
  font-weight: 1000;
}

.timer-label {
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.plan-list,
.guide-grid {
  display: grid;
  gap: 12px;
}

.info-panel,
.done-panel {
  padding: 16px;
}

.plan-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.plan-num {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #17211b;
  color: #fffdf7;
  font-weight: 1000;
}

.plan-copy p,
.info-panel p,
.done-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  padding: 6px 9px;
  border-radius: 999px;
  background: #ede6d8;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ee;
}

.history-item span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.equipment-image {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(23, 33, 27, 0.96);
  border-top: 1px solid rgba(255, 253, 247, 0.14);
}

.nav-button {
  min-height: 52px;
  border: 1px solid rgba(255, 253, 247, 0.18);
  border-radius: 8px;
  background: transparent;
  color: #fffdf7;
  font-weight: 1000;
}

.nav-button.is-active {
  background: #fffdf7;
  color: var(--ink);
}

.done-panel {
  text-align: left;
}

.done-panel .primary-button {
  margin-top: 14px;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
}

.compact-table th,
.compact-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.compact-table tr:last-child th,
.compact-table tr:last-child td {
  border-bottom: 0;
}

.compact-table th {
  width: 38%;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

@media (min-width: 650px) {
  .hero-row {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .segmented {
    width: 240px;
  }

  .button-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .preview-actions {
    grid-template-columns: 0.8fr 1.1fr 1.1fr;
  }
}
