* { box-sizing: border-box; }
:root {
  --bg: #111318;
  --card: #1b1e26;
  --text: #eef0f4;
  --muted: #8b92a3;
  --accent: #4ade80;
  --accent2: #60a5fa;
  --warn: #f87171;
  --border: #2a2e3a;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 480px; margin: 0 auto; padding: 16px; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar select {
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}

.day-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 12px; }
.day-nav span { font-size: 14px; color: var(--muted); min-width: 110px; text-align: center; }
.day-nav button { font-size: 16px; padding: 4px 12px; }
.day-nav button:disabled { opacity: 0.3; cursor: not-allowed; }

.progress { background: var(--card); border-radius: 16px; padding: 16px; display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.ring-wrap { flex-shrink: 0; }
.ring {
  width: 96px; height: 96px; border-radius: 50%; border: 6px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring span { font-size: 20px; font-weight: 700; }
.ring small { color: var(--muted); font-size: 10px; }
.ring.over { border-color: var(--warn); }

.macros { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.macro { display: grid; grid-template-columns: 60px 1fr 60px; align-items: center; gap: 6px; font-size: 12px; }
.macro label { color: var(--muted); }
.macro span { text-align: right; color: var(--muted); }
.bar { height: 6px; background: var(--border); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent2); width: 0%; }
.bar .fill.over { background: var(--warn); }

.meals { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.meal-card {
  background: var(--card); border-radius: 12px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.meal-card .meal-info { flex: 1; }
.meal-card .meal-items { color: var(--muted); font-size: 12px; margin-top: 2px; }
.meal-card .meal-kcal { font-weight: 700; margin-right: 10px; }
.meal-card button { background: none; border: none; color: var(--warn); font-size: 18px; cursor: pointer; }
.empty-hint { color: var(--muted); text-align: center; padding: 20px 0; font-size: 14px; }

.pending { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.pending[hidden] { display: none; }
.pending-card {
  background: var(--card); border: 1px solid var(--accent2); border-radius: 12px; padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.pending-card.analyzing { border-color: var(--border); color: var(--muted); cursor: default; }
.pending-card.error { border-color: var(--warn); }
.pending-card .pending-info { flex: 1; }
.pending-card .pending-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pending-card .spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent2); animation: spin 0.8s linear infinite; flex-shrink: 0; }
.pending-card .discard-pending { background: none; border: none; color: var(--warn); font-size: 18px; cursor: pointer; margin-left: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.capture { background: var(--card); border-radius: 16px; padding: 14px; position: sticky; bottom: 12px; }
.preview { position: relative; margin-bottom: 10px; }
.preview img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 12px; display: block; }
.preview .btn-ghost { position: absolute; top: 8px; right: 8px; }

textarea#textInput {
  width: 100%; background: #12141a; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; font-size: 14px; resize: none; min-height: 44px; margin-bottom: 10px;
}

.capture-row { display: flex; align-items: center; gap: 10px; }
.btn-icon {
  width: 48px; height: 48px; border-radius: 50%; background: #12141a; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; flex-shrink: 0;
}
.btn-icon.mic.recording { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.btn-primary {
  flex: 1; background: var(--accent); color: #06210f; border: none; border-radius: 12px;
  padding: 14px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
.btn-ghost { background: rgba(0,0,0,0.5); color: var(--text); border: none; border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; }

.rec-status { text-align: center; color: var(--warn); font-size: 12px; margin-top: 8px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.modal[hidden] { display: none; }
.modal-content {
  background: var(--card); width: 100%; max-width: 480px; border-radius: 16px 16px 0 0; padding: 18px;
  max-height: 85vh; overflow-y: auto;
}
.modal-content h2 { margin-top: 0; font-size: 18px; }
.item-row { display: grid; grid-template-columns: 1fr 60px 50px; gap: 8px; align-items: center; margin-bottom: 10px; }
.item-row input[type=text] { background: #12141a; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; }
.item-row input[type=number] { background: #12141a; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; width: 100%; }
.item-row .item-kcal { color: var(--muted); font-size: 12px; text-align: right; }
.modal-total { font-weight: 700; margin: 12px 0; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-ghost { flex: 1; padding: 12px; font-size: 14px; }

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #06210f; padding: 10px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600; z-index: 20;
}
