:root {
  --bg: #141414;
  --header: #1a1a1a;
  --card: #1e1e1e;
  --field: #252525;
  --line: #2a2a2a;
  --line-2: #333333;
  --line-3: #3a3a3a;
  --text: #ffffff;
  --body: #cccccc;
  --muted: #888888;
  --meta: #666666;
  --accent: #ff6b35;
  --danger: #e05555;
  --success: #39c47a;
  --warning: #d6a13a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(920px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 68px 16px 80px;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  display: flex;
  height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--header);
}

.brand-button,
.avatar-button {
  border: 0;
  background: transparent;
  color: var(--text);
}

.brand-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}

.brand-icon {
  width: 22px;
  height: 22px;
  fill: var(--accent);
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}

.avatar-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
}

.avatar-dot {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--field);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.screen-head {
  min-height: 40px;
  margin-bottom: 16px;
}

.screen-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.screen-head p {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1 {
  display: none;
}

h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

p {
  margin-top: 0;
}

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

.section,
.hero-card,
.day-card,
.meal,
.report,
.knowledge-detail {
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}

.section:first-child,
.hero-card:first-child {
  margin-top: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tasks {
  margin: 8px 0 0;
  padding-left: 18px;
}

.tasks li {
  margin-bottom: 8px;
  color: var(--body);
}

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

.exercise-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.exercise-row:last-child {
  border-bottom: 0;
}

.exercise-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  background: #2a1a0a;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.exercise-name {
  color: var(--body);
  font-size: 14px;
  line-height: 1.35;
}

.exercise-badge {
  max-width: 48vw;
  padding: 5px 8px;
  border-radius: 999px;
  background: #2a2a2a;
  color: var(--body);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workout-card-head {
  align-items: center;
}

.hint {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #181818;
  color: var(--muted);
  font-size: 13px;
}

.inline-link,
.text-link {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
}

.collapse-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  text-align: left;
}

.collapse-toggle span {
  display: grid;
  gap: 3px;
}

.collapse-toggle span strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.collapse-toggle span small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.collapse-toggle em {
  min-width: 96px;
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: #2a1a0a;
  color: var(--accent);
  font-size: 14px;
  font-style: normal;
  font-weight: 800;
}

.collapse-body {
  display: none;
}

.collapse-body.open {
  display: block;
  margin-top: 12px;
}

.metric-grid,
.profile-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 64px;
  padding: 12px;
  border-radius: 10px;
  background: var(--field);
}

.metric span,
.label {
  display: block;
  margin-bottom: 4px;
  color: var(--meta);
  font-size: 12px;
}

.metric strong {
  color: var(--text);
  font-size: 18px;
}

.profile-summary {
  margin-bottom: 16px;
}

.nutrition-focus {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
}

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

.day-picker-section,
.week-section {
  padding-top: 12px;
  padding-bottom: 12px;
}

.calorie-ring {
  display: flex;
  flex-direction: column;
  width: 100px;
  height: 100px;
  align-items: center;
  justify-content: center;
  place-items: center;
  justify-self: start;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress), #303030 0);
  position: relative;
}

.calorie-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--card);
}

.calorie-ring strong,
.calorie-ring span {
  position: relative;
  z-index: 1;
  display: block;
  width: 74px;
  text-align: center;
}

.calorie-ring strong {
  color: var(--text);
  font-size: 21px;
  line-height: 1;
}

.calorie-ring span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
  overflow-wrap: normal;
  white-space: normal;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field.full {
  grid-column: 1 / -1;
}

label,
.scale-help {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--field);
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

select {
  color: var(--text);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.button,
.ghost-button {
  min-height: 48px;
  border-radius: 10px;
  padding: 0 14px;
  font-weight: 700;
}

.button {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #000000;
  font-size: 15px;
}

.button.secondary,
.ghost-button {
  width: auto;
  min-height: 40px;
  border: 1px solid var(--line-3);
  background: transparent;
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
}

.ai-test-button {
  width: 100%;
}

.button.danger {
  width: auto;
  min-height: 40px;
  border: 1px solid var(--danger);
  background: #3a1a1a;
  color: var(--danger);
  font-size: 14px;
}

.danger-zone {
  display: flex;
  justify-content: flex-start;
  margin-top: 24px;
}

.notice {
  margin: 10px 0 0;
  color: var(--success);
}

.text-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 16px;
}

.manual-form {
  display: none;
  margin-top: 12px;
}

.manual-form.open {
  display: grid;
}

.diary-section {
  display: grid;
  gap: 10px;
}

.meal {
  margin-top: 0;
  padding: 12px;
}

.meal strong {
  color: var(--text);
}

.plan-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -2px 12px;
  padding: 2px 2px 8px;
  scrollbar-width: none;
}

.day-select-panel {
  display: none;
  margin-top: 12px;
}

.day-select-panel.open {
  display: block;
}

.plan-chips::-webkit-scrollbar {
  display: none;
}

.day-chip {
  position: relative;
  display: grid;
  min-width: 54px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #191919;
  color: var(--muted);
  padding: 6px 10px;
}

.day-chip strong {
  color: currentColor;
  font-size: 13px;
}

.day-chip span {
  color: currentColor;
  font-size: 11px;
}

