:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #ffffff;
  --ink: #111114;
  --muted: #73737a;
  --line: rgba(20, 20, 24, 0.09);
  --blue: #0a84ff;
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff453a;
  --purple: #bf5af2;
  --shadow: 0 16px 44px rgba(22, 22, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(245, 245, 247, 0.92)),
    radial-gradient(circle at 10% 0%, rgba(10, 132, 255, 0.14), transparent 22rem),
    radial-gradient(circle at 85% 12%, rgba(48, 209, 88, 0.12), transparent 18rem);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 12px max(22px, env(safe-area-inset-bottom));
}

.hero-panel,
.card,
.coach-card,
.progress-card,
.photo-upload {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.65rem;
  line-height: 0.98;
}

h2 {
  font-size: 1.35rem;
}

.subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.score-ring {
  display: grid;
  place-items: center;
  flex: 0 0 78px;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--score, 0%), rgba(120, 120, 128, 0.16) 0);
  position: relative;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--panel-strong);
}

.score-ring span,
.score-ring small {
  position: relative;
}

.score-ring span {
  font-weight: 850;
}

.score-ring small {
  margin-top: -22px;
  color: var(--muted);
  font-size: 0.68rem;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin: 12px 0 16px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(118, 118, 128, 0.12);
}

.tab {
  min-width: 0;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head.compact {
  margin-top: 0;
}

.quick-stats,
.macro-summary,
.macro-grid,
.target-grid {
  display: grid;
  gap: 8px;
}

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

.quick-stats article,
.macro-summary article {
  min-width: 0;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.quick-stats span,
.macro-summary span {
  display: block;
  font-size: 1.06rem;
  font-weight: 850;
}

small {
  color: var(--muted);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  margin: 10px 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  outline: 0;
}

input,
select {
  min-height: 48px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  min-height: 108px;
  padding: 12px 13px;
  line-height: 1.4;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(10, 132, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.14);
}

button {
  cursor: pointer;
}

.input-row button,
.nutrition-form button,
.sleep-form button,
.wide-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.icon-button {
  width: 40px;
  height: 40px;
  background: rgba(118, 118, 128, 0.18);
  color: var(--ink);
}

.ghost-button {
  min-height: 40px;
  padding: 0 12px;
}

.wide-button {
  width: 100%;
  min-height: 48px;
  margin: 10px 0;
}

.card {
  padding: 14px;
  margin-top: 12px;
}

.list,
.habit-stats {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.item {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.item span {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.item.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.check,
.delete {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
}

.check {
  background: rgba(118, 118, 128, 0.16);
}

.item.done .check {
  background: var(--green);
}

.item.done .check::after {
  content: "✓";
  color: white;
  font-weight: 900;
}

.delete {
  background: rgba(255, 69, 58, 0.12);
  color: var(--red);
  font-size: 1.2rem;
}

.pill {
  display: inline-grid;
  place-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(10, 132, 255, 0.12);
  color: var(--blue);
  font-weight: 850;
}

.chart-card {
  padding: 14px 12px 10px;
}

.week-chart,
.sleep-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  height: 176px;
}

.bar-wrap {
  display: grid;
  align-items: end;
  gap: 7px;
  height: 100%;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.bar {
  width: 100%;
  min-height: 8px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--blue), #64d2ff);
}

.sleep-chart .bar {
  background: linear-gradient(180deg, var(--purple), var(--blue));
}

.habit-stat-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.habit-stat-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 820;
}

.mini-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.mini-day {
  height: 8px;
  border-radius: 99px;
  background: rgba(118, 118, 128, 0.16);
}

.mini-day.done {
  background: var(--green);
}

.sleep-form,
.nutrition-form,
.goal-card,
.goal-form {
  display: grid;
  gap: 9px;
}

.sleep-form {
  grid-template-columns: 1fr;
}

.macro-grid,
.macro-summary,
.target-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.goal-form {
  margin-bottom: 12px;
}

.goal-form button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.macro-summary {
  margin: 12px 0;
}

.photo-upload {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 15px;
  color: var(--ink);
  text-align: center;
}

.photo-upload input {
  display: none;
}

.photo-upload span {
  font-weight: 850;
}

.progress-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.16);
}

.progress-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--orange));
}

.coach-card {
  display: grid;
  gap: 9px;
  padding: 14px;
  line-height: 1.42;
}

.coach-card p {
  margin: 0;
}

.coach-card strong {
  color: var(--blue);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.day-cell {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 850;
}

.day-cell.today {
  border-color: var(--orange);
  color: var(--orange);
}

.day-cell.done {
  background: var(--green);
  color: white;
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 9px;
  }

  h1 {
    font-size: 2.25rem;
  }

  .score-ring {
    flex-basis: 68px;
    width: 68px;
    height: 68px;
  }

  .tab {
    font-size: 0.7rem;
  }
}
