:root {
  --bg: #f7f8fc;
  --card: #ffffff;
  --card-strong: #f8fafc;
  --line: #e6eaf2;
  --line-soft: rgba(148, 163, 184, 0.18);
  --text: #101828;
  --muted: #667085;
  --accent: #5b8def;
  --accent-strong: #3662c8;
  --accent-soft: #edf3ff;
  --accent-alt: #f3f6ff;
  --danger: #d95f7a;
  --danger-soft: #fff1f4;
  --warning: #f59e0b;
  --shadow: 0 18px 40px rgba(99, 114, 156, 0.08);
  --shadow-inner: inset 0 1px 0 rgba(255, 255, 255, 0.84);
  --radius-lg: 30px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --font-ui:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "SF Pro Text",
    "Segoe UI",
    sans-serif;
  --font-display:
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "SF Pro Text",
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(840px 520px at 0% 0%, rgba(210, 223, 255, 0.64), transparent 55%),
    radial-gradient(720px 460px at 100% 0%, rgba(255, 228, 236, 0.56), transparent 56%),
    linear-gradient(180deg, #fbfcff 0%, #f6f8fd 45%, #f3f5fb 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-over-limit {
  background:
    radial-gradient(840px 520px at 0% 0%, rgba(255, 214, 224, 0.5), transparent 55%),
    radial-gradient(720px 460px at 100% 0%, rgba(255, 235, 214, 0.46), transparent 56%),
    linear-gradient(180deg, #fff9fb 0%, #fff5f7 45%, #fff1f4 100%);
}

.bg-blob {
  display: none;
}

.blob-a {
  width: 360px;
  height: 360px;
  top: 48px;
  left: -120px;
  background: rgba(105, 160, 255, 0.42);
}

.blob-b {
  width: 340px;
  height: 340px;
  right: -110px;
  top: 24px;
  background: rgba(255, 171, 211, 0.38);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 24px));
  margin: 18px auto 40px;
  display: grid;
  gap: 14px;
}

.hero-card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  position: relative;
}

