:root {
  --bg: #f4efe7;
  --bg-accent: #ece2d4;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --surface-soft: #fbf7f1;
  --text: #1e2320;
  --muted: #66706a;
  --border: #d9d0c4;
  --border-strong: #c7b9a8;
  --primary: #115e59;
  --primary-strong: #0d4c48;
  --primary-soft: #d9eeea;
  --danger: #a63b2f;
  --shadow: 0 18px 40px rgba(63, 47, 27, 0.08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --focus: 0 0 0 4px rgba(17, 94, 89, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 32%),
    radial-gradient(circle at top right, rgba(221, 239, 229, 0.75), transparent 24%),
    linear-gradient(180deg, #f7f2ea 0%, var(--bg) 48%, #f8f4ee 100%);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  font-family:
    "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP",
    -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(420px, 100%);
}

.auth-card {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid rgba(201, 188, 173, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 18px 44px rgba(63, 47, 27, 0.12);
}

.auth-card h1 {
  margin: 0;
  font-size: 1.8rem;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.app-shell {
  position: relative;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding:
    calc(18px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
}

.hero {
  position: relative;
  display: grid;
  gap: 18px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 64ch;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.tab-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.tab-button,
.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
}

.tab-button {
  min-height: 48px;
  padding: 0 12px;
  border-radius: 16px;
  background: transparent;
  font-weight: 700;
}

.tab-button.is-active {
  background: var(--surface-strong);
  box-shadow: 0 6px 18px rgba(22, 39, 32, 0.08);
}

.content {
  display: grid;
}

.panel {
  display: none;
  gap: 16px;
}

.panel.is-active {
  display: grid;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h2,
.panel-head h3,
.section-title h3,
.table-head h3 {
  margin: 0;
}

.panel-head p,
.table-head span,
.section-title span {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.panel-meta {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.card,
.table-card,
.import-panel,
.summary-card,
.action-strip,
.input-console,
.recipe-form,
.shopping-layout,
.result-card {
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.ingredient-form,
.store-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
}

.ingredient-form .form-actions,
.purchase-form .form-actions,
.store-form .form-actions {
  flex-wrap: nowrap;
  align-items: center;
}

.input-console {
  display: grid;
  gap: 10px;
}

.input-console-main {
  display: grid;
  grid-template-columns: minmax(140px, 0.6fr) minmax(160px, 0.7fr) minmax(260px, 1.2fr) auto auto;
  gap: 12px;
  align-items: end;
}

.input-console-main label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.barcode-field {
  min-width: 220px;
}

.purchase-form .upload-zone,
.purchase-form .preview-pair {
  grid-column: span 2;
}

.action-strip {
  display: flex;
  align-items: center;
  gap: 14px;
}

.action-strip span {
  color: var(--muted);
  line-height: 1.6;
}

.recipe-basic {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.28fr);
}

.recipe-image-drop,
.recipe-image-preview {
  grid-column: 1 / -1;
}

.recipe-form {
  display: grid;
  gap: 22px;
}

.recipe-form .recipe-basic {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(201, 188, 173, 0.55);
}

.form-grid label {
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 700;
}

.form-grid span {
  color: var(--muted);
  font-weight: 700;
}

.field-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  vertical-align: 1px;
}

.field-badge.required {
  background: #fff0e8;
  color: #a3441f;
}

.field-badge.optional {
  background: #eef5f2;
  color: #437262;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background-color: rgba(255, 255, 255, 0.95);
  color: var(--text);
}

select {
  padding-right: 42px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

select:hover {
  border-color: var(--border-strong);
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.form-actions,
.shopping-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.notes-copy-help {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.65;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.store-form .form-actions {
  min-width: 300px;
}

.primary-button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(17, 94, 89, 0.18);
}

.primary-button:hover {
  background: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--border);
  background: #fff;
}

.ghost-button,
.icon-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.68);
}

.ghost-button:hover,
.secondary-button:hover,
.icon-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  align-self: start;
}

.hero-actions {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top));
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reset-sample-button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  opacity: 0.72;
}

.reset-sample-button:hover {
  opacity: 1;
}

.logout-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  color: #7b8790;
  text-decoration: none;
}

.logout-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button {
  color: var(--danger);
  white-space: nowrap;
}

.table-head,
.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: linear-gradient(90deg, rgba(217, 238, 234, 0.86), rgba(255, 250, 241, 0.7));
  border-left: 4px solid var(--primary);
}

