@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --paper: #EDEAE2;
  --paper2: #E2DCCB;
  --paper3: #D9D2BE;
  --ink: #1C1E1A;
  --steel: #5C6B66;
  --steel-light: #8A9590;
  --orange: #FF6A39;
  --orange-dim: #E85A2C;
  --green: #3F7D58;
  --line: #C7BFAC;
  --red: #B23A2B;
  --display: 'Oswald', "Helvetica Neue", Arial, sans-serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background-color: var(--paper);
  background-image:
    radial-gradient(circle, rgba(28,30,26,0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--body);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
input, select, button { font-family: inherit; }
button { cursor: pointer; -webkit-appearance: none; appearance: none; }

#app { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); max-width: 560px; margin: 0 auto; }

/* ---------- header ---------- */
.header {
  padding: max(22px, env(safe-area-inset-top)) 18px 16px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--orange);
  position: relative;
  overflow: hidden;
}
.header::before {
  content: "";
  position: absolute; top: 0; right: 0; width: 140px; height: 140px;
  background: radial-gradient(circle at top right, rgba(255,106,57,0.18), transparent 70%);
  pointer-events: none;
}
.header-row { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--orange);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; color: var(--ink); }
.h-title {
  font-family: var(--display); font-weight: 700; font-size: 19px;
  letter-spacing: 0.02em; text-transform: uppercase; line-height: 1.1;
}
.h-date {
  font-family: var(--mono); font-size: 11px; color: var(--steel-light);
  text-transform: capitalize; margin-top: 3px; letter-spacing: 0.02em;
}

.streak-ring { position: relative; width: 56px; height: 56px; flex-shrink: 0; }
.streak-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.streak-ring-num {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.streak-ring-num b { font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--paper); line-height: 1; }
.streak-ring-num span { font-family: var(--mono); font-size: 7px; color: var(--steel-light); letter-spacing: 0.1em; margin-top: 1px; }

.week-strip { display: flex; gap: 5px; margin-top: 16px; position: relative; z-index: 1; }
.week-cell {
  flex: 1; text-align: center; padding: 7px 0 6px; border-radius: 5px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,0.06); color: var(--steel-light);
  border: 1px solid transparent;
}
.week-cell.today { border-color: var(--orange); color: var(--paper); }
.week-cell.done { background: var(--green); color: var(--paper); border-color: var(--green); }
.week-cell .wd { display:block; font-size: 8px; opacity: .65; margin-bottom: 2px; font-weight: 500; letter-spacing: 0.06em;}

/* ---------- tabs ---------- */
.tabs {
  display: flex; background: var(--paper); position: sticky; top: 0; z-index: 5;
  border-bottom: 1px solid var(--line); padding: 6px 10px 0;
  gap: 4px;
}
.tab {
  flex: 1; border: none; background: transparent; color: var(--steel);
  padding: 9px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  border-radius: 8px 8px 0 0; position: relative;
}
.tab.active { color: var(--ink); }
.tab.active::after {
  content: ""; position: absolute; left: 14%; right: 14%; bottom: -1px; height: 2.5px; background: var(--orange); border-radius: 2px;
}
.tab svg { width: 18px; height: 18px; }
.tab span {
  font-family: var(--display); font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
}

.content { padding: 18px 16px 56px; }

.section-label {
  font-family: var(--display); font-weight: 600; font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--steel);
  margin: 22px 0 9px; display: flex; align-items: center; gap: 8px;
}
.section-label:first-child { margin-top: 0; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.card {
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 11px;
  box-shadow: 0 1px 0 rgba(28,30,26,0.04);
}

/* ---------- day selector ---------- */
.daytype-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.daytype-btn {
  font-family: var(--display); font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--ink); border-radius: 8px; background: var(--paper);
  color: var(--ink); padding: 9px 18px; min-width: 46px; transition: transform .08s ease;
}
.daytype-btn:active { transform: scale(0.96); }
.daytype-btn.active { background: var(--ink); color: var(--paper); }
.daytype-btn.rest-active { background: var(--steel); color: var(--paper); border-color: var(--steel); }
.daytype-btn.cardio-active { background: var(--orange); color: var(--ink); border-color: var(--orange); }

