:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --bg: #071d20;
  --panel: #102f34;
  --panel-soft: rgba(246, 240, 232, 0.07);
  --line: rgba(246, 240, 232, 0.14);
  --ink: #f6f0e8;
  --muted: #b7c5c0;
  --teal: #18b9ad;
  --purple: #a78bfa;
  --amber: #e9b45d;
  --coral: #ed7566;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(167, 139, 250, 0.18), transparent 32%),
    linear-gradient(135deg, #071d20 0%, #102f34 52%, #201c27 100%);
  color: var(--ink);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), #8ad9cb);
  color: #042326;
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
}

button:hover,
button:focus-visible {
  background: linear-gradient(135deg, #35c9be, #f0d08d);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(246, 240, 232, 0.17);
  border-radius: 8px;
  outline: 0;
  background: rgba(5, 18, 21, 0.66);
  color: var(--ink);
  padding: 12px 13px;
}

input,
select {
  min-height: 46px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(167, 139, 250, 0.9);
  box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.16);
}

label {
  color: #dbe3df;
  font-size: 0.9rem;
  font-weight: 750;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 1.7rem;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 29, 32, 0.84);
  padding: 14px 26px;
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 820;
  text-decoration: none;
}

.brand-lockup img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
}

.section-nav {
  display: flex;
  gap: 8px;
}

.nav-link {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 9px 12px;
  text-decoration: none;
}

.nav-link.active,
.nav-link:hover,
.nav-link:focus-visible {
  border-color: rgba(167, 139, 250, 0.72);
  color: var(--ink);
}

.fitness-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 30px 26px 48px;
}

.module-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 820;
  text-transform: uppercase;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin: 12px 0 0;
  border: 1px solid rgba(24, 185, 173, 0.34);
  border-radius: 8px;
  background: rgba(24, 185, 173, 0.1);
  color: #d6f5ef;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.25;
  padding: 6px 10px;
}

.sync-status::before {
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(24, 185, 173, 0.14);
  content: "";
  flex: 0 0 auto;
}

.sync-status.waiting {
  border-color: rgba(233, 180, 93, 0.36);
  background: rgba(233, 180, 93, 0.1);
  color: #f3dfbd;
}

.sync-status.waiting::before {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(233, 180, 93, 0.14);
}

.sync-status.offline {
  border-color: rgba(237, 117, 102, 0.38);
  background: rgba(237, 117, 102, 0.1);
  color: #ffd3cc;
}

.sync-status.offline::before {
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(237, 117, 102, 0.14);
}

.date-control {
  display: grid;
  min-width: 220px;
  gap: 8px;
}

.summary-grid,
.workspace-grid,
.entry-grid {
  display: grid;
  gap: 14px;
}

.summary-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 14px;
}

.summary-tile,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
    rgba(9, 31, 35, 0.8);
  box-shadow: var(--shadow);
}

.summary-tile {
  min-width: 0;
  padding: 16px;
}

.summary-tile-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

.text-button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d8c9ff;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button:hover,
.text-button:focus-visible {
  background: transparent;
  color: #f0d08d;
}

.summary-tile strong {
  display: block;
  margin: 10px 0 6px;
  color: var(--ink);
  font-size: clamp(1.28rem, 2.2vw, 2.1rem);
  line-height: 1;
}