.form-head {
  margin-bottom: 4px;
}

.form-grid-head {
  grid-column: 1 / -1;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  margin: -4px 0 16px;
}

.head-jan,
.head-image {
  background: linear-gradient(90deg, rgba(217, 238, 234, 0.9), rgba(244, 250, 248, 0.72));
  border-left-color: #0f766e;
}

.head-queue {
  background: linear-gradient(90deg, rgba(255, 239, 205, 0.9), rgba(255, 252, 244, 0.72));
  border-left-color: #c47a1c;
}

.head-history {
  background: linear-gradient(90deg, rgba(224, 235, 248, 0.9), rgba(248, 251, 255, 0.72));
  border-left-color: #4776a8;
}

.recipe-ingredients-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding-top: 4px;
}

.recipe-ingredients-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.recipe-ingredients-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.recipe-add-button {
  min-height: 40px;
  padding-inline: 14px;
  color: var(--primary);
}

.store-folder-row,
.draft-grid,
.receipt-list {
  gap: 12px;
}

.store-folder-row {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.store-folder-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 190px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid rgba(201, 188, 173, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  text-align: left;
}

.purchase-row-list {
  display: grid;
  gap: 10px;
}

.purchase-input-row {
  display: grid;
  grid-template-columns: 88px minmax(240px, 1.4fr) minmax(150px, 0.75fr) minmax(150px, 0.75fr) minmax(130px, 0.6fr) 104px auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(201, 188, 173, 0.6);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.purchase-input-row .row-image {
  grid-column: 1;
  grid-row: span 2;
}

.purchase-input-row .row-name-field {
  grid-column: 2;
  grid-row: 1;
}

.purchase-input-row .row-store-field {
  grid-column: 3;
  grid-row: 1;
}

.purchase-input-row .row-jan-field {
  grid-column: 4 / span 2;
  grid-row: 1;
}

.purchase-input-row .row-price-field {
  grid-column: 2;
  grid-row: 2;
}

.purchase-input-row .row-quantity-field {
  grid-column: 3;
  grid-row: 2;
}

.purchase-input-row .row-unit-field {
  grid-column: 4;
  grid-row: 2;
}

.purchase-input-row .receipt-drop-target {
  grid-column: 6;
  grid-row: 1 / span 2;
  align-self: start;
}

.purchase-input-row .js-remove-row {
  grid-column: 7;
  grid-row: 1 / span 2;
  align-self: start;
}

.purchase-input-row .js-row-jan {
  min-width: 0;
}

.purchase-input-row label,
.purchase-input-row .row-name-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.lookup-message {
  display: block;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.35;
  user-select: text;
  -webkit-user-select: text;
}

.lookup-found {
  color: var(--primary);
}

.lookup-missing {
  color: var(--danger);
}

.row-image .ingredient-media {
  width: 82px;
  height: 82px;
}

.material-preview-button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.material-drop-target {
  position: relative;
  display: grid;
  width: 88px;
  min-height: 112px;
  place-items: center;
  align-self: stretch;
  padding: 4px;
  border: 1px dashed rgba(201, 188, 173, 0.82);
  border-radius: 16px;
  background: #f7efe6;
}

.material-drop-target.has-image {
  border-style: solid;
  background: #fffaf4;
}

.material-drop-hint {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.material-drop-target.has-image .material-drop-hint {
  margin-top: 4px;
}

.store-folder-card:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.store-folder-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.receipt-tray {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(201, 188, 173, 0.58);
  border-radius: 18px;
  background: var(--surface-soft);
}

.receipt-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 120px));
}

