/* Palette: garden green on a cool off-white; slate with a mint accent in dark mode. */
:root {
  --bg: #f4f6f2;
  --surface: #ffffff;
  --line: #c9d1c6;
  --text: #1c2620;
  --muted: #5b675f;
  --accent: #1f6f55;
  --on-accent: #ffffff;
  --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191a;
    --surface: #1d2426;
    --line: #3a4649;
    --text: #e6ece8;
    --muted: #9aa8a0;
    --accent: #4fc79b;
    --on-accent: #0c1d16;
    --err: #ff8a80;
  }
}

@font-face {
  font-family: KitchenEmoji;
  src: url('/kitchen-emoji.woff2') format('woff2');
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: KitchenEmoji, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
button { font: inherit; color: inherit; cursor: pointer; margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.page { max-width: 1280px; margin: 0 auto; padding: 8px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.top h1 { margin: 0; font-size: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sections { display: flex; flex: 1; gap: 8px; margin-right: 12px; }
.section { flex: 1; max-width: 220px; min-height: 44px; font-size: 17px; font-weight: bold; color: var(--muted); background: transparent; border: 2px solid var(--line); border-radius: 10px; }
.section.on { color: var(--text); background: var(--surface); border-color: var(--accent); box-shadow: inset 0 -4px 0 var(--accent); }
.top .logout { min-height: 40px; padding: 4px 14px; background: transparent; border: 2px solid var(--line); border-radius: 10px; color: var(--muted); }

.tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.tab { flex: 1; min-height: 44px; font-size: 16px; font-weight: bold; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.tab.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.err { margin: 0 0 8px; padding: 8px 12px; border: 2px solid var(--err); border-radius: 8px; font-size: 15px; background: var(--surface); }
.msg { padding: 16px; text-align: center; color: var(--muted); font-size: 16px; }
.grid .msg { grid-column: 1 / -1; }

.main { display: block; }
.side { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.aisle { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 20px; font-size: 15px; }
.aisle.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: bold; }
.aisle .full { display: none; }
.content { flex: 1; min-width: 0; }

@media (min-width: 700px) {
  .main { display: flex; gap: 12px; align-items: flex-start; }
  .side { display: block; width: 250px; flex: none; margin: 0; max-height: calc(100vh - 130px); overflow-y: auto; }
  .aisle { width: 100%; min-height: 48px; margin-bottom: 6px; padding: 4px 10px; border-radius: 10px; text-align: left; }
  .aisle .full { display: inline; }
  .aisle .short { display: none; }
  .content { max-height: calc(100vh - 130px); overflow-y: auto; }
}

input[type=search], input[type=text], input[type=password], select {
  width: 100%; min-height: 44px; padding: 6px 12px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 10px;
}
.searchwrap { margin-bottom: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 92px; padding: 6px 4px; background: var(--surface); border: 3px solid var(--line); border-radius: 12px;
  text-align: center; -webkit-user-select: none; user-select: none;
}
.tile.buy { border-color: var(--accent); }
.tile .emo { font-size: 34px; line-height: 40px; }
.tile .nm { font-size: 14px; line-height: 17px; max-height: 34px; overflow: hidden; word-break: break-word; }
.tile .where { font-size: 11px; color: var(--muted); }
.tile .chk { position: absolute; top: 2px; right: 4px; min-width: 22px; height: 22px; line-height: 22px; border-radius: 11px; font-size: 14px; font-weight: bold; background: var(--accent); color: var(--on-accent); }
.tile.add { border-style: dashed; color: var(--muted); }

.grp { margin: 12px 0 4px; font-size: 15px; font-weight: bold; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 4px 8px; margin-bottom: 6px; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.row .check { flex: none; width: 44px; height: 44px; font-size: 26px; line-height: 1; background: transparent; border: 2px solid var(--accent); border-radius: 8px; }
.row .emo { font-size: 26px; }
.row .txt { flex: 1; min-width: 0; font-size: 17px; word-break: break-word; }
.row .note { display: block; font-size: 14px; color: var(--muted); }
.row .edit { flex: none; min-width: 44px; height: 44px; font-size: 20px; background: transparent; border: 2px solid var(--line); border-radius: 8px; }
.row input { min-height: 40px; }

.scrim { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(0, 0, 0, .55); overflow: auto; padding: 12px; }
.dlg { max-width: 560px; margin: 0 auto; padding: 14px; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; }
.dlg h3 { margin: 0 0 10px; font-size: 18px; }
.dlg label { display: block; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.dlg .pick { font-size: 36px; margin-left: 8px; }
.dlg .egrp { margin: 8px 0 2px; font-size: 13px; color: var(--muted); }
.dlg .emojis { display: flex; flex-wrap: wrap; gap: 4px; }
.dlg .em { width: 44px; height: 44px; font-size: 24px; line-height: 1; padding: 0; background: var(--bg); border: 2px solid var(--line); border-radius: 8px; }
.dlg .em.on { border-color: var(--accent); border-width: 4px; }
.dlg .buyrow { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 10px; font-size: 16px; }
.dlg .buyrow label { margin: 0; font-size: 16px; color: var(--text); }
.dlg .buyrow input { width: 24px; height: 24px; }
.dlg .derr { margin-top: 8px; color: var(--err); font-weight: bold; }
.dlg .foot { position: sticky; bottom: 0; margin: 0 -14px -14px; padding: 6px 14px 14px; background: var(--surface); }
.dlg .btns { display: flex; gap: 8px; margin-top: 8px; }
.dlg .btns button { flex: 1; min-height: 48px; font-size: 16px; font-weight: bold; background: var(--bg); border: 2px solid var(--line); border-radius: 10px; }
.dlg .btns .ok { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* Login */
.login { max-width: 360px; margin: 0 auto; padding: 24px 16px; }
.login h1 { margin: 24px 0 16px; font-size: 24px; }
.login label { display: block; margin: 0 0 4px; font-size: 14px; color: var(--muted); }
.login button { width: 100%; min-height: 48px; margin-top: 12px; font-size: 16px; font-weight: bold; color: var(--on-accent); background: var(--accent); border: 2px solid var(--accent); border-radius: 10px; }
.login .derr { min-height: 24px; margin-top: 10px; color: var(--err); font-weight: bold; }

.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.tab { font-size: 15px; padding: 4px 6px; }
.row .shop { flex: none; min-width: 44px; height: 44px; font-size: 20px; background: transparent; border: 2px solid var(--accent); border-radius: 8px; }

.login .gap { margin-top: 12px; }

/* Recetas IA */
.subtabs { display: flex; gap: 8px; margin-bottom: 10px; }
.subtab { flex: 1; min-height: 44px; font-size: 15px; font-weight: bold; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.subtab.on { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.rview { max-width: 720px; margin: 0 auto; }
.rview textarea { display: block; width: 100%; min-height: 84px; padding: 10px; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 10px; resize: vertical; }
.rhead { margin: 12px 0 6px; font-size: 14px; color: var(--muted); }
.modes { display: flex; flex-direction: column; gap: 8px; }
.mode { display: block; width: 100%; padding: 10px 12px; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.mode.on { border-color: var(--accent); border-width: 3px; padding: 9px 11px; }
.mtitle { display: block; font-weight: bold; font-size: 16px; }
.mhint { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.go { display: block; width: 100%; min-height: 52px; margin-top: 12px; font-size: 16px; font-weight: bold; color: var(--on-accent); background: var(--accent); border: 2px solid var(--accent); border-radius: 10px; }
.go[disabled] { opacity: 0.5; cursor: default; }
.rsum { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.rback { min-height: 44px; margin-bottom: 8px; padding: 4px 12px; background: transparent; border: 2px solid var(--line); border-radius: 10px; color: var(--muted); }
.rcard { display: block; width: 100%; margin-bottom: 8px; padding: 12px; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; }
.rtitle { display: block; font-size: 17px; font-weight: bold; }
.rmeta { display: block; margin: 2px 0 8px; font-size: 13px; color: var(--muted); }
.badges { display: block; }
.badge { display: inline-block; margin-right: 6px; padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: bold; }
.badge.ok { background: rgba(31, 111, 85, 0.15); color: var(--accent); }
.badge.warn { background: rgba(200, 120, 0, 0.15); color: #a35a00; }
.dtitle { font-size: 19px; font-weight: bold; }
.ings { padding: 4px 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.ing { padding: 6px 0; font-size: 16px; }
.ing.miss { font-weight: bold; color: #a35a00; }
.steps { margin: 0; padding: 8px 12px 8px 32px; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; font-size: 16px; line-height: 1.4; }
.steps li { margin: 4px 0; }
.rsave, .rdel { display: block; width: 100%; min-height: 48px; margin-top: 10px; font-size: 16px; font-weight: bold; background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.rsave[disabled] { opacity: 0.7; cursor: default; }
@media (prefers-color-scheme: dark) {
  .badge.ok { background: rgba(79, 199, 155, 0.18); }
  .badge.warn { background: rgba(255, 170, 60, 0.18); color: #ffb454; }
  .ing.miss { color: #ffb454; }
}

/* Recetas IA: reemplazar ingredientes */
.ing { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ing .itxt { flex: 1; min-width: 0; }
.ing .swap { flex: none; min-height: 40px; padding: 4px 12px; font-size: 14px; font-weight: bold; background: transparent; border: 2px solid var(--line); border-radius: 8px; }
.swapbox { margin: 4px 0 8px; padding: 8px; background: var(--bg); border: 2px solid var(--accent); border-radius: 10px; }
.swapbox input { display: block; width: 100%; min-height: 44px; margin-bottom: 6px; padding: 6px 10px; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 8px; }
.swaplist { max-height: 260px; overflow-y: auto; }
.swapbox .grp { margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.swapbox .pick { display: block; width: 100%; min-height: 44px; margin-bottom: 4px; padding: 4px 10px; text-align: left; font-size: 16px; background: var(--surface); border: 2px solid var(--line); border-radius: 8px; }
.swapbox .swapcancel { display: block; width: 100%; min-height: 44px; margin-top: 6px; font-weight: bold; background: transparent; border: 2px solid var(--line); border-radius: 8px; }
.libq { display: block; width: 100%; min-height: 48px; margin-bottom: 10px; padding: 6px 12px; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 10px; }
.rprev { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ingpick { display: block; width: 100%; min-height: 44px; padding: 6px 0; text-align: left; font-size: 16px; color: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.ingpick:last-child { border-bottom: 0; }
.libadd { margin-bottom: 4px; }
.rlink { display: inline-block; margin: 4px 0 2px; min-height: 44px; line-height: 44px; font-weight: bold; color: var(--accent); }
