:root {
  --ink: #17384a;
  --muted: #5f7481;
  --line: #dbe7eb;
  --paper: #ffffff;
  --canvas: #f3f8f8;
  --major: #8fd9aa;
  --major-strong: #1f9d5b;
  --trace: #aeb8f6;
  --trace-strong: #5968d9;
  --other: #f5c7c0;
  --other-strong: #d46c60;
  --focus: #ffb703;
  --focus-dark: #8a5700;
  --shadow: 0 18px 48px rgba(24, 65, 76, 0.12);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(95, 192, 163, 0.16), transparent 28rem),
    radial-gradient(circle at 100% 12%, rgba(89, 104, 217, 0.12), transparent 24rem),
    var(--canvas);
}

button {
  font: inherit;
}

.model-shell {
  width: min(1540px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 44px);
}

.model-header {
  margin-bottom: 24px;
}

.shell-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(188, 210, 216, 0.82);
}

.shell-back-link,
.shell-control {
  min-height: 42px;
  border: 1px solid rgba(184, 203, 209, 0.9);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 5px 16px rgba(24, 65, 76, 0.06);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.shell-back-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.shell-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.shell-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 13px;
  cursor: pointer;
}

.shell-control span {
  min-width: 17px;
  color: #31816e;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
}

.shell-control strong {
  font-size: 12px;
}

.shell-back-link:hover,
.shell-back-link:focus-visible,
.shell-control:hover,
.shell-control:focus-visible {
  border-color: #4f8d80;
  outline: none;
  background: #fff;
  box-shadow: 0 8px 20px rgba(24, 65, 76, 0.11);
  transform: translateY(-1px);
}

.shell-control[aria-pressed="true"] {
  border-color: #59a58f;
  background: #e9f8f2;
  box-shadow: 0 0 0 3px rgba(95, 192, 163, 0.16);
}

.model-heading {
  max-width: 900px;
}

.eyebrow,
.selection-kicker {
  margin: 0 0 8px;
  color: #31816e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.45vw, 18px);
  line-height: 1.7;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 300px);
  gap: 18px;
  align-items: start;
}

.table-card,
.composition-card,
.selection-panel {
  border: 1px solid rgba(188, 210, 216, 0.78);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.table-card {
  min-width: 0;
  padding: clamp(16px, 2vw, 26px);
}

.composition-card {
  position: sticky;
  top: 16px;
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  max-width: 470px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
}

.section-index {
  color: #84a8a0;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 12px;
  font-weight: 800;
}

.composition-heading {
  display: block;
}

.composition-heading > div {
  margin-bottom: 9px;
}

.composition-heading p {
  text-align: left;
}

.periodic-scroll {
  overflow-x: auto;
  padding: 6px 4px 12px;
  scrollbar-color: #9abcb5 #edf4f3;
  scrollbar-width: thin;
}

.periodic-scroll:focus-visible {
  outline: 3px solid rgba(49, 129, 110, 0.3);
  outline-offset: 3px;
  border-radius: 10px;
}

.periodic-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(38px, 1fr));
  grid-template-rows: repeat(9, minmax(48px, auto));
  gap: 4px;
  min-width: 820px;
}

.element-cell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 48px;
  padding: 4px 3px 3px;
  border: 1px solid color-mix(in srgb, var(--category-strong) 45%, #ffffff);
  border-radius: 7px;
  color: #18333f;
  background: var(--category-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
  cursor: pointer;
  opacity: 1;
  transform: translateZ(0);
  transition: opacity 170ms ease, transform 170ms ease, box-shadow 170ms ease, filter 170ms ease, background-color 170ms ease, border-color 170ms ease;
}

.element-cell.category-major {
  --category-color: var(--major);
  --category-strong: var(--major-strong);
}

.element-cell.is-major-caveat {
  --category-color: #d9f3e2;
  --category-strong: #62b68a;
}

.element-cell.category-trace {
  --category-color: var(--trace);
  --category-strong: var(--trace-strong);
}

.element-cell.category-other {
  --category-color: var(--other);
  --category-strong: var(--other-strong);
}

.element-cell:hover,
.element-cell:focus-visible {
  z-index: 3;
  outline: none;
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 8px 18px rgba(33, 68, 78, 0.22);
}

.element-cell.is-dimmed {
  opacity: 0.22;
  filter: grayscale(0.35);
}

.element-cell.is-highlighted {
  z-index: 2;
  border-color: var(--focus-dark);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, 0.55), 0 8px 18px rgba(116, 76, 0, 0.22);
  transform: translateY(-2px);
}

