/* =========================================================
   Kalori — styles
   ========================================================= */

:root {
  --bg: #0A0B0E;
  --surface: #121419;
  --surface-2: #1A1D24;
  --surface-3: #242832;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #F5F6F8;
  --muted: #8A90A2;
  --dim: #5B6172;

  --mint: #8CF5A8;
  --teal: #3ED8C9;
  --warm: #FF9A5E;
  --red: #FF5E6C;

  --grad: linear-gradient(135deg, var(--mint), var(--teal));
  --grad-warm: linear-gradient(135deg, #FFB86B, #FF7A59);

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  /* Fallback springs (overridden by real spring curves below when supported) */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-soft: cubic-bezier(0.22, 1.2, 0.36, 1);

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017 18.8%, 1.077 20.9%, 1.121 23%, 1.149 25.1%, 1.159 27%, 1.154 29.4%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991 46.9%, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1);
    --spring-soft: linear(0, 0.006, 0.025 2.8%, 0.101 6.1%, 0.539 18.9%, 0.721 25.3%, 0.849 31.5%, 0.937 38.1%, 0.968 41.8%, 0.991 45.7%, 1.006 50.1%, 1.015 55%, 1.017 63.9%, 1.001 85.9%, 1);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.locked { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
button:focus-visible,
input:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
button:disabled { cursor: default; }

h1, h2, p { margin: 0; }

.i {
  width: 1em; height: 1em;
  fill: none; stroke: currentColor;
  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

/* ---------- Background aurora ---------- */
.aurora {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.aurora span {
  position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.22;
  will-change: transform;
}
.aurora span:nth-child(1) {
  width: 60vmax; height: 60vmax; left: -20vmax; top: -30vmax;
  background: radial-gradient(circle, var(--teal), transparent 65%);
  animation: drift1 22s var(--ease-in-out) infinite alternate;
}
.aurora span:nth-child(2) {
  width: 50vmax; height: 50vmax; right: -22vmax; top: 10vmax;
  background: radial-gradient(circle, var(--mint), transparent 65%);
  opacity: 0.12;
  animation: drift2 28s var(--ease-in-out) infinite alternate;
}
body.is-over .aurora span:nth-child(1) { background: radial-gradient(circle, #FF7A59, transparent 65%); }
@keyframes drift1 { to { transform: translate(12vmax, 8vmax) scale(1.1); } }
@keyframes drift2 { to { transform: translate(-10vmax, 12vmax) scale(0.9); } }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) 20px calc(130px + var(--safe-b));
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 8px;
}
.eyebrow {
  color: var(--muted); font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  text-transform: capitalize;
}
h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-top: 2px; }

.goal-pill {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 18px 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background-color 0.2s, transform 0.5s var(--spring);
}
.goal-pill:hover { background: var(--surface-3); }
.goal-pill-ico {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(140, 245, 168, 0.12); color: var(--mint); font-size: 20px;
}
.goal-pill-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.goal-pill-text small { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.goal-pill-text b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }

.layout { display: grid; gap: 22px; }
.col-left { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* ---------- Ring ---------- */
.hero { display: flex; flex-direction: column; align-items: center; padding-top: 6px; }

.ring-wrap {
  position: relative;
  width: min(76vw, 320px);
  aspect-ratio: 1;
  margin: 8px auto 0;
}
.ring-glow {
  position: absolute; inset: 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(62, 216, 201, 0.35), transparent 70%);
  filter: blur(30px);
  opacity: calc(0.25 + var(--prog, 0) * 0.75);
  transition: opacity 1s var(--ease-out), background 0.6s;
  animation: breathe 5s var(--ease-in-out) infinite;
}
body.is-over .ring-glow { background: radial-gradient(circle, rgba(255, 106, 90, 0.45), transparent 70%); }
@keyframes breathe { 50% { transform: scale(1.08); } }

.ring { position: relative; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring circle { fill: none; stroke-width: 18; }
.ring-track { stroke: var(--surface-2); }
.ring-arc {
  stroke-linecap: round;
  stroke-dasharray: 100 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 1.3s var(--spring-soft), opacity 0.5s var(--ease-out);
}
.ring-mint { stroke: url(#gMint); }
.ring-warm { stroke: url(#gWarm); opacity: 0; }
.ring-over { stroke: url(#gRed); filter: drop-shadow(0 0 6px rgba(255, 61, 127, 0.55)); opacity: 0; }
.ring-arc.is-zero { opacity: 0 !important; }
body.is-over .ring-warm { opacity: 1; }
body.is-over .ring-over { opacity: 1; }

.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.ring-label {
  font-size: 13px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
}
.ring-num {
  font-size: clamp(48px, 15vw, 68px);
  font-weight: 800; letter-spacing: -0.045em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 4px;
  transition: color 0.5s;
}
body.is-over .ring-num { color: #FFB49A; }
.ring-sub { font-size: 16px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }

.ring-pulse {
  position: absolute; inset: 4%; border-radius: 50%;
  border: 3px solid var(--teal);
  pointer-events: none;
}
body.is-over .ring-pulse { border-color: #FF7A59; }

.remaining {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 18px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 17px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.4s, background-color 0.4s, border-color 0.4s;
}
.remaining b { color: var(--text); font-weight: 800; }
.remaining-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--mint);
  box-shadow: 0 0 0 4px rgba(140, 245, 168, 0.15);
  transition: background-color 0.4s, box-shadow 0.4s;
}
body.is-over .remaining { background: rgba(255, 94, 108, 0.08); border-color: rgba(255, 94, 108, 0.2); }
body.is-over .remaining b { color: #FFB49A; }
body.is-over .remaining-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 94, 108, 0.18); }
.swap-in { animation: swapIn 0.45s var(--spring-soft); }
@keyframes swapIn { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }

/* ---------- Buttons ---------- */
.press { transition: transform 0.55s var(--spring), background-color 0.2s, box-shadow 0.3s, opacity 0.2s; }
.press:active:not(:disabled) { transform: scale(0.95); transition-duration: 0.12s, 0.2s, 0.3s, 0.2s; transition-timing-function: var(--ease-out); }

.ripple { position: relative; overflow: hidden; isolation: isolate; }
.ripple-ink {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: 0.18; transform: scale(0);
  z-index: -1;
}

.big-btn {
  height: 72px;
  border-radius: 22px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
}
.big-btn.block { width: 100%; }
.btn-ico { font-size: 22px; display: inline-flex; }

.primary {
  background: var(--grad);
  color: #04261C;
  box-shadow: 0 14px 34px -14px rgba(62, 216, 201, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.primary::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  transform: translateX(-120%);
}
@media (hover: hover) {
  .primary:hover::after { transform: translateX(120%); transition: transform 0.9s var(--ease-out); }
  .secondary:hover { background: var(--surface-3); }
}
.primary:disabled {
  background: var(--surface-2); color: var(--dim);
  box-shadow: none;
}
.secondary {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
}
.secondary .btn-ico { color: var(--mint); }
.ghost-danger {
  height: 60px;
  color: var(--red);
  background: rgba(255, 94, 108, 0.08);
  font-size: 17px;
  margin-top: 10px;
}

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 20px;
  flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }

.text-btn {
  height: 40px; padding: 0 16px; border-radius: 999px;
  font-size: 15px; font-weight: 700; color: var(--mint);
  background: rgba(140, 245, 168, 0.1);
  transition: background-color 0.25s, color 0.25s, transform 0.5s var(--spring);
}
.text-btn.on { background: var(--mint); color: #04261C; }

/* ---------- Actions ---------- */
.actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

@media (max-width: 899px) {
  .actions {
    position: fixed; z-index: 20;
    left: 0; right: 0; bottom: 0;
    padding: 18px 16px calc(14px + var(--safe-b));
    background: linear-gradient(to top, rgba(10, 11, 14, 0.96) 55%, rgba(10, 11, 14, 0));
  }
  .actions .big-btn { height: 68px; font-size: 18px; }
}

/* ---------- Log ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.log { padding: 20px 14px 10px; }
.log-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 12px; }
.log-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.count-badge {
  min-width: 32px; height: 32px; padding: 0 10px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.count-badge.bump { animation: badgeBump 0.5s var(--spring); }
@keyframes badgeBump { 40% { transform: scale(1.25); background: var(--mint); color: #04261C; } }

.log-list { list-style: none; margin: 0; padding: 0; }
.entry-wrap { overflow: hidden; }
.entry {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 8px 12px 10px;
  margin-bottom: 4px;
  border-radius: 18px;
  transition: background-color 0.2s;
}
@media (hover: hover) { .entry:hover { background: rgba(255, 255, 255, 0.025); } }
.entry.enter { animation: itemIn 0.7s var(--spring-soft) both; animation-delay: calc(var(--s, 0) * 45ms + 320ms); }
.entry-ico {
  width: 48px; height: 48px; border-radius: 15px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 800;
  background: hsl(var(--h, 160) 70% 60% / 0.13);
  color: hsl(var(--h, 160) 85% 72%);
}
.entry-ico.quick { background: rgba(140, 245, 168, 0.12); color: var(--mint); }
.entry-main { flex: 1; min-width: 0; }
.entry-name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-meta { font-size: 14px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.entry-meta .pct-tag {
  display: inline-block; padding: 1px 7px; margin-left: 4px; border-radius: 6px;
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 12px;
}
.entry-kcal { text-align: right; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.entry-kcal small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.entry-del {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
  color: var(--dim); font-size: 19px;
  transition: color 0.2s, background-color 0.2s, transform 0.5s var(--spring);
}
.entry-del:hover { color: var(--red); background: rgba(255, 94, 108, 0.1); }
.entry-del:active { transform: scale(0.88); transition-duration: 0.1s; }

.log-empty {
  display: none;
  flex-direction: column; align-items: center; text-align: center;
  padding: 30px 20px 40px;
}
.log-empty.show { display: flex; animation: fadeUp 0.6s var(--ease-out) both; }
.log-empty-title { font-size: 18px; font-weight: 800; margin-top: 18px; }
.log-empty-sub { color: var(--muted); margin-top: 6px; font-size: 15px; }
.plate { position: relative; width: 92px; height: 92px; animation: float 4s var(--ease-in-out) infinite; }
.plate-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px dashed var(--surface-3); animation: spin 24s linear infinite; }
.plate-inner { position: absolute; inset: 18px; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 8px var(--surface); }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .app { padding: 40px 32px 60px; }
  h1 { font-size: 40px; }
  .top { margin-bottom: 28px; }
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .col-left { position: sticky; top: 32px; }
  .ring-wrap { width: min(36vw, 340px); }
  .log { padding: 26px 18px 14px; min-height: 520px; }
}

/* ---------- Page reveal ---------- */
.reveal { animation: reveal 0.9s var(--spring-soft) both; animation-delay: calc(var(--i, 0) * 80ms + 60ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(18px) scale(0.98); filter: blur(6px); } }

/* =========================================================
   Sheet
   ========================================================= */
.sheet-root { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.sheet-root.open { pointer-events: auto; }

.backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 5, 8, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}
.sheet-root.open .backdrop { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 94dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line-2);
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -20px 60px -10px rgba(0, 0, 0, 0.6);
  padding-bottom: var(--safe-b);
  transform: translateY(105%);
  transition: transform 0.42s var(--ease-sheet);
  outline: none;
  will-change: transform;
}
.sheet-root.open .sheet { transform: translateY(0); transition: transform 0.7s var(--spring-soft); }

.grabber { display: flex; justify-content: center; padding: 10px 0 2px; cursor: grab; touch-action: none; }
.grabber span { width: 42px; height: 5px; border-radius: 99px; background: var(--surface-3); }

.sheet-body { position: relative; overflow: hidden; }

@media (min-width: 720px) {
  .sheet {
    left: 50%; top: 50%; right: auto; bottom: auto;
    width: 460px;
    max-height: 90dvh;
    border-radius: 30px;
    border: 1px solid var(--line-2);
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
    padding-bottom: 0;
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.94);
    transition: transform 0.28s var(--ease-out), opacity 0.2s var(--ease-out);
  }
  .sheet-root.open .sheet {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transition: transform 0.6s var(--spring-soft), opacity 0.25s var(--ease-out);
  }
  .grabber { display: none; }
}

/* ---------- Views ---------- */
.view {
  padding: 6px 22px 22px;
  max-height: calc(94dvh - 30px - var(--safe-b));
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (min-width: 720px) { .view { padding: 22px 26px 26px; max-height: 90dvh; } }
.view.abs { position: absolute; top: 0; left: 0; right: 0; }

.view-head {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; margin-bottom: 8px;
  touch-action: none;
}
.view-head h2 {
  flex: 1; min-width: 0;
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* staggered children inside a newly opened view */
.stagger > * { animation: itemIn 0.6s var(--spring-soft) both; animation-delay: calc(var(--s, 0) * 40ms + 60ms); }
@keyframes itemIn { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Number display + keypad ---------- */
.num-display {
  display: flex; align-items: baseline; justify-content: center; gap: 10px;
  height: 104px; padding-top: 6px;
  font-variant-numeric: tabular-nums;
}
.num-display .digits { display: inline-flex; font-size: 72px; font-weight: 800; letter-spacing: -0.045em; line-height: 1; }
.num-display .digits .d { display: inline-block; }
.num-display .digits .d.pop { animation: digitIn 0.5s var(--spring) both; }
.num-display[data-empty="true"] .digits { color: var(--surface-3); }
.num-display .unit { font-size: 22px; font-weight: 700; color: var(--muted); }
@keyframes digitIn { from { opacity: 0; transform: translateY(45%) scale(0.5); filter: blur(4px); } }

.shake { animation: shake 0.45s var(--ease-out); }
@keyframes shake {
  15% { transform: translateX(-9px); } 30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); } 60% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0 16px; }
.chip {
  height: 46px; padding: 0 16px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 16px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chip:hover { color: var(--text); }
.chip.on { background: rgba(140, 245, 168, 0.14); border-color: rgba(140, 245, 168, 0.4); color: var(--mint); }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.key {
  height: 66px; border-radius: 20px;
  background: var(--surface-2);
  font-size: 28px; font-weight: 700;
  display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
  transition: transform 0.5s var(--spring), background-color 0.25s;
}
.key:active, .key.flash { transform: scale(0.92); background: var(--surface-3); transition-duration: 0.08s; }
.key-fn { background: transparent; color: var(--muted); font-size: 18px; font-weight: 800; }
.key-fn .i { font-size: 28px; }
@media (hover: hover) { .key:hover { background: var(--surface-3); } }

/* ---------- Presets ---------- */
.search {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 16px; margin-bottom: 14px;
  border-radius: 16px; background: var(--surface-2);
  color: var(--muted); font-size: 18px;
}
.search input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 17px;
}

.preset-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-bottom: 4px; }
.preset-card {
  position: relative;
  min-height: 116px;
  padding: 14px;
  border-radius: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px;
  text-align: left;
  transition: transform 0.55s var(--spring), background-color 0.2s, border-color 0.3s;
}
.preset-card.enter { animation: cardIn 0.6s var(--spring-soft) both; animation-delay: calc(var(--s, 0) * 35ms + 80ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(0.94); } }
@media (hover: hover) { .preset-card:hover { background: var(--surface-3); } }
.preset-card:active { transform: scale(0.95); transition-duration: 0.12s; }
.preset-card .avatar {
  width: 40px; height: 40px; border-radius: 13px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 800;
  background: hsl(var(--h) 70% 60% / 0.14);
  color: hsl(var(--h) 85% 72%);
}
.pc-name {
  font-size: 16px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-word;
}
.pc-text { display: block; width: 100%; }
.pc-kcal { display: block; font-size: 14px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 3px; }
.pc-del {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red); color: #fff; font-size: 16px;
  transform: scale(0); opacity: 0;
  transition: transform 0.45s var(--spring), opacity 0.2s;
}
.pc-del .i { stroke-width: 3; }
.editing .pc-del { transform: scale(1); opacity: 1; }
.editing .preset-card:not(.new-card) { animation: jiggle 0.3s ease-in-out infinite alternate; }
.editing .preset-card:not(.new-card):nth-child(2n) { animation-delay: -0.15s; animation-duration: 0.28s; }
.editing .preset-card:not(.new-card):nth-child(3n) { animation-duration: 0.33s; }
@keyframes jiggle { from { transform: rotate(-1.1deg); } to { transform: rotate(1.1deg); } }

.new-card {
  align-items: center; justify-content: center; text-align: center;
  background: transparent;
  border: 2px dashed var(--surface-3);
  color: var(--muted); font-weight: 700;
}
.new-card .plus-ico {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(140, 245, 168, 0.12); color: var(--mint); font-size: 22px;
}
@media (hover: hover) { .new-card:hover { border-color: rgba(140, 245, 168, 0.4); color: var(--text); background: transparent; } }

.card-new { animation: cardHighlight 1.4s var(--ease-out) both !important; }
@keyframes cardHighlight {
  0% { opacity: 0; transform: scale(0.6); }
  35% { opacity: 1; transform: scale(1.04); box-shadow: 0 0 0 3px rgba(140, 245, 168, 0.6); }
  60% { transform: scale(1); }
  100% { box-shadow: 0 0 0 3px rgba(140, 245, 168, 0); }
}

.preset-empty { text-align: center; padding: 20px 6px 4px; }
.preset-empty .big-ico {
  width: 84px; height: 84px; border-radius: 28px; margin: 6px auto 18px;
  display: grid; place-items: center;
  background: rgba(140, 245, 168, 0.1); color: var(--mint); font-size: 40px;
  animation: float 4s var(--ease-in-out) infinite;
}
.preset-empty h3 { font-size: 20px; font-weight: 800; margin: 0; }
.preset-empty p { color: var(--muted); margin: 8px auto 22px; max-width: 300px; line-height: 1.5; }
.no-result { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 20px 0; }

/* ---------- Percent view ---------- */
.pct-base { text-align: center; color: var(--muted); font-size: 15px; margin-bottom: 10px; }
.pct-base b { color: var(--text); }
.pct-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; }
.round-btn {
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); font-size: 26px; color: var(--text);
}
.round-btn .i { stroke-width: 2.6; }
@media (hover: hover) { .round-btn:hover { background: var(--surface-3); } }
.pct-field {
  flex: 1; display: flex; align-items: baseline; justify-content: center;
  font-size: 72px; font-weight: 800; letter-spacing: -0.045em; line-height: 1;
  font-variant-numeric: tabular-nums; cursor: text;
}
.pct-field .sym { font-size: 0.55em; color: var(--mint); margin-right: 2px; }
.pct-field input {
  width: 3.2ch; min-width: 1.2ch;
  padding: 0; border: 0; outline: none; background: none;
  color: var(--text); font: inherit; letter-spacing: inherit; text-align: center;
  caret-color: var(--mint);
}
.pct-field.bump { animation: pctBump 0.45s var(--spring); }
@keyframes pctBump { 40% { transform: scale(1.07); } }

.slider {
  --p: 50%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 48px; margin: 4px 0 8px;
  background: transparent; cursor: pointer;
  touch-action: pan-y;
}
.slider:focus-visible { outline: none; }
.slider::-webkit-slider-runnable-track {
  height: 14px; border-radius: 99px;
  background: var(--grad) 0 0 / var(--p) 100% no-repeat, var(--surface-3);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 34px; height: 34px; margin-top: -10px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(140, 245, 168, 0.18);
  transition: transform 0.4s var(--spring), box-shadow 0.3s;
}
.slider:active::-webkit-slider-thumb { transform: scale(1.18); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 10px rgba(140, 245, 168, 0.2); }
.slider::-moz-range-track { height: 14px; border-radius: 99px; background: var(--surface-3); }
.slider::-moz-range-progress { height: 14px; border-radius: 99px; background: var(--grad); }
.slider::-moz-range-thumb {
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(140, 245, 168, 0.18);
}

.result {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; margin-bottom: 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(140, 245, 168, 0.1), rgba(62, 216, 201, 0.06));
  border: 1px solid rgba(140, 245, 168, 0.18);
}
.result-label { color: var(--muted); font-weight: 700; font-size: 16px; }
.result-val { font-variant-numeric: tabular-nums; }
.result-num { font-size: 36px; font-weight: 800; letter-spacing: -0.035em; }
.result-unit { font-size: 16px; color: var(--muted); font-weight: 700; margin-left: 6px; }

/* ---------- Form ---------- */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 700; color: var(--muted); margin: 0 0 8px 4px; }
.field input, .input-suffix {
  width: 100%; height: 64px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 2px solid transparent;
  color: var(--text);
  font: inherit; font-size: 20px; font-weight: 700;
  padding: 0 18px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.3s, background-color 0.25s;
}
.field input::placeholder { color: var(--dim); font-weight: 600; }
.field input:focus, .input-suffix:focus-within {
  border-color: rgba(140, 245, 168, 0.55);
  box-shadow: 0 0 0 5px rgba(140, 245, 168, 0.1);
  background: var(--surface-3);
}
.input-suffix { display: flex; align-items: center; padding: 0 18px 0 0; }
.input-suffix input { height: 100%; border: 0 !important; box-shadow: none !important; background: none !important; font-variant-numeric: tabular-nums; }
.input-suffix em { font-style: normal; color: var(--muted); font-weight: 700; }
.field.invalid input, .field.invalid .input-suffix { border-color: rgba(255, 94, 108, 0.7); }
.hint {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; margin: 4px 0 18px;
  border-radius: 16px; background: var(--surface-2);
  color: var(--muted); font-size: 14px; line-height: 1.5;
}
.hint b { color: var(--text); font-variant-numeric: tabular-nums; }
.hint .i { font-size: 20px; color: var(--mint); margin-top: 1px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 80;
  left: 50%; bottom: calc(108px + var(--safe-b));
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 20px; min-height: 56px;
  border-radius: 18px;
  background: #F5F6F8; color: #0A0B0E;
  font-weight: 700; font-size: 16px;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 160%);
  opacity: 0;
  transition: transform 0.35s var(--ease-out), opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; transition: transform 0.6s var(--spring), opacity 0.2s; pointer-events: auto; }
.toast button {
  height: 40px; padding: 0 16px; border-radius: 12px;
  background: #0A0B0E; color: var(--mint); font-weight: 800; font-size: 15px;
}
.toast:not(:has(button)) { padding-right: 20px; }
@media (min-width: 900px) { .toast { bottom: 32px; } }
@media (max-width: 719px) {
  body.locked .toast { bottom: auto; top: calc(14px + var(--safe-t)); transform: translate(-50%, -160%); }
  body.locked .toast.show { transform: translate(-50%, 0); }
}

/* ---------- Fly-to-ring pill ---------- */
.fly { position: fixed; z-index: 90; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.fly-pill {
  position: absolute; left: 0; top: 0;
  padding: 10px 18px; border-radius: 999px;
  background: var(--grad); color: #04261C;
  font-weight: 800; font-size: 20px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 30px -6px rgba(62, 216, 201, 0.8);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
