:root {
  --forest-950: #0b1c17;
  --forest-900: #102820;
  --forest-800: #173a2e;
  --forest-700: #245844;
  --cream-50: #fbfaf5;
  --cream-100: #f2efe4;
  --cream-200: #e7e1d2;
  --ink: #17211d;
  --muted: #68736d;
  --orange: #ef6c3f;
  --orange-soft: #fce4d9;
  --yellow: #e8b84e;
  --blue: #4c83a6;
  --purple: #886da8;
  --shadow: 0 22px 50px rgba(20, 35, 29, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream-100);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  min-height: 100vh;
}

.library-panel {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 24px 22px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(81, 137, 108, 0.25), transparent 34%),
    linear-gradient(165deg, var(--forest-800), var(--forest-950) 75%);
  box-shadow: 14px 0 42px rgba(7, 22, 17, 0.14);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 13px;
  color: var(--forest-950);
  background: var(--orange);
  transform: rotate(-2deg);
}
.brand-mark svg { width: 28px; fill: currentColor; }
.brand h1 { margin: 2px 0 0; font-size: 19px; letter-spacing: 0.08em; }
.eyebrow, .section-kicker {
  margin: 0;
  color: rgba(255,255,255,.54);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}
.eyebrow.dark { color: var(--orange); }
.section-kicker { color: var(--orange); }

.icon-button {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
}
.close-library { display: none; margin-left: auto; color: #fff; font-size: 28px; }
.open-library { display: none; width: 38px; height: 38px; border-radius: 10px; background: var(--forest-900); color: #fff; }

.library-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 38px 0 18px;
}
.library-heading h2 { margin: 5px 0 0; font-size: 25px; letter-spacing: -.04em; }
.count-pill {
  padding: 5px 9px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 99px;
  color: rgba(255,255,255,.7);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(255,255,255,.07);
}
.search-box:focus-within { border-color: rgba(239,108,63,.8); box-shadow: 0 0 0 3px rgba(239,108,63,.12); }
.search-box svg { width: 18px; fill: none; stroke: rgba(255,255,255,.48); stroke-width: 1.8; }
.search-box input {
  width: 100%;
  padding: 12px 0;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
}
.search-box input::placeholder { color: rgba(255,255,255,.38); }

.category-filters {
  display: flex;
  gap: 7px;
  margin: 14px 0 13px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 99px;
  color: rgba(255,255,255,.6);
  background: transparent;
  font-size: 11px;
}
.filter-chip.active { border-color: var(--orange); color: #fff; background: rgba(239,108,63,.17); }

.library-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  color: rgba(255,255,255,.42);
  font-size: 11px;
}
.drag-glyph { color: var(--orange); font-size: 17px; }

.exercise-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  padding-right: 5px;
  overflow-y: auto;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  scrollbar-width: thin;
}
.exercise-card {
  position: relative;
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 11px;
  min-height: 114px;
  padding: 13px 14px 13px 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 13px;
  background: rgba(255,255,255,.065);
  cursor: grab;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), background .2s ease, border-color .2s ease, opacity .2s ease;
}
.exercise-card:hover { transform: translateY(-3px); border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.1); }
.exercise-card:active { cursor: grabbing; }
.exercise-card.dragging { opacity: .28; transform: scale(.96); }
.exercise-card .category-bar { align-self: stretch; border-radius: 0 4px 4px 0; background: var(--category-color); }
.exercise-copy { min-width: 0; }
.exercise-card strong { display: block; overflow: hidden; font-size: 14px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.exercise-card small { display: block; margin-top: 5px; color: rgba(255,255,255,.42); font-size: 10px; }
.exercise-card .grip { color: rgba(255,255,255,.3); font-size: 18px; letter-spacing: -3px; }
.custom-badge { color: var(--orange) !important; }
.exercise-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.exercise-presets label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 9px 6px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 9px;
  color: rgba(255,255,255,.78);
  background: rgba(0,0,0,.11);
  cursor: text;
  transition: border-color .18s ease, background .18s ease;
}
.exercise-presets label:focus-within { border-color: var(--category-color); background: rgba(255,255,255,.09); }
.exercise-presets svg { width: 18px; height: 18px; fill: none; stroke: var(--category-color); stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.exercise-presets input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}
.exercise-presets input::placeholder { color: rgba(255,255,255,.42); }
.exercise-presets em { color: rgba(255,255,255,.52); font-size: 10px; font-style: normal; font-weight: 700; }
.preset-updated .exercise-presets { animation: preset-pulse .5s ease; }
@keyframes preset-pulse { 45% { transform: scale(1.035); filter: brightness(1.45); } }

