/* ---------- 设计变量（浅色） ---------- */
:root,
[data-theme="light"] {
  --bg-page: linear-gradient(160deg, #fef8f3 0%, #f5ebe0 50%, #f0e6dc 100%);
  --bg-card: #fffbf7;
  --bg-card-hover: #fff;
  --accent: #c45c3e;
  --accent-soft: #e8a88a;
  --accent-dark: #a04a32;
  --text: #2d2a26;
  --text-muted: #6b6560;
  --border: rgba(196, 92, 62, 0.2);
  --shadow: 0 2px 12px rgba(45, 42, 38, 0.06);
  --shadow-hover: 0 6px 24px rgba(45, 42, 38, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Microsoft YaHei", "微软雅黑", "PingFang SC", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 0.2s;
  --duration-normal: 0.35s;
  --input-bg: #fff;
  --placeholder: #aaa;
}

/* ---------- 深色模式 ---------- */
[data-theme="dark"] {
  --bg-page: linear-gradient(160deg, #1a1816 0%, #252220 50%, #2d2a26 100%);
  --bg-card: #2d2a26;
  --bg-card-hover: #363330;
  --accent: #e08b6a;
  --accent-soft: #c45c3e;
  --accent-dark: #e8a88a;
  --text: #f0e6dc;
  --text-muted: #a8a09a;
  --border: rgba(224, 139, 106, 0.25);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 6px 24px rgba(0, 0, 0, 0.4);
  --input-bg: #363330;
  --placeholder: #7a7570;
}

[data-theme="dark"] .dialog select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a8a09a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

[data-theme="dark"] .dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

/* ---------- 关键帧动画 ---------- */
@keyframes itemIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes itemOut {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes backdropIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes emptyPulse {

  0%,
  100% {
    opacity: 0.92;
  }

  50% {
    opacity: 1;
  }
}

@keyframes headerIn {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes searchBarIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes addBtnGlow {

  0%,
  100% {
    box-shadow: var(--shadow);
  }

  50% {
    box-shadow: 0 0 0 4px rgba(196, 92, 62, 0.2), var(--shadow);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

body.loaded .header {
  animation: headerIn 0.5s var(--ease-out) backwards;
}

body.loaded .search-bar {
  animation: searchBarIn 0.5s var(--ease-out) 0.08s backwards;
}

body.loaded .actions {
  animation: searchBarIn 0.5s var(--ease-out) 0.12s backwards;
}

body.loaded .list-section {
  animation: searchBarIn 0.5s var(--ease-out) 0.16s backwards;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  box-sizing: border-box;
}

/* ---------- 页头 ---------- */
.header {
  position: relative;
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  padding-right: 200px;
  border-bottom: 2px solid var(--border);
  box-sizing: border-box;
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.theme-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: rgba(196, 92, 62, 0.12);
  color: var(--accent-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: background var(--duration-fast), transform var(--duration-fast);
}

.theme-toggle:hover {
  background: rgba(196, 92, 62, 0.22);
  transform: scale(1.05);
}

[data-theme="dark"] .theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-moon {
  display: inline;
}

.theme-icon-moon {
  display: none;
}

.theme-icon-sun {
  display: inline;
}

.header h1::before {
  content: "🍳 ";
}

/* 多用户：当前用户、退出、深浅色切换 — 统一在右侧一排，不重叠 */
.header-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.current-user {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.btn-logout:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 登录/注册面板（多用户） ---------- */
.auth-panel {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 32px;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-title {
  margin: 0 0 8px;
  font-size: 1.5rem;
  color: var(--text);
  text-align: center;
}

.auth-subtitle {
  margin: 0 0 24px;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.95rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.auth-tab-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.auth-form label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text);
}

.auth-form label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  box-sizing: border-box;
}

.auth-form label input::placeholder {
  color: var(--placeholder);
}

.btn-auth-submit {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background var(--duration-fast), opacity var(--duration-fast);
}

.btn-auth-submit:hover {
  background: var(--accent-dark);
}

.btn-auth-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-error {
  margin: 12px 0 0;
  padding: 10px;
  font-size: 0.85rem;
  color: #c0392b;
  background: rgba(192, 57, 43, 0.1);
  border-radius: var(--radius-sm);
}

[data-theme="dark"] .auth-error {
  background: rgba(192, 57, 43, 0.2);
}

/* ---------- 搜索区 ---------- */
.search-bar {
  margin-bottom: 24px;
  padding: 20px 22px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow var(--duration-fast) var(--ease-out);
}

.search-main-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.search-bar:focus-within {
  box-shadow: 0 0 0 2px rgba(196, 92, 62, 0.15), var(--shadow);
}

/* 焦点环：仅键盘聚焦时显示，更明显的可访问性样式 */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent);
}

.search-bar input[type="text"]:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent);
}

.search-type {
  display: flex;
  gap: 16px;
}

.search-type label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.search-type label:hover {
  color: var(--text);
}

.search-type input {
  accent-color: var(--accent);
}

.search-main-row .search-type {
  flex-shrink: 0;
}

.search-bar .search-input-name {
  flex: 1;
  min-width: 140px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input[type="text"]::placeholder {
  color: var(--placeholder);
}

.search-bar input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(196, 92, 62, 0.12);
}

.search-category-filter {
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.search-category-filter .filter-group {
  flex: 1;
  min-width: 180px;
}

.search-category-filter .filter-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.search-category-filter .filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.search-category-filter .filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.search-category-filter .filter-checkbox input {
  accent-color: var(--accent);
}

#searchBtn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast);
}

#searchBtn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 92, 62, 0.35);
}

#searchBtn:active {
  transform: translateY(0) scale(0.98);
}

/* ---------- 添加按钮 ---------- */
.btn-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  transition: background var(--duration-fast), box-shadow var(--duration-normal), transform var(--duration-fast) var(--ease-out);
}

.btn-add:hover {
  background: var(--accent-dark);
  box-shadow: 0 6px 20px rgba(196, 92, 62, 0.4);
  transform: translateY(-2px);
  animation: addBtnGlow 2s var(--ease-in-out) infinite;
}

.btn-add:active {
  transform: translateY(0) scale(0.98);
  animation: none;
}

.btn-add::before {
  content: "+";
  font-size: 1.2em;
  font-weight: 600;
  line-height: 1;
}

/* ---------- 列表区 ---------- */
.list-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.list-section-head h2 {
  margin: 0;
}

.list-section h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-count {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.search-category-filter .btn-clear-filter {
  flex: 1 1 100%;
  margin-top: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  background: rgba(45, 42, 38, 0.06);
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.search-category-filter .btn-clear-filter:hover {
  background: rgba(45, 42, 38, 0.1);
  color: var(--text);
}

/* 操作区：与搜索区明确分区，主操作更突出 */
.actions {
  margin-bottom: 28px;
  padding: 24px 0 0;
  border-top: 2px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.actions-primary {
  flex-shrink: 0;
}

.actions-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-secondary {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(196, 92, 62, 0.08);
  border-color: var(--accent-soft);
  color: var(--text);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.recipe-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recipe-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: background var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast) var(--ease-out), opacity var(--duration-normal), margin var(--duration-normal);
  animation: itemIn var(--duration-normal) var(--ease-out) backwards;
}

.recipe-list li:nth-child(1) {
  animation-delay: 0.02s;
}

.recipe-list li:nth-child(2) {
  animation-delay: 0.06s;
}

.recipe-list li:nth-child(3) {
  animation-delay: 0.1s;
}

.recipe-list li:nth-child(4) {
  animation-delay: 0.14s;
}

.recipe-list li:nth-child(5) {
  animation-delay: 0.18s;
}

.recipe-list li:nth-child(n+6) {
  animation-delay: 0.22s;
}

.recipe-list li:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-hover);
  border-color: rgba(196, 92, 62, 0.3);
  transform: translateY(-2px);
}

.recipe-list li.removing {
  animation: itemOut 0.3s var(--ease-in-out) forwards;
  pointer-events: none;
}

.recipe-list .item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.recipe-list .item-star {
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  user-select: none;
  transition: color var(--duration-fast);
}

.recipe-list .item-star:hover {
  color: var(--accent);
}

.recipe-list .item-star.is-favorite {
  color: var(--accent);
}

.recipe-list .item-shopping {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.recipe-list .item-shopping input {
  margin: 0;
  accent-color: var(--accent);
}

.recipe-list .name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.recipe-list .item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.recipe-list .item-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(196, 92, 62, 0.12);
  color: var(--accent-dark);
}

.recipe-list .item-tag.tag-category {
  background: rgba(180, 140, 80, 0.2);
  color: #7a6235;
}

.recipe-list .btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.recipe-list .btns button {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--duration-fast), transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast);
}

