:root {
  --bg: #f7f3ea;
  --bg-ink: #ebe4d7;
  --surface: #fffdf8;
  --surface-alt: #f0f5ee;
  --surface-warm: #fff5e6;
  --text: #1f2924;
  --text-soft: #53605a;
  --muted: #788179;
  --border: #ddd4c4;
  --border-strong: #c9beab;
  --accent: #2f6f5e;
  --accent-strong: #214f43;
  --tomato: #c64b36;
  --amber: #d89a36;
  --shadow: 0 18px 45px rgba(45, 39, 30, 0.12);
  --shadow-soft: 0 10px 24px rgba(45, 39, 30, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --font-display: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --font-body: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(47, 111, 94, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(47, 111, 94, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  font-family: var(--font-body);
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(320px, 1fr);
  min-height: 100vh;
  padding: 40px;
  gap: 28px;
  align-items: center;
}

.login-panel,
.share-card,
.form-card,
.settings-card,
.preview-pane,
.detail-pane,
.sidebar {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.login-panel {
  padding: 34px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup.compact {
  gap: 10px;
}

.brand-lockup h1,
.brand-lockup strong {
  display: block;
  margin: 0;
  font-family: var(--font-display);
  font-size: 32px;
}

.brand-lockup.compact strong {
  font-size: 18px;
}

.brand-lockup.compact span:last-child {
  display: block;
  max-width: 160px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  flex: 0 0 auto;
  background: var(--accent);
  border: 2px solid var(--accent-strong);
  border-radius: var(--radius);
  color: #fffaf0;
  font-size: 23px;
  font-weight: 900;
}

.login-copy {
  max-width: 34rem;
  margin: 22px 0;
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1.75;
}

.login-form,
.form-card {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fffefa;
  color: var(--text);
  outline: none;
}

input {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 11px 12px;
  line-height: 1.65;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.15);
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.form-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 15px;
  font-weight: 800;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.button svg,
.nav-button svg,
.mobile-nav svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.button:hover,
.recipe-card:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  color: #fffaf0;
}

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

.button.secondary {
  border-color: var(--border-strong);
  background: var(--surface-warm);
  color: var(--text);
}

.button.ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text-soft);
}

.button.wide {
  width: 100%;
}

.login-preview {
  position: relative;
  min-height: 520px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 26% 20%, rgba(198, 75, 54, 0.16), transparent 34%),
    linear-gradient(145deg, rgba(47, 111, 94, 0.18), rgba(216, 154, 54, 0.18)),
    var(--bg-ink);
  overflow: hidden;
}

.preview-card {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.preview-card.large {
  width: min(72%, 420px);
  left: 12%;
  top: 16%;
  padding: 28px;
}

.preview-card.large h2 {
  margin: 12px 0;
  font-size: 31px;
}

.preview-card.large p {
  margin: 8px 0;
  color: var(--text-soft);
}

.preview-card.small {
  right: 9%;
  bottom: 15%;
  display: grid;
  gap: 8px;
  width: min(44%, 260px);
  padding: 18px;
}

.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) minmax(300px, 380px);
  min-height: 100vh;
  gap: 16px;
  padding: 16px;
}

.sidebar {
  position: sticky;
  top: 16px;
  display: flex;
  height: calc(100vh - 32px);
  flex-direction: column;
  padding: 18px;
}

.side-nav {
  display: grid;
  gap: 8px;
  margin: 28px 0;
}

.nav-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-weight: 800;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  border-color: rgba(47, 111, 94, 0.18);
  background: var(--surface-alt);
  color: var(--accent-strong);
}

.side-panel {
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fffaf0;
}

.stat-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-list div {
  display: grid;
  gap: 3px;
}

.stat-list strong {
  font-size: 24px;
}

.stat-list span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding-bottom: 72px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 4px 0 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 34px;
}

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

