:root {
  --brown-400: #a67c52;
  --brown-500: #8b5e3c;
  --brown-600: #6f4a2e;
  --brown-700: #5a3d26;
  --brown-50: #faf6f1;
  --bg: #f5f3f0;
  --card: #ffffff;
  --text: #2c2419;
  --muted: #7a6f63;
  --border: #e8e2da;
  --shadow: 0 12px 32px rgba(90, 61, 38, 0.1);
  --radius: 20px;
  --radius-sm: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1100px 520px at 15% -8%, rgba(139, 94, 60, 0.16), transparent 55%),
    radial-gradient(800px 420px at 105% 5%, rgba(166, 124, 82, 0.12), transparent 48%), var(--bg);
  color: var(--text);
  min-height: 100%;
}

a {
  color: var(--brown-600);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

code {
  font-size: 0.9em;
  background: #f5efe8;
  padding: 2px 6px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

.container {
  width: min(520px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 100px;
}

.page-enter {
  animation: pageEnter 0.45s ease both;
}

.page-slide-in {
  animation: slideIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.brand-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 17px;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brown-400), var(--brown-600));
  box-shadow: 0 10px 22px rgba(111, 74, 46, 0.35);
  display: grid;
  place-items: center;
  color: #fff;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--brown-600);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  text-decoration: none;
}

.nav-link:hover,
.nav-link.is-active {
  background: #fff;
  border-color: var(--brown-400);
  text-decoration: none;
}

.disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #fff9f3, #fff);
  border: 1px solid #f0e6d8;
  color: #6b5a48;
  font-size: 12px;
  line-height: 1.55;
}

.disclaimer-icon {
  flex-shrink: 0;
  color: var(--brown-500);
  margin-top: 1px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(232, 226, 218, 0.9);
  overflow: hidden;
}

.card-pad {
  padding: 22px 18px 20px;
}

.h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.h2 {
  margin: 20px 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--brown-700);
}

.sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.dropzone {
  border: 2px dashed #dcc9b5;
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, var(--brown-50), #fff);
  transition: border-color 0.2s, transform 0.2s;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--brown-400);
  transform: translateY(-1px);
  outline: none;
}

.dropzone-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
}

.dropzone-title {
  font-weight: 800;
  font-size: 16px;
}

.dropzone-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.preview {
  margin: 12px 0 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-inline {
  max-height: 200px;
}

.preview img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* result.php: show full image, proportional scale, no crop */
.preview-result {
  max-height: none;
  overflow: visible;
  background: #faf8f5;
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-result img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(70vh, 520px);
  object-fit: contain;
  object-position: center;
  margin: 0 auto;
}

.toolbar {
  margin-top: 8px;
}

.toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, var(--brown-500), var(--brown-700));
  box-shadow: 0 12px 24px rgba(90, 61, 38, 0.28);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: #faf8f5;
  color: var(--brown-700);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.note {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.content-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-info {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 13px;
  margin-bottom: 14px;
}

.trait-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trait-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #faf8f5;
  border: 1px solid var(--border);
}

.trait-card.is-editing {
  background: #fff;
  border-color: var(--brown-400);
  box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12);
}

.trait-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.trait-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 14px;
  color: var(--brown-700);
}

.trait-view {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.trait-input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  min-height: 96px;
  color: var(--text);
  background: #fff;
}

.trait-input:focus {
  outline: none;
  border-color: var(--brown-400);
  box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.15);
}

.detail-block {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: #faf8f5;
  border: 1px solid var(--border);
}

.detail-highlight {
  background: linear-gradient(135deg, #fff9f3, #faf8f5);
  border-color: #e8d9c8;
}

.detail-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
  color: var(--brown-700);
}

.detail-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

.footer-link {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
}

.footer-link a {
  color: var(--brown-600);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.site-footer {
  margin-top: 28px;
  padding: 20px 0 8px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 18px;
  margin-bottom: 12px;
}

.footer-nav a {
  font-weight: 700;
  color: var(--brown-600);
  text-decoration: none;
}

.footer-copy {
  margin: 0 0 8px;
}

.footer-note {
  margin: 0;
  line-height: 1.5;
  max-width: 42em;
  margin-left: auto;
  margin-right: auto;
}

.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(480px, calc(100% - 24px));
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideUp 0.35s ease;
}

.cookie-banner p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.prose p,
.prose ul,
.prose ol {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}

.prose ul {
  padding-left: 1.2em;
}

.legal-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.steps-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brown-400), var(--brown-600));
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(44, 36, 25, 0.45);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

.loading-card {
  background: #fff;
  border-radius: 24px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  min-width: 200px;
}

.loading-text {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--brown-700);
}

.progress-ring {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-track {
  fill: none;
  stroke: #f0e6d8;
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--brown-500);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 82;
  animation: ringSpin 1.2s linear infinite;
}

.progress-ring-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--brown-600);
}

.progress-ring-icon .icon {
  width: 28px;
  height: 28px;
  animation: iconPulse 1s ease-in-out infinite;
}

@keyframes ringSpin {
  to {
    stroke-dashoffset: -245;
  }
}

@keyframes iconPulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.95);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (min-width: 520px) {
  .card-pad {
    padding: 26px 24px 24px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.form-stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.field input,
.field select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  background: #fff;
  width: 100%;
}

.recharge-banner {
  border: 2px solid rgba(139, 94, 60, 0.35);
  background: linear-gradient(180deg, var(--brown-50), #fff);
}

.recharge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.recharge-single {
  margin-top: 14px;
}

.recharge-single .recharge-btn {
  width: 100%;
  max-width: 280px;
}

@media (min-width: 520px) {
  .recharge-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.recharge-btn {
  flex-direction: column;
  width: 100%;
  min-height: 72px;
}

.recharge-usd {
  font-size: 20px;
  font-weight: 900;
}

.recharge-meta {
  font-size: 12px;
  opacity: 0.9;
}

.status-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #faf8f5;
  margin: 12px 0 16px;
}

.food-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0 20px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: #faf8f5;
  font-weight: 800;
}

.admin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 24px;
  font-weight: 900;
  margin-top: 6px;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
  font-weight: 700;
}

.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.day-tab {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  color: var(--brown-700);
  text-decoration: none;
}

.day-tab.is-active,
.day-tab:hover {
  background: var(--brown-500);
  color: #fff;
  border-color: var(--brown-500);
  text-decoration: none;
}

.day-tab.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f0ebe5;
  color: var(--muted);
  border-color: var(--border);
  pointer-events: none;
}

.forgot-row {
  margin: -4px 0 4px;
  text-align: right;
}

.forgot-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--brown-600);
  text-decoration: none;
}

.forgot-link:hover {
  text-decoration: underline;
}

.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.account-head .h1 {
  margin: 0;
}

.download-row {
  margin-top: 18px;
  margin-bottom: 8px;
}

.download-row .btn {
  width: 100%;
}
