:root {
  color-scheme: light;
  --background: #f1f2f3;
  --text: #242729;
  --muted: #7d8289;
  --line: #e1e4e7;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .5; }
button:focus-visible, input:focus-visible { outline: 2px solid #777f86; outline-offset: 4px; }
button { touch-action: manipulation; }

.tracker {
  width: 100%;
  max-width: 360px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: 14px 20px max(30px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.search-area { position: relative; z-index: 2; }
.search-field {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 10px 0 12px;
  transition: border-color 150ms;
}
.search-field:focus-within { border-color: #aeb4ba; }
.search-icon { flex-shrink: 0; }
.search-field input { width: 100%; min-width: 0; height: 100%; padding: 0 10px; border: 0; outline: 0; background: transparent; font-size: 14px; }
.search-field input:focus-visible { outline: 0; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.icon-button { border: 0; background: transparent; padding: 0; width: 28px; height: 32px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 5px; }
.icon-button:hover { background: #e7e9eb; }
.search-panel { position: absolute; top: calc(100% + 7px); left: 0; right: 0; max-height: min(440px, 65svh); overflow-y: auto; background: #f8f9fa; border: 1px solid var(--line); border-radius: 11px; padding: 7px; box-shadow: 0 8px 24px #24272908; }
.search-caption { display: flex; justify-content: space-between; padding: 7px 8px 10px; font-size: 10px; color: var(--muted); }
.search-result { width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left; gap: 14px; padding: 11px 8px; background: transparent; border: 0; border-radius: 5px; line-height: 1.4; }
.search-result:hover, .search-result[aria-selected="true"] { background: #e9ecee; }
.result-calories { color: var(--muted); white-space: nowrap; font-size: 11px; }
.custom-food { display: flex; align-items: center; gap: 9px; width: 100%; padding: 12px 8px 8px; margin-top: 5px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; font-size: 11px; }
.custom-food:hover { color: #606970; }
.custom-food > span { font-size: 17px; font-weight: 400; }
.search-message { padding: 4px 8px 12px; font-size: 12px; color: var(--muted); line-height: 1.6; }

.entries { list-style: none; padding: 0 12px; margin: 6px 0 40px; }
.entry { position: relative; display: flex; align-items: flex-start; padding: 5px 0; min-height: 46px; gap: 10px; }
.entry-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text); margin-top: 4px; flex: 0 0 4px; }
.entry-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; text-align: left; line-height: 1.35; border-radius: 2px; }
.entry-name { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.entry-calories { font-size: 11px; color: var(--muted); }
.entry-main:hover .entry-name { color: #626a70; }
.remove-entry { width: 26px; height: 28px; margin-top: -5px; margin-right: -7px; color: var(--muted); opacity: 0; transition: opacity 120ms; }
.entry:hover .remove-entry, .entry:focus-within .remove-entry { opacity: 1; }
.empty-state { margin: 14px 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.summary { margin: auto 12px 0; padding-top: 8px; border-top: 1px solid var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: center; min-height: 29px; }
.total-label { font-size: 11px; font-weight: 600; }
.total-value { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.total-value strong { font-size: 13px; line-height: 1.2; font-weight: 600; }
.total-value > span { color: var(--muted); font-size: 9px; }
.text-button { display: block; padding: 6px 0 0; border: 0; background: transparent; font-size: 10px; text-decoration: underline; text-underline-offset: 2px; }
.text-button:hover { color: var(--muted); }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0 0; }
.macros dt { font-size: 10px; color: var(--muted); }
.macros dd { margin: 6px 0 0; font-size: 13px; }
.macro-unit { margin-left: 3px; font-size: 10px; color: var(--muted); }

dialog { width: calc(100% - 40px); max-width: 320px; padding: 22px; background: #f8f9fa; color: var(--text); border: 1px solid var(--line); border-radius: 13px; max-height: calc(100svh - 40px); overflow-y: auto; }
dialog::backdrop { background: #24272930; backdrop-filter: blur(2px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 24px; }
.dialog-heading h1 { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.dialog-heading .icon-button { margin-right: -7px; }
.form-label { display: block; margin-bottom: 8px; font-size: 11px; }
.form-label > span, .nutrition-fields label > span { color: var(--muted); }
.form-input { display: block; width: 100%; height: 39px; padding: 9px 10px; border: 1px solid #d9dde0; border-radius: 6px; background: transparent; }
.form-input:focus { border-color: #8e979e; outline: 0; }
.form-note { margin: 22px 0 12px; font-size: 11px; color: var(--muted); }
.nutrition-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.nutrition-fields label { font-size: 11px; }
.nutrition-fields input { margin-top: 8px; }
.save-button { display: block; width: 100%; height: 38px; margin-top: 22px; border: 0; border-radius: 6px; background: var(--text); color: #fff; font-size: 12px; }
.save-button:hover { background: #41474b; }
.form-error { margin: 12px 0 0; color: #9b3f38; font-size: 11px; line-height: 1.6; }
.notice { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 40px); padding: 11px 15px; border-radius: 7px; background: var(--text); color: #fff; font-size: 11px; line-height: 1.5; z-index: 5; }
.noscript { text-align: center; font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (hover: none) { .remove-entry { opacity: .65; } }
@media (min-width: 600px) { .tracker { padding-top: 24px; padding-bottom: 34px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