.receipt-preview-button,
.receipt-tray-item {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 14px;
  background: #f1e8dc;
  cursor: zoom-in;
  overflow: hidden;
}

.receipt-preview-button {
  width: 48px;
  height: 64px;
}

.receipt-preview-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.receipt-upload-zone {
  width: 132px;
  min-height: 64px;
  padding: 8px 10px;
}

.receipt-upload-zone .image-drop-main {
  font-size: 0.72rem;
  line-height: 1.35;
}

.receipt-upload-zone .image-drop-sub {
  font-size: 0.64rem;
  line-height: 1.25;
}

.receipt-tray-item {
  width: 74px;
  height: 96px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.receipt-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

.draft-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.draft-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(201, 188, 173, 0.64);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.draft-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.draft-images {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
}

.draft-images > img,
.receipt-drop-target {
  width: 100%;
  height: 150px;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 16px;
  object-fit: cover;
  background: #f1e8dc;
}

.receipt-drop-target {
  position: relative;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
}

.purchase-input-row .receipt-drop-target {
  width: 82px;
  height: 70px;
  justify-self: center;
}

.receipt-drop-target.has-image {
  border-style: solid;
  background: transparent;
}

.image-clear-button {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(201, 188, 173, 0.75);
  border-radius: 999px;
  background: #fff;
  color: var(--danger);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(63, 47, 27, 0.14);
}

.image-clear-button:hover {
  background: #fff6f2;
}

.image-modal[hidden] {
  display: none;
}

.image-modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 35, 32, 0.58);
  backdrop-filter: blur(4px);
}

.image-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: min(760px, 94vw);
  max-height: 92vh;
  padding: 14px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 26px 80px rgba(16, 22, 18, 0.32);
}

.image-modal-panel img {
  max-width: 100%;
  max-height: calc(92vh - 76px);
  border-radius: 16px;
  object-fit: contain;
}

.image-modal-close {
  justify-self: end;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  font-weight: 800;
  cursor: pointer;
}

body.is-modal-open {
  overflow: hidden;
}

.draft-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preview-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.image-preview {
  display: grid;
  min-height: 120px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 16px;
  background: var(--surface-soft);
}

.image-preview img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.capture-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}

.flow-step {
  display: grid;
  gap: 8px;
  min-height: 132px;
  padding: 16px;
  border: 1px solid rgba(201, 188, 173, 0.58);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.flow-step span {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 900;
}

.flow-step p,
.flow-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.flow-step.is-primary {
  background: linear-gradient(135deg, rgba(217, 238, 234, 0.86), rgba(255, 255, 255, 0.78));
}

.flow-arrow {
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: 1.6rem;
  font-weight: 900;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.flow-card {
  border: 1px solid rgba(201, 188, 173, 0.58);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.summary-card {
  display: grid;
  gap: 12px;
}

.summary-head {
  margin-bottom: 0;
}

.summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#recipeIngredients {
  display: grid;
  gap: 10px;
}

.recipe-form-actions {
  justify-content: flex-end;
  padding-top: 8px;
}

.list,
.shopping-list {
  display: grid;
  gap: 12px;
}

#ingredientList {
  gap: 6px;
}

.list-item,
.shopping-item,
.result-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(201, 188, 173, 0.6);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.list-item {
  grid-template-columns: 1.6fr 0.8fr 0.7fr 0.8fr auto;
  align-items: center;
}

.purchase-item {
  grid-template-columns: minmax(190px, 1.35fr) minmax(120px, 0.8fr) minmax(86px, 0.45fr) minmax(74px, 0.4fr) minmax(132px, 0.7fr) minmax(92px, auto);
}

.purchase-receipt-cell {
  position: relative;
  width: fit-content;
}

.purchase-receipt-cell.has-image {
  justify-self: center;
}

.master-item {
  grid-template-columns: minmax(220px, 1.4fr) minmax(130px, 0.75fr) minmax(100px, 0.55fr) minmax(120px, 0.65fr) auto;
}

.ingredient-category {
  display: grid;
  gap: 10px;
}

.ingredient-category summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(201, 188, 173, 0.58);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  font-weight: 800;
}

