:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #edf2ee;
  --ink: #18211f;
  --muted: #68716d;
  --line: #dce2dd;
  --brand: #15322c;
  --accent: #e0644f;
  --gold: #f6c35b;
  --green: #4d8a70;
  --danger: #b93434;
  --shadow: 0 18px 45px rgba(21, 50, 44, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 13px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: #b9c8c0;
}

button.primary,
.button.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
}

button.danger {
  border-color: #efc1c1;
  color: var(--danger);
}

button.ghost {
  background: transparent;
}

button:disabled {
  cursor: wait;
  opacity: 0.55;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.94);
  padding: 14px 22px;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--brand);
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  padding: 7px 10px;
  font-size: 0.84rem;
  white-space: nowrap;
}

.status-pill.online {
  color: var(--green);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(0, 1fr);
  min-height: calc(100vh - 69px);
}

.library-pane {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  padding: 18px;
}

.detail-pane {
  min-width: 0;
  padding: 24px;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-row {
  display: flex;
  gap: 10px;
}

.toolbar-row input {
  min-width: 0;
}

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

.library-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.library-summary button {
  min-height: 34px;
  padding: 6px 10px;
}

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

.recipe-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
  text-align: left;
}

.recipe-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(21, 50, 44, 0.12);
}

.recipe-thumb,
.detail-image {
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(135deg, #15322c, #4d8a70 58%, #f6c35b);
}

.recipe-thumb {
  width: 72px;
  height: 72px;
}

.recipe-thumb img,
.detail-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.recipe-card h3,
.detail-header h1 {
  margin: 0;
  letter-spacing: 0;
}

.recipe-card h3 {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.8rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  border: 1px dashed #bec9c3;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.2rem;
}

.detail-card,
.auth-card,
.editor-card {
  max-width: 980px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-card,
.editor-card {
  overflow: hidden;
}

.detail-image {
  aspect-ratio: 16 / 7;
  border-radius: 0;
}

.detail-content {
  display: grid;
  gap: 22px;
  padding: 22px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.detail-header h1 {
  font-size: clamp(1.7rem, 4vw, 3.2rem);
  line-height: 1.05;
}

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

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 11px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat strong {
  display: block;
  margin-top: 4px;
}

.section {
  display: grid;
  gap: 10px;
}

.section h2 {
  margin: 0;
  font-size: 1.05rem;
}

.ingredients,
.steps {
  margin: 0;
  padding-left: 22px;
}

.ingredients li,
.steps li {
  margin: 7px 0;
}

.auth-wrap,
.match-placeholder {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.match-placeholder section {
  width: min(460px, 100%);
  padding: 24px;
}

.auth-card h1,
.match-placeholder h1 {
  margin: 0 0 10px;
  line-height: 1.08;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0;
}

.auth-tabs button[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

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

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

.form-columns.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.editor-card {
  padding: 22px;
}

.editor-card h1 {
  margin: 0;
}

.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.editor-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-section-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.ingredient-editor-list,
.step-editor-list {
  display: grid;
  gap: 10px;
}

.ingredient-editor-row,
.step-editor-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.ingredient-editor-row {
  grid-template-columns: minmax(74px, 0.45fr) minmax(84px, 0.5fr) minmax(160px, 1.5fr) minmax(120px, 1fr) auto;
  align-items: end;
}

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

.check-label {
  align-self: center;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--ink);
}

.check-label input {
  width: auto;
}

.step-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ingredient-editor-row .row-actions {
  grid-column: 1 / -1;
}

.row-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.tool-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 16px;
}

.tool-section h2 {
  margin: 0;
  font-size: 1.05rem;
}

.tool-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.message.error {
  color: var(--danger);
}

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

.match-page {
  min-height: calc(100vh - 69px);
  padding: 24px;
}

.match-panel {
  width: min(1040px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.match-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.match-panel-head h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1.05;
}

.match-select-list,
.results-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.match-select-row,
.result-row {
  display: grid;
  grid-template-columns: auto 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.match-select-row {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
}

.match-select-row input {
  width: 20px;
  height: 20px;
}

.result-row {
  grid-template-columns: 72px minmax(0, 1fr);
}

.result-row h2 {
  margin: 0;
  font-size: 1.05rem;
}

.result-row.everyone-match {
  border-color: var(--green);
  background: #f2faf5;
}

.share-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.swipe-shell {
  min-height: calc(100vh - 69px);
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto;
  background: #0c1614;
  color: #ffffff;
}

.swipe-card {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}

.swipe-card img,
.swipe-fallback {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.swipe-fallback {
  background: linear-gradient(135deg, #15322c, #4d8a70 58%, #f6c35b);
}

.swipe-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.86), rgba(0, 0, 0, 0.12) 62%, rgba(0, 0, 0, 0.35));
}

.swipe-overlay {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 10px;
  padding: 24px;
}

.swipe-overlay h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(2rem, 7vw, 5.6rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.swipe-overlay .recipe-meta,
.swipe-overlay .chip {
  color: #ffffff;
}

.swipe-overlay .chip,
.swipe-overlay .status-pill {
  border-color: rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.16);
}

.swipe-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  padding: 14px;
  background: #0c1614;
}

.swipe-controls button {
  min-height: 54px;
  border-radius: 999px;
}

.swipe-details {
  width: min(860px, calc(100% - 28px));
  margin: 0 auto 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 18px;
}

.swipe-details h2 {
  margin: 18px 0 8px;
}

@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .library-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-pane {
    padding: 16px;
  }

  .detail-header,
  .editor-head {
    display: grid;
  }

  .detail-actions,
  .editor-actions {
    justify-content: start;
  }

  .detail-grid,
  .form-columns,
  .form-columns.three,
  .ingredient-editor-row,
  .step-editor-row,
  .result-summary {
    grid-template-columns: 1fr;
  }

  .ingredient-editor-row .row-actions {
    grid-column: auto;
  }

  .match-panel-head,
  .share-box {
    display: grid;
  }

  .swipe-shell {
    grid-template-rows: minmax(58vh, 1fr) auto;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar-row,
  .library-summary {
    width: 100%;
  }

  .toolbar-row,
  .library-summary {
    display: grid;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  button,
  .button {
    width: 100%;
  }

  .check-label input {
    width: auto;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .recipe-card {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .recipe-thumb {
    width: 62px;
    height: 62px;
  }

  .match-page {
    padding: 14px;
  }

  .match-panel {
    padding: 14px;
  }

  .match-select-row,
  .result-row {
    grid-template-columns: auto 62px minmax(0, 1fr);
  }

  .result-row {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .swipe-controls {
    grid-template-columns: 1fr 1fr;
  }

  .swipe-controls button[data-action="toggle-details"] {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media print {
  @page {
    margin: 14mm;
  }

  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --ink: #111111;
    --muted: #444444;
    --line: #cccccc;
    font-size: 11pt;
  }

  body {
    background: #ffffff;
  }

  .topbar,
  .library-pane,
  .detail-actions,
  .status-pill,
  .source-link::after {
    display: none !important;
  }

  .layout {
    display: block;
    min-height: auto;
  }

  .detail-pane {
    padding: 0;
  }

  .detail-card {
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .detail-card,
  .editor-card {
    overflow: visible;
  }

  .detail-image {
    max-height: 72mm;
    border-radius: 0;
    page-break-after: avoid;
  }

  .detail-content {
    gap: 13px;
    padding: 0;
  }

  .detail-header {
    display: block;
    page-break-after: avoid;
  }

  .detail-header h1 {
    font-size: 24pt;
    line-height: 1.1;
  }

  .recipe-meta,
  .chip,
  .stat span,
  .stat strong {
    color: #111111;
  }

  .chip,
  .stat {
    border-color: #cccccc;
    background: #ffffff;
  }

  .detail-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    page-break-inside: avoid;
  }

  .detail-grid input {
    border: 0;
    padding: 0;
  }

  .section,
  .detail-grid,
  .source-link {
    break-inside: avoid;
  }

  a {
    color: #111111;
    text-decoration: none;
  }
}
