:root {
  color-scheme: light;
  --page: #f3ead8;
  --app: #fff9ec;
  --surface: #fffdf7;
  --surface-soft: #fff4dc;
  --text: #2d2417;
  --muted: #766a58;
  --line: #ead9ba;
  --line-strong: #dec597;
  --accent: #d8951e;
  --accent-dark: #9f6710;
  --accent-soft: #ffe4ad;
  --danger: #b8582b;
  --shadow: 0 22px 60px rgba(121, 86, 29, 0.16);
  --soft-shadow: 0 10px 28px rgba(121, 86, 29, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 224, 151, 0.8), transparent 28rem),
    linear-gradient(150deg, #fff8e8 0%, #f0eadc 55%, #fff4dd 100%);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Microsoft YaHei",
    sans-serif;
}

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

.file-input {
  display: none;
}

button {
  border: 0;
  cursor: pointer;
}

.phone-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 88px;
  background: rgba(255, 249, 236, 0.94);
  box-shadow: var(--shadow);
}

.app-header,
.editor-title-row,
.menu-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header {
  padding: 6px 2px 16px;
}

.startup-error {
  margin-bottom: 12px;
  border: 1px solid #e7b490;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--danger);
  background: #fff1e8;
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 16px;
  color: #533707;
  background: #fff4d8;
  box-shadow: var(--soft-shadow);
  font-size: 14px;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.brand-title {
  display: inline-block;
  color: #2c2113;
  font-size: 31px;
  font-weight: 950;
  line-height: 1.05;
  text-shadow:
    2px 2px 0 #ffd36a,
    4px 4px 0 rgba(164, 104, 12, 0.18);
  transform: skew(-4deg);
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  font-size: 20px;
}

.bottom-tabs,
.segmented {
  display: grid;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.78);
}

.bottom-tabs {
  grid-template-columns: repeat(4, 1fr);
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  width: min(calc(100% - 28px), 398px);
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
  box-shadow: 0 14px 34px rgba(121, 86, 29, 0.16);
}

.segmented {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 16px;
}

.tab,
.segment {
  min-height: 40px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.bottom-tabs .tab {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 48px;
  font-size: 12px;
}

.bottom-tabs .tab span {
  font-size: 17px;
  line-height: 1;
}

.bottom-tabs .import-tab {
  color: #fffaf0;
  background: var(--accent);
}

.tab.active,
.segment.active {
  color: #fffaf0;
  background: var(--accent);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.tab:active,
.segment:active,
.primary-button:active,
.secondary-button:active,
.chip:active,
.food-type:active,
.recipe-card:active,
.menu-item:active {
  transform: scale(0.985);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  margin-bottom: 16px;
}

.compact-heading {
  margin-bottom: 12px;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.input-label {
  display: block;
  margin: 14px 0 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

input,
select {
  height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 149, 30, 0.16);
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 900;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.primary-button {
  color: #fffaf0;
  background: linear-gradient(180deg, #e1a33a, #c98412);
  box-shadow: 0 10px 22px rgba(177, 114, 16, 0.2);
}

.secondary-button,
.back-button {
  color: var(--accent-dark);
  border: 1px solid var(--line-strong);
  background: #fff7e8;
}

.small {
  min-height: 38px;
  padding-inline: 14px;
}

.full {
  width: 100%;
  margin-top: 16px;
}

.import-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 18px;
}

.recipe-editor,
.recipe-card,
.menu-result,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--soft-shadow);
}

.recipe-editor {
  padding: 16px;
}

.hidden {
  display: none;
}

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

.two-col,
.planner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  color: #6d4a0d;
  background: #fff0cf;
  font-size: 12px;
  font-weight: 850;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.search-box span {
  color: var(--muted);
  font-size: 22px;
}

.search-box input {
  border: 0;
  box-shadow: none;
}

.chip-row,
.preset-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 9px;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 13px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.chip.active {
  border-color: #d6a849;
  color: #533707;
  background: var(--accent-soft);
}

.food-type-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 4px;
}

.food-type {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--soft-shadow);
  font-weight: 900;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.food-type.active,
.food-type:focus-visible {
  border-color: var(--accent);
  background: #fff2cc;
  outline: none;
}

.home-step,
.home-options {
  display: none;
}

.lucky-button {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 118px;
  margin-top: 14px;
  border: 1px solid #e8ca8f;
  border-radius: 18px;
  padding: 22px;
  color: #4d3306;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.72), transparent 6rem),
    linear-gradient(135deg, #ffe9ad, #f2b94d);
  box-shadow: 0 18px 38px rgba(177, 114, 16, 0.2);
  text-align: left;
}

.lucky-button span {
  color: #7a5816;
  font-size: 14px;
  font-weight: 850;
}

.lucky-button strong {
  font-size: 28px;
  letter-spacing: 0;
}

.home-step.active,
.home-options.active {
  display: block;
}

.meal-count-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

#noodleOptions .meal-count-line,
#fillingOptions .meal-count-line {
  grid-template-columns: 1fr;
}

.inline-count {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

.inline-count input {
  height: 40px;
  border: 0;
  padding: 0;
  box-shadow: none;
  background: transparent;
}

.inline-count:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 149, 30, 0.16);
}