.atomic-number {
  align-self: start;
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: clamp(7px, 0.63vw, 10px);
  font-weight: 700;
  line-height: 1;
  opacity: 0.68;
}

.element-symbol {
  align-self: center;
  justify-self: center;
  font-size: clamp(14px, 1.35vw, 21px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: -0.04em;
}

.element-chinese-corner {
  align-self: end;
  justify-self: end;
  color: rgba(23, 56, 74, 0.72);
  font-family: "SimSun-ExtB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: clamp(8px, 0.66vw, 10px);
  font-weight: 750;
  line-height: 1;
  text-align: right;
}

.model-shell.labels-hidden .atomic-number,
.model-shell.labels-hidden .element-chinese-corner {
  visibility: hidden;
}

.series-label {
  display: flex;
  align-items: center;
  padding-left: 8px;
  color: #58717a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.lanthanide-label {
  grid-column: 1 / span 3;
  grid-row: 8;
}

.actinide-label {
  grid-column: 1 / span 3;
  grid-row: 9;
}

.category-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.category-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid #d5e2e5;
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.category-button:hover,
.category-button:focus-visible {
  outline: none;
  transform: translateY(-2px);
  border-color: var(--button-strong);
}

.category-button[aria-pressed="true"] {
  border-color: var(--button-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--button-color) 50%, transparent);
}

.category-major {
  --button-color: var(--major);
  --button-strong: var(--major-strong);
}

.category-trace {
  --button-color: var(--trace);
  --button-strong: var(--trace-strong);
}

.category-other {
  --button-color: var(--other);
  --button-strong: var(--other-strong);
}

.category-swatch {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--button-strong) 55%, #fff);
  border-radius: 9px;
  background: var(--button-color);
}

.category-button strong,
.category-button small {
  display: block;
}

.category-button strong {
  font-size: 15px;
}

