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

html, body {
  margin: 0;
  padding: 0;
}

body {
  color: #1a1a1a;
  background: #fafafa;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;
  line-height: 1.4;
}

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

button {
  cursor: pointer;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: .5rem 1rem;
}

button:active {
  background: #f0f0f0;
}

input {
  border: 1px solid #ccc;
  border-radius: 6px;
  min-height: 44px;
  padding: .5rem;
}

.app-header {
  border-bottom: 1px solid #ddd;
  padding: 1rem;
}

.app-name {
  font-size: 1.25rem;
  font-weight: 600;
}

.offline-badge {
  color: #fff;
  vertical-align: middle;
  background: #666;
  border-radius: 6px;
  margin-left: .5rem;
  padding: .15rem .5rem;
  font-size: .8rem;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}

.desktop-nav, .desktop-pantry, .tab-pane {
  display: none;
}

.tab-pane.tab-active {
  display: block;
}

.login form {
  flex-direction: column;
  gap: 1rem;
  display: flex;
}

.login label {
  flex-direction: column;
  gap: .25rem;
  display: flex;
}

.error {
  color: #b00020;
}

.status {
  text-align: center;
  color: #666;
}

.list-page {
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 4rem;
  display: flex;
}

.priority-section summary {
  cursor: pointer;
  padding: .5rem 0;
  font-weight: 600;
}

.priority-section ul {
  flex-direction: column;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
}

.item-row {
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  min-height: 48px;
  padding: .25rem 0;
  display: flex;
}

.item-thumb {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  flex: none;
  width: 32px;
  height: 32px;
}

.item-name {
  text-align: left;
  min-width: 6rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: none;
  flex: auto;
}

.item-name:active {
  background: #f0f0f0;
}

.amount-stepper {
  align-items: center;
  gap: .25rem;
  display: flex;
}

.amount-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.amount-value {
  text-align: center;
  min-width: 1.5rem;
}

.priority-buttons {
  gap: .25rem;
  display: flex;
}

.prio-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
}

.one-time-btn {
  white-space: nowrap;
}

.one-time-btn.on {
  background: #dff0d8;
  border-color: #4caf50;
}

.check-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-weight: 700;
}

.toast-host {
  z-index: 10;
  flex-direction: column;
  gap: .5rem;
  padding: .5rem;
  display: flex;
  position: fixed;
  bottom: 56px;
  left: 0;
  right: 0;
}

.toast {
  color: #fff;
  background: #1a1a1a;
  border-radius: 8px;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  display: flex;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}

.toast-undo {
  color: #8ecaff;
  background: none;
  border: none;
  min-height: 32px;
  font-weight: 600;
}

@media (width >= 480px) {
  .toast-host {
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 480px;
  }
}

.job-cards {
  flex-direction: column;
  gap: .5rem;
  display: flex;
}

.job-cards:empty {
  display: none;
}

.job-card {
  background: #f0f4f1;
  border: 1px solid #d6e2da;
  border-radius: 8px;
  flex-direction: column;
  gap: .5rem;
  padding: .75rem 1rem;
  display: flex;
}

.job-card-label {
  color: #2f6f4f;
  font-weight: 600;
}

.job-card-failed {
  background: #fbecec;
  border-color: #e6c9c9;
}

.job-card-failed .job-card-label {
  color: #a12c2c;
}

.job-card blockquote {
  color: #444;
  border-left: 3px solid #ccc;
  margin: 0;
  padding: .5rem .75rem;
  font-style: italic;
}

.job-dismiss {
  color: #a12c2c;
  background: none;
  border: none;
  align-self: flex-end;
  min-height: 32px;
  font-weight: 600;
}

.default-amount-badge {
  text-align: center;
  background: #eee;
  border-radius: 999px;
  min-width: 1.5rem;
  padding: .15rem .5rem;
  font-weight: 600;
}

.pantry-add-btn {
  min-width: 44px;
  min-height: 44px;
  font-weight: 700;
}

.pantry-delete-btn {
  min-width: 44px;
  min-height: 44px;
}

.input-bar {
  margin-bottom: 1rem;
  position: relative;
}

.input-row {
  gap: .5rem;
  display: flex;
}

.input-bar-field {
  flex: auto;
  min-width: 0;
}

.interpret-btn, .mic-btn {
  flex: none;
}

