/* Menu Cost — warm kitchen ledger, dark */
:root {
  --bg: #1c1612;
  --bg-elevated: #262019;
  --bg-card: #2e261f;
  --ink: #e8dcc8;
  --ink-muted: #a89884;
  --accent: #c45c3e;
  --accent-soft: rgba(196, 92, 62, 0.15);
  --border: rgba(232, 220, 200, 0.12);
  --radius: 12px;
  --font-ui: 'Figtree', system-ui, sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(196, 92, 62, 0.12), transparent),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(40, 32, 25, 0.9), transparent);
}

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

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(28, 22, 18, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__back {
  border: none;
  background: var(--bg-elevated);
  color: var(--ink);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
}

.topbar__titles {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.topbar__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.topbar__tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
}

.topbar__nav {
  margin-left: auto;
  display: flex;
  gap: 0.35rem;
}

.topbar__nav a {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
}

.topbar__nav a:hover,
.topbar__nav a:focus-visible {
  color: var(--ink);
  background: var(--bg-elevated);
}

.topbar__nav a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.topbar__out {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-muted);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.topbar__out:hover {
  color: var(--ink);
}

/* Main */
.main {
  flex: 1;
  padding: 1rem 1rem 5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

/* Typography */
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.65rem;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.sub {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow);
}

.card--press {
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.card--press:hover,
.card--press:focus-visible {
  border-color: rgba(196, 92, 62, 0.35);
  transform: translateY(-1px);
}

.card__title {
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
}

.card__meta {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
  font-size: 1.15rem;
}

/* Screen header row */
.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

/* Search */
.search {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  font: inherit;
  margin-bottom: 1rem;
}

.search::placeholder {
  color: var(--ink-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.65rem 1rem;
  min-height: 44px;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.06);
}

.btn--ghost {
  background: var(--bg-elevated);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn--danger {
  background: transparent;
  color: #e07a6e;
  border: 1px solid rgba(224, 122, 110, 0.4);
}

.btn--fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0;
}

/* FAB — fixed bottom-right floating action button */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 1.85rem;
  line-height: 1;
  padding: 0;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 24px rgba(196, 92, 62, 0.45), var(--shadow);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(196, 92, 62, 0.55), var(--shadow);
}

.fab:active {
  transform: scale(0.96);
}

/* Forms */
.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}

.input,
select.input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  font: inherit;
  min-height: 44px;
}

.input:focus,
select.input:focus,
.search:focus {
  outline: 2px solid rgba(196, 92, 62, 0.45);
  outline-offset: 0;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 520px) {
  .row-3 {
    grid-template-columns: 1fr;
  }
}

/* Login */
.login {
  max-width: 380px;
  margin: 4rem auto;
  padding: 0 1rem;
}

.login .card {
  padding: 1.5rem;
}

.login h1 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.login .sub {
  text-align: center;
}

/* Price-per row in add ingredient form */
.price-per-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 0.35rem;
}

.price-per-row {
  display: grid;
  grid-template-columns: 1fr auto 5rem 5rem;
  gap: 0.5rem;
  align-items: center;
}

.price-per-sep {
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: center;
  white-space: nowrap;
}

.price-per-amt {
  text-align: right;
}

.price-per-hint {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin: 0.3rem 0 0;
  min-height: 1.1em;
}

/* Ingredient row */
.ing-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.5rem 0.75rem;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.ing-row:last-child {
  border-bottom: none;
}

.ing-row__name {
  font-weight: 500;
  min-width: 0;
  word-break: break-word;
}

.price-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.price-edit input {
  width: 5.5rem;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ing-row__unit {
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 0.35rem;
  cursor: pointer;
  border-radius: 6px;
}

.icon-btn:hover {
  color: #e07a6e;
  background: rgba(224, 122, 110, 0.1);
}

/* Recipe lines */
.line-grid {
  display: grid;
  /* ingredient | qty | unit | cost | remove */
  grid-template-columns: 1fr 6rem 6rem auto auto;
  gap: 0.5rem;
  align-items: end;
  margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
  .line-grid {
    grid-template-columns: 1fr 1fr;
    row-gap: 0.35rem;
  }
  .line-grid .picker-wrap {
    grid-column: 1 / -1;
  }
  .line-grid .line-qty {
    grid-column: 1;
  }
  .line-grid .line-unit {
    grid-column: 2;
  }
  .line-grid .line-cost {
    grid-column: 1;
    align-self: center;
    padding-bottom: 0;
  }
  .line-grid .line-remove {
    grid-column: 2;
    justify-self: end;
    align-self: center;
  }
}

.line-cost {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--accent);
  padding-bottom: 0.5rem;
}