.search-box {
  position: relative;
  display: block;
  width: min(360px, 40vw);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 13px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-box input {
  padding-left: 40px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.chip,
.tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

.chip {
  min-height: 36px;
  padding: 0 14px;
}

.chip.active,
.chip:hover {
  border-color: rgba(47, 111, 94, 0.24);
  background: var(--accent);
  color: #fffaf0;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
}

.tag.green {
  border-color: rgba(47, 111, 94, 0.24);
  background: #e6f1ec;
  color: var(--accent-strong);
}

.tag.red {
  border-color: rgba(198, 75, 54, 0.24);
  background: #fae8e2;
  color: #8c2f21;
}

.tag.amber {
  border-color: rgba(216, 154, 54, 0.26);
  background: #fff1d3;
  color: #825b12;
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.recipe-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease;
}

.recipe-card.selected,
.recipe-card:hover {
  border-color: var(--accent);
}

.recipe-card button {
  display: grid;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.card-cover,
.detail-cover,
.share-cover,
.generated-cover {
  display: grid;
  min-height: 154px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(47, 111, 94, 0.22), rgba(216, 154, 54, 0.28)),
    #efe4d3;
}

.card-cover img,
.detail-cover img,
.share-cover img {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
}

.cover-letter {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  border: 2px solid rgba(31, 41, 36, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.64);
  color: var(--accent-strong);
  font-size: 35px;
  font-weight: 900;
}

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

.card-body h2,
.detail-content h2,
.settings-card h2,
.form-head h2,
.share-body h1 {
  margin: 0;
}

.card-body h2 {
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.meta-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.meta-row {
  color: var(--muted);
  font-size: 13px;
}

.card-ingredients {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.detail-pane {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  overflow: auto;
}

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

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

.detail-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.detail-title-row h2 {
  font-size: 26px;
  line-height: 1.25;
}

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

.section-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  background: #fffaf0;
}

.section-box h3,
.share-body h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

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

.ingredient-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.ingredient-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ingredient-item strong {
  overflow-wrap: anywhere;
}

.step-list {
  margin: 0;
  padding-left: 22px;
}

.step-list li {
  margin: 0 0 10px;
  line-height: 1.72;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.form-card,
.preview-pane {
  padding: 18px;
}

.form-head,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

.tag-field {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0;
  padding: 14px;
}

.tag-field legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tag-field label {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
}

.tag-field input {
  width: 16px;
  min-height: 16px;
}

.ai-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 12px;
}

.ai-box summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-strong);
  font-weight: 900;
  cursor: pointer;
}

.ai-box label {
  margin-top: 14px;
}

.ai-box .button {
  margin-top: 10px;
}

.preview-pane {
  position: sticky;
  top: 16px;
  height: max-content;
}

.recipe-card.preview {
  min-height: 320px;
  box-shadow: none;
}

.nutrition-box {
  display: grid;
  gap: 5px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-warm);
}

.nutrition-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nutrition-box strong {
  font-size: 18px;
}

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

.settings-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.copy-block {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fffaf0;
}

.copy-block span {
  color: var(--muted);
  font-size: 12px;
}

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

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.75);
  padding: 28px;
  text-align: center;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--accent);
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

.empty-state p {
  max-width: 430px;
  color: var(--text-soft);
  line-height: 1.7;
}

.share-screen {
  min-height: 100vh;
  padding: 24px;
}

.share-card {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  max-width: 980px;
  margin: 32px auto;
  overflow: hidden;
}

.share-cover {
  min-height: 520px;
}

.share-body {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.share-body h1 {
  font-size: 38px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid rgba(31, 41, 36, 0.16);
  border-radius: var(--radius);
  background: #1f2924;
  color: #fffaf0;
  box-shadow: var(--shadow);
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(14px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav {
  display: none;
}

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

  .detail-pane {
    display: none;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    position: static;
  }
}

@media (max-width: 820px) {
  body {
    background-size: 24px 24px;
  }

  .login-screen {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .login-preview {
    min-height: 240px;
  }

  .preview-card.large {
    left: 18px;
    top: 18px;
    width: calc(100% - 68px);
    padding: 18px;
  }

  .preview-card.small {
    right: 18px;
    bottom: 18px;
    width: calc(100% - 110px);
  }

  .app {
    display: block;
    padding: 12px 12px 82px;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .search-box {
    width: 100%;
  }

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

  .view.active {
    max-height: calc(100vh - 330px);
    overflow: auto;
    padding-bottom: 14px;
  }

  #editorView.view.active,
  #accountView.view.active {
    max-height: calc(100vh - 250px);
  }

  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .form-head,
  .form-actions,
  .detail-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .share-card {
    grid-template-columns: 1fr;
    margin: 0;
  }

  .share-cover {
    min-height: 260px;
  }

  .mobile-nav {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 10;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 253, 248, 0.96);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .mobile-nav button {
    display: grid;
    min-height: 48px;
    place-items: center;
    gap: 3px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 900;
  }

  .mobile-nav button.active {
    background: var(--surface-alt);
    color: var(--accent-strong);
  }
}

@media (max-width: 420px) {
  .login-panel,
  .form-card,
  .preview-pane,
  .settings-card,
  .share-body {
    padding: 16px;
  }

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

  .top-actions .button {
    width: 100%;
  }

  .card-cover {
    min-height: 180px;
  }
}
