@font-face { font-family: "PuffTab Inter"; src: url("../fonts/Inter-Black.woff2") format("woff2"); font-weight: 900; font-display: swap; }
:root {
  --bg: var(--pt-background);
  --surface: var(--pt-surface);
  --ink: var(--pt-ink);
  --muted: var(--pt-muted);
  --accent: var(--pt-accent);
  --accent-ink: var(--pt-on-accent);
  --border: var(--pt-border);
  --danger: var(--pt-danger);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.app { display: flex; flex-direction: column; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.75rem;
  padding: max(0.6rem, env(safe-area-inset-top)) 1rem 0.6rem;
  background: var(--bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
.toast { font-size: 0.8rem; color: var(--muted); }

main { flex: 1; padding: 0.75rem 1rem calc(7.75rem + var(--safe-bottom)); } /* clears tabbar + fab */

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex;
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar button {
  flex: 1; padding: 0.8rem 0; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 0.85rem; font-weight: 600;
}
.tabbar button.active { color: var(--accent); }

/* journal */
.list section { margin-bottom: 1.25rem; }
.day {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0.5rem 0 0.25rem;
}
.day h3 { font-size: 0.9rem; margin: 0; }
.daytotal { font-size: 0.78rem; color: var(--muted); }
.row {
  display: flex; justify-content: space-between; gap: 0.75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.7rem 0.9rem; margin: 0.4rem 0;
  box-shadow: var(--shadow);
}
.row-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; white-space: nowrap; }
.grams { font-weight: 650; font-variant-numeric: tabular-nums; }
.notes { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--muted); }
.prewrap { white-space: pre-wrap; }
.muted { color: var(--muted); font-size: 0.85rem; }
.small { font-size: 0.78rem; }

/* supplies */
.grid {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  display: flex; flex-direction: column; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; padding: 0;
  font: inherit; color: inherit; box-shadow: var(--shadow);
}
.card.finished { border-style: dashed; }
.card-photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.card-body { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.6rem 0.7rem 0.7rem; }

/* supply detail */
.detail-photo { width: 100%; max-height: 40dvh; object-fit: cover; border-radius: 12px; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; margin: 0.75rem 0; }
dl div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.7rem; }
dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
dd { margin: 0; font-weight: 600; }
.terps { list-style: none; padding: 0; margin: 0.25rem 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.terps li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 0.2rem 0.7rem; font-size: 0.85rem;
}

/* vault tab */
.stack { display: flex; flex-direction: column; gap: 0.9rem; max-width: 560px; margin: 0 auto; }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.panel h3 { margin: 0 0 0.35rem; }
.panel p { margin: 0.35rem 0; }
.button {
  display: inline-block; margin-top: 0.5rem; margin-right: 0.5rem;
  padding: 0.6rem 1.1rem; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.button[disabled] { opacity: 0.5; }
.linklike { border: 0; background: none; color: var(--accent); font: inherit; padding: 0; text-decoration: underline; }
.error { color: var(--danger); font-size: 0.9rem; }
.ok { color: var(--accent); font-size: 0.9rem; }
code { background: color-mix(in srgb, var(--border) 45%, transparent); padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.9em; }

.empty { text-align: center; padding: 4rem 1rem; }

/* log entry: fab and form */
.fab {
  position: fixed; right: max(1rem, env(safe-area-inset-right));
  bottom: calc(3.9rem + var(--safe-bottom)); z-index: 6;
  width: 3.25rem; height: 3.25rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); border: 0;
  font-size: 1.9rem; line-height: 1; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.fab:active { transform: scale(0.94); }
.row { cursor: pointer; }
.field {
  display: flex; flex-direction: column; gap: 0.3rem; margin: 0.65rem 0;
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
}
.field input, .field select, .field textarea {
  font: inherit; font-weight: 400; font-size: 1rem; color: var(--ink);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.7rem; width: 100%;
}
.field.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; margin-top: 2.1rem; }
.field.checkbox input { width: 1.15rem; height: 1.15rem; }
.field-row { display: flex; gap: 0.75rem; }
.field-row .field { flex: 1; }
.stepper { display: flex; align-items: center; gap: 0.5rem; }
.stepper input { text-align: center; }
.stepper .unit { color: var(--muted); font-weight: 400; }
.stepper button {
  width: 2.4rem; height: 2.4rem; flex: none; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 1.2rem;
}
.hint { font-size: 0.78rem; color: var(--muted); margin: 0.2rem 0 0; font-weight: 400; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1rem; }

button, .button { touch-action: manipulation; }
fieldset.form-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.row-photo { width: 3rem; height: 3rem; border-radius: 8px; object-fit: cover; flex: none; align-self: center; }
.photobox { display: flex; flex-direction: column; gap: 0.5rem; }
.photo-preview { width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px; }
.showolder { display: block; width: 100%; text-align: center; margin: 0.75rem 0 0.5rem; }