.summary-tile p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.quick-weight-form,
.quick-target-form {
  display: grid;
  grid-template-columns: minmax(64px, 0.7fr) minmax(118px, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.quick-target-form[hidden],
.quick-food-form[hidden],
.more-food-button[hidden] {
  display: none;
}

.quick-weight-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.quick-food-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.quick-weight-form input,
.quick-target-form input,
.quick-food-form input {
  min-height: 40px;
  padding: 9px 10px;
}

.quick-weight-form button,
.quick-target-form button,
.quick-food-form button {
  min-height: 40px;
  padding: 0 12px;
}

.compact-food-list {
  display: grid;
  gap: 5px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.compact-food-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #dbe3df;
  font-size: 0.78rem;
  line-height: 1.25;
}

.compact-food-list small {
  flex: 0 0 auto;
  color: var(--muted);
}

.compact-food-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-food-button {
  display: inline-flex;
  margin-top: 8px;
}

.positive-message {
  min-height: 19px;
  margin-top: 8px;
  color: #f0d08d;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.summary-tile.accent {
  border-color: rgba(167, 139, 250, 0.4);
}

.workspace-grid {
  grid-template-columns: minmax(0, 2fr) minmax(0, 0.82fr);
  margin-bottom: 14px;
}

.entry-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.range-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.range-control button {
  min-height: 36px;
  border: 1px solid rgba(246, 240, 232, 0.16);
  background: rgba(246, 240, 232, 0.07);
  color: var(--muted);
  padding: 0 11px;
}

.range-control button.active,
.range-control button:hover,
.range-control button:focus-visible {
  border-color: rgba(167, 139, 250, 0.76);
  background: rgba(167, 139, 250, 0.18);
  color: var(--ink);
}

.chart-wrap {
  min-height: 300px;
  border: 1px solid rgba(246, 240, 232, 0.1);
  border-radius: 8px;
  background: rgba(5, 18, 21, 0.42);
  padding: 8px;
}

#weight-chart {
  display: block;
  width: 100%;
  height: 300px;
}

.chart-grid {
  stroke: rgba(246, 240, 232, 0.11);
  stroke-width: 1;
}

.chart-axis-label {
  fill: rgba(246, 240, 232, 0.7);
  font-size: 12px;
}

.chart-weight-line {
  fill: none;
  stroke: #42d7c9;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-target-line {
  stroke: #a78bfa;
  stroke-dasharray: 8 7;
  stroke-width: 3;
}

.chart-projection-line {
  fill: none;
  stroke: #ed7566;
  stroke-dasharray: 6 9;
  stroke-linecap: round;
  stroke-width: 4;
}

.chart-point {
  fill: #f0d08d;
  stroke: #071d20;
  stroke-width: 3;
}

.chart-empty {
  fill: rgba(246, 240, 232, 0.72);
  font-size: 18px;
  font-weight: 760;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chart-legend i {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 999px;
}

.legend-weight {
  background: #42d7c9;
}

.legend-target {
  background: var(--purple);
}

.legend-projection {
  background: repeating-linear-gradient(
    90deg,
    var(--coral) 0 6px,
    transparent 6px 12px
  );
}

.advice-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.advice-list li {
  border-left: 3px solid var(--purple);
  background: rgba(246, 240, 232, 0.07);
  border-radius: 6px;
  color: #dbe3df;
  line-height: 1.45;
  padding: 12px;
}

.stack-form,
.two-column-form,
.profile-form {
  display: grid;
  gap: 10px;
}

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

.profile-form {
  grid-template-columns: minmax(90px, 0.8fr) minmax(0, 1fr);
  align-items: center;
}

.two-column-form button,
.profile-form button {
  grid-column: 1 / -1;
}

.entry-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.entry-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(246, 240, 232, 0.1);
  border-radius: 8px;
  background: rgba(246, 240, 232, 0.06);
  color: #dbe3df;
  padding: 10px;
}

.entry-list small {
  color: var(--muted);
}

.estimate-line {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.phone-sync-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.phone-sync-actions button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}

#phone-sync-token {
  min-height: 86px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
  resize: none;
}

.compare-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin-top: 18px;
}

.photo-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 210px;
  margin-top: 14px;
}

.photo-slot {
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid rgba(246, 240, 232, 0.12);
  border-radius: 8px;
  background: rgba(5, 18, 21, 0.42);
  min-height: 210px;
  padding: 10px;
}

.photo-slot img {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 6px;
  object-fit: cover;
}

.photo-slot p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-topbar,
  .module-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .app-topbar {
    gap: 12px;
    padding: 14px 18px;
  }

  .section-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    text-align: center;
  }

  .fitness-shell {
    padding: 22px 18px 36px;
  }

  .summary-grid,
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .quick-weight-form,
  .quick-target-form,
  .quick-food-form,
  .profile-form,
  .phone-sync-actions,
  .two-column-form,
  .compare-controls,
  .photo-compare {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    display: grid;
  }

  .range-control {
    justify-content: stretch;
  }

  .range-control button {
    flex: 1;
  }

  h1 {
    font-size: 1.55rem;
  }
}