.empty-library {
  padding: 35px 15px;
  border: 1px dashed rgba(255,255,255,.13);
  border-radius: 14px;
  color: rgba(255,255,255,.45);
  text-align: center;
  font-size: 13px;
}

.add-exercise-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(239,108,63,.55);
  border-radius: 12px;
  color: #fff;
  background: rgba(239,108,63,.12);
  font-weight: 700;
}
.add-exercise-button span { color: var(--orange); font-size: 20px; line-height: 1; }
.add-exercise-button:hover { background: rgba(239,108,63,.22); }

.main-panel { min-width: 0; background: var(--cream-50); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 26px 30px 21px;
  border-bottom: 1px solid var(--cream-200);
  background: rgba(251,250,245,.9);
  backdrop-filter: blur(15px);
}
.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-title h2 { margin: 3px 0 0; font-size: 28px; letter-spacing: -.045em; }
.week-stats { display: flex; align-items: center; gap: 18px; }
.stat-block { display: flex; align-items: baseline; gap: 6px; }
.stat-block strong { font-size: 23px; }
.stat-block span { color: var(--muted); font-size: 11px; }
.stat-divider { width: 1px; height: 30px; background: var(--cream-200); }
.status-chip {
  padding: 7px 11px;
  border: 1px solid #cdded5;
  border-radius: 99px;
  color: var(--forest-700);
  background: #edf6f0;
  font-size: 11px;
  font-weight: 700;
}
.status-chip span { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #4c9b6d; }

.planner-intro {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  padding: 20px 30px 16px;
}
.planner-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 3px; }
.legend-dot.compound { background: var(--orange); }
.legend-dot.accessory { background: var(--blue); }

.calendar-scroll { padding: 0 30px 30px; overflow-x: auto; }
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(222px, 1fr));
  gap: 10px;
  min-width: 1614px;
  min-height: calc(100vh - 158px);
}
.day-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-md);
  background: #f5f2e9;
  transition: border-color .22s ease, background .22s ease, transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease;
}
.day-column.drop-active {
  border-color: var(--orange);
  background: #fff6f1;
  box-shadow: 0 12px 28px rgba(239,108,63,.09), inset 0 3px 0 rgba(239,108,63,.22);
  transform: none;
}
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 14px 15px;
  border-bottom: 1px solid var(--cream-200);
  background: rgba(255,255,255,.48);
}
.day-label { display: flex; align-items: center; gap: 9px; }
.day-number { color: var(--orange); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 800; }
.day-name { font-size: 16px; font-weight: 800; }
.day-count { color: #7c8781; font-size: 11px; font-weight: 650; }
.day-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 11px;
  min-height: 260px;
  padding: 10px;
}
.day-empty {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 180px;
  border: 1px dashed #d8d1c0;
  border-radius: 12px;
  color: #a29b8e;
  text-align: center;
  font-size: 13px;
  line-height: 1.7;
  pointer-events: none;
}
.day-empty svg { display: block; width: 25px; margin: 0 auto 8px; fill: none; stroke: #bdb4a3; stroke-width: 1.5; }

.schedule-card {
  position: relative;
  padding: 13px 12px;
  border: 1px solid #e6dfd1;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(23,33,29,.065);
  transition: opacity .2s ease, transform .24s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease;
  animation: card-in .22s ease both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(5px); } }