.picker-wrap {
  position: relative;
}

.picker-dd {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 5;
  margin-top: 4px;
  box-shadow: var(--shadow);
}

.picker-dd button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.picker-dd button:hover,
.picker-dd button:focus-visible {
  background: var(--accent-soft);
}

.totals {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.totals dl {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.totals dt {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.totals dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
  max-width: 90vw;
  font-size: 0.9rem;
}

.toast--err {
  border-color: rgba(224, 122, 110, 0.5);
  color: #f0b4a8;
}

/* Remember me / login extras */
.remember-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 1rem;
  cursor: pointer;
}

.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.login-error {
  color: #f0b4a8;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  text-align: center;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Install hint on login */
.install-hint {
  display: block;
  margin: 0.85rem auto 0;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
}

.install-hint:hover {
  color: var(--ink);
}

/* Install banner (bottom of screen) */
.install-banner {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  z-index: 40;
  box-shadow: var(--shadow);
}

@media (min-width: 600px) {
  .install-banner {
    max-width: 380px;
    left: auto;
    right: 1.5rem;
    bottom: 1.5rem;
  }
}

.install-banner__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.install-banner__body {
  flex: 1;
  min-width: 0;
}

.install-banner__title {
  font-size: 0.9rem;
  font-weight: 600;
}

.install-banner__desc {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 1px;
}

.install-banner__actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Install modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

@media (min-width: 600px) {
  .modal-overlay {
    align-items: center;
  }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  animation: modalIn 0.18s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 1.1rem;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.install-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.install-step__num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.install-step__text {
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.install-step__text strong {
  color: var(--ink);
  font-weight: 600;
}

.install-step__icon {
  display: inline-block;
  font-size: 1rem;
  vertical-align: middle;
  margin: 0 2px;
}

.install-note {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin: 0 0 1rem;
}

.install-note strong {
  color: var(--ink);
}

/* ── Category sections ──────────────────────────────────────────────────────── */

.cat-section {
  margin-bottom: 0.35rem;
}

.cat-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.75rem 0.85rem 1rem;
  margin: 0 0 0.65rem;
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  background: linear-gradient(
    90deg,
    rgba(196, 92, 62, 0.12) 0%,
    rgba(46, 38, 31, 0.35) 42%,
    transparent 100%
  );
  position: sticky;
  top: 64px;
  z-index: 5;
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--border);
}

.cat-header__name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
  min-width: 0;
}

.cat-header__meta {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.35em 0.65em;
  border-radius: 999px;
  background: rgba(232, 220, 200, 0.07);
  border: 1px solid var(--border);
}

/* cards grid inside a section */
.cat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* money label inside recipe card */
.money-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-weight: 400;
}

/* ── Bottom sheet ────────────────────────────────────────────────────────────── */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 30;
  backdrop-filter: blur(3px);
}

.sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 31;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 0.5rem 1.25rem 1.5rem;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.5);
  animation: sheetIn 0.22s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90dvh;
  overflow-y: auto;
}

@keyframes sheetIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet__grip {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0.5rem auto 1rem;
}

.sheet__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 1rem;
}

.sheet__actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.sheet__actions .btn {
  flex: 1;
}

@media (min-width: 600px) {
  .sheet {
    max-width: 460px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
  }
  @keyframes sheetIn {
    from { transform: translateX(-50%) translateY(100%); }
    to   { transform: translateX(-50%) translateY(0); }
  }
}

/* Prevent body scroll when sheet open */
body.sheet-open {
  overflow: hidden;
}

/* optional label */
.field__opt {
  font-weight: 400;
  color: var(--ink-muted);
  font-size: 0.75em;
  margin-left: 0.2em;
}

/* Config error */
.config-err {
  background: rgba(224, 122, 110, 0.12);
  border: 1px solid rgba(224, 122, 110, 0.35);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-muted);
}

.line-err {
  font-size: 0.75rem;
  color: #e07a6e;
  margin-top: 0.25rem;
}
