:root {
  color: #131821;
  background: #ece7dc;
  font-family: "Aptos", "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #121620;
  --ink-2: #1f2937;
  --muted: #6b7280;
  --paper: rgba(255, 252, 242, 0.9);
  --paper-strong: #fffaf0;
  --charcoal: #0b0e14;
  --amber: #ffb000;
  --acid: #d9ff45;
  --blue: #2764ff;
  --danger: #df2b2b;
  --green: #1f9d55;
  --line: rgba(18, 22, 32, 0.12);
  --white-line: rgba(255, 255, 255, 0.12);
  --shadow: 0 26px 90px rgba(34, 28, 18, 0.16);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(18,22,32,0.035) 1px, transparent 1px) 0 0 / 38px 38px,
    linear-gradient(0deg, rgba(18,22,32,0.035) 1px, transparent 1px) 0 0 / 38px 38px,
    radial-gradient(circle at 86% -8%, rgba(255,176,0,0.42), transparent 30%),
    radial-gradient(circle at 6% 10%, rgba(39,100,255,0.18), transparent 32%),
    linear-gradient(180deg, #fff8e8 0%, #e9e2d5 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image: radial-gradient(rgba(18,22,32,0.18) 0.7px, transparent 0.7px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}
button, input, select, textarea { font: inherit; }
button, a { transition: transform .16s ease, background .16s ease, border-color .16s ease, color .16s ease, opacity .16s ease; }
button { border: 0; cursor: pointer; }
button:hover:not(:disabled), a:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 304px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  color: #fff7e8;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  background:
    linear-gradient(155deg, rgba(217,255,69,0.12), transparent 34%),
    linear-gradient(180deg, #11151e, #07090d);
  border-right: 1px solid rgba(255,255,255,0.08);
}
.brand-mark h1 { font-size: 31px; line-height: .93; letter-spacing: -0.06em; margin: 8px 0 0; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a, .profile-card button {
  color: #dce4f2;
  background: transparent;
  text-align: left;
  border-radius: 18px;
  padding: 13px 14px;
  font-weight: 850;
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: var(--acid);
  color: #0b0e14;
}
.profile-card {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding: 17px;
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
}
.profile-card small { color: #9aa9bc; word-break: break-word; }
.main-stage { padding: 34px; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: 1.16fr 0.84fr; gap: 24px; align-items: center; padding: 34px; }
.hero-panel {
  min-height: calc(100vh - 68px);
  border-radius: 42px;
  padding: 54px;
  color: #fff8ea;
  background:
    linear-gradient(135deg, rgba(217,255,69,0.92), rgba(217,255,69,0) 25%),
    radial-gradient(circle at 80% 24%, rgba(39,100,255,0.62), transparent 30%),
    #0b0e14;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: var(--shadow);
}
.hero-panel h1 { font-size: clamp(42px, 6.4vw, 92px); line-height: .86; letter-spacing: -0.08em; max-width: 960px; margin: 0; }
.hero-panel p:not(.eyebrow) { max-width: 700px; color: #cbd5e1; font-size: 18px; }
.auth-card { max-width: 450px; width: 100%; display: grid; gap: 16px; }
.auth-card h2 { margin: 0; font-size: 36px; letter-spacing: -0.05em; }

.stack { display: grid; gap: 22px; max-width: 1260px; }
.compact-stack { margin-top: 16px; gap: 12px; }
.page-header { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.page-header h2, .card h3 { margin: 0; }
.page-header h2 { font-size: clamp(32px, 4vw, 56px); line-height: .92; letter-spacing: -0.065em; }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 950; letter-spacing: .18em; margin: 0 0 8px; text-transform: uppercase; }
.card {
  background: var(--paper);
  border: 1px solid rgba(255,255,255,0.68);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 22px;
  backdrop-filter: blur(18px);
}
.primary, .danger, .ghost, .danger-ghost, .segmented a, .segmented button {
  border-radius: 16px;
  font-weight: 950;
}
.primary { background: var(--charcoal); color: #fffaf0; padding: 12px 18px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.primary:hover:not(:disabled) { background: #1a2230; }
.danger { background: var(--danger); color: #fff; padding: 12px 18px; }
.ghost { background: transparent; color: #475569; padding: 10px 12px; }
.ghost:hover { background: rgba(15,23,42,0.07); }
.danger-ghost { background: rgba(223,43,43,.09); color: #b91c1c; padding: 10px 12px; }
.danger-ghost:hover { background: rgba(223,43,43,.16); }
label { display: grid; gap: 8px; font-weight: 850; color: #566170; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  outline: none;
}
textarea { min-height: 112px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(39,100,255,0.5); box-shadow: 0 0 0 4px rgba(39,100,255,0.11); }
.error { color: var(--danger); margin: 0; }
.muted { color: var(--muted); }
.loading-card, .empty-state { text-align: center; padding: 48px; color: var(--muted); }

.stats-grid, .workout-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.workout-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric { background: var(--paper-strong); border-radius: 20px; padding: 16px; display: grid; gap: 8px; border: 1px solid var(--line); min-width: 0; }
.metric span { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { font-size: 26px; letter-spacing: -0.045em; overflow-wrap: anywhere; }
.metric-dark { background: rgba(255,255,255,.075); border-color: var(--white-line); color: #fff7e8; }
.metric-dark span { color: #9aa9bc; }
.metric-danger strong { color: var(--danger); }
.segmented { display: flex; background: rgba(15,23,42,0.06); border-radius: 999px; padding: 4px; border: 1px solid var(--line); }
.segmented a, .segmented button { background: transparent; padding: 10px 14px; color: #586579; }
.segmented a.active, .segmented button.active { background: var(--charcoal); color: #fff8e8; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 16px; align-items: end; }

.daily-command { min-height: 260px; display: flex; justify-content: space-between; gap: 26px; align-items: flex-end; overflow: hidden; position: relative; }
.daily-command::after { content: ""; position: absolute; inset: auto -10% -38% auto; width: 360px; height: 360px; border-radius: 50%; background: rgba(217,255,69,.32); filter: blur(6px); }
.daily-command h3 { font-size: clamp(34px, 5vw, 70px); line-height: .9; letter-spacing: -0.07em; max-width: 660px; }
.daily-command p { color: var(--muted); max-width: 560px; }
.active-session { background: linear-gradient(135deg, rgba(11,14,20,.96), rgba(37,100,255,.55)); color: #fff8e8; border-color: rgba(255,255,255,.14); }
.active-session p { color: #cbd5e1; }
.pulse-action { position: relative; z-index: 1; min-width: 190px; }

.catalog-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.catalog-card { overflow: hidden; padding: 0; transition: transform .18s ease, box-shadow .18s ease; }
.catalog-card:hover { transform: translateY(-2px); box-shadow: 0 28px 80px rgba(34, 28, 18, 0.21); }
.catalog-card img, .image-placeholder { width: 100%; height: 172px; object-fit: cover; background: linear-gradient(135deg, var(--acid), #dbeafe 56%, #1e293b); display: grid; place-items: center; font-weight: 950; color: var(--charcoal); }
.catalog-card div:last-child { padding: 18px; display: grid; gap: 10px; }
.catalog-card p { color: var(--muted); margin: 0; }
.catalog-card small { color: #334155; font-weight: 900; }
.card-pills, .chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.card-pills.muted-pills span, .chip-row button { border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; background: rgba(255,255,255,.68); color: #526071; font-size: 12px; font-weight: 900; }
.chip-row button.active { background: var(--charcoal); color: #fff8e8; border-color: var(--charcoal); }
.pill.kind { background: #dbeafe; color: #1d4ed8; }
.catalog-controls { display: grid; gap: 12px; }
.catalog-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pill, .source-pill, .status-chip { display: inline-flex; width: fit-content; border-radius: 999px; background: #eef2f7; color: #475569; padding: 5px 10px; font-size: 11px; font-weight: 950; text-transform: uppercase; letter-spacing: .05em; }
.pill.user { background: #dcfce7; color: #166534; }

.workout-cta { text-align: center; padding: 58px 32px; display: flex; flex-direction: column; align-items: center; gap: 16px; background: linear-gradient(135deg, rgba(255,250,240,.94), rgba(217,255,69,.18)); }
.workout-cta h3 { font-size: 34px; letter-spacing: -0.045em; }
.workout-cta p { color: var(--muted); max-width: 580px; }
.live-header { position: sticky; top: 18px; z-index: 4; display: grid; grid-template-columns: 1.15fr auto 1.4fr auto; gap: 18px; align-items: center; color: #fff8e8; background: linear-gradient(135deg, #0b0e14, #161e2a); border-color: rgba(255,255,255,.1); }
.live-header h2 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: .9; letter-spacing: -0.07em; }
.live-header span { color: #9aa9bc; }
.live-clock { font-family: "Cascadia Code", "SF Mono", ui-monospace, monospace; font-size: clamp(34px, 5vw, 58px); font-weight: 950; color: var(--acid); letter-spacing: -0.06em; }
.live-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.live-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.exercise-journal { display: grid; gap: 18px; }
.empty-workout { min-height: 330px; display: grid; place-items: center; text-align: center; align-content: center; gap: 14px; background: linear-gradient(135deg, rgba(255,250,240,.92), rgba(39,100,255,.12)); }
.empty-workout h3 { font-size: 40px; letter-spacing: -0.055em; }
.empty-workout p { color: var(--muted); max-width: 520px; }
.sticky-add { justify-self: center; }

.workout-exercise-card { padding: 0; overflow: hidden; display: grid; grid-template-columns: 180px 1fr; background: rgba(255,252,242,.94); }
.exercise-card-media { min-height: 100%; background: #0b0e14; display: grid; place-items: center; color: var(--acid); font-weight: 950; letter-spacing: .12em; }
.exercise-card-media img { width: 100%; height: 100%; object-fit: cover; }
.exercise-card-body { padding: 22px; display: grid; gap: 16px; }
.exercise-card-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.exercise-card-header h3 { font-size: 30px; letter-spacing: -0.055em; margin: 8px 0 4px; }
.exercise-card-header p { color: var(--muted); margin: 0; }
.exercise-microstats { display: flex; gap: 8px; flex-wrap: wrap; }
.exercise-microstats span { border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; font-size: 12px; font-weight: 900; color: #475569; background: rgba(255,255,255,.64); }
.sets-list { display: grid; gap: 8px; }
.set-row { display: grid; grid-template-columns: 36px 1fr 82px 42px; gap: 8px; align-items: center; padding: 8px 10px; background: rgba(11,14,20,.055); border-radius: 14px; }
.set-row.editing { grid-template-columns: 36px 1fr 1fr auto; }
.set-index { width: 28px; height: 28px; border-radius: 10px; background: var(--charcoal); color: var(--acid); display: grid; place-items: center; font-weight: 950; font-size: 12px; }
.set-data { background: transparent; text-align: left; color: var(--ink); font-weight: 900; padding: 6px; border-radius: 10px; }
.set-data:hover { background: rgba(39,100,255,.08); }
.set-cal { color: var(--muted); font-size: 12px; }
.set-remove, .tiny { background: transparent; color: #64748b; font-size: 17px; padding: 4px 7px; border-radius: 9px; line-height: 1; }
.set-remove:hover, .tiny:hover { color: #fecaca; background: rgba(223,43,43,.18); }
.set-row-actions { display: flex; gap: 4px; }
.tiny.success { color: var(--green); }
.single-set-console { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; padding: 16px; border-radius: 22px; background: #11151e; color: #fff8e8; }
.dynamic-console { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.dynamic-set-row { grid-template-columns: 36px repeat(auto-fit, minmax(90px, 1fr)) auto; }
.stepper-field > span { display: block; color: #9aa9bc; font-size: 11px; font-weight: 950; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.stepper-field > div { display: grid; grid-template-columns: 42px minmax(80px, 1fr) 42px; gap: 7px; }
.stepper-field button { background: rgba(255,255,255,.1); color: #fff8e8; border-radius: 14px; font-size: 22px; font-weight: 950; }
.stepper-field input { text-align: center; font-weight: 950; }
.compact-input { color: #9aa9bc; }
.record-set { min-height: 48px; background: var(--acid); color: var(--charcoal); }
.batch-link { justify-self: start; }

.drawer-scrim, .dialog-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(5,7,11,.62); backdrop-filter: blur(9px); }
.add-drawer { position: absolute; inset: 18px 18px 18px auto; width: min(500px, calc(100vw - 36px)); overflow: auto; border-radius: 34px; padding: 24px; background: #fff8ea; box-shadow: 0 34px 120px rgba(0,0,0,.36); display: grid; align-content: start; gap: 16px; }
.add-drawer header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.add-drawer h2, .modal-card h2 { margin: 0; font-size: 34px; line-height: .96; letter-spacing: -0.055em; }
.round-close { width: 40px; height: 40px; border-radius: 50%; background: #11151e; color: #fff8ea; font-size: 24px; line-height: 1; }
.drawer-tabs { width: fit-content; }
.drawer-categories { margin-top: -4px; }
.drawer-list { display: grid; gap: 10px; }
.drawer-pick { display: grid; grid-template-columns: 76px 1fr 42px; gap: 12px; align-items: center; padding: 10px; border-radius: 20px; border: 1px solid var(--line); background: rgba(255,255,255,.56); cursor: pointer; }
.drawer-pick:hover { background: #fff; }
.drawer-pick.already-added { box-shadow: inset 0 0 0 2px rgba(31,157,85,.22); }
.drawer-pick img, .drawer-placeholder { width: 76px; height: 76px; border-radius: 16px; object-fit: cover; display: grid; place-items: center; background: linear-gradient(135deg, var(--acid), #dbeafe); font-weight: 950; }
.drawer-pick h3 { font-size: 16px; margin: 0 0 4px; }
.drawer-pick p { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drawer-pick b { color: var(--green); font-size: 12px; }
.plus-chip { width: 38px; height: 38px; border-radius: 14px; background: var(--charcoal); color: #fff8ea; font-size: 22px; font-weight: 950; }
.modal-card { max-width: 560px; width: calc(100% - 32px); display: grid; gap: 18px; position: fixed; inset: 50% auto auto 50%; transform: translate(-50%, -50%); }
.modal-card:hover { transform: translate(-50%, -50%); }
.modal-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }
.batch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.discard-dialog { border-color: rgba(223,43,43,.25); }
.discard-dialog p { color: var(--muted); }

.workout-summary { display: grid; gap: 18px; }
.status-discarded { opacity: .7; filter: grayscale(.35); }
.summary-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.summary-title h3 { margin: 8px 0 6px; }
.summary-title p { margin: 0; color: var(--muted); }
.detail-link { display: inline-flex; }
.discarded-list summary { cursor: pointer; font-weight: 950; }
.detail-hero, .analytics-controls { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; align-items: end; }
.analytics-controls { grid-template-columns: 1.4fr repeat(3, 1fr); }
.detail-item h3, .notes-card h3, .chart-card h3 { margin-bottom: 14px; }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 70px; gap: 12px; align-items: center; }
.bar-row div { height: 16px; border-radius: 999px; background: #e2dccf; overflow: hidden; }
.bar-row i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--acid), var(--amber)); }

@media (max-width: 1180px) {
  .live-header { grid-template-columns: 1fr; position: static; }
  .live-actions { justify-content: flex-start; }
  .detail-hero, .analytics-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; padding-bottom: 88px; }
  .sidebar { position: fixed; inset: auto 12px 12px; z-index: 20; height: auto; border-radius: 26px; padding: 12px; display: block; }
  .brand-mark, .profile-card { display: none; }
  .sidebar nav { grid-template-columns: repeat(5, 1fr); }
  .sidebar nav a { text-align: center; padding: 10px 6px; font-size: 12px; }
  .main-stage { padding: 20px; }
  .auth-layout { grid-template-columns: 1fr; padding: 20px; }
  .hero-panel { min-height: 48vh; padding: 30px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .stats-grid, .workout-stats { grid-template-columns: 1fr; }
  .workout-exercise-card { grid-template-columns: 1fr; }
  .exercise-card-media { min-height: 130px; }
  .single-set-console { grid-template-columns: 1fr; }
  .live-metrics { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page-header, .daily-command, .exercise-card-header, .summary-title { align-items: stretch; flex-direction: column; }
  .daily-command { min-height: auto; }
  .catalog-grid, .detail-hero, .analytics-controls, .batch-grid, .modal-stats { grid-template-columns: 1fr; }
  .add-drawer { inset: auto 0 0; width: 100%; max-height: 86vh; border-radius: 32px 32px 0 0; }
  .drawer-pick { grid-template-columns: 62px 1fr 38px; }
  .drawer-pick img, .drawer-placeholder { width: 62px; height: 62px; }
  .set-row, .set-row.editing { grid-template-columns: 30px 1fr; }
  .set-cal, .set-remove, .set-row-actions { justify-self: start; }
  .bar-row { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}
