:root {
  color-scheme: dark;
  --bg: #061733;
  --panel: #082A59;
  --panel-2: #0A3673;
  --ink: #F6EFDF;
  --muted: #F2EBDF;
  --muted-2: #C9D8EE;
  --line: #174C8F;
  --line-strong: #3587F2;
  --primary: #3587F2;
  --primary-strong: #084DA6;
  --primary-ink: #041226;
  --accent: #F2b07b;
  --accent-soft: #3A2C25;
  --danger: #F2b07b;
  --danger-strong: #C96F45;
  --danger-soft: #3A1F1D;
  --shadow: 0 18px 50px rgba(0, 0, 0, .34);
}

/* Professional light UI pass, loaded last to replace the old dark production theme. */
:root {
  color-scheme: light;
  --bg: #fbf7f1;
  --panel: #ffffff;
  --panel-2: #fffaf3;
  --ink: #2d2925;
  --muted: #74695f;
  --muted-2: #918479;
  --line: #eadfd4;
  --line-strong: #d7c8ba;
  --primary: #d96f52;
  --primary-strong: #bf563b;
  --primary-ink: #ffffff;
  --accent: #769f82;
  --accent-soft: #eef6ef;
  --danger: #b95c46;
  --danger-strong: #9f4935;
  --danger-soft: #fff1ed;
  --shadow: 0 18px 45px rgba(83, 61, 42, .10);
}

body {
  background:
    linear-gradient(180deg, #fffdf9 0, #fbf7f1 420px),
    #fbf7f1;
  color: var(--ink);
}

.app {
  width: min(100% - 28px, 1240px);
  padding: 20px 0 36px;
}

.topnav {
  top: 12px;
  gap: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 12px 30px rgba(83, 61, 42, .08);
}

.topnav a,
.logout-form span {
  color: var(--muted);
}

.topnav a:hover,
.topnav a.active {
  border-color: #efc8ba;
  background: #fff1eb;
  color: #8f432e;
}

.hero {
  min-height: 190px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .96), rgba(255, 248, 238, .96)),
    linear-gradient(90deg, rgba(217, 111, 82, .12), rgba(118, 159, 130, .10));
  box-shadow: var(--shadow);
  color: var(--ink);
}

.hero h1,
.hero h2,
.hero p,
.hero strong,
.section-title h2,
.section-title h3,
.recipes-head h2,
.detail-summary h2,
.recipe-section h3,
.listing-top h3,
.listing-meta strong,
.recipe-facts dd,
label {
  color: var(--ink);
}

.eyebrow,
.section-title span,
.status span,
.recipe-facts dt {
  color: var(--accent);
}

.subtitle,
.description,
.empty,
.tiktok-import p,
.backup-box p,
.listing-body p,
.ai-loading p {
  color: var(--muted);
}

.status,
.status.ready {
  border-color: var(--line);
  background: #fff6ee;
}

.notice {
  border-color: #d6ead9;
  background: #eff8f1;
  color: #355d3d;
}

.notice.error,
.helper-warning {
  border-color: #f0c8bb;
  background: var(--danger-soft);
  color: #8a3c2b !important;
}