.ingredient-category summary::marker,
.ingredient-category summary::-webkit-details-marker {
  display: none;
  content: "";
}

.ingredient-category summary span::before {
  content: "▶";
  display: inline-block;
  margin-right: 8px;
  color: var(--primary);
  font-size: 0.78em;
  transform: translateY(-1px);
}

.ingredient-category[open] summary span::before {
  content: "▼";
}

.ingredient-category summary small {
  color: var(--muted);
  font-size: 0.82rem;
}

.ingredient-category-list {
  display: grid;
  gap: 9px;
  padding: 6px 0 0 16px;
}

.store-item {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.list-item strong,
.shopping-item strong {
  display: block;
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.ingredient-identity,
.recipe-identity,
.shopping-recipe-meta,
.ingredient-pill,
.suggestion-item {
  display: flex;
  align-items: center;
}

.ingredient-identity {
  min-width: 0;
  gap: 12px;
}

.recipe-identity {
  min-width: 0;
  gap: 13px;
}

.ingredient-media {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 15px;
  object-fit: cover;
  background: #f1e8dc;
}

.ingredient-media-contain {
  object-fit: contain;
  background: linear-gradient(180deg, #faf5ed 0%, #f1e8dc 100%);
}

.ingredient-media-placeholder {
  display: inline-grid;
  place-items: center;
  color: var(--primary);
  font-weight: 800;
}

.ingredient-media-small {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 0.72rem;
}

.recipe-media {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 18px;
  object-fit: cover;
  background: #f1e8dc;
}

.recipe-media-placeholder {
  display: inline-grid;
  place-items: center;
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 800;
}

.recipe-media-small {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 0.8rem;
}

.image-drop-zone {
  display: grid;
  min-height: 68px;
  place-content: center;
  padding: 9px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.image-drop-zone:hover,
.image-drop-zone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.image-drop-zone.has-image {
  border-style: solid;
}

.image-drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-drop-main {
  font-size: 0.86rem;
  font-weight: 800;
}

.image-drop-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.ingredient-image-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 58px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(201, 188, 173, 0.45);
}

.recipe-image-preview {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 72px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(201, 188, 173, 0.45);
}

.recipe-image-preview.is-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.ingredient-image-preview.is-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.ingredient-image-preview-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.ingredient-image-preview-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 12px;
  object-fit: contain;
  background: linear-gradient(180deg, #faf5ed 0%, #f1e8dc 100%);
}

.recipe-image-preview-thumb {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid rgba(201, 188, 173, 0.65);
  border-radius: 12px;
  object-fit: cover;
  background: #f1e8dc;
}

.ingredient-image-preview-label {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.image-remove-button {
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  min-width: 92px;
}

.small-button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-weight: 700;
}

.small-danger {
  color: var(--danger);
}

.recipe-list-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(201, 188, 173, 0.6);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.recipe-list-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.recipe-image-actions {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  align-items: center;
  gap: 10px;
}

.recipe-image-actions .image-drop-zone {
  min-height: 58px;
}

.ingredient-lines,
.result-list {
  display: grid;
  gap: 8px;
}

.ingredient-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.ingredient-pill {
  align-items: center;
  padding: 4px 10px;
  gap: 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid rgba(201, 188, 173, 0.5);
}

.card-inline {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(110px, 0.25fr) minmax(120px, 0.25fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(201, 188, 173, 0.5);
}

.card-inline > label {
  display: grid;
  gap: 8px;
}

.recipe-ingredient-search {
  position: relative;
}

.recipe-suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid rgba(201, 188, 173, 0.85);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 28px rgba(63, 47, 27, 0.12);
}

.recipe-suggestion-item {
  display: grid;
  width: 100%;
  gap: 4px;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid rgba(201, 188, 173, 0.45);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.recipe-suggestion-item:last-child {
  border-bottom: 0;
}

.recipe-suggestion-item:hover,
.recipe-suggestion-item:focus {
  background: #f5f0e7;
  outline: none;
}

.recipe-suggestion-item span {
  color: var(--text);
  font-weight: 800;
}

.recipe-suggestion-item small {
  color: var(--muted);
  font-size: 0.78rem;
}

.card-inline .icon-button {
  min-height: 48px;
}

.ingredient-search {
  position: relative;
}

.ingredient-search label {
  display: grid;
  gap: 8px;
}

.ingredient-search span {
  color: var(--muted);
  font-weight: 700;
}

.suggestions {
  position: absolute;
  z-index: 3;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid rgba(201, 188, 173, 0.85);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 28px rgba(63, 47, 27, 0.12);
}

.suggestion-item {
  width: 100%;
  gap: 9px;
  padding: 12px 14px;
  border: 0;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.suggestion-item:hover {
  background: #f5f0e7;
}

.shopping-layout {
  display: grid;
  gap: 18px;
}

.shopping-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.shopping-check {
  display: flex;
  align-items: center;
}

.shopping-check label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.shopping-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.shopping-check input[type="number"] {
  max-width: 120px;
}

.shopping-servings-field {
  display: grid;
  gap: 6px;
  min-width: 128px;
}

.shopping-servings-field span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.shopping-servings-field input[type="number"] {
  max-width: 128px;
}

.shopping-recipe-meta {
  justify-content: space-between;
  gap: 12px;
}

.ingredient-image-strip {
  display: flex;
}

.ingredient-image-strip .ingredient-media + .ingredient-media {
  margin-left: -7px;
}

.ingredient-image-strip .ingredient-media {
  box-shadow: 0 0 0 2px #fff;
}

.result-card {
  min-height: 140px;
}

.result-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.result-row strong {
  font-size: 1.02rem;
}

.empty-state {
  padding: 12px 2px;
  color: var(--muted);
}

.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

.helper-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .panel-head,
  .table-head,
  .section-title {
    align-items: start;
    flex-direction: column;
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .ingredient-item .image-drop-zone {
    grid-column: 1 / -1;
  }

  .card-inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .input-console-main,
  .purchase-input-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purchase-input-row .row-image,
  .purchase-input-row .receipt-drop-target {
    grid-row: span 2;
  }

  .purchase-input-row .row-image,
  .purchase-input-row .row-name-field,
  .purchase-input-row .row-store-field,
  .purchase-input-row .row-jan-field,
  .purchase-input-row .row-price-field,
  .purchase-input-row .row-quantity-field,
  .purchase-input-row .row-unit-field,
  .purchase-input-row .receipt-drop-target,
  .purchase-input-row .js-remove-row {
    grid-column: auto;
    grid-row: auto;
  }

  .recipe-image-actions {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .card-inline .ingredient-search {
    grid-column: 1 / -1;
  }

  .card-inline .icon-button {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .ingredient-form,
  .store-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ingredient-form .form-actions,
  .input-console-main .primary-button,
  .input-console-main .secondary-button,
  .store-form .form-actions,
  .recipe-form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding-inline: 12px;
  }

  .tab-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    gap: 14px;
    padding-top: 28px;
  }

  .hero-copy {
    margin-top: 10px;
  }

  .table-card,
  .import-panel,
  .summary-card,
  .action-strip {
    padding: 14px;
  }

  .action-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .ingredient-form,
  .store-form,
  .input-console-main,
  .purchase-input-row,
  .preview-pair,
  .draft-fields {
    grid-template-columns: 1fr;
  }

  .ingredient-form .form-actions,
  .input-console-main .primary-button,
  .input-console-main .secondary-button,
  .store-form .form-actions,
  .recipe-form-actions {
    grid-column: auto;
  }

  .material-drop-target,
  .purchase-input-row .receipt-drop-target {
    width: 100%;
  }
}