.recipe-list .btns button:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.recipe-list .btns button:active {
  transform: translateY(0) scale(0.97);
}

.recipe-list .btn-view {
  background: rgba(196, 92, 62, 0.12);
  color: var(--accent-dark);
}

.recipe-list .btn-edit {
  background: rgba(180, 140, 80, 0.2);
  color: #7a6235;
}

.recipe-list .btn-del {
  background: rgba(200, 100, 90, 0.15);
  color: #a04a40;
}

/* 常用 / 最近查看 区块 */
.block-section {
  margin-bottom: 24px;
}

.block-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.recipe-list-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.recipe-list-inline li {
  margin-bottom: 0;
}

/* 详情弹窗：份量时间难度、常用按钮 */
.view-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin: -4px 0 12px;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.btn-view-favorite {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.btn-view-favorite:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-view-favorite.is-favorite {
  color: var(--accent);
  border-color: var(--accent);
}

/* 采购清单弹窗 */
.shopping-list-content {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.shopping-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.shopping-item:last-child {
  border-bottom: none;
}

.shopping-item strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

.shopping-item pre {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

.shopping-empty {
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* 表单：份量时间难度 */
.form-fieldset .label-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-fieldset .label-checkbox input {
  margin: 0;
  accent-color: var(--accent);
}

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 24px;
  margin: 0;
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  animation: emptyPulse 3s var(--ease-in-out) infinite;
}

.empty-hint-icon {
  display: block;
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.7;
}

.empty-hint p {
  margin: 0 0 12px;
}

.empty-hint.hidden {
  display: none;
}

.btn-empty-add {
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.btn-empty-add:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow-hover);
  animation: toastIn 0.25s var(--ease-out);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.toast-success {
  background: var(--accent-dark);
}

.toast.toast-warning {
  background: #9a7b2e;
}

.toast.toast-error {
  background: #a04a40;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 确认弹窗 ---------- */
.dialog-confirm .confirm-content {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.dialog-confirm .confirm-content p {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text);
}

.dialog-confirm .dialog-actions {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* ---------- 弹窗 ---------- */
.dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 12px 40px rgba(45, 42, 38, 0.18);
  max-width: 90vw;
  width: 420px;
  overflow: hidden;
}

.dialog::backdrop {
  background: rgba(45, 42, 38, 0.4);
  backdrop-filter: blur(4px);
  animation: backdropIn 0.25s var(--ease-out);
}

.dialog[open] form,
.dialog[open] .view-content {
  animation: dialogIn 0.3s var(--ease-out);
}

.dialog form,
.dialog .view-content {
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.dialog-form form {
  max-height: 85vh;
  overflow-y: auto;
}

.dialog-view .view-content {
  max-height: 85vh;
  overflow-y: auto;
}

.dialog-manage-styles .manage-styles-content {
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.dialog-manage-styles .manage-styles-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.form-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 14px;
  margin: 0 0 20px;
}

.form-fieldset legend {
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dialog .form-fieldset label {
  margin-bottom: 14px;
}

.dialog .form-fieldset label:last-of-type {
  margin-bottom: 0;
}

.dialog textarea {
  min-height: 100px;
}

.dialog h3 {
  margin: 0 0 20px;
  padding-bottom: 12px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}

.dialog label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.dialog label:last-of-type {
  margin-bottom: 0;
}

.dialog input[type="text"],
.dialog select,
.dialog textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dialog select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6560' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.dialog input[type="text"]:focus,
.dialog select:focus,
.dialog textarea:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(196, 92, 62, 0.1);
}

.dialog .add-style-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  margin-bottom: 14px;
}

.dialog .add-style-row input {
  flex: 1;
  min-width: 120px;
  margin-top: 0;
}

.dialog .add-style-row button {
  flex-shrink: 0;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: rgba(196, 92, 62, 0.15);
  color: var(--accent-dark);
  transition: background var(--duration-fast), opacity var(--duration-fast);
}

.dialog .add-style-row button:hover {
  background: rgba(196, 92, 62, 0.25);
}

.dialog .add-style-row #manageStylesBtn,
.dialog .add-category-row #manageCategoriesBtn {
  background: rgba(45, 42, 38, 0.08);
  color: var(--text-muted);
}

.dialog .add-style-row #manageStylesBtn:hover,
.dialog .add-category-row #manageCategoriesBtn:hover {
  background: rgba(45, 42, 38, 0.14);
  color: var(--text);
}

/* 管理菜系弹窗 */
.dialog-manage-styles .manage-styles-content {
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.dialog-manage-styles h3 {
  margin: 0 0 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.manage-styles-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.manage-styles-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.manage-styles-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  background: var(--input-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.manage-style-name {
  font-weight: 500;
  flex: 1;
}

.manage-style-tip {
  font-size: 12px;
  color: var(--text-muted);
}

.dialog-manage-styles .btn-del-style {
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  background: rgba(200, 100, 90, 0.15);
  color: #a04a40;
  transition: opacity var(--duration-fast);
}

.dialog-manage-styles .btn-del-style:hover {
  opacity: 0.9;
}

.dialog-manage-styles #closeManageStylesBtn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: rgba(45, 42, 38, 0.08);
  color: var(--text-muted);
}

.dialog-manage-styles #closeManageStylesBtn:hover {
  background: rgba(45, 42, 38, 0.12);
  color: var(--text);
}

.dialog textarea {
  resize: vertical;
  min-height: 100px;
}

#step {
  min-height: 140px;
}

.dialog-actions {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.dialog-actions button,
#closeViewBtn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--duration-fast), transform var(--duration-fast) var(--ease-out);
}

.dialog-actions button:active,
#closeViewBtn:active {
  transform: scale(0.98);
}

#submitBtn {
  background: var(--accent);
  color: #fff;
}

