:root {
  --ink: #19332c;
  --green: #173f35;
  --green-2: #286758;
  --mint: #d9e7df;
  --cream: #f3f0e8;
  --paper: #fffdf8;
  --gold: #f2b65a;
  --gold-soft: #fde8bd;
  --line: #d9ddd5;
  --muted: #66746e;
  --danger: #a8443b;
  --shadow: 0 18px 45px rgba(23, 63, 53, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 90% 0, #e7eee8, transparent 35%), var(--cream); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(243, 240, 232, .90); backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(25, 51, 44, .08);
}
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-size: 18px; line-height: 1.05; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: var(--green); color: var(--gold); font-weight: 900; }
.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; font-size: 28px; }
.icon-button { border: 0; background: transparent; color: var(--green); font-size: 23px; padding: 8px; border-radius: 12px; }
.icon-button:hover { background: var(--mint); }

.app-shell { width: min(960px, 100%); margin: 0 auto; padding: 24px 16px 112px; }
.view { animation: fade .2s ease; }
@keyframes fade { from { opacity: .25; transform: translateY(4px); } }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 4px 0 22px; }
.page-heading h1 { margin: 0; font-size: clamp(28px, 7vw, 44px); letter-spacing: -.04em; }
.page-heading p { margin: 6px 0 0; }
.eyebrow { margin: 0 0 5px; color: var(--green-2); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 800; }
.muted { color: var(--muted); }

.hero-card { position: relative; overflow: hidden; color: white; background: var(--green); border-radius: 28px; padding: 24px; box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%; right: -80px; top: -90px; background: rgba(242, 182, 90, .18); }
.hero-card h2 { position: relative; margin: 6px 0 8px; font-size: 28px; letter-spacing: -.03em; }
.hero-card p { position: relative; color: #dce9e4; margin: 0; }
.hero-card .button { position: relative; margin-top: 22px; }
.progress-row { position: relative; display: flex; gap: 18px; margin-top: 22px; }
.progress-stat strong { display: block; color: var(--gold); font-size: 22px; }
.progress-stat span { font-size: 12px; color: #dce9e4; }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 28px 0 12px; }
.section-heading h2 { margin: 0; font-size: 20px; }
.card-grid { display: grid; gap: 12px; }
.card { background: var(--paper); border: 1px solid rgba(25,51,44,.09); border-radius: 20px; padding: 18px; box-shadow: 0 6px 22px rgba(23,63,53,.04); }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.card h3 { margin: 0; font-size: 18px; }
.card p { margin: 5px 0 0; }
.badge { display: inline-flex; align-items: center; white-space: nowrap; border-radius: 999px; padding: 6px 9px; background: var(--mint); color: var(--green); font-size: 11px; font-weight: 800; }
.badge.done { background: #d9ead3; color: #2f6236; }
.badge.today { background: var(--gold-soft); color: #74501b; }
.exercise-count { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 12px; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; border: 0; border-radius: 13px; padding: 11px 15px; font-weight: 800; text-decoration: none; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-2); }
.button.secondary { background: var(--mint); color: var(--green); }
.button.ghost { background: transparent; color: var(--green); padding-inline: 8px; }
.button.danger { background: #f7e3df; color: var(--danger); }
.button.small { font-size: 13px; padding: 8px 10px; border-radius: 10px; }
.button.full { width: 100%; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 0; width: min(600px, 100%); display: grid; grid-template-columns: repeat(4, 1fr); padding: 8px 8px max(8px, env(safe-area-inset-bottom)); background: rgba(255,253,248,.96); backdrop-filter: blur(16px); border: 1px solid rgba(25,51,44,.1); border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(23,63,53,.08); }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; border-radius: 13px; color: var(--muted); font-size: 11px; font-weight: 700; text-decoration: none; }
.bottom-nav a span { font-size: 20px; line-height: 1; }
.bottom-nav a.active { color: var(--green); background: var(--mint); }

.week-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 14px; }
.week-select { min-width: min(100%, 330px); }
.session-card { padding: 0; overflow: hidden; }
.session-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 17px 18px; background: var(--paper); }
.session-actions { display: flex; gap: 6px; }
.plan-items { border-top: 1px solid var(--line); }
.plan-item { display: grid; grid-template-columns: minmax(150px, 1fr) repeat(3, 82px) 36px; gap: 8px; align-items: end; padding: 12px 18px; border-bottom: 1px solid rgba(25,51,44,.07); }
.plan-item:last-child { border-bottom: 0; }
.plan-item .item-name { align-self: center; }
.plan-item .item-name strong { display: block; }
.plan-item .item-name small { color: var(--muted); }
.compact-label { font-size: 10px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.compact-label input { margin-top: 4px; }
.add-row { display: flex; gap: 8px; padding: 12px 18px 17px; }
.add-row select { flex: 1; }

label { display: block; color: var(--ink); font-size: 13px; font-weight: 750; }
input, select, textarea { width: 100%; margin-top: 6px; border: 1px solid #cbd3cd; border-radius: 12px; padding: 11px 12px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(40,103,88,.12); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.check { display: flex; gap: 9px; align-items: center; }
.check input { width: auto; margin: 0; }

.catalog-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.catalog-card .card-actions { display: flex; gap: 5px; margin-top: 15px; }
.prescription { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.prescription span { border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; color: var(--muted); font-size: 12px; }
.empty { text-align: center; padding: 34px 18px; color: var(--muted); }

.dialog { width: min(560px, calc(100% - 22px)); max-height: calc(100vh - 24px); border: 0; border-radius: 24px; padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 30px 90px rgba(10,30,24,.28); }
.dialog.wide { width: min(820px, calc(100% - 22px)); }
.dialog::backdrop { background: rgba(12,31,25,.58); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 15px; padding: 21px; overflow: auto; max-height: calc(100vh - 24px); }
.dialog-heading { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.dialog-heading h2 { margin: 0; font-size: 24px; }
.dialog-actions { display: flex; justify-content: end; padding-top: 4px; }

.workout-rows { display: grid; gap: 10px; }
.workout-row { border: 1px solid var(--line); border-radius: 15px; padding: 13px; background: #faf9f4; }
.workout-row h3 { margin: 0 0 11px; font-size: 15px; }
.workout-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.history-card { display: grid; grid-template-columns: 58px 1fr auto; gap: 13px; align-items: center; }
.history-date { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 16px; background: var(--mint); }
.history-date strong { display: block; font-size: 22px; line-height: .95; }
.history-date span { font-size: 10px; text-transform: uppercase; font-weight: 800; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 94px; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; background: var(--ink); color: white; border-radius: 999px; padding: 10px 16px; font-size: 13px; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.login-page { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); padding: 30px; border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); }
.login-card h1 { margin: 10px 0 8px; font-size: 36px; letter-spacing: -.04em; }
.login-card form { display: grid; gap: 15px; margin-top: 25px; }
.error { color: var(--danger); background: #f7e3df; border-radius: 11px; padding: 10px; margin: 0; }

@media (max-width: 680px) {
  .app-shell { padding-inline: 12px; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .plan-item { grid-template-columns: 1fr 1fr 1fr 34px; }
  .plan-item .item-name { grid-column: 1 / -1; }
  .plan-item .compact-label:nth-of-type(3) { grid-column: auto; }
  .form-grid.three, .workout-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.three input, .workout-inputs input { padding-inline: 8px; }
  .history-card { grid-template-columns: 54px 1fr; }
  .history-card > .button { grid-column: 2; justify-self: start; }
}