.recipe-list {
  display: grid;
  gap: 12px;
  min-height: 190px;
}

.empty-state {
  display: grid;
  gap: 10px;
  place-items: center;
  min-height: 190px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 22px;
  color: var(--muted);
  background: rgba(255, 253, 247, 0.58);
  text-align: center;
}

.empty-state p {
  margin-bottom: 0;
}

.empty-emoji {
  font-size: 34px;
}

.recipe-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  padding: 14px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.recipe-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  color: #fffaf0;
  font-size: 20px;
  font-weight: 950;
}

.mark-hot {
  background: #d66b3d;
}

.mark-sour {
  background: #d6a22a;
}

.mark-light {
  background: #8ba96a;
}

.mark-rich {
  background: #a56d2f;
}

.mark-fresh {
  background: #c98f2d;
}

.recipe-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 149, 30, 0.16);
  outline: none;
}

.recipe-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  min-width: 0;
}

.recipe-card h3 {
  margin: 0 0 5px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recipe-card .tag-row {
  grid-column: 2;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.recipe-card .tag {
  flex: 0 0 auto;
}

.card-image-row,
.image-picker-row,
.image-preview-list,
.detail-image-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.image-picker-row {
  align-items: center;
  margin-top: 8px;
}

.image-add-box {
  flex: 0 0 auto;
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 253, 247, 0.62);
  font-size: 34px;
  line-height: 1;
}

.card-image-row {
  margin-top: 8px;
}

.card-image-row img {
  width: 72px;
  height: 54px;
  border-radius: 10px;
  object-fit: cover;
}

.image-preview-list {
  min-height: 72px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.image-preview-list img,
.detail-image-row img {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
}

.image-preview-item {
  position: relative;
  flex: 0 0 auto;
}

.image-preview-item button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--muted);
  background: #fff3dd;
  font-weight: 900;
  box-shadow: var(--soft-shadow);
}

.detail-image-row {
  margin-top: 12px;
}

.delete-button {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--muted);
  background: #fff3dd;
  font-size: 18px;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--text);
  font-weight: 800;
}

.toggle-line input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

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

.tiny {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 13px;
}

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

.ingredient-row {
  display: grid;
  grid-template-columns: 1fr 1fr 34px;
  gap: 8px;
  align-items: center;
}

.step-editor-head {
  margin-top: 4px;
}

.step-list-editor {
  display: grid;
  gap: 8px;
}

.step-row {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
  align-items: start;
}

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

.step-input {
  min-height: 68px;
  border: 0;
  border-radius: 0;
  padding: 2px 0 8px;
  background: transparent;
  box-shadow: none;
}

.step-input:focus {
  box-shadow: none;
}

.step-image-row,
.step-image-preview,
.step-detail-images {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.step-image-row {
  align-items: center;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.step-image-add {
  flex: 0 0 auto;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 253, 247, 0.62);
  font-size: 24px;
  font-weight: 900;
}

.step-image-preview img,
.step-detail-images img {
  width: 64px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}

.step-detail-images {
  margin-top: 8px;
}

.step-add-bar {
  display: grid;
  width: 100%;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-dark);
  background: var(--surface);
  font-size: 24px;
  font-weight: 900;
}

.menu-result {
  min-height: 110px;
  margin-top: 16px;
  padding: 14px;
}

.menu-result.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  box-shadow: none;
}

.menu-title {
  margin-bottom: 12px;
}

.menu-item-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.menu-item-row:first-of-type {
  border-top: 0;
}

.menu-item {
  display: block;
  width: 100%;
  padding: 12px 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  transition: transform 0.15s ease;
}

.menu-item strong {
  display: block;
  margin-bottom: 4px;
}

.reroll-menu-item {
  width: 36px;
  height: 32px;
  border-radius: 999px;
  color: #6d4a0d;
  background: #fff0cf;
  font-size: 13px;
  font-weight: 900;
}

.menu-item span {
  color: var(--muted);
  font-size: 13px;
}

.back-button {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 12px;
  font-weight: 900;
}

.compact-back {
  margin-bottom: 10px;
}

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

.detail-actions .secondary-button {
  min-height: 40px;
}

.detail-panel {
  overflow: hidden;
}

.detail-head {
  padding: 18px 16px 14px;
  background: linear-gradient(135deg, #fff2d1, #fffaf0);
}

.detail-head h2 {
  margin-bottom: 12px;
  font-size: 26px;
}

.detail-section {
  padding: 16px;
  border-top: 1px solid var(--line);
}

.detail-section h3 {
  margin-bottom: 10px;
}

.detail-section p,
.step-list li {
  color: var(--muted);
  line-height: 1.7;
}

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

.ingredient-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.ingredient-detail-row:first-child {
  border-top: 0;
}

.ingredient-detail-row strong {
  font-size: 15px;
}

.ingredient-detail-row span {
  color: var(--muted);
  text-align: right;
}

.step-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
    padding: 28px;
  }

  .phone-shell {
    min-height: 860px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 28px;
  }
}

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

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

  .two-col,
  .planner-grid,
  .import-actions,
  .ingredient-row,
  .step-row,
  .meal-count-line {
    grid-template-columns: 1fr;
  }
}