.day-chip em {
  position: absolute;
  top: -4px;
  right: -4px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.day-chip.completed {
  border-color: rgba(255, 107, 53, 0.7);
  background: #191919;
  color: var(--body);
}

.day-chip.today,
.day-chip.selected {
  border-color: var(--accent);
  color: var(--accent);
}

.day-chip.completed.selected,
.day-chip.completed.today {
  border-color: var(--accent);
  background: #2a1a0a;
  color: var(--accent);
}

.day-chip.rest {
  background: #222222;
  color: var(--meta);
}

.day-chip.selected:not(.completed) {
  background: #2a1a0a;
}

.selected-day {
  border-color: var(--line);
}

.set-day:disabled {
  opacity: 1;
  border-color: var(--accent);
  color: var(--accent);
}

.day-card .hint + .set-day {
  margin-top: 16px;
}

.inline-status {
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 12px;
}

.charts {
  display: grid;
  gap: 12px;
}

.chart-plain svg,
.chart-card svg {
  display: block;
  width: 100%;
  height: 160px;
}

.chart-axis {
  stroke: var(--line-2);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-line.secondary {
  stroke: var(--success);
}

.chart-dot {
  fill: var(--accent);
}

.bar {
  fill: var(--success);
}

.week-status {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.week-day {
  display: grid;
  min-height: 72px;
  place-items: center;
  gap: 3px;
  text-align: center;
}

.week-day strong {
  color: var(--body);
  font-size: 12px;
}

.week-day small {
  color: var(--meta);
  font-size: 11px;
}

.status-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: #2a2a2a;
  color: var(--meta);
  font-size: 22px;
  font-weight: 800;
}

.week-day.done .status-icon {
  background: var(--accent);
  color: #000;
}

.week-day.partial .status-icon {
  background: var(--warning);
  color: #000;
}

.week-day.missed .status-icon {
  background: #3a1a1a;
  color: var(--danger);
}

.stacked-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(32px, 1fr));
  gap: 10px;
  min-height: 180px;
  align-items: end;
  padding: 8px 0 4px;
}

.stacked-day {
  display: grid;
  gap: 6px;
  align-items: end;
}

.stacked-bar {
  display: flex;
  flex-direction: column-reverse;
  height: 150px;
  overflow: hidden;
  border-radius: 8px 8px 4px 4px;
  background: #252525;
}

.stack {
  display: block;
  width: 100%;
}

.stack.protein,
.legend-protein {
  background: #78b7b1;
}

.stack.fat,
.legend-fat {
  background: #e15759;
}

.stack.carbs,
.legend-carbs {
  background: #f28e2b;
}

.stacked-label {
  color: var(--meta);
  font-size: 11px;
  text-align: center;
}

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

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

.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline-item {
  position: relative;
  padding-left: 18px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-item::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: -12px;
  left: 3px;
  width: 1px;
  background: var(--line-2);
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-item strong {
  color: var(--text);
}

.timeline-item p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.more-tile {
  display: grid;
  height: 80px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--body);
}

.more-tile span {
  font-size: 22px;
}

.more-tile strong {
  color: var(--text);
  font-size: 14px;
}

.back-button {
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font-weight: 600;
}

.accordion {
  display: grid;
  gap: 10px;
}

.accordion-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.accordion-header {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0 14px;
  text-align: left;
}

.accordion-header strong {
  font-size: 14px;
  font-weight: 600;
}

.accordion-body {
  display: none;
  border-top: 1px solid var(--line);
  padding: 10px;
}

.accordion-item.open .accordion-body {
  display: block;
}

.knowledge-list {
  display: grid;
  gap: 8px;
}

.chip {
  min-height: 42px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--field);
  color: var(--body);
  padding: 0 12px;
  text-align: left;
}

.chip.active {
  border-color: var(--accent);
  background: #2a1a0a;
  color: var(--accent);
}

.knowledge-detail {
  margin: -2px 0 10px;
  border-color: var(--line-2);
  background: #202020;
}

.chevron {
  color: var(--accent);
  font-weight: 800;
}

.admin-tile {
  border-color: rgba(255, 107, 53, 0.45);
  background: #21160f;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.admin-stat {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.admin-stat.active {
  border-color: var(--accent);
  background: #2a1a0a;
}

.admin-stat span,
.admin-user small,
.admin-activity-row span {
  color: var(--muted);
  font-size: 12px;
}

.admin-stat strong {
  color: var(--accent);
  font-size: 22px;
}

.admin-activity {
  display: grid;
  gap: 12px;
}

.admin-activity-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  align-items: center;
  gap: 12px;
}

.admin-activity-row > div:first-child {
  display: grid;
  gap: 2px;
}

.mini-bars {
  display: flex;
  align-items: end;
  min-height: 40px;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.mini-bars i {
  display: block;
  width: 8px;
  border-radius: 6px 6px 0 0;
  background: var(--accent);
}

.mini-bars em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-user {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 10px;
}

.admin-user strong {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.admin-user strong span {
  color: var(--accent);
  font-size: 12px;
}

.admin-user p {
  margin: 0;
  color: var(--body);
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  height: calc(60px + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--header);
}

.tab {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--meta);
  padding: 4px;
}

.tab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab strong {
  color: #555555;
  max-width: 86px;
  color: #555555;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
}

.tab.active {
  background: #2a1a0a;
  color: var(--accent);
}

.tab.active strong {
  color: var(--accent);
}

@media (max-width: 640px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .nutrition-focus {
    grid-template-columns: 100px 1fr;
  }

  .metric-grid {
    gap: 8px;
  }

  .metric {
    padding: 10px;
  }

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

  .field.full {
    grid-column: 1 / -1;
  }

  .week-status,
  .stacked-chart {
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    overflow-x: auto;
  }

  .exercise-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .exercise-badge {
    grid-column: 2;
    justify-self: start;
    max-width: 100%;
    white-space: normal;
  }

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

  .admin-activity-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .brand-name {
    font-size: 15px;
  }

  .tab strong {
    font-size: 10px;
  }

  .nutrition-focus,
  .metric-grid,
  .profile-grid {
    grid-template-columns: 1fr;
  }
}