.category-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.composition-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.composition-button {
  position: relative;
  min-height: 62px;
  padding: 10px 8px;
  overflow: hidden;
  border: 1px solid #e5b752;
  border-radius: 14px;
  color: #3d3417;
  background: linear-gradient(145deg, #ffd66c, #ffb703);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.composition-button:hover,
.composition-button:focus-visible {
  outline: none;
  transform: translateY(-2px);
  box-shadow: 0 9px 18px rgba(141, 98, 0, 0.2);
}

.composition-button[aria-pressed="true"] {
  color: #fff;
  border-color: #855300;
  background: linear-gradient(145deg, #b46f00, #744600);
  box-shadow: 0 0 0 3px rgba(255, 183, 3, 0.34);
}

.composition-button strong,
.composition-button small {
  display: block;
}

.composition-button strong {
  font-size: 17px;
}

.composition-button small {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.72;
}

.scope-note {
  margin: 16px 0 0;
  padding: 12px;
  border-radius: 12px;
  color: #66767b;
  background: #f3f7f6;
  font-size: 11px;
  line-height: 1.65;
}

.selection-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 24px;
  margin-top: 18px;
  padding: clamp(18px, 2.2vw, 28px);
}

.selection-copy h2 {
  margin-bottom: 8px;
  font-size: clamp(20px, 2.2vw, 29px);
}

.selection-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.element-chips {
  display: flex;
  align-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.element-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 58px;
  padding: 8px 10px;
  border: 1px solid #d5e3e6;
  border-radius: 12px;
  background: #f8fbfb;
}

.element-chip strong {
  font-size: 18px;
}

.element-chip span {
  color: var(--muted);
  font-size: 9px;
}

.placeholder-chip {
  color: #789098;
  border-style: dashed;
  background: transparent;
}

.teaching-card {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid rgba(188, 210, 216, 0.78);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.teaching-card summary {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 76px;
  padding: 15px clamp(18px, 2.2vw, 28px);
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.teaching-card summary::-webkit-details-marker {
  display: none;
}

.teaching-card summary:focus-visible {
  outline: 3px solid rgba(49, 129, 110, 0.28);
  outline-offset: -3px;
}

.teaching-card-icon {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(145deg, #56ad94, #287a66);
  font-family: ui-serif, Georgia, serif;
  font-size: 19px;
  font-weight: 850;
  font-style: italic;
}

.teaching-card-heading {
  display: grid;
  gap: 3px;
}

.teaching-card-heading strong {
  font-size: 16px;
}

.teaching-card-heading small {
  color: var(--muted);
  font-size: 11px;
}

.teaching-card-toggle {
  margin-left: auto;
  color: #31816e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.teaching-card-toggle::before {
  content: "展开  +";
}

.teaching-card[open] .teaching-card-toggle::before {
  content: "收起  −";
}

.teaching-card-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px clamp(18px, 2.2vw, 28px) 24px;
  border-top: 1px solid #e1ebed;
  background: rgba(249, 252, 252, 0.74);
}

.teaching-card-content section {
  min-width: 0;
  padding: 16px;
  border: 1px solid #e0ebed;
  border-radius: 16px;
  background: #fff;
}

.teaching-card-content section:nth-child(3) {
  grid-column: 1 / -1;
}

.teaching-card-content h3 {
  margin: 0 0 8px;
  color: #245f52;
  font-size: 13px;
}

.teaching-card-content h3 small {
  margin-left: 5px;
  color: #83a09a;
  font-size: 9px;
  letter-spacing: 0.09em;
}

.teaching-card-content p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.teaching-warning {
  border-color: #f0ddb0 !important;
  background: #fffaf0 !important;
}

.teaching-warning h3 {
  color: #986507;
}

.teaching-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.teaching-keyword {
  padding: 6px 9px;
  border: 1px solid #cfe2dd;
  border-radius: 999px;
  color: #286b5a;
  background: #edf8f4;
  font-size: 10px;
  font-weight: 750;
}

.model-shell:fullscreen,
.model-shell.is-css-fullscreen {
  width: 100%;
  max-width: none;
  overflow: auto;
  background:
    radial-gradient(circle at 10% 0%, rgba(95, 192, 163, 0.16), transparent 28rem),
    radial-gradient(circle at 100% 12%, rgba(89, 104, 217, 0.12), transparent 24rem),
    var(--canvas);
}

.model-shell.is-css-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  height: 100vh;
}

html.model-css-fullscreen-active,
html.model-css-fullscreen-active body {
  overflow: hidden;
}

.model-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 4px 0;
  color: #667b83;
  font-size: 11px;
  line-height: 1.6;
}

.model-footer p {
  margin: 0;
}

.element-count {
  flex: 0 0 auto;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .composition-card {
    position: static;
  }

  .composition-buttons {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 720px) {
  .model-shell {
    padding: 16px 12px 24px;
  }

  .shell-topbar {
    align-items: flex-start;
    margin-bottom: 20px;
  }

  .shell-back-link {
    padding-inline: 11px;
    font-size: 11px;
  }

  .shell-control {
    padding-inline: 10px;
  }

  .shell-control strong {
    font-size: 11px;
  }

  .section-heading {
    display: block;
  }

  .section-heading > div {
    margin-bottom: 7px;
  }

  .section-heading p {
    text-align: left;
  }

  .category-controls,
  .composition-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .category-button:last-child {
    grid-column: 1 / -1;
  }

  .selection-panel {
    grid-template-columns: 1fr;
  }

  .teaching-card-content {
    grid-template-columns: 1fr;
  }

  .teaching-card-content section:nth-child(3) {
    grid-column: auto;
  }

  .model-footer {
    display: block;
  }

  .element-count {
    margin-top: 8px !important;
  }
}

@media (max-width: 480px) {
  .shell-topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .shell-back-link {
    justify-self: start;
  }

  .shell-controls {
    justify-content: stretch;
  }

  .shell-control {
    flex: 1 1 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