/* Everyday screens and full-page editors. */
.wide { max-width: 840px; }
main > .list { max-width: 840px; margin: 0 auto; }
h2 { font-size: 1.8rem; letter-spacing: -0.04em; margin: 0; }
.page-heading, .section-heading { display: flex; gap: 1rem; justify-content: space-between; align-items: center; }
.page-heading { margin: 0.5rem 0 0.8rem; }
.page-heading .button { flex-shrink: 0; margin: 0; }
.page-heading p { margin: 0.25rem 0 0; }
.section-heading h3 { margin: 0.5rem 0; font-size: 1.05rem; }
.eyebrow { color: var(--muted); font-size: 0.8rem; }
.welcome { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.stat { display: flex; flex-direction: column; gap: 0.3rem; border: 1px solid var(--border); border-radius: 16px; padding: 1.1rem; background: var(--surface); }
.stat strong { font-size: clamp(1.8rem, 5vw, 2.7rem); letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.method-row { font: inherit; color: inherit; text-align: left; width: 100%; align-items: center; }
.filters { display: flex; gap: 0.5rem; }
.filters button { padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); background: var(--surface); font: inherit; font-size: 0.85rem; }
.filters button.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.low-stock { color: var(--danger); font-size: 0.85rem; }
.search { margin: 0; }
.card-body { gap: 0.3rem; padding: 1rem; }
.card strong, .row strong { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }
.field.checkbox { margin-top: 1rem; }
.field-row > * { min-width: 0; }
.field input[type=file] { font-size: 0.85rem; }
.form-actions { flex-wrap: wrap; }
.form-actions .button { margin-right: 0; }
@media (min-width: 650px) {
  .tabbar { justify-content: center; }
  .tabbar button { flex: 0 1 168px; }
  main { padding-top: 1.5rem; }
}
@media (max-width: 360px) {
  .page-heading { align-items: flex-start; flex-direction: column; }
  .day { flex-wrap: wrap; }
  .stat { padding: 0.75rem; }
}
@media (prefers-reduced-motion: reduce) { .fab:active { transform: none; } }

.editor-page { max-width: 720px; margin: 0 auto; padding-bottom: 1.5rem; }
.editor-heading { margin-bottom: 1.5rem; }
.editor-heading h2 { margin-top: 1rem; }
.editor-heading h2:focus { outline: none; }
.back-button { display: inline-flex; align-items: center; min-height: 44px; padding: 0.4rem 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; }
.confirmation { margin-top: 1rem; padding: 1rem; border: 1px solid var(--danger); border-radius: 12px; background: var(--surface); }
.confirmation h3 { margin: 0 0 0.4rem; }
.confirmation p { color: var(--muted); font-size: 0.9rem; }

/* Native-inspired grouped navigation, adapted to a top web navigation bar. */
.app-header { position: relative; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--border); }
.brandbar { display: flex; align-items: center; gap: 1.5rem; max-width: 1100px; margin: auto; padding: 0 1rem; }
.brandbar h1 { flex: none; font-size: 1.3rem; margin: 0; letter-spacing: -0.04em; }
.header-status { max-width: 1100px; margin: auto; padding: 0.4rem 1rem; }
.tabbar { position: relative; inset: auto; display: flex; flex: 1; min-width: 0; flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; border: 0; padding: 0; background: transparent; backdrop-filter: none; }
.tabbar > button { flex: 0 0 auto; min-height: 52px; padding: 0.8rem 1.1rem; white-space: nowrap; border-bottom: 3px solid transparent; }
.tabbar > button.active { border-bottom: 3px solid var(--accent); }
.mega-menu { max-width: 1100px; margin: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: 1rem; border-top: 1px solid var(--border); }
.mega-menu h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0.25rem 0 0.75rem; }
.more-link { display: flex; gap: 0.75rem; width: 100%; align-items: center; border: 0; background: transparent; text-align: left; padding: 0.65rem 0; font: inherit; color: var(--ink); }
.more-link small { display: block; color: var(--muted); margin-top: 0.2rem; }
.nav-symbol { display: grid; place-items: center; flex: 0 0 40px; height: 40px; border-radius: 12px; color: var(--accent); background: var(--pt-raised); font-size: 1.5rem; }
main { padding-bottom: calc(5rem + var(--safe-bottom)); }
.fab { bottom: calc(1.25rem + var(--safe-bottom)); }
.section-tabs { display: flex; border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.section-tabs button { flex: 1; border: 0; border-radius: 7px; padding: 0.6rem; background: transparent; color: var(--muted); font: inherit; }
.section-tabs .selected { color: var(--accent); background: var(--surface); box-shadow: var(--shadow); }
.group-list { margin: 1.25rem 0; }
.group-list h3, .settings-sections h3 { font-size: 0.9rem; color: var(--muted); }
.settings-sections > section { margin-bottom: 1rem; }
.row { width: 100%; text-align: left; font: inherit; color: var(--ink); }
dd { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .brandbar { gap: 0.5rem; padding: 0 0.5rem; }
  .brandbar h1 { font-size: 1.1rem; }
  .tabbar { justify-content: flex-start; }
  .tabbar > button { flex: 0 0 auto; font-size: 0.75rem; padding: 0.8rem 0.4rem; }
  .mega-menu { grid-template-columns: 1fr; gap: 1rem; }
}

.supply-related-link { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; text-align: left; }
.related-photo { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; background: var(--surface); flex: none; }

/* Detail screens follow the native image → summary → related records pattern. */
.detail-content { display: flex; flex-direction: column; gap: 1rem; }
.detail-section { margin: 1rem 0; }
.detail-section > h3 { margin-bottom: 0.75rem; }
.detail-stats { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0.75rem; }
.detail-stats .stat { border-radius: 20px; padding: 1rem; min-width: 0; }
.detail-stats strong { font-size: 1.25rem; overflow-wrap: anywhere; }
.identity-photo { width: 100%; max-height: 320px; object-fit: contain; border-radius: 24px; background: var(--surface); }
.relationship-photo { width: 64px; height: 64px; object-fit: cover; border-radius: 16px; flex: none; }
.related-record .relationship-photo { object-fit: contain; }
.related-supplies .row, .related-record { border-radius: 18px; padding: 0.9rem; }
.related-supplies .row-side { max-width: 35%; overflow-wrap: anywhere; }
.linked-identity { display: flex; align-items: center; gap: 0.5rem; color: var(--accent); border: 0; background: none; padding: 0; text-align: left; font: inherit; }
.membership-card { border: 1px solid var(--border); border-radius: 24px; padding: 2rem; background: var(--surface); }
.membership-card strong { font-size: 2rem; overflow-wrap: anywhere; }
progress { width: 100%; height: 12px; accent-color: var(--accent); }

.detail-content > .eyebrow { margin: 0; text-transform: uppercase; }
.detail-content > .form-actions { margin-top: 0; }
.detail-content .detail-section { margin: 0.5rem 0; }
.detail-section > h3 { margin-top: 0; }

.photo-open { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.full-photo { display: block; width: 100%; height: auto; object-fit: contain; }

/* Dashboard: native section order and rounded inventory/metric cards. */
.dashboard { max-width: 840px; gap: 1.5rem; }
.dashboard-heading h2 { color: var(--accent); font-size: 2rem; margin: 0; }
.dashboard-heading p { margin: 0.25rem 0 0; font-size: 0.8rem; }
.dashboard-card, .dashboard-chart-card { padding: 1rem; border: 1px solid var(--border); border-radius: 24px; background: var(--surface); }
.dashboard-card h3 { margin-top: 0; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 0.75rem; }
.dashboard-metrics .stat { min-width: 0; padding: 1rem; border-radius: 24px; color: var(--ink); text-align: left; font: inherit; }
.dashboard-metrics .stat strong { font-size: 1.3rem; overflow-wrap: anywhere; }
.dashboard-supply { border-radius: 24px; padding: 0.9rem; }
.dashboard-supply progress { margin: 0.4rem 0; }
.inventory-labels { display: flex; justify-content: space-between; gap: 0.5rem; color: var(--muted); font-size: 0.75rem; }
.empty-current { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; color: var(--ink); font: inherit; text-align: center; }
.onboarding-step { display: flex; width: 100%; gap: 0.75rem; align-items: center; border: 0; background: none; padding: 0.8rem 0; color: var(--ink); font: inherit; text-align: left; }
.onboarding-step > span:nth-child(2) { flex: 1; }
.onboarding-step small { display: block; color: var(--muted); margin-top: 0.25rem; }
.step-number { display: grid; place-items: center; background: var(--pt-raised); color: var(--accent); width: 36px; height: 36px; border-radius: 50%; flex: none; }
.dashboard-controls { flex-wrap: wrap; gap: 0.75rem; }
.dashboard-controls select { width: auto; padding: 0.4rem; }
.dashboard-controls > div { display: flex; gap: 0.5rem; }
.dashboard-chart { display: block; width: 100%; color: var(--accent); }
.dashboard-chart text { fill: var(--muted); font-size: 12px; }
.chart-grid { stroke: var(--border); }
.chart-empty { min-height: 160px; display: grid; place-items: center; color: var(--muted); }
.chart-legend, .trend-summary { text-align: center; }
.chart-table { max-height: 320px; overflow: auto; }
.chart-table table { width: 100%; font-size: 0.8rem; border-collapse: collapse; }
.chart-table td, .chart-table th { padding: 0.4rem; text-align: left; border-bottom: 1px solid var(--border); }
.dashboard-log { position: sticky; bottom: 0; padding: 0.7rem 0 max(0.7rem,env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--border); }
.dashboard-log .button { width: 100%; margin: 0; }
@media (max-width: 420px) {
  .dashboard-metrics { gap: 0.5rem; }
  .dashboard-metrics .stat { padding: 0.7rem; }
  .dashboard-metrics .stat strong { font-size: 1.1rem; }
  .dashboard-metrics .stat .muted { font-size: 0.75rem; }
}

.brandbar h1 { font-family: "PuffTab Inter", sans-serif; font-weight: 900; color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.tabbar button.active { text-decoration: underline; text-underline-offset: 0.3em; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
