:root {
  --bg: #f3ede3;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e8dfd2;
  --primary-soft: #7db9a2;
  --primary-soft-hover: #6aa88f;
  --primary-soft-active: #5e987f;
  --success: #34c759;
  --warning: #ffd60a;
  --neutral: #e5e5ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.top-right-report-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1000;
  box-shadow: 0 6px 14px rgba(106, 168, 143, 0.22);
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px;
}

.app-intro {
  margin-bottom: 10px;
}

.app-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.encourage-text {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg);
  padding: 8px 0;
}

h1 {
  margin: 0;
  font-size: 1.2rem;
}

.floating-profile-btn {
  position: fixed;
  top: 14px;
  right: 172px;
  z-index: 1000;
  min-height: 36px;
  padding: 0 10px;
}

.ghost-btn,
.primary-btn {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ghost-btn {
  background: #fff;
}

.primary-btn {
  background: var(--primary-soft);
  border-color: #6aa88f;
  color: #fff;
  box-shadow: 0 4px 10px rgba(106, 168, 143, 0.18);
}

.primary-btn:hover {
  background: var(--primary-soft-hover);
}

.primary-btn:active {
  background: var(--primary-soft-active);
  transform: translateY(1px);
}

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

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.dot-success {
  background: var(--success);
}

.dot-warning {
  background: var(--warning);
}

.dot-neutral {
  background: var(--neutral);
}

.calendar-wrap,
.drawer {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-top: 14px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  color: var(--muted);
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-cell {
  min-height: 84px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  padding: 8px;
  cursor: pointer;
}

.day-cell.empty {
  opacity: 0.45;
  cursor: default;
}

.day-cell.selected {
  outline: 2px solid #111827;
}

.day-cell.success {
  background: #dbe8de;
  border-color: #b7ccbc;
}

.day-cell.warning {
  background: #fff;
  border-color: var(--border);
}

.day-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.day-kcal {
  margin-top: 8px;
  font-size: 0.78rem;
}

.actions {
  margin-top: 14px;
}

.drawer-head h2 {
  margin: 0;
}

.date-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.trend-advice {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.82rem;
}

.drawer-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.nutrition-progress {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.nutrition-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #faf7f2;
}

.nutrition-macros-inline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nutrition-row-macro {
  min-width: 0;
}

.nutrition-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.nutrition-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #ece6db;
  overflow: hidden;
}

.nutrition-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8abfa8 0%, #6aa88f 100%);
}

.entry-box {
  margin-top: 12px;
}

.meal-entry {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.meal-form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  resize: vertical;
}

.entry-actions {
  margin-top: 8px;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meal-text-image-slot {
  position: relative;
}

.meal-text-image-slot.has-thumb .meal-text-input {
  padding-bottom: 86px;
}

.meal-text-inbox-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.1);
  z-index: 2;
  pointer-events: none;
}

.meal-text-inbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-label {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  background: #fff;
}

.file-label input {
  display: none;
}

.hint {
  color: var(--muted);
  margin-top: 10px;
}

.report-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-output {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
}

.records {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.record-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.record-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.record-thumb {
  margin-top: 8px;
  max-width: 180px;
  border-radius: 12px;
  border: 1px solid #e4dccf;
  box-shadow: 0 6px 16px rgba(138, 122, 104, 0.12);
}

.danger-btn {
  min-height: 36px;
  border: 1px solid #ef4444;
  color: #ef4444;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
}

.record-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-actions .ghost-btn,
.record-actions .danger-btn {
  min-height: 36px;
  padding: 0 10px;
}

.record-actions .primary-btn {
  min-height: 36px;
  padding: 0 10px;
}

.inline-edit-label {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.inline-edit-meal,
.inline-edit-text {
  width: 100%;
}

dialog {
  border: none;
  border-radius: 12px;
  width: min(90vw, 360px);
}

.profile-form {
  display: grid;
  gap: 10px;
}

.profile-form label {
  display: grid;
  gap: 6px;
}

.profile-form .field-hint {
  font-weight: normal;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.profile-form input,
.profile-form select,
.meal-entry select,
.meal-entry input {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.celebration-fireworks {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3000;
  background: rgba(17, 24, 39, 0.08);
}

.celebration-text {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  color: #0f766e;
  border: 1px solid #cbd5e1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  font-weight: 600;
}

.firework-particle {
  --size: 8px;
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  background: hsl(calc(360 * var(--hue, 0.5)), 95%, 63%);
  animation: firework-burst 0.95s ease-out forwards;
}

.firework-particle:nth-child(odd) {
  --hue: 0.12;
}

.firework-particle:nth-child(even) {
  --hue: 0.62;
}

@keyframes firework-burst {
  0% {
    transform: translate(0, 0) scale(0.2);
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(1.2);
    opacity: 0;
  }
}
