:root {
  --ink: #1c1f1b;
  --muted: #6d746b;
  --line: #dfe4dc;
  --paper: #fbfbf8;
  --surface: #ffffff;
  --green: #2f541a;
  --green-soft: #e7efdf;
  --tomato: #b44735;
  --amber: #b8872d;
  --blue: #3a6977;
  --shadow: 0 16px 40px rgba(28, 31, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #f4f1ec;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

button,
select {
  min-height: 38px;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--paper);
  padding: 22px 18px;
}

.brand-block {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark,
.empty-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--green);
  color: var(--green);
  border-radius: 50%;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-logo {
  display: block;
  border: 0;
  border-radius: 8px;
  object-fit: contain;
}

.empty-logo {
  width: 48px;
  height: 48px;
  display: block;
  margin: 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.brand-block h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand-block p,
.filter-section h2,
.summary-row span,
.recipe-card-meta,
.detail-meta,
.small-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.filter-section {
  margin-top: 24px;
}

.filter-section h2,
.auth-card h2 {
  margin-bottom: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.filter-list,
.chip-list {
  display: grid;
  gap: 8px;
}

.filter-button,
.tag-chip,
.tab,
.icon-button {
  border-radius: 8px;
}

.filter-button {
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.filter-button.active,
.tag-chip.active,
.tab.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.tag-chip {
  padding: 7px 9px;
  text-align: left;
}

.auth-card {
  margin-top: 26px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.auth-stack {
  display: grid;
  gap: 8px;
}

.auth-stack label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-stack .inline-check,
.photo-choice label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.auth-stack .inline-check input,
.photo-choice input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.auth-stack input {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  width: 100%;
}

.auth-stack button {
  border-radius: 8px;
  padding: 0 10px;
}

#authEmailDisplay {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.sync-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.workspace {
  min-width: 0;
  padding: 22px 24px;
}

.topbar {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.search-box {
  min-width: 220px;
  max-width: 560px;
  flex: 1;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.search-box svg {
  width: 18px;
  height: 18px;
  justify-self: center;
  color: var(--green);
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.search-box input {
  border: 0;
  outline: 0;
  min-height: 42px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
}

select,
.primary-button,
.toolbar button,
.dialog-actions button {
  border-radius: 8px;
  padding: 0 12px;
}

.primary-button {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.summary-row {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.summary-row div {
  min-height: 62px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
}

.summary-row strong {
  display: block;
  font-size: 22px;
  line-height: 1;
  color: var(--green);
}

.recipe-grid {
  display: block;
  column-width: 236px;
  column-gap: 16px;
}

.recipe-card {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 12px 28px rgba(28, 31, 27, 0.08);
}

.recipe-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-soft);
}

.recipe-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  background: linear-gradient(135deg, #e7efdf, #f8e7d2);
  display: block;
}

.recipe-card:nth-child(4n + 1) .recipe-image {
  aspect-ratio: 1 / 1;
}

.recipe-card:nth-child(4n + 2) .recipe-image {
  aspect-ratio: 5 / 6;
}

.recipe-card:nth-child(4n + 3) .recipe-image {
  aspect-ratio: 3 / 2;
}

.recipe-image.placeholder {
  display: grid;
  place-items: center;
  color: var(--green);
  font-size: 32px;
  font-weight: 900;
}

.recipe-card-body {
  display: grid;
  gap: 12px;
  padding: 13px;
}

.recipe-card h3 {
  font-size: 17px;
  line-height: 1.15;
}

.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.pill.review {
  background: #f7e9d0;
  color: #754f00;
}

.pill.accent {
  background: #f7ddd8;
  color: var(--tomato);
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: auto;
}

.card-actions button,
.card-actions a {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-decoration: none;
  font-size: 13px;
}

.heart-button {
  width: 34px;
  flex: 0 0 34px;
  display: inline-grid;
  place-items: center;
  color: var(--green);
}

.heart-button svg,
.action-button svg,
.icon-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.heart-button.favorite-on svg {
  fill: currentColor;
}

.card-actions .favorite-on,
.detail-actions .favorite-on {
  color: var(--tomato);
  border-color: #efc4bb;
  background: #fff4f2;
}

.action-button,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.icon-link span,
.action-button span {
  white-space: nowrap;
}

.icon-only {
  width: 34px;
  flex: 0 0 34px;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

.icon-only span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.detail-panel {
  border-left: 1px solid var(--line);
  background: var(--paper);
  padding: 22px;
  overflow: auto;
}

.empty-detail {
  min-height: 60vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
}

.recipe-detail {
  display: grid;
  gap: 16px;
}

.detail-hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.recipe-detail h2 {
  font-size: 28px;
  line-height: 1.05;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-actions a,
.detail-actions button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  text-decoration: none;
}

.detail-actions .heart-button {
  min-height: 38px;
}

.ready-action {
  border-color: var(--green) !important;
  color: var(--green) !important;
  background: var(--green-soft) !important;
}

.detail-section {
  display: grid;
  gap: 8px;
}

.detail-section h3 {
  color: var(--green);
  font-size: 14px;
  text-transform: uppercase;
}

.detail-section ul,
.detail-section ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.5;
}

.detail-note {
  border-left: 4px solid var(--amber);
  background: #fff8e8;
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
}

.hidden {
  display: none !important;
}

.import-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.import-dialog::backdrop {
  background: rgba(28, 31, 27, 0.38);
}

.dialog-shell {
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  background: var(--paper);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.dialog-header h2 {
  font-size: 22px;
}

.dialog-header p {
  color: var(--muted);
  font-size: 13px;
}

.help-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  padding: 0 10px;
  font-weight: 800;
}

.tab-panel {
  display: none;
  gap: 12px;
}

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

.photo-choice {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin: 0;
  background: var(--surface);
}

.photo-choice legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  border-radius: 8px;
  padding: 10px;
  text-transform: none;
}

textarea {
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: var(--paper);
}

.split-actions {
  justify-content: space-between;
}

.camera-frame {
  position: relative;
  min-height: 280px;
  background: #101410;
  border-radius: 8px;
  overflow: hidden;
}

.camera-frame video,
.camera-frame canvas {
  width: 100%;
  height: 280px;
  object-fit: cover;
  display: block;
}

.camera-frame canvas {
  display: none;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar,
  .workspace,
  .detail-panel {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .recipe-grid {
    column-width: auto;
    column-count: 1;
  }
}