.hero-card {
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.hero-card h1 {
  margin: 6px 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.05em;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 0.98;
  color: #0f172a;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-strong);
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.panel {
  padding: 18px;
}

.auth-panel h2,
.summary-card h2 {
  margin: 8px 0 10px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head--tight {
  margin-bottom: 10px;
}

.panel-head h3 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

.links-row {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8faff;
}

.chip-link.is-static {
  cursor: default;
}

.dashboard[hidden],
.auth-panel[hidden],
.pending-panel[hidden],
.mode-panel[hidden] {
  display: none !important;
}

.dashboard {
  display: grid;
  gap: 14px;
}

.summary-card {
  display: grid;
  gap: 16px;
}

.summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid #dce7ff;
}

body.is-over-limit .status-chip {
  color: var(--danger);
  background: #ffeef3;
  border-color: #ffd8e2;
}

.summary-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  align-items: center;
}

.ring-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.progress-ring {
  --angle: 0deg;
  width: 190px;
  height: 190px;
  padding: 12px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, #7da6f3 var(--angle), #e7edf8 0deg);
  box-shadow: inset 0 0 0 1px #dfe6f2;
}

.progress-ring.is-empty {
  background: #e7edf8;
}

body.is-over-limit .progress-ring {
  background: conic-gradient(from -90deg, #e58aa0 var(--angle), #f5dfe6 0deg);
  box-shadow: inset 0 0 0 1px #f1d5dd;
}

body.is-over-limit .progress-ring.is-empty {
  background: #f5dfe6;
}

.progress-ring__inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  text-align: center;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #edf1f7;
}

body.is-over-limit .progress-ring__inner {
  background: #fffafb;
}

.progress-percent {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  color: var(--accent-strong);
  text-align: center;
}

body.is-over-limit .progress-percent {
  color: var(--danger);
}

.progress-ring__inner strong {
  display: block;
  font-family: var(--font-display);
  font-size: 38px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.progress-caption {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.progress-mini {
  position: absolute;
  right: -4px;
  bottom: 2px;
  width: 84px;
  height: 84px;
  padding: 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  background: #eef4ff;
  border: 1px solid #dbe6fb;
  box-shadow: 0 10px 22px rgba(99, 114, 156, 0.1);
}

body.is-over-limit .progress-mini {
  background: #fff1f4;
  border-color: #f3d5dd;
}

.progress-mini__label {
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-align: center;
}

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

.metric-card {
  min-height: 112px;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fbfcfe;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

body.is-over-limit .metric-card {
  border-color: #f3d9e0;
  background: #fff7f9;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.target-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.target-form label,
.stack label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-family: var(--font-ui);
}

input {
  height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 16px 18px;
  font-size: 16px;
  line-height: 1.55;
  caret-color: var(--accent-strong);
}

textarea::placeholder {
  color: #98a2b3;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.58);
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.14);
}

#text-form textarea {
  background: #fcfdff;
  border: 1px solid #d7e2f0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 1px 2px rgba(15, 23, 42, 0.02);
}

#text-form textarea:focus {
  background: #ffffff;
  border-color: #7da6f3;
  box-shadow:
    0 0 0 4px rgba(125, 166, 243, 0.16),
    0 10px 24px rgba(125, 166, 243, 0.08);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font: inherit;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-decoration: none;
}

.btn.primary {
  color: #fff;
  background:
    linear-gradient(135deg, #6e97ee 0%, #5b8def 100%);
  box-shadow: 0 12px 24px rgba(91, 141, 239, 0.24);
}

.btn.ghost {
  color: var(--accent-strong);
  background: #f8faff;
  border-color: var(--line);
}

.btn:hover,
.mode-btn:hover,
.chip-link:hover,
.delete-btn:hover {
  transform: translateY(-1px);
}

.btn:active,
.mode-btn:active,
.chip-link:active,
.delete-btn:active {
  transform: translateY(0);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.danger-btn {
  color: var(--danger);
  border-color: #f1d5dd;
  background: #fff7f9;
}

.pending-panel {
  display: grid;
  gap: 14px;
}

.limit-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid #f5d3dc;
  color: var(--danger);
  font-weight: 700;
}

.macro-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fbfcfe;
}

body.is-over-limit .macro-panel {
  border-color: #f3d9e0;
  background: #fff8fa;
}

.macro-list {
  display: grid;
  gap: 12px;
}

.macro-row {
  display: grid;
  gap: 8px;
}

.macro-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.macro-copy span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.macro-copy strong {
  font-size: 17px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.macro-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

body.is-over-limit .macro-track {
  background: #f5dde4;
}

.macro-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 220ms ease;
}

.macro-fill.is-protein {
  background: linear-gradient(90deg, #6ea8ff 0%, #4f82ea 100%);
}

.macro-fill.is-fat {
  background: linear-gradient(90deg, #f5a977 0%, #ee8a52 100%);
}

.macro-fill.is-carbs {
  background: linear-gradient(90deg, #9a8dff 0%, #7768ee 100%);
}

.workspace {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 14px;
}

.compose-panel,
.journal-panel {
  display: grid;
  align-content: start;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border-radius: 16px;
  background: #f3f6fc;
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mode-btn.is-active {
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(99, 114, 156, 0.1);
}

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

.upload-tile {
  position: relative;
  min-height: 156px;
  padding: 18px;
  display: grid;
  gap: 8px;
  align-content: end;
  border: 1px dashed #d8e2f0;
  border-radius: var(--radius-md);
  background: #fbfcfe;
  cursor: pointer;
}

.upload-tile input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-tile span {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

.upload-tile small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.voice-recorder {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px dashed #d8e2f0;
  background: #fbfcfe;
}

.voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-trigger {
  position: relative;
  overflow: hidden;
}

.file-trigger input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.voice-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-line {
  margin-top: 14px;
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-line.is-busy {
  color: var(--warning);
}

.status-line.is-error {
  color: var(--danger);
}

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

.entry-empty {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed #d8e2f0;
  color: var(--muted);
  background: #fbfcfe;
}

.entry-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #ffffff;
  display: grid;
  gap: 10px;
}

.entry-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.entry-card__title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

.entry-card__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.entry-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-strong);
  background: #f4f7fd;
  border: 1px solid #e3eaf5;
}

.entry-calories {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.entry-card__items {
  display: grid;
  gap: 6px;
}

.entry-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.entry-notes {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.delete-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 13px;
  font-weight: 800;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.admin-shell {
  width: min(1180px, calc(100% - 24px));
}

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

.admin-panel-block {
  display: grid;
  gap: 14px;
}

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

.admin-list.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.admin-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #ffffff;
}

.admin-user-card.compact {
  align-items: flex-start;
}

.admin-user-copy {
  display: grid;
  gap: 6px;
}

.admin-user-copy strong {
  font-size: 18px;
  letter-spacing: -0.02em;
  font-family: var(--font-display);
}

.admin-user-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 940px) {
  .summary-layout,
  .workspace,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 16px, 100%);
    margin: 10px auto 22px;
  }

  .hero-card {
    padding: 16px;
    flex-direction: column;
  }

  .hero-card h1 {
    font-size: clamp(30px, 9vw, 42px);
  }

  .panel {
    padding: 16px;
  }

  .summary-top {
    flex-direction: column;
  }

  .summary-card h2 {
    font-size: 30px;
  }

  .progress-ring {
    width: 168px;
    height: 168px;
  }

  .progress-ring__inner strong {
    font-size: 34px;
  }

  .progress-mini {
    width: 74px;
    height: 74px;
    right: -2px;
    bottom: 0;
  }

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

  .mode-switch {
    width: 100%;
  }

  .upload-tile {
    min-height: 132px;
  }

  .voice-actions,
  .admin-user-card {
    grid-template-columns: 1fr;
    display: grid;
  }

  .voice-actions .btn,
  .voice-actions .file-trigger {
    width: 100%;
  }
}
