:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #f5f5e7;
  background: #101610;
  --accent: #d9f584;
  --muted: #b9c3b2;
  --hairline: #d6e7c825;
}

*, *::before, *::after { box-sizing: border-box; }
body { min-width: 280px; min-height: 100vh; margin: 0; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, #0b110c78, #10161028 75%),
    linear-gradient(0deg, #101610 0%, #10161012 37%, #10161000 78%),
    url("assets/backdrop.webp") center center / cover no-repeat,
    radial-gradient(ellipse at 75% 20%, #4d5330, #131b14 60%);
}

button, input { font: inherit; }
button, summary { cursor: pointer; color: inherit; }
button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
svg { display: block; width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.icon-library, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.shell { width: min(100% - 64px, 1056px); margin-inline: auto; padding-block: clamp(27px, 6vh, 64px) 95px; }
.masthead { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.brand-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  color: #263019;
  background: var(--accent);
  border-radius: 15px;
  box-shadow: 0 7px 25px #13190563, inset 0 1px #f0ffc2;
}
.brand-icon svg { width: 25px; height: 25px; fill: currentColor; stroke-width: 0; }
h1 { font-size: clamp(1.8rem, 4.4vw, 2.8rem); line-height: 1; margin: 0; letter-spacing: -.07em; font-weight: 730; text-shadow: 0 2px 12px #10181080; }
h1 span { color: #ecf1dc; font-weight: 475; }
.local-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 7px 10px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: #1b241cb8;
  color: #dae4ce;
  font-size: .73rem;
  white-space: nowrap;
}
.local-label span { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.47fr) minmax(0, 1fr);
  grid-template-areas: "overview log" "history history";
  gap: 15px;
  align-items: start;
}
.panel {
  padding: clamp(17px, 2.5vw, 27px);
  border: 1px solid var(--hairline);
  border-radius: 23px;
  background: linear-gradient(135deg, #242c2197, #101811c9 80%), #10171042;
  box-shadow: 0 14px 45px #080d0a52, inset 0 1px #e0ecc512;
  backdrop-filter: blur(18px);
}
.overview {
  grid-area: overview;
  min-width: 0;
  background: radial-gradient(ellipse at 12% 4%, #63783c29, transparent 65%), linear-gradient(145deg, #242e20ba, #101811e0);
}
h2 { margin: 0; font-size: 1.18rem; line-height: 1.2; font-weight: 640; letter-spacing: -.025em; }
.kicker { margin: 1px 0 22px; color: #e1e9c7; font-size: .7rem; font-weight: 680; letter-spacing: .14em; text-transform: uppercase; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(11px, 2.3vw, 25px); margin: 0 0 22px; }
.metric + .metric { border-left: 1px solid var(--hairline); padding-left: clamp(11px, 2.3vw, 25px); }
.metric dt { color: #c8d3bf; font-size: .86rem; margin-bottom: 5px; }
.metric dd {
  display: flex;
  align-items: baseline;
  gap: .13em;
  margin: 0;
  color: var(--accent);
  font-size: clamp(2rem, 5.5vw, 4.05rem);
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  line-height: .98;
  letter-spacing: -.07em;
}
.metric dd > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.metric + .metric dd { color: #f1f4e4; }
.unit { color: #d0ddbc; font-size: clamp(.75rem, 1.9vw, 1.25rem); font-weight: 500; letter-spacing: -.03em; }
.trend { margin: 0; padding: 15px 12px 5px; border: 1px solid #d6e7c821; border-radius: 15px; background: #0c140f77; }
.trend figcaption { display: flex; gap: 8px; align-items: center; padding-inline: 3px; font-size: .79rem; color: #d3ddc4; }
.chart-key { width: 13px; height: 2px; border-radius: 2px; background: var(--accent); }
#chart { display: block; width: 100%; height: clamp(125px, 17vw, 163px); margin-top: 7px; }
.estimate-note { margin: 12px 0 0; color: var(--muted); font-size: .75rem; }

.log { grid-area: log; }
.log-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.log-heading span { color: var(--muted); font-size: .73rem; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset {
  min-width: 0;
  min-height: 79px;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: clamp(6px, 1vw, 10px);
  padding: 10px 7px 10px 10px;
  text-align: left;
  border: 1px solid #e1ecc92e;
  border-radius: 14px;
  background: linear-gradient(150deg, #d6eaad19, #29302540);
}
.preset:hover, .preset:focus-visible { background-color: #51653772; border-color: #cee7847a; }
.preset:active { background-color: #62783c; }
.drink-icon { color: #e6cbab; }
.preset:nth-child(n+3) .drink-icon { color: #cbe19c; }
.drink-icon svg { width: 21px; height: 21px; }
.preset-plus { display: none; }
.preset strong, .preset small { display: block; }
.preset strong { margin-bottom: 4px; font-size: .88rem; line-height: 1.08; font-weight: 650; }
.preset small { color: #d8e8ba; font-size: .75rem; }
.custom-entry { margin-top: 13px; }
.custom-entry summary {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  gap: 7px;
  border: 1px dashed #c9dfa552;
  border-radius: 12px;
  font-size: .83rem;
  color: #e4eccf;
}
.custom-entry summary::-webkit-details-marker { display: none; }
.custom-entry summary::marker { content: ""; }
.custom-entry summary:hover { background: #d8ed9d19; }
.custom-entry[open] summary svg { transform: rotate(45deg); }
#custom-form { padding-top: 14px; }
.custom-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.custom-fields label { display: block; color: var(--muted); font-size: .77rem; }
.custom-fields input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #121913;
  color: #f5f5e7;
  font-size: 1rem;
}
.custom-fields input::placeholder { color: #9fa99a; }
.submit {
  width: 100%;
  min-height: 40px;
  margin-top: 9px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #202816;
  font-size: .85rem;
  font-weight: 680;
}
.submit:hover { background: #e8ffaf; }

.history { grid-area: history; }
.history-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 12px; }
.history-controls { display: flex; align-items: center; gap: 8px; margin-left: auto; }
#history-count { color: var(--muted); font-size: .8rem; }
#history-empty { display: flex; align-items: center; gap: 8px; margin: 15px 0 0; color: var(--muted); font-size: .86rem; }
#history-empty svg { color: #d3dfa9; }
#history-list { list-style: none; padding: 0; margin: 0; }
.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--hairline);
}
.history-entry-detail { min-width: 0; }
.history-entry-detail strong { display: block; overflow-wrap: anywhere; font-weight: 650; }
.history-entry-detail small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; }
.history-entry-actions { display: flex; align-items: center; gap: clamp(7px, 1.8vw, 19px); flex-shrink: 0; }
.history-dose { font-size: .86rem; color: #e1f7a9; white-space: nowrap; }
.history-remove, #undo {
  min-height: 35px;
  padding: 6px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #d8ed9d16;
  font-size: .78rem;
  color: #e9eddf;
}
.history-remove:hover, #undo:hover { background: #d8ed9d2e; }
.feedback {
  position: fixed;
  z-index: 1;
  right: max(15px, env(safe-area-inset-right));
  bottom: max(15px, env(safe-area-inset-bottom));
  left: max(15px, env(safe-area-inset-left));
  width: max-content;
  max-width: calc(100% - 30px);
  margin-left: auto;
  display: flex;
  align-items: center;
  pointer-events: none;
  padding: 9px 13px;
  border: 1px solid #d6e7c84a;
  border-radius: 13px;
  background: #242d1f;
  box-shadow: 0 10px 30px #0a0e08bb;
}
.feedback:has(#status:empty) { opacity: 0; }
#status { margin: 0; font-size: .86rem; overflow-wrap: anywhere; }
#undo { color: var(--accent); }

@media (min-width: 960px) {
  .preset { min-height: 89px; padding-inline: 12px 22px; }
  .preset-plus { display: block; position: absolute; top: 7px; right: 7px; width: 12px; height: 12px; color: #d3e3bb; }
}
@media (max-width: 720px) {
  .shell { width: min(100% - 28px, 530px); padding-top: max(19px, env(safe-area-inset-top)); }
  .masthead { margin-bottom: 16px; }
  .brand-icon { width: 37px; height: 37px; border-radius: 12px; }
  .brand-icon svg { width: 21px; height: 21px; }
  .dashboard { grid-template-columns: minmax(0, 1fr); grid-template-areas: "log" "overview" "history"; gap: 10px; }
  .panel { border-radius: 18px; }
  .metric dd { font-size: clamp(2.3rem, 10.7vw, 3.7rem); }
  .kicker { margin-bottom: 16px; }
  .metrics { margin-bottom: 16px; }
  .preset { min-height: 55px; padding-inline: 10px; }
  .custom-entry summary, .submit, .history-remove, #undo { min-height: 44px; }
  body::before { background-position: center, center, 58% center, center; }
}
@media (max-width: 365px) {
  .masthead { gap: 8px; }
  .local-label { padding: 5px 7px; font-size: .67rem; }
  .metric dt { min-height: 2.4em; font-size: .76rem; }
  .metric dd { font-size: 1.95rem; }
  .preset { gap: 5px; padding-inline: 7px; }
  .drink-icon svg { width: 17px; height: 17px; }
  .preset small { font-size: .67rem; }
}