.schedule-card:hover { box-shadow: 0 12px 25px rgba(23,33,29,.1); transform: translateY(-1px); }
.schedule-card.moving { opacity: .18; transform: scale(.96); }
.schedule-card::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 13px 0 0 13px;
  background: var(--category-color);
  content: "";
}
.schedule-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; padding-left: 4px; }
.schedule-title { min-width: 0; flex: 1; }
.schedule-title strong { display: block; overflow: hidden; font-size: 15px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.schedule-title small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.schedule-drag {
  flex: 0 0 auto;
  padding: 0 1px;
  border: 0;
  color: #b6b0a4;
  background: transparent;
  cursor: grab;
  font-size: 20px;
  line-height: 1;
}
.delete-entry {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #a49d90;
  background: #f4f1ea;
  font-size: 17px;
  line-height: 1;
}
.delete-entry:hover { color: #fff; background: var(--orange); }
.metrics {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.rep-equation {
  display: grid;
  grid-template-columns: 64px 20px 64px;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.equation-x {
  display: grid;
  place-items: center;
  color: var(--orange);
  font-size: 18px;
  font-weight: 600;
}
.compact-metric {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 5px 2px;
  border: 0;
  border-radius: 0;
  background: #fff;
}
.compact-value {
  display: block;
  min-width: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}
.metric-sets, .metric-reps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.metric-sets .compact-value, .metric-reps .compact-value {
  width: auto;
  text-align: center;
}
.compact-unit {
  flex: 0 0 auto;
  color: #6f7973;
  font-size: 12px;
  font-weight: 800;
}
.metric-weight {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 4px 2px 5px;
}
.compact-metric-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: var(--category-color);
}
.compact-metric-icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}
.metric-weight .compact-value {
  width: auto;
  font-size: 19px;
  text-align: center;
}
.metric-weight .compact-unit { font-size: 13px; text-transform: lowercase; }

.drag-ghost {
  position: fixed !important;
  top: -1000px !important;
  left: -1000px !important;
  z-index: 9999 !important;
  max-height: 132px;
  overflow: hidden;
  opacity: .96 !important;
  box-shadow: 0 24px 45px rgba(8, 24, 18, .26) !important;
  transform: rotate(1.5deg) scale(1.025) !important;
  pointer-events: none !important;
}
.drop-placeholder {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  min-height: 92px;
  border: 2px dashed rgba(239,108,63,.52);
  border-radius: 13px;
  color: #c85d38;
  background: linear-gradient(110deg, rgba(239,108,63,.06), rgba(239,108,63,.14), rgba(239,108,63,.06));
  background-size: 220% 100%;
  font-size: 12px;
  font-weight: 800;
  animation: placeholder-flow 1.2s ease infinite, placeholder-in .16s ease both;
}
.drop-placeholder span { padding: 5px 9px; border-radius: 99px; background: #fff8f4; }
.day-body.has-placeholder .day-empty { display: none; }
@keyframes placeholder-flow { to { background-position: -120% 0; } }
@keyframes placeholder-in { from { opacity: 0; transform: scaleY(.78); } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 20, 15, .6);
  backdrop-filter: blur(7px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: min(440px, 100%);
  padding: 32px;
  border-radius: 22px;
  background: var(--cream-50);
  box-shadow: var(--shadow);
}
.modal h2 { margin: 6px 0 8px; font-size: 27px; letter-spacing: -.04em; }
.modal-copy { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.modal-close { position: absolute; top: 15px; right: 17px; border: 0; color: #7b847f; background: transparent; font-size: 28px; }
.modal form { display: grid; gap: 16px; }
.modal label span { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.modal input, .modal select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #dcd5c7;
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: #fff;
}
.modal input:focus, .modal select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.primary-button {
  margin-top: 4px;
  padding: 13px;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--forest-800);
  font-weight: 800;
}
.primary-button:hover { background: var(--forest-700); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  padding: 11px 15px;
  border-radius: 11px;
  color: #fff;
  background: var(--forest-900);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9d3e2a; }

[style*="--category-color"] { --category-color: var(--orange); }
.cat-chest { --category-color: #ef6c3f !important; }
.cat-back { --category-color: #4f8f70 !important; }
.cat-shoulder { --category-color: #d19b31 !important; }
.cat-legs { --category-color: #4c83a6 !important; }
.cat-biceps { --category-color: #886da8 !important; }
.cat-triceps { --category-color: #c65e78 !important; }
.cat-forearms { --category-color: #8b765b !important; }
.cat-core { --category-color: #447c82 !important; }
.cat-other { --category-color: #6d7872 !important; }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 1fr; }
  .library-panel {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(350px, 92vw);
    transition: transform .24s ease;
  }
  .library-panel.open { transform: translateX(0); }
  .open-library, .close-library { display: grid; }
  .topbar { padding-inline: 20px; }
  .planner-intro { padding-inline: 20px; }
  .calendar-scroll { padding-inline: 20px; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 18px 14px; }
  .topbar-title h2 { font-size: 22px; }
  .status-chip, .stat-divider { display: none; }
  .week-stats { gap: 9px; }
  .stat-block { display: block; text-align: center; }
  .stat-block strong { display: block; font-size: 18px; }
  .planner-intro { display: block; padding: 14px; }
  .legend { margin-top: 10px; }
  .calendar-scroll { padding: 0 14px 20px; }
  .week-grid { grid-template-columns: repeat(7, minmax(190px, 1fr)); min-width: 1390px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