/* ---------- exercise card ---------- */
.ex-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ex-num {
  font-family: var(--mono); font-size: 10px; color: var(--steel); letter-spacing: 0.08em;
}
.ex-name { font-family: var(--display); font-weight: 600; font-size: 16px; line-height: 1.25; margin-top: 2px; }
.ex-icon { width: 92px; height: 108px; flex-shrink: 0; }
.ex-icon svg { display: block; width: 100%; height: 100%; }
.tag {
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--ink); color: var(--paper); border-radius: 5px; padding: 3px 8px;
}
.ex-body { display: flex; gap: 14px; align-items: flex-start; }
.ex-info { flex: 1; min-width: 0; }
.sets-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.set-item {
  display: flex; align-items: center; gap: 5px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 6px 4px 8px;
}
.set-label { font-family: var(--mono); font-size: 10.5px; color: var(--steel); font-weight: 600; }
.weight-input {
  width: 42px; padding: 4px 2px; text-align: center;
  font-family: var(--mono); font-size: 13px; font-weight: 600; border: none;
  border-radius: 4px; background: var(--paper2); color: var(--ink);
}
.check-btn {
  width: 24px; height: 24px; border: 1.5px solid var(--ink); border-radius: 6px;
  background: transparent; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.check-btn svg { width: 13px; height: 13px; }
.check-btn.done { background: var(--green); border-color: var(--green); color: var(--paper); }

/* ---------- buttons ---------- */
.btn-primary {
  width: 100%; padding: 15px; border: none; border-radius: 10px;
  background: var(--orange); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: 14.5px; letter-spacing: 0.04em;
  text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; box-shadow: 0 3px 0 var(--orange-dim);
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--orange-dim); }
.btn-primary svg { width: 17px; height: 17px; }
.btn-done {
  width: 100%; padding: 15px; border-radius: 10px;
  background: var(--green); color: var(--paper);
  font-family: var(--display); font-weight: 700; font-size: 14.5px; letter-spacing: 0.04em;
  text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
}
.btn-done svg { width: 17px; height: 17px; }
.btn-secondary {
  padding: 11px 18px; border: none; border-radius: 9px;
  background: var(--ink); color: var(--paper);
  font-family: var(--display); font-weight: 600; font-size: 13px; letter-spacing: 0.03em;
  text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-secondary svg { width: 14px; height: 14px; }

.weight-input-row { display: flex; gap: 8px; }
.weight-input-row input {
  flex: 1; padding: 11px 14px; font-family: var(--mono); font-size: 16px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink);
}

.stat-row { display: flex; justify-content: space-between; margin-bottom: 14px; }
.stat-big { font-family: var(--mono); font-size: 24px; font-weight: 700; }
.stat-cap { font-size: 11px; color: var(--steel); margin-top: 2px; }

.field-row { display: flex; gap: 12px; }
.field { flex: 1; }
.field-label { font-size: 11px; color: var(--steel); margin-bottom: 5px; font-weight: 500; }
.field input, .field select {
  width: 100%; padding: 9px 10px; font-family: var(--mono); font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink);
}
.field select { font-family: var(--body); font-size: 13px; font-weight: 500; }

.kcal-row { display: flex; justify-content: space-between; align-items: center; }
.kcal-num { font-family: var(--mono); font-size: 28px; font-weight: 700; color: var(--orange); }
.protein-num { font-family: var(--mono); font-size: 28px; font-weight: 700; }
.kcal-cap { font-size: 10.5px; color: var(--steel); margin-top: 3px; font-weight: 500; }
.hint { font-size: 12.5px; color: var(--steel); font-style: italic; margin-top: 10px; line-height: 1.4; }

.meal-name { font-family: var(--display); font-weight: 600; font-size: 16px; }
.meal-target {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink); background: var(--paper3);
  padding: 3px 7px; border-radius: 5px; font-weight: 600; white-space: nowrap;
}
.meal-main { font-size: 13.5px; margin: 8px 0 6px; line-height: 1.45; }
.meal-alt { font-size: 12px; color: var(--steel); line-height: 1.4; }

.install-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--orange); color: var(--ink); padding: 11px 16px; font-size: 12.5px; font-weight: 500;
}
.install-banner button {
  background: var(--ink); color: var(--paper); border: none; border-radius: 7px;
  padding: 8px 13px; font-family: var(--display); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.install-close { background: transparent !important; color: rgba(28,30,26,0.55) !important; padding: 4px !important; font-size: 16px !important; }

.save-flash {
  text-align: center; margin-top: 10px; color: var(--green); font-size: 12.5px;
  font-family: var(--mono); font-weight: 600;
}

.empty-card { text-align: center; padding: 28px 16px; }
.empty-card svg { width: 36px; height: 36px; color: var(--steel-light); margin-bottom: 10px; }
.empty-card p { color: var(--steel); font-size: 13.5px; margin: 0; line-height: 1.5; }