.mic-btn.mic-recording {
  color: #fff;
  background: #d32f2f;
  animation: 1.2s ease-in-out infinite mic-pulse;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 rgba(211, 47, 47, .5);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(211, 47, 47, 0);
  }
}

.input-dropdown {
  z-index: 6;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  max-height: 60vh;
  margin: .25rem 0 0;
  padding: 0;
  list-style: none;
  position: absolute;
  left: 0;
  right: 0;
  overflow-y: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.input-dropdown li {
  border-bottom: 1px solid #eee;
}

.input-dropdown li:last-child {
  border-bottom: none;
}

.dropdown-hit, .dropdown-create {
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  width: 100%;
}

.dropdown-create {
  font-weight: 600;
}

.create-dialog {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  flex-direction: column;
  gap: .5rem;
  margin-top: .5rem;
  padding: .75rem;
  display: flex;
}

.create-dialog-actions {
  justify-content: flex-end;
  gap: .5rem;
  display: flex;
}

.one-time-check {
  align-items: center;
  gap: .5rem;
  display: flex;
}

.pantry-page {
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 4rem;
  display: flex;
}

.pantry-filter {
  width: 100%;
}

.pantry-list {
  flex-direction: column;
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
}

.tab-bar {
  z-index: 5;
  background: #fff;
  border-top: 1px solid #ddd;
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.tab-bar button {
  background: none;
  border: none;
  border-top: 2px solid rgba(0, 0, 0, 0);
  border-radius: 0;
  flex: auto;
}

.tab-bar button.active {
  border-top-color: #1a1a1a;
  font-weight: 700;
}

.sheet-backdrop {
  z-index: 20;
  background: rgba(0, 0, 0, .4);
  justify-content: center;
  align-items: flex-end;
  display: flex;
  position: fixed;
  inset: 0;
}

.detail-sheet {
  background: #fff;
  border-radius: 12px 12px 0 0;
  flex-direction: column;
  gap: .75rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  padding: 1rem;
  display: flex;
  overflow-y: auto;
}

.sheet-field {
  flex-direction: column;
  gap: .25rem;
  display: flex;
}

.sheet-label {
  font-weight: 600;
}

.alias-chips {
  flex-wrap: wrap;
  gap: .35rem;
  display: flex;
}

.alias-chip {
  background: #eef2ff;
  border-radius: 999px;
  align-items: center;
  gap: .25rem;
  padding: .15rem .5rem .15rem .75rem;
  display: inline-flex;
}

.alias-remove {
  background: none;
  border: none;
  min-width: auto;
  min-height: auto;
  padding: 0 .25rem;
}

.alias-add-btn {
  align-self: flex-start;
  min-width: 44px;
  min-height: 44px;
}

.image-placeholder {
  flex-direction: row;
  align-items: center;
  gap: .75rem;
}

.image-box {
  background: #f7f7f7;
  border: 1px dashed #ccc;
  border-radius: 6px;
  flex: none;
  width: 64px;
  height: 64px;
}

.image-note {
  color: #666;
  font-size: .9rem;
}

.sheet-actions {
  justify-content: flex-end;
  gap: .5rem;
  display: flex;
}

@media (width >= 900px) {
  .app-shell {
    grid-template-columns: 220px 1fr 340px;
    align-items: start;
    gap: 0 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
  }

  .app-header {
    grid-column: 1 / -1;
  }

  .desktop-nav {
    flex-direction: column;
    gap: .5rem;
    padding-top: 1rem;
    display: flex;
  }

  .desktop-nav .app-name {
    font-size: 1.1rem;
  }

  .desktop-nav-placeholder {
    color: #666;
    font-size: .85rem;
  }

  main {
    max-width: none;
    margin: 0;
    padding-bottom: 1rem;
  }

  .desktop-pantry {
    border-left: 1px solid #ddd;
    padding-top: 1rem;
    padding-left: 1.5rem;
    display: block;
  }

  .desktop-pantry-title {
    margin: 0 0 .75rem;
    font-size: 1rem;
  }

  .tab-bar {
    display: none;
  }

  .tab-pane-list, .tab-pane-list.tab-active {
    display: block;
  }

  .tab-pane-pantry, .tab-pane-pantry.tab-active {
    display: none;
  }

  .toast-host {
    bottom: 1rem;
  }
}