#submitBtn:hover {
  opacity: 0.92;
}

#cancelBtn,
#closeViewBtn {
  background: rgba(45, 42, 38, 0.08);
  color: var(--text-muted);
}

#cancelBtn:hover,
#closeViewBtn:hover {
  background: rgba(45, 42, 38, 0.12);
  color: var(--text);
}

/* 查看详情弹窗 */
.view-content dl {
  margin: 0 0 20px;
}

.view-content dt {
  margin-top: 14px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.view-content dt:first-child {
  margin-top: 0;
}

.view-content dd {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.view-content #closeViewBtn {
  margin-top: 8px;
}

/* ---------- 响应式：小屏（减少拥挤，页头两行） ---------- */
@media (max-width: 520px) {
  .app {
    padding: 20px 18px 40px;
  }

  .header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 0 0 16px;
    margin-bottom: 24px;
    padding-right: 0;
    border-bottom: 2px solid var(--border);
  }

  .header h1 {
    flex: none;
    font-size: 1.5rem;
    padding: 0;
    margin: 0;
  }

  .header-actions {
    position: static;
    transform: none;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    justify-content: center;
    gap: 12px;
  }

  .current-user {
    max-width: 120px;
    font-size: 0.85rem;
  }

  .btn-logout {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }

  /* 搜索区：更大内边距，输入框单独一行 */
  .search-bar {
    padding: 18px 18px;
    margin-bottom: 22px;
  }

  .search-main-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 12px;
  }

  .search-main-row .search-type {
    order: 1;
    flex: 1 1 auto;
  }

  .search-main-row #searchBtn {
    order: 2;
    flex-shrink: 0;
  }

  .search-bar .search-input-name {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    margin-top: 8px;
  }

  #searchCategoryFilter {
    order: 4;
    margin-top: 10px;
    padding-top: 12px;
  }

  .actions {
    padding-top: 20px;
    margin-bottom: 24px;
    gap: 14px;
  }

  .list-section-head {
    margin-bottom: 12px;
  }

  .empty-hint {
    padding: 36px 20px;
  }
}