.panel,
.composer,
.detail,
.recipe-results,
.auth-panel,
.modal-card,
.recipe-section,
.backup-box {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.tiktok-import,
.manual-create,
.recipe-section,
.backup-box {
  border-color: var(--line);
  background: var(--panel-2);
}

.tiktok-import {
  background:
    linear-gradient(135deg, rgba(217, 111, 82, .08), rgba(118, 159, 130, .08)),
    var(--panel-2);
}

.create-switch,
.optional-fields {
  border-color: var(--line);
  background: #f8efe6;
}

.create-switch a {
  color: var(--muted);
}

.create-switch a.active {
  border-color: #efc8ba;
  background: #ffffff;
  color: #8f432e;
  box-shadow: 0 8px 18px rgba(83, 61, 42, .08);
}

.optional-fields summary {
  color: #8f432e;
}

.optional-fields summary::after {
  background: #ffffff;
  color: #8f432e;
}

input,
select,
textarea,
.recipe-results input,
.recipe-results select,
.auth-panel input,
.auth-panel select,
.auth-panel textarea,
.recipe-search input,
.recipe-search select {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

input::placeholder,
textarea::placeholder,
.recipe-results input::placeholder,
.auth-panel input::placeholder,
.auth-panel textarea::placeholder {
  color: #aa9b8f;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #d96f52;
  box-shadow: 0 0 0 4px rgba(217, 111, 82, .14);
}

button,
.button-link {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 8px 18px rgba(217, 111, 82, .18);
}

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

.secondary-link,
button.secondary-button,
.import-recipe-button,
.source-link,
.icon-close {
  border: 1px solid #d8e8da;
  background: #f1f8f2;
  color: #3f714b;
  box-shadow: none;
}

.secondary-link:hover,
button.secondary-button:hover,
.import-recipe-button:hover,
.source-link:hover,
.icon-close:hover {
  background: #e2f0e5;
  color: #315b3b;
}

button.ghost {
  border: 1px solid #efc8ba;
  background: #fff1ed;
  color: #9a4935;
}

button.ghost:hover,
button.danger-button,
button.danger-button:hover {
  background: var(--danger-strong);
  color: #ffffff;
}

.ai-loading {
  border-color: #d8e8da;
  background: #f1f8f2;
  color: var(--ink);
}

.ai-spinner {
  border-color: rgba(217, 111, 82, .18);
  border-top-color: var(--primary);
}

.recipes-head,
.open-recipe,
.path,
.detail-content {
  border-color: var(--line);
}

.recipes-toolbar span,
.listing-meta span,
.recipe-facts div {
  border-color: var(--line);
  background: #fff7ef;
  color: var(--muted);
}

.listing-card {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 12px 30px rgba(83, 61, 42, .08);
}

.listing-card:hover,
.listing-card.active {
  border-color: #e7b4a4;
  background: #fffaf5;
  box-shadow: 0 18px 42px rgba(83, 61, 42, .12);
}

.listing-meta span:first-child {
  border-color: #d8e8da;
  background: #f1f8f2;
  color: #3f714b;
}

.listing-media,
.image-upload-surface,
.detail-media {
  background:
    linear-gradient(135deg, rgba(217, 111, 82, .16), rgba(118, 159, 130, .16)),
    #f6eadf;
}

.image-placeholder,
.image-upload-surface {
  color: var(--muted);
}

.open-recipe,
.back-link {
  color: #bf563b;
}

.detail {
  background: var(--panel);
}

.detail-summary {
  background: #ffffff;
  color: var(--ink);
}

.detail-content {
  background: #fbf7f1;
}

.ingredients-section {
  border-top: 3px solid #d96f52;
}

.steps-section {
  border-top: 3px solid #769f82;
}

.utensils-section {
  border-top: 3px solid #d8c0aa;
}

.notes {
  border-left-color: var(--accent);
  background: #eef6ef;
  color: #395f43;
}

.backup-box code {
  background: #f8efe6;
  color: var(--ink);
}

.backup-state {
  border-left-color: var(--accent);
  background: #eef6ef;
  color: #395f43;
}

.image-upload-hint,
.image-upload-surface:hover .image-upload-hint {
  border-color: rgba(255, 255, 255, .82);
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(83, 61, 42, .14);
}

.modal-backdrop {
  background: rgba(45, 41, 37, .38);
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 16px, 1240px);
  }

  .topnav {
    background: rgba(255, 255, 255, .96);
  }

  .listing-actions .open-recipe {
    border: 1px solid #efc8ba;
    background: #fff1eb;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(180deg, #041226 0%, var(--bg) 46%, #020A16 100%);
  background-size: 72px 72px, 72px 72px, auto;
  color: var(--ink);
}

.app {
  width: min(100% - 22px, 1320px);
  margin: 0 auto;
  padding: 12px 0 28px;
}

a {
  color: inherit;
}

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

h1 {
  margin-bottom: 14px;
  font-size: 2.35rem;
  line-height: .96;
}

h2 {
  margin-bottom: 0;
  font-size: 1.32rem;
  line-height: 1.1;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
  line-height: 1.2;
}

.topnav {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  padding: 7px;
  border: 1px solid rgba(53, 135, 242, .72);
  border-radius: 8px;
  background: rgba(4, 18, 38, .92);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  backdrop-filter: blur(18px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.topnav a {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.topnav a:hover,
.topnav a.active {
  border-color: rgba(53, 135, 242, .34);
  background: rgba(53, 135, 242, .11);
  color: var(--ink);
}

.logout-form {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.logout-form span {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero {
  display: grid;
  gap: 18px;
  overflow: hidden;
  position: relative;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(8, 42, 89, .96), rgba(10, 54, 115, .92)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 1px, transparent 1px 76px);
  box-shadow: var(--shadow);
}

.hero > * {
  position: relative;
  z-index: 1;
}

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

.subtitle,
.description,
.empty,
.tiktok-import p,
.backup-box p,
.listing-body p,
.ai-loading p {
  color: var(--muted);
  line-height: 1.58;
}

.subtitle {
  margin-bottom: 0;
  max-width: 700px;
  font-size: 1rem;
}

.status {
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(4, 18, 38, .74);
}

.status.ready {
  border-color: rgba(53, 135, 242, .36);
  background: rgba(53, 135, 242, .10);
}

.status span,
.section-title span {
  display: block;
  color: var(--muted-2);
  font-size: .78rem;
  font-weight: 850;
}

.status strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  word-break: break-word;
}

.notice {
  margin-top: 12px;
  border: 1px solid rgba(53, 135, 242, .34);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(53, 135, 242, .10);
  color: #F6EFDF;
  font-weight: 800;
}

.notice.error {
  border-color: rgba(242, 176, 123, .46);
  background: var(--danger-soft);
  color: #F2EBDF;
}

.workspace,
.recipe-columns,
.auth-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.workspace,
.auth-layout,
.recipe-index,
.recipe-detail-page {
  margin-top: 12px;
}

.workspace.with-key .composer {
  grid-column: 1 / -1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 42, 89, .96);
  box-shadow: var(--shadow);
}

.composer,
.detail,
.recipe-results {
  padding: 18px;
}

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

.stack {
  display: grid;
  gap: 13px;
}

.compact-stack textarea {
  min-height: 150px;
}

.compact-stack label:first-of-type input {
  min-height: 52px;
}

.create-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 16px 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #041226;
}

.create-switch a {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.create-switch a.active {
  border-color: rgba(53, 135, 242, .38);
  background: rgba(53, 135, 242, .14);
  color: #F6EFDF;
}

.create-options {
  display: grid;
  gap: 14px;
}

.tiktok-import,
.manual-create,
.recipe-section,
.backup-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.tiktok-import,
.manual-create {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.tiktok-import {
  border-color: rgba(53, 135, 242, .28);
  background:
    linear-gradient(135deg, rgba(53, 135, 242, .08), rgba(242, 176, 123, .06)),
    var(--panel-2);
}

.manual-create {
  border-color: rgba(242, 176, 123, .26);
}

.tiktok-import h3 {
  margin-bottom: 6px;
}

.tiktok-import textarea {
  min-height: 112px;
}

.optional-fields {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: rgba(4, 18, 38, .56);
}

.optional-fields summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  color: #F2b07b;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.optional-fields summary::-webkit-details-marker {
  display: none;
}

.optional-fields summary::after {
  content: "+";
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #F2b07b;
  font-size: 1rem;
  line-height: 1;
}

.optional-fields[open] {
  padding-bottom: 13px;
}

.optional-fields[open] summary::after {
  content: "-";
}

.optional-fields label,
.optional-fields .optional-grid {
  margin: 0 13px;
}

.optional-grid {
  display: grid;
  gap: 12px;
}

.ai-loading {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(53, 135, 242, .34);
  border-radius: 8px;
  padding: 13px;
  background: rgba(53, 135, 242, .09);
  color: var(--ink);
}

.ai-loading[hidden] {
  display: none;
}

.ai-loading strong {
  display: block;
  margin-bottom: 3px;
  font-size: .95rem;
}

.ai-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid rgba(53, 135, 242, .18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ai-spin .8s linear infinite;
}

.is-analyzing input,
.is-analyzing select,
.is-analyzing textarea {
  opacity: .68;
}

@keyframes ai-spin {
  to {
    transform: rotate(360deg);
  }
}

.helper-warning {
  border-left: 4px solid var(--danger);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  background: var(--danger-soft);
  color: #F2EBDF !important;
  font-weight: 850;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
}

.inline-check {
  display: flex;
  gap: 9px;
  align-items: center;
}

.inline-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #041226;
  color: var(--ink);
  font: inherit;
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: #9BBBE5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(53, 135, 242, .86);
  box-shadow: 0 0 0 4px rgba(53, 135, 242, .14);
}

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

button,
.button-link {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 12px 15px;
  background: var(--primary);
  color: var(--primary-ink);
  font: inherit;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

button {
  width: 100%;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.button-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.compact-button {
  min-height: 42px;
  padding: 10px 13px;
  font-size: .9rem;
}

.secondary-link,
button.secondary-button,
.import-recipe-button,
.source-link {
  border: 1px solid rgba(242, 176, 123, .34);
  background: var(--accent-soft);
  color: #F2b07b;
}

.secondary-link:hover,
button.secondary-button:hover,
.import-recipe-button:hover,
.source-link:hover {
  background: #5A3525;
}

button.ghost {
  border: 1px solid rgba(242, 176, 123, .45);
  background: var(--danger-soft);
  color: #F2EBDF;
}

button.ghost:hover,
button.danger-button,
button.danger-button:hover {
  background: var(--danger-strong);
  color: #F6EFDF;
}

.icon-action {
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.icon-action svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: currentColor;
}

.form-actions,
.detail-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.detail-actions form,
.form-actions {
  margin: 0;
}

.auth-panel {
  min-height: 100%;
}

.recipes-head {
  display: grid;
  gap: 12px;
  align-items: start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.recipes-head h2 {
  font-size: 1.9rem;
  line-height: 1.05;
}

.recipes-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: 100%;
}

.recipes-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.recipes-toolbar span,
.listing-meta span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  background: #061E40;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 800;
}

.recipe-search {
  margin-top: 16px;
  color: var(--ink);
}

.recipe-search input,
.recipe-search select {
  min-height: 48px;
  font-weight: 780;
}

.ideal-list {
  margin-top: 18px;
  display: grid;
  gap: 14px;
}

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

.listing-card {
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .20);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.listing-card[hidden],
.pagination[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.listing-card:hover,
.listing-card.active {
  transform: translateY(-3px);
  border-color: rgba(53, 135, 242, .54);
  background: #0B3B7D;
  box-shadow: 0 22px 45px rgba(0, 0, 0, .30);
}

.listing-media,
.image-upload-surface {
  background:
    linear-gradient(135deg, rgba(53, 135, 242, .14), rgba(242, 176, 123, .13)),
    #061A35;
}

.listing-media {
  height: 210px;
  min-height: 210px;
}

.listing-media img,
.detail-image,
.detail-media img,
.image-upload-surface img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.listing-media img {
  height: 100%;
  min-height: 210px;
  aspect-ratio: 4 / 3;
}

.image-placeholder {
  min-height: 210px;
  display: grid;
  place-items: center;
  color: #F6EFDF;
  font-weight: 900;
}

.listing-body {
  display: grid;
  gap: 11px;
  padding: 16px;
}

.listing-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.listing-top h3 {
  margin-bottom: 0;
  font-size: 1.2rem;
  line-height: 1.16;
}

.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.listing-meta span:first-child {
  border-color: rgba(53, 135, 242, .30);
  color: #F6EFDF;
}

.listing-meta strong {
  color: var(--ink);
}

.listing-actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.open-recipe {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: #F6EFDF;
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
}

.detail {
  margin-top: 0;
  overflow: hidden;
}

.recipe-detail-page .detail {
  padding: 0;
}

.empty.large {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  text-align: center;
}

.detail-hero {
  display: grid;
  gap: 0;
}

.detail-media {
  position: relative;
  height: 320px;
  min-height: 260px;
  background: #061A35;
}

.detail-media img {
  height: 100%;
  min-height: 260px;
  aspect-ratio: 16 / 9;
}

.image-upload-form {
  height: 100%;
  margin: 0;
}

.image-upload-surface {
  position: relative;
  height: 100%;
  min-height: 260px;
  display: grid;
  place-items: center;
  gap: 10px;
  color: #F6EFDF;
  font-weight: 900;
  cursor: pointer;
  overflow: hidden;
}

.image-upload-surface img {
  height: 100%;
  min-height: 260px;
  aspect-ratio: 16 / 9;
}

.image-upload-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  border: 1px solid rgba(53, 135, 242, .28);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(8, 77, 166, .88);
  color: #F6EFDF;
  text-align: center;
  font-size: .9rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .32);
}

.image-upload-surface:hover .image-upload-hint {
  background: rgba(53, 135, 242, .95);
  color: var(--primary-ink);
}

.image-upload-surface input,
.import-recipe-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.readonly-image {
  cursor: default;
}

.detail-summary {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.detail-summary h2 {
  font-size: 2rem;
  line-height: 1;
}

.back-link {
  width: fit-content;
  color: #F6EFDF;
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
}

.source-link {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
}

.recipe-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 0;
}

.recipe-facts div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #061E40;
}

.recipe-facts dt {
  margin-bottom: 4px;
  color: var(--muted-2);
  font-size: .73rem;
  font-weight: 850;
  text-transform: uppercase;
}

.recipe-facts dd {
  margin: 0;
  color: var(--ink);
  font-size: .95rem;
  font-weight: 900;
  word-break: break-word;
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
}

.recipe-section,
.backup-box {
  padding: 16px;
}

.section-title.compact {
  margin-bottom: 14px;
}

ul,
ol {
  margin: 0;
  padding-left: 1.25rem;
  line-height: 1.72;
}

li + li {
  margin-top: 7px;
}

.notes {
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 13px 15px;
  background: var(--accent-soft);
  color: #F2b07b;
  font-weight: 750;
  line-height: 1.58;
}

.backup-grid {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.backup-box code {
  display: block;
  margin: 10px 0 16px;
  padding: 12px;
  border-radius: 8px;
  background: #041226;
  color: var(--ink);
  white-space: normal;
  word-break: break-all;
}

.backup-state {
  margin-top: 14px;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  background: rgba(53, 135, 242, .10);
  color: #F6EFDF;
  font-weight: 800;
  line-height: 1.5;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.pagination span {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .70);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .52);
}

.icon-close {
  border: 1px solid var(--line);
  background: #041226;
  color: var(--ink);
}

.icon-close:hover {
  background: var(--panel-2);
}

@media (min-width: 700px) {
  .app {
    width: min(100% - 34px, 1320px);
    padding: 22px 0 34px;
  }

  .hero {
    grid-template-columns: 1fr auto;
    align-items: end;
    min-height: 210px;
    padding: 30px;
  }

  h1 {
    max-width: 760px;
    font-size: 4rem;
  }

  .subtitle {
    font-size: 1.06rem;
  }

  .section-title,
  .detail-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
  }

  .recipe-results,
  .composer {
    padding: 24px;
  }

  .recipes-head {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .recipes-actions {
    grid-template-columns: auto auto;
    width: auto;
  }

  button {
    width: auto;
  }

  .stack button {
    width: 100%;
  }

  .recipe-columns {
    grid-template-columns: minmax(240px, .75fr) minmax(300px, 1fr);
    gap: 24px;
  }

  .auth-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .detail-actions {
    grid-template-columns: repeat(4, minmax(0, max-content));
  }

  .form-actions {
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
  }

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

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

  .detail-media,
  .detail-media img,
  .image-upload-surface,
  .image-upload-surface img {
    height: 330px;
    min-height: 330px;
  }

  .detail-summary {
    align-content: center;
    padding: 24px;
  }

  .detail-content {
    grid-template-columns: minmax(260px, .75fr) minmax(320px, 1fr);
    padding: 18px;
  }

  .notes-section {
    grid-column: 1 / -1;
  }

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

  .listing-actions {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .optional-grid {
    grid-template-columns: 1fr 160px;
  }
}

@media (min-width: 980px) {
  .detail-hero {
    grid-template-columns: minmax(0, .95fr) minmax(0, 1fr);
  }

  .detail-media,
  .detail-media img,
  .image-upload-surface,
  .image-upload-surface img {
    height: 430px;
    min-height: 430px;
  }

  .detail-summary {
    padding: 34px;
  }

  .detail-summary h2 {
    font-size: 3.2rem;
  }
}

@media (min-width: 1120px) {
  .topnav {
    margin-bottom: 14px;
  }

  .workspace,
  .recipe-index,
  .recipe-detail-page {
    margin-top: 16px;
  }

  .workspace {
    gap: 16px;
    align-items: start;
  }

  .workspace.needs-key {
    grid-template-columns: minmax(250px, 330px) minmax(360px, 1fr) minmax(250px, 330px);
  }

  .workspace.with-key {
    grid-template-columns: minmax(420px, 1fr) minmax(280px, 360px);
  }

  .list-layout {
    margin-top: 16px;
    display: grid;
    grid-template-columns: minmax(520px, 1fr) minmax(360px, 520px);
    gap: 16px;
    align-items: start;
  }

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

  .recipe-results,
  .detail {
    min-height: 620px;
  }

  .recipe-results {
    padding: 28px;
  }

  .composer,
  .detail {
    padding: 22px;
  }

  .recipe-detail-page .detail {
    padding: 0;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 16px, 1320px);
    padding-bottom: 92px;
  }

  .topnav {
    position: fixed;
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    align-items: stretch;
    justify-content: space-between;
    margin: 0;
    padding: 6px;
  }

  .topnav a,
  .logout-form button {
    min-height: 48px;
    padding: 9px 10px;
    font-size: .82rem;
  }

  .logout-form {
    margin-left: 0;
  }

  .logout-form span {
    display: none;
  }

  .hero {
    gap: 12px;
    padding: 18px;
  }

  h1 {
    font-size: 1.9rem;
  }

  .subtitle {
    font-size: .94rem;
  }

  .status {
    display: none;
  }

  .composer,
  .recipe-results {
    padding: 14px;
  }

  .create-switch {
    position: sticky;
    top: 8px;
    z-index: 3;
  }

  input,
  select,
  textarea,
  button,
  .button-link {
    min-height: 48px;
  }

  .recipe-facts {
    grid-template-columns: 1fr;
  }

  .detail-actions,
  .listing-actions {
    grid-template-columns: 1fr;
  }
}

/* High-contrast palette pass: make the redesign unmistakable in production. */
.topnav {
  border-color: rgba(246, 239, 223, .22);
  background: #084DA6;
}

.topnav a {
  color: rgba(246, 239, 223, .78);
}

.topnav a:hover,
.topnav a.active {
  border-color: rgba(246, 239, 223, .70);
  background: #F6EFDF;
  color: #084DA6;
}

.hero {
  border-color: rgba(246, 239, 223, .16);
  background:
    linear-gradient(135deg, rgba(246, 239, 223, .98), rgba(242, 235, 223, .94)),
    linear-gradient(115deg, rgba(53, 135, 242, .18), transparent 52%);
  color: #084DA6;
}

.hero .subtitle,
.hero .status span {
  color: rgba(8, 77, 166, .72);
}

.hero h1,
.hero .status strong {
  color: #084DA6;
}

.hero .status {
  border-color: rgba(8, 77, 166, .18);
  background: rgba(53, 135, 242, .10);
}

.recipe-results,
.auth-panel,
.detail,
.modal-card,
.recipe-section,
.backup-box {
  border-color: rgba(246, 239, 223, .16);
}

.recipe-results,
.auth-panel {
  background: #F6EFDF;
  color: #061733;
}

.recipe-results .eyebrow,
.auth-panel .section-title span {
  color: #084DA6;
}

.recipe-results h2,
.auth-panel h2,
.recipe-results label,
.auth-panel label {
  color: #061733;
}

.recipe-results .empty,
.recipe-results .description,
.recipe-results .listing-body p,
.auth-panel .description {
  color: rgba(6, 23, 51, .72);
}

.recipe-results input,
.recipe-results select,
.auth-panel input,
.auth-panel select,
.auth-panel textarea {
  border-color: rgba(8, 77, 166, .22);
  background: #F2EBDF;
  color: #061733;
}

.recipe-results input::placeholder,
.auth-panel input::placeholder,
.auth-panel textarea::placeholder {
  color: rgba(8, 77, 166, .54);
}

.recipes-toolbar span,
.listing-meta span {
  border-color: rgba(8, 77, 166, .16);
  background: rgba(53, 135, 242, .10);
  color: #084DA6;
}

.listing-card {
  border-color: rgba(8, 77, 166, .16);
  background: #F2EBDF;
  color: #061733;
}

.listing-card:hover,
.listing-card.active {
  border-color: #3587F2;
  background: #F6EFDF;
}

.listing-top h3,
.listing-meta strong {
  color: #061733;
}

.listing-meta span:first-child {
  border-color: rgba(242, 176, 123, .70);
  background: rgba(242, 176, 123, .18);
  color: #084DA6;
}

.listing-media,
.image-placeholder {
  background:
    linear-gradient(135deg, rgba(8, 77, 166, .90), rgba(53, 135, 242, .82)),
    #084DA6;
  color: #F6EFDF;
}

.open-recipe {
  color: #084DA6;
}

.detail-summary {
  background: #F6EFDF;
  color: #061733;
}

.detail-summary h2,
.detail-summary .recipe-facts dd {
  color: #061733;
}

.detail-summary .description,
.detail-summary .recipe-facts dt {
  color: rgba(6, 23, 51, .68);
}

.recipe-facts div {
  border-color: rgba(8, 77, 166, .16);
  background: #F2EBDF;
}

.detail-content {
  background: #061733;
}

.recipe-section {
  background: #F6EFDF;
  color: #061733;
}

.recipe-section h3,
.recipe-section li {
  color: #061733;
}

.recipe-section .section-title span {
  color: rgba(8, 77, 166, .68);
}

.notes {
  background: rgba(242, 176, 123, .22);
  color: #061733;
}

/* Full app refresh, preserving the create recipe flow. */
body {
  background:
    radial-gradient(circle at 18% 0%, rgba(53, 135, 242, .20), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(242, 176, 123, .13), transparent 24%),
    linear-gradient(180deg, #041226 0%, #061733 48%, #020A16 100%);
}

.app {
  width: min(100% - 20px, 1180px);
}

.topnav {
  top: 10px;
  border-color: rgba(246, 239, 223, .10);
  background: rgba(4, 18, 38, .78);
  box-shadow: 0 14px 38px rgba(0, 0, 0, .28);
}

.topnav a {
  color: rgba(246, 239, 223, .72);
}

.topnav a:hover,
.topnav a.active {
  border-color: rgba(53, 135, 242, .72);
  background: #084DA6;
  color: #F6EFDF;
}

.hero {
  min-height: 190px;
  align-items: end;
  border-color: rgba(246, 239, 223, .10);
  background:
    linear-gradient(135deg, rgba(8, 77, 166, .92), rgba(4, 18, 38, .90)),
    linear-gradient(90deg, rgba(246, 239, 223, .08) 1px, transparent 1px);
  background-size: auto, 64px 64px;
}

.hero h1 {
  max-width: 760px;
}

.eyebrow {
  color: #F2b07b;
}

.status {
  border-color: rgba(242, 176, 123, .40);
  background: rgba(4, 18, 38, .56);
}

.notice {
  border-color: rgba(53, 135, 242, .42);
  background: rgba(8, 77, 166, .30);
  color: #F6EFDF;
}

.panel {
  border-color: rgba(246, 239, 223, .10);
  background: rgba(8, 42, 89, .82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

.auth-layout {
  align-items: stretch;
}

.auth-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.auth-panel:first-child {
  background:
    linear-gradient(145deg, rgba(8, 77, 166, .82), rgba(8, 42, 89, .88)),
    var(--panel);
}

.section-title span,
.status span,
.recipe-facts dt {
  color: rgba(242, 235, 223, .70);
}

.recipe-results {
  background: rgba(4, 18, 38, .66);
}

.recipes-head {
  gap: 16px;
  padding-bottom: 18px;
}

.recipes-head h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.recipes-actions {
  align-items: stretch;
}

.recipes-toolbar span,
.listing-meta span,
.recipe-facts div {
  border-color: rgba(246, 239, 223, .10);
  background: rgba(6, 30, 64, .74);
}

.recipe-search {
  margin-top: 12px;
}

.recipe-search input,
.recipe-search select {
  border-color: rgba(246, 239, 223, .12);
  background: rgba(4, 18, 38, .78);
}

.ideal-list {
  gap: 12px;
}

.listing-card {
  border-color: rgba(246, 239, 223, .10);
  background: rgba(10, 54, 115, .68);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
}

.listing-card:hover,
.listing-card.active {
  border-color: rgba(53, 135, 242, .72);
  background: rgba(8, 77, 166, .78);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .28);
}

.listing-media,
.image-upload-surface {
  background:
    linear-gradient(135deg, rgba(53, 135, 242, .22), rgba(242, 176, 123, .20)),
    #061A35;
}

.image-placeholder,
.image-upload-surface {
  color: #F6EFDF;
}

.listing-body {
  gap: 12px;
}

.listing-top h3 {
  font-size: 1.15rem;
}

.listing-meta span:first-child {
  border-color: rgba(242, 176, 123, .36);
  color: #F2b07b;
}

.open-recipe,
.back-link {
  color: #F2b07b;
}

.detail {
  background: rgba(4, 18, 38, .72);
}

.detail-media {
  background: #061A35;
}

.detail-summary {
  background:
    linear-gradient(145deg, rgba(8, 77, 166, .46), rgba(8, 42, 89, .18)),
    rgba(8, 42, 89, .72);
}

.detail-summary h2 {
  max-width: 780px;
}

.recipe-section,
.backup-box {
  border-color: rgba(246, 239, 223, .10);
  background: rgba(8, 42, 89, .72);
}

.ingredients-section {
  border-top: 3px solid #3587F2;
}

.steps-section {
  border-top: 3px solid #F2b07b;
}

.utensils-section {
  border-top: 3px solid #F6EFDF;
}

.notes {
  background: rgba(58, 44, 37, .72);
  color: #F2EBDF;
}

.source-link,
.secondary-link,
button.secondary-button,
.import-recipe-button {
  border-color: rgba(242, 176, 123, .42);
  background: rgba(58, 44, 37, .82);
  color: #F2b07b;
}

.source-link:hover,
.secondary-link:hover,
button.secondary-button:hover,
.import-recipe-button:hover {
  background: rgba(90, 53, 37, .96);
  color: #F6EFDF;
}

.image-upload-hint {
  border-color: rgba(246, 239, 223, .18);
  background: rgba(4, 18, 38, .86);
  color: #F6EFDF;
}

.image-upload-surface:hover .image-upload-hint {
  background: #3587F2;
  color: #041226;
}

.modal-card {
  border-color: rgba(246, 239, 223, .12);
  background: #082A59;
}

@media (min-width: 700px) {
  .auth-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .recipe-search {
    display: inline-grid;
    width: min(100%, 420px);
    margin-right: 8px;
    vertical-align: top;
  }

  .listing-card {
    grid-template-rows: auto 1fr;
  }
}

@media (min-width: 980px) {
  .recipe-detail-page {
    max-width: 1180px;
    margin-right: auto;
    margin-left: auto;
  }

  .detail-content {
    grid-template-columns: minmax(280px, .72fr) minmax(420px, 1fr);
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 14px, 1180px);
  }

  .topnav {
    border-color: rgba(246, 239, 223, .12);
  }

  .topnav a {
    display: grid;
    place-items: center;
    min-width: 0;
    white-space: normal;
    text-align: center;
  }

  .hero {
    min-height: 150px;
  }

  .recipe-results,
  .composer,
  .detail-summary,
  .detail-content {
    padding: 14px;
  }

  .listing-media,
  .listing-media img {
    height: 178px;
    min-height: 178px;
  }

  .listing-actions .open-recipe {
    display: grid;
    min-height: 48px;
    place-items: center;
    border: 1px solid rgba(242, 176, 123, .34);
    border-radius: 8px;
    background: rgba(58, 44, 37, .72);
  }

  .detail-media,
  .detail-media img,
  .image-upload-surface,
  .image-upload-surface img {
    height: 260px;
    min-height: 260px;
  }
}

/* Final light design override. Keep this block at EOF. */
:root {
  color-scheme: light;
  --bg: #fbf7f1;
  --panel: #ffffff;
  --panel-2: #fffaf3;
  --ink: #2d2925;
  --muted: #74695f;
  --muted-2: #918479;
  --line: #eadfd4;
  --line-strong: #d7c8ba;
  --primary: #d96f52;
  --primary-strong: #bf563b;
  --primary-ink: #ffffff;
  --accent: #769f82;
  --accent-soft: #eef6ef;
  --danger: #b95c46;
  --danger-strong: #9f4935;
  --danger-soft: #fff1ed;
  --shadow: 0 18px 45px rgba(83, 61, 42, .10);
}

body {
  background: linear-gradient(180deg, #fffdf9 0, #fbf7f1 420px), #fbf7f1 !important;
  color: var(--ink) !important;
}

.topnav {
  border-color: var(--line) !important;
  background: rgba(255, 255, 255, .94) !important;
  box-shadow: 0 12px 30px rgba(83, 61, 42, .08) !important;
}

.topnav a,
.logout-form span {
  color: var(--muted) !important;
}

.topnav a:hover,
.topnav a.active {
  border-color: #efc8ba !important;
  background: #fff1eb !important;
  color: #8f432e !important;
}

.hero,
.panel,
.composer,
.detail,
.recipe-results,
.auth-panel,
.modal-card,
.detail-summary,
.recipe-section,
.backup-box {
  border-color: var(--line) !important;
  background: var(--panel) !important;
  color: var(--ink) !important;
  box-shadow: var(--shadow) !important;
}

.hero {
  background: linear-gradient(135deg, #ffffff, #fff8ee) !important;
}

.tiktok-import,
.manual-create,
.recipe-section,
.backup-box {
  background: var(--panel-2) !important;
}

.tiktok-import {
  background: linear-gradient(135deg, rgba(217, 111, 82, .08), rgba(118, 159, 130, .08)), var(--panel-2) !important;
}

.hero h1,
.hero h2,
.hero p,
.hero strong,
.section-title h2,
.section-title h3,
.recipes-head h2,
.detail-summary h2,
.recipe-section h3,
.recipe-section li,
.listing-top h3,
.listing-meta strong,
.recipe-facts dd,
label {
  color: var(--ink) !important;
}

.eyebrow,
.section-title span,
.status span,
.recipe-facts dt {
  color: var(--accent) !important;
}

.subtitle,
.description,
.empty,
.tiktok-import p,
.backup-box p,
.listing-body p,
.ai-loading p {
  color: var(--muted) !important;
}

.status,
.status.ready,
.create-switch,
.optional-fields,
.recipes-toolbar span,
.listing-meta span,
.recipe-facts div,
.backup-box code {
  border-color: var(--line) !important;
  background: #fff7ef !important;
  color: var(--muted) !important;
}

input,
select,
textarea {
  border-color: var(--line) !important;
  background: #ffffff !important;
  color: var(--ink) !important;
}

input::placeholder,
textarea::placeholder {
  color: #aa9b8f !important;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 4px rgba(217, 111, 82, .14) !important;
}

button,
.button-link {
  background: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(217, 111, 82, .18) !important;
}

button:hover,
button:active,
.button-link:hover {
  background: var(--primary-strong) !important;
}

.secondary-link,
button.secondary-button,
.import-recipe-button,
.source-link,
.icon-close {
  border: 1px solid #d8e8da !important;
  background: #f1f8f2 !important;
  color: #3f714b !important;
  box-shadow: none !important;
}

.secondary-link:hover,
button.secondary-button:hover,
.import-recipe-button:hover,
.source-link:hover,
.icon-close:hover {
  background: #e2f0e5 !important;
  color: #315b3b !important;
}

button.ghost {
  border: 1px solid #efc8ba !important;
  background: #fff1ed !important;
  color: #9a4935 !important;
}

button.danger-button,
button.danger-button:hover {
  background: var(--danger-strong) !important;
  color: #ffffff !important;
}

.listing-card {
  border-color: var(--line) !important;
  background: #ffffff !important;
  color: var(--ink) !important;
  box-shadow: 0 12px 30px rgba(83, 61, 42, .08) !important;
}

.listing-card:hover,
.listing-card.active {
  border-color: #e7b4a4 !important;
  background: #fffaf5 !important;
}

.listing-meta span:first-child,
.ai-loading,
.notes,
.backup-state {
  border-color: #d8e8da !important;
  background: #f1f8f2 !important;
  color: #395f43 !important;
}

.listing-media,
.image-upload-surface,
.detail-media,
.image-placeholder {
  background: linear-gradient(135deg, rgba(217, 111, 82, .16), rgba(118, 159, 130, .16)), #f6eadf !important;
  color: var(--muted) !important;
}

.detail-content {
  background: #fbf7f1 !important;
}

.open-recipe,
.back-link {
  color: #bf563b !important;
}

.ingredients-section {
  border-top: 3px solid #d96f52 !important;
}

.steps-section {
  border-top: 3px solid #769f82 !important;
}

.utensils-section {
  border-top: 3px solid #d8c0aa !important;
}

.image-upload-hint,
.image-upload-surface:hover .image-upload-hint {
  border-color: rgba(255, 255, 255, .82) !important;
  background: rgba(255, 255, 255, .92) !important;
  color: var(--ink) !important;
  box-shadow: 0 10px 24px rgba(83, 61, 42, .14) !important;
}

.modal-backdrop {
  background: rgba(45, 41, 37, .38) !important;
}

.manual-grid {
  display: grid;
  gap: 16px;
}

.ai-text-import {
  border-color: #d8e8da !important;
  background: linear-gradient(135deg, #ffffff, #f3faf4) !important;
}

.ai-text-import textarea[name="recipe_text"] {
  min-height: 320px;
}

@media (min-width: 980px) {
  .manual-grid {
    grid-template-columns: minmax(320px, .85fr) minmax(420px, 1.15fr);
    align-items: start;
  }
}
