:root {
  color-scheme: light;
  --accent: #168f79;
  --accent-dark: #0e6f5e;
  --background: #f3f4f6;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --border: #dfe5e3;
  --text: #263238;
  --muted: #63706d;
  --shadow: 0 8px 24px rgba(28, 45, 41, 0.08);
  --header-background: rgba(255, 255, 255, 0.96);
  --selected-background: #eafaf4;
  --table-heading: #f0f4f3;
  --badge-background: #e4f6f1;
  --badge-text: #086451;
}

html.dark-mode {
  color-scheme: dark;
  --accent: #35c7aa;
  --accent-dark: #72dcc7;
  --background: #1b222a;
  --surface: #252e37;
  --surface-soft: #202831;
  --border: #3b4854;
  --text: #edf2f6;
  --muted: #aeb9c4;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  --header-background: rgba(32, 40, 49, 0.96);
  --selected-background: #203c37;
  --table-heading: #2d3843;
  --badge-background: #24463f;
  --badge-text: #8fe3d2;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}

a {
  color: var(--accent-dark);
  text-underline-offset: 3px;
}

a:hover,
a:focus {
  color: var(--accent);
}

img {
  max-width: 100%;
}

.page-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-background);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

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

.theme-toggle {
  min-height: 34px;
  padding: 5px 12px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.language-switcher select {
  min-height: 34px;
  max-width: 190px;
  padding: 4px 28px 4px 9px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  font: inherit;
}

.language-switcher select:focus {
  border-color: var(--accent);
  outline: none;
}

.theme-toggle:hover,
.theme-toggle:focus {
  color: var(--accent-dark);
  border-color: var(--accent);
  outline: none;
}

.site-header nav a {
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a:focus,
.site-header nav a[aria-current="page"] {
  color: var(--accent-dark);
}

.breadcrumbs {
  display: flex;
  padding: 22px 0 12px;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

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

.item-hero,
.catalog-hero {
  margin: 10px 0 22px;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.item-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 30px;
}

.item-image-wrap {
  display: flex;
  width: 180px;
  height: 180px;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.item-image-wrap img {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  line-height: 1.35;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 25px;
}

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

h4 {
  margin-bottom: 10px;
  font-size: 16px;
}

.english-name {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 18px;
}

.lead {
  max-width: 900px;
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 17px;
}

.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  padding: 9px 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}

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

.button-primary:hover,
.button-primary:focus {
  color: #ffffff;
  background: var(--accent-dark);
}

.button-secondary {
  color: var(--accent-dark);
  background: var(--surface);
}

.item-detail {
  padding: 28px 0 52px;
}

.item-name-header {
  margin-bottom: 18px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.item-name-header h1 {
  margin: 0;
  font-size: 28px;
}

.recipe-group-card {
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.recipe-group-title {
  min-height: 50px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.recipe-group-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.recipe-group-title small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.recipe-group-content {
  padding: 16px 20px;
}

.recipe-edit-item-readonly {
  display: grid;
  margin-bottom: 9px;
  padding: 10px 12px;
  grid-template-columns: 68px minmax(190px, 0.7fr) minmax(300px, 1fr) auto minmax(300px, 1fr) 132px;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow-x: auto;
}

.recipe-edit-item-readonly:last-child {
  margin-bottom: 0;
}

.recipe-edit-item-readonly.recipe-selected {
  background: var(--selected-background);
  border-color: var(--accent);
}

.recipe-edit-item-readonly.recipe-locked {
  color: var(--muted);
  background: var(--surface-soft);
  opacity: 0.72;
}

.recipe-edit-item-readonly.recipe-locked .io-chip,
.recipe-edit-item-readonly.recipe-locked .recipe-device {
  filter: grayscale(0.8);
}

.recipe-status {
  padding-right: 10px;
  color: var(--muted);
  border-right: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.recipe-selected .recipe-status {
  color: var(--accent-dark);
}

.recipe-card-actions {
  display: flex;
  justify-content: flex-end;
}

.recipe-card-action {
  width: 100%;
  min-height: 34px;
  padding: 5px 10px;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.recipe-card-action:hover,
.recipe-card-action:focus {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  outline: none;
}

.recipe-card-action:disabled {
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
  cursor: default;
}

.recipe-device {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.recipe-device img {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  object-fit: contain;
}

.recipe-device-label {
  color: var(--muted);
  font-size: 13px;
}

.recipe-device strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.io-list {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.io-chip {
  display: inline-flex;
  min-height: 34px;
  padding: 5px 9px;
  align-items: center;
  gap: 5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}

.io-chip img {
  width: 30px;
  height: 30px;
  margin-right: 2px;
  flex: 0 0 auto;
  object-fit: contain;
}

.io-chip a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.io-chip a:hover,
.io-chip a:focus {
  color: var(--accent-dark);
}

.io-chip small {
  padding: 0 5px;
  color: var(--badge-text);
  background: var(--badge-background);
  border-radius: 3px;
  font-size: 11px;
}

.io-empty {
  color: var(--muted);
}

.io-equal {
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.item-facts {
  display: grid;
  margin: 0 0 22px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.item-facts > div {
  min-width: 0;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.item-facts dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.item-facts dd {
  margin: 0;
  font-size: 17px;
  font-weight: 750;
}

.page-toc {
  display: flex;
  margin-bottom: 28px;
  padding: 14px 18px;
  flex-wrap: wrap;
  gap: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.page-toc a {
  font-weight: 700;
  text-decoration: none;
}

.profile-section,
.content-section,
.related-section,
.faq-section,
.catalog-section {
  margin: 0 0 26px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.section-heading,
.recipe-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
}

.recipe-count,
.recipe-index,
.main-product-badge,
.byproduct-badge {
  display: inline-flex;
  padding: 3px 8px;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.recipe-count,
.recipe-index,
.main-product-badge {
  color: var(--badge-text);
  background: var(--badge-background);
}

.byproduct-badge {
  color: #765608;
  background: #fff3cf;
}

.recipe-card {
  margin-top: 18px;
  padding: 22px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.recipe-card-selected {
  border-color: #7bc6b6;
  box-shadow: inset 3px 0 0 var(--accent);
}

.recipe-index {
  margin-bottom: 7px;
}

.recipe-machine {
  display: flex;
  margin: 0;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.recipe-machine div {
  min-width: 90px;
}

.recipe-machine dt {
  color: var(--muted);
  font-size: 12px;
}

.recipe-machine dd {
  margin: 0;
  font-weight: 700;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--table-heading);
  font-size: 13px;
}

td:last-child,
th:last-child {
  width: 130px;
  text-align: right;
  white-space: nowrap;
}

.empty-cell {
  color: var(--muted);
  text-align: left !important;
  white-space: normal !important;
}

.related-grid,
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.related-card,
.item-card {
  display: flex;
  min-width: 0;
  padding: 12px;
  align-items: center;
  gap: 11px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
}

.related-card:hover,
.related-card:focus,
.item-card:hover,
.item-card:focus {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(22, 143, 121, 0.1);
}

.related-card img,
.item-card img {
  flex: 0 0 auto;
  object-fit: contain;
}

.item-card span {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.item-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.faq-section details {
  padding: 15px 0;
  border-top: 1px solid var(--border);
}

.faq-section details:first-of-type {
  border-top: 0;
}

.faq-section summary {
  cursor: pointer;
  font-weight: 750;
}

.faq-section details p {
  margin: 10px 0 0;
  color: var(--muted);
}

.catalog-hero {
  margin-bottom: 26px;
}

.catalog-section .section-heading {
  margin-bottom: 18px;
}

footer {
  margin-top: 34px;
  padding: 30px 0 38px;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

footer p {
  margin: 4px 0;
}

@media (max-width: 860px) {
  .item-hero {
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 22px;
  }

  .item-image-wrap {
    width: 120px;
    height: 120px;
  }

  .item-image-wrap img {
    width: 104px;
    height: 104px;
  }

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

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

  .recipe-edit-item-readonly {
    grid-template-columns: 58px minmax(180px, 0.7fr) minmax(260px, 1fr) auto minmax(260px, 1fr) 126px;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 24px, 1160px);
  }

  .header-inner {
    padding: 10px 0;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .site-header {
    position: static;
  }

  .site-header nav {
    gap: 12px;
    font-size: 14px;
  }

  .header-actions {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .item-detail {
    padding-top: 16px;
  }

  .item-name-header,
  .recipe-group-title,
  .recipe-group-content {
    padding-right: 14px;
    padding-left: 14px;
  }

  .recipe-edit-item-readonly {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    overflow: visible;
  }

  .recipe-status {
    padding: 0 0 7px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .io-equal {
    align-self: center;
  }

  .recipe-card-actions {
    justify-content: flex-start;
  }

  .recipe-card-action {
    width: auto;
  }

  .item-hero,
  .catalog-hero,
  .profile-section,
  .content-section,
  .related-section,
  .faq-section,
  .catalog-section {
    padding: 20px;
  }

  .item-hero {
    grid-template-columns: 1fr;
  }

  .item-image-wrap {
    width: 112px;
    height: 112px;
  }

  .item-image-wrap img {
    width: 96px;
    height: 96px;
  }

  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

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

  .section-heading,
  .recipe-card-header {
    flex-direction: column;
  }

  .recipe-machine {
    width: 100%;
  }

  .related-grid,
  .item-grid {
    grid-template-columns: 1fr;
  }
}