/* 列表项按钮小屏缩小 */
@media (max-width: 480px) {
  .recipe-list li {
    flex-wrap: wrap;
    gap: 10px;
  }

  .recipe-list .item-main {
    flex: 1 1 100%;
  }

  .recipe-list .btns {
    flex: 1 1 100%;
    justify-content: flex-end;
    gap: 6px;
  }

  .recipe-list .btns button {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* ========== 菜谱广场 ========== */
.btn-square {
  background: linear-gradient(135deg, rgba(196, 92, 62, 0.15), rgba(180, 140, 80, 0.15)) !important;
  color: var(--accent-dark) !important;
  border-color: rgba(196, 92, 62, 0.25) !important;
  font-weight: 500;
}

.btn-square:hover {
  background: linear-gradient(135deg, rgba(196, 92, 62, 0.25), rgba(180, 140, 80, 0.25)) !important;
}

.dialog-square {
  width: 600px;
  max-width: 95vw;
}

.square-content {
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  max-height: 85vh;
  overflow-y: auto;
}

.square-subtitle {
  margin: -8px 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.square-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.square-search {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.square-search:focus {
  outline: none;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(196, 92, 62, 0.1);
}

.square-count {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.square-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.square-list li {
  padding: 16px;
  margin-bottom: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
  animation: itemIn 0.35s var(--ease-out) backwards;
}

.square-list li:nth-child(1) {
  animation-delay: 0s;
}

.square-list li:nth-child(2) {
  animation-delay: 0.05s;
}

.square-list li:nth-child(3) {
  animation-delay: 0.1s;
}

.square-list li:nth-child(4) {
  animation-delay: 0.15s;
}

.square-list li:nth-child(n+5) {
  animation-delay: 0.2s;
}

.square-list li:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(196, 92, 62, 0.3);
}

.square-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.square-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.square-card-user {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  background: rgba(196, 92, 62, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
}

.square-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.square-card-tags .item-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(196, 92, 62, 0.12);
  color: var(--accent-dark);
}

.square-card-tags .tag-category {
  background: rgba(180, 140, 80, 0.2);
  color: #7a6235;
}

.square-card-material {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.square-card-actions {
  display: flex;
  gap: 8px;
}

.square-card-actions button {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.square-card-actions button:hover {
  transform: translateY(-1px);
}

.square-card-actions button:active {
  transform: translateY(0) scale(0.97);
}

.square-card-actions .btn-sq-view {
  background: rgba(196, 92, 62, 0.12);
  color: var(--accent-dark);
}

.square-card-actions .btn-sq-collect {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}

.square-card-actions .btn-sq-mine {
  background: rgba(180, 140, 80, 0.2);
  color: #7a6235;
  cursor: default;
  opacity: 0.7;
}

.square-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}

.square-empty .empty-hint-icon {
  font-size: 2.5rem;
}

.square-user-detail {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 12px;
  padding: 6px 12px;
  background: rgba(196, 92, 62, 0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-soft);
}

/* 分享按钮 */
.btn-share {
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--accent-soft);
  border-radius: var(--radius-sm);
  background: rgba(196, 92, 62, 0.08);
  color: var(--accent-dark);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--duration-fast);
}

.btn-share:hover {
  background: rgba(196, 92, 62, 0.18);
  border-color: var(--accent);
}

.btn-share.is-shared {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-share.is-shared:hover {
  opacity: 0.9;
}

/* 收藏按钮 */
.btn-collect {
  padding: 8px 16px;
  font-size: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.btn-collect:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-collect:active {
  transform: scale(0.98);
}

/* 深色模式适配 */
[data-theme="dark"] .square-card-tags .tag-category {
  background: rgba(180, 140, 80, 0.3);
  color: #c4a860;
}

[data-theme="dark"] .square-card-user {
  background: rgba(224, 139, 106, 0.15);
}

[data-theme="dark"] .square-user-detail {
  background: rgba(224, 139, 106, 0.08);
  border-left-color: var(--accent);
}

[data-theme="dark"] .square-card-actions .btn-sq-mine {
  background: rgba(180, 140, 80, 0.3);
  color: #c4a860;
}

#closeSquareBtn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  background: rgba(45, 42, 38, 0.08);
  color: var(--text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
}

#closeSquareBtn:hover {
  background: rgba(45, 42, 38, 0.12);
  color: var(--text);
}

/* 广场弹窗响应式 */
@media (max-width: 520px) {
  .dialog-square {
    width: 95vw;
  }

  .square-content {
    padding: 20px 16px;
  }

  .square-card-head {
    flex-direction: column;
    gap: 4px;
  }

  .square-card-actions {
    flex-wrap: wrap;
  }
}

/* ========== 菜谱图片 ========== */
.item-thumb {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 10px;
  border: 1px solid var(--border);
}

.view-recipe-image {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 12px 0 4px;
  border: 1px solid var(--border);
}

/* ========== 评分组件 ========== */
.rating-container {
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

.rating-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.rating-avg {
  font-size: 18px;
  font-weight: 600;
  color: #d4a017;
}

.rating-count {
  font-size: 13px;
  color: var(--text-muted);
}

.rating-stars {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rating-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-right: 4px;
}

.star-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #ccc;
  padding: 0 2px;
  transition: color 0.15s, transform 0.15s;
}

.star-btn:hover {
  transform: scale(1.2);
  color: #d4a017;
}

.star-btn.star-filled {
  color: #d4a017;
}

/* ========== 密码修改 ========== */
.btn-changepwd {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  margin-right: 6px;
}

.btn-changepwd:hover {
  background: rgba(196, 92, 62, 0.1);
  color: var(--accent);
}

.change-pwd-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.change-pwd-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--text-muted);
}

.change-pwd-form input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
}

/* ========== 深色模式追加 ========== */
[data-theme="dark"] .star-btn {
  color: #555;
}

[data-theme="dark"] .star-btn:hover,
[data-theme="dark"] .star-btn.star-filled {
  color: #f0c040;
}

[data-theme="dark"] .item-thumb {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .view-recipe-image {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .change-pwd-form input {
  background: var(--bg-card);
  border-color: var(--border);
}

/* ========== item-main flex修正（支持缩略图） ========== */
.item-main {
  display: flex;
  align-items: center;
}

/* ========== 用户头像 ========== */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-soft);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast);
  margin-right: 6px;
  flex-shrink: 0;
}

.user-avatar:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(196, 92, 62, 0.2);
}

/* ========== 图片上传区域 ========== */
.image-upload-area {
  margin-top: 10px;
}

.image-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.image-upload-label:hover {
  border-color: var(--accent);
  background: rgba(196, 92, 62, 0.05);
}

.image-preview {
  position: relative;
  margin-top: 10px;
  display: inline-block;
  max-width: 100%;
}

.image-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
}

.btn-remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--duration-fast);
}

.btn-remove-image:hover {
  background: rgba(200, 50, 50, 0.9);
}

/* ========== 广场卡片封面图 ========== */
.square-card-cover {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: block;
}

/* ========== 广场卡片评分标签 ========== */
.square-card-rating {
  color: #e6a817;
  font-size: 13px;
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

/* ========== 深色模式追加（V3.0） ========== */
[data-theme="dark"] .user-avatar {
  border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .image-upload-label {
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .image-upload-label:hover {
  border-color: var(--accent);
  background: rgba(196, 92, 62, 0.1);
}

[data-theme="dark"] .image-preview img {
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .square-card-cover {
  opacity: 0.92;
}