/* Colours of the kitchen device (src/ui.cpp): parchment, dark green bar, amber accent. */
:root {
  --bg: #f7f3d6;
  --surface: #fffbff;
  --bar: #213d3a;
  --bar-text: #fffbff;
  --text: #292929;
  --muted: #7b797b;
  --checked: #a8a5a8;
  --accent: #dea242;
  --border: #d6d284;
  --danger: #ce1421;
  --radius: 10px;
  --tap: 44px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

button:disabled { color: var(--checked); cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--bar); border-color: var(--bar); color: var(--bar-text); }
button.danger { color: var(--danger); border-color: var(--danger); }

input, select {
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
}

/* ---- Header ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: var(--bar);
  color: var(--bar-text);
  border-bottom: 3px solid var(--accent);
}

.title { display: grid; flex: 1; min-width: 0; }
.bar h1 { margin: 0; font-size: 20px; font-weight: 600; white-space: nowrap; }
.sync { font-size: 13px; opacity: .85; white-space: nowrap; min-height: 1.2em; }
.sync.offline { color: #ffb4b4; opacity: 1; }
.logout { background: transparent; border-color: rgba(255, 255, 255, .35); color: var(--bar-text); font-size: 14px; }
.logout span { opacity: .75; }

main { max-width: 560px; margin: 0 auto; padding: 12px 16px 96px; }

/* ---- Login ---- */

.card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card h2 { margin: 0 0 4px; font-size: 20px; }
.card label { display: grid; gap: 4px; font-size: 15px; color: var(--muted); }
.card label input, .card label select { color: var(--text); }
.login { margin-top: 24px; }
.error { margin: 0; color: var(--danger); min-height: 1.4em; }

/* ---- Tabs ---- */

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.tab { padding: 0 6px; font-size: 15px; }
.tab[aria-selected="true"] { background: var(--bar); border-color: var(--bar); color: var(--bar-text); }
.tab .count { margin-left: 6px; font-size: 13px; color: var(--accent); font-weight: 600; }

/* ---- Adding ---- */

.add { display: grid; grid-template-columns: 1fr 64px auto; gap: 6px; }
.add input[type="number"] { padding: 0 6px; text-align: center; }
.warning { margin: 4px 2px 0; font-size: 14px; color: var(--muted); min-height: 0; }
.warning:empty { display: none; }

.suggestions { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.suggestion {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  border-style: dashed;
}
.suggestion .hint { font-size: 13px; color: var(--muted); }

/* ---- Items ---- */

.items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; }

.item {
  display: grid;
  grid-template-columns: var(--tap) 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.item.pending { border-style: dashed; }

.check {
  width: var(--tap);
  padding: 0;
  border: 2px solid var(--text);
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
}

.body {
  display: grid;
  min-height: var(--tap);
  padding: 4px 8px;
  border: none;
  background: transparent;
  text-align: left;
  overflow-wrap: anywhere;
}

.body .name { font-size: 18px; }
.body .note { font-size: 14px; color: var(--muted); }

.checked .name { text-decoration: line-through; }
.checked .name, .checked .note, .checked .quantity { color: var(--checked); }
.checked .check { border-color: var(--checked); color: var(--checked); }

.stepper { display: flex; align-items: center; gap: 2px; }
.step { width: 40px; padding: 0; border-color: var(--bar); color: var(--bar); font-size: 22px; line-height: 1; }
.step.bin { border-color: var(--danger); }
.step.bin::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 20px;
  background: var(--danger);
  /* A waste bin, drawn as a mask (no image file, CSP stays strict). */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 20'%3E%3Cpath d='M6 1h6v2h5v2H1V3h5zM3 6h12l-1 13H4zm3 2v9h2V8zm4 0v9h2V8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 20'%3E%3Cpath d='M6 1h6v2h5v2H1V3h5zM3 6h12l-1 13H4zm3 2v9h2V8zm4 0v9h2V8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.step:disabled { border-color: var(--border); }
.quantity { min-width: 28px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }

.empty { margin: 24px 0; text-align: center; color: var(--muted); }

.actions { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ---- Dialog and toast ---- */

dialog { width: min(92vw, 420px); padding: 0; border: none; border-radius: var(--radius); background: transparent; }
dialog::backdrop { background: rgba(33, 61, 58, .45); }
.dialog-buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dialog-buttons .danger { margin-right: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(92vw, 520px);
  padding: 10px 12px 10px 16px;
  background: var(--bar);
  color: var(--bar-text);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast span { flex: 1; }
.toast-action { background: transparent; border-color: var(--accent); color: var(--accent); }
