:root {
  color-scheme: light;
  --bg: #fff7fb;
  --panel: #fffefe;
  --panel-soft: #fff1f7;
  --line: #ecd5e3;
  --text: #463344;
  --muted: #8a6f82;
  --accent: #7fd8c8;
  --accent-strong: #ff8fbd;
}

body.night-mode {
  color-scheme: dark;
  --bg: #071f25;
  --panel: #0d2e35;
  --panel-soft: #123b43;
  --line: #2f6971;
  --text: #e9fffb;
  --muted: #9ac6c4;
  --accent: #5fe0c7;
  --accent-strong: #6bb7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 143, 189, 0.25), transparent 22%),
    radial-gradient(circle at 88% 18%, rgba(127, 216, 200, 0.28), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body.night-mode {
  background:
    radial-gradient(circle at 14% 10%, rgba(95, 224, 199, 0.2), transparent 22%),
    radial-gradient(circle at 86% 18%, rgba(107, 183, 255, 0.18), transparent 24%),
    var(--bg);
}

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

button,
a {
  color: inherit;
}

a {
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
}

.sim-shell {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.sim-topbar,
.section-head,
.top-actions,
.picker-row,
.inline-controls {
  display: flex;
  align-items: center;
}

.sim-topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 56px);
}

h2 {
  font-size: 20px;
}

.sim-grid {
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.paper-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 254, 254, 0.92);
  box-shadow: 0 18px 50px rgba(180, 107, 139, 0.16);
  padding: 16px;
}

body.night-mode .paper-panel {
  background: rgba(13, 46, 53, 0.92);
  box-shadow: 0 18px 50px rgba(0, 28, 34, 0.3);
}

.section-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.avatar-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 132px);
  grid-template-rows: 118px 118px 118px 118px;
  gap: 8px;
  justify-content: center;
  padding: 16px;
  border-radius: 18px;
  background: #102125;
  box-shadow: inset 0 0 0 2px rgba(127, 216, 200, 0.18);
}

.slot {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 10px;
  border: 2px solid #274246;
  border-radius: 10px;
  color: #85a7a9;
  background: #172b2f;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.slot:hover,
.slot.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(95, 224, 199, 0.18);
  transform: translateY(-1px);
}

.slot span {
  display: -webkit-box;
  overflow: hidden;
  max-width: 100%;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  word-break: break-all;
}

.slot.filled {
  color: #132b2f;
  background: linear-gradient(135deg, #bdf5ea, #ffd8ea);
}

body.night-mode .slot.filled {
  color: #06282d;
  background: linear-gradient(135deg, #5fe0c7, #6bb7ff);
}

.head {
  grid-column: 2;
  grid-row: 1;
}

.robe {
  grid-column: 3;
  grid-row: 4;
}

.body {
  grid-column: 2;
  grid-row: 2 / span 2;
}

.hands {
  grid-column: 1;
  grid-row: 4;
}

.feet {
  grid-column: 2;
  grid-row: 4;
}

.acc1 {
  grid-column: 1;
  grid-row: 1;
}

.acc2 {
  grid-column: 3;
  grid-row: 1;
}

.rightHand {
  grid-column: 1;
  grid-row: 2 / span 2;
}

.leftHand {
  grid-column: 3;
  grid-row: 2 / span 2;
}

.slot.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.slot-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field.full {
  grid-column: 1 / -1;
}

.two-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.picker-row,
.inline-controls {
  gap: 8px;
}

.icon-search {
  width: 34px;
  height: 34px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--panel-soft);
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fffafd;
  outline: none;
}

body.night-mode input,
body.night-mode select,
body.night-mode textarea {
  background: #092932;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.45;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}

.checkline input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.primary,
.secondary,
.ghost,
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  background: #fff7fb;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.secondary:hover,
.ghost:hover,
.nav-link:hover {
  border-color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(127, 216, 200, 0.2);
  transform: translateY(-1px);
}

body.night-mode .secondary,
body.night-mode .ghost,
body.night-mode .nav-link {
  background: #123b43;
}

.summary {
  min-height: 220px;
}

.autocomplete {
  position: relative;
}

.suggest-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 10;
  display: none;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 16px 30px rgba(180, 107, 139, 0.2);
}

body.night-mode .suggest-list {
  box-shadow: 0 16px 30px rgba(0, 28, 34, 0.38);
}

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

.suggest-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-align: left;
  background: var(--panel-soft);
}

.suggest-item:hover {
  border-color: var(--accent);
}

.suggest-item small {
  color: var(--muted);
  line-height: 1.35;
}

.search-dialog {
  width: min(900px, calc(100vw - 18px));
  height: min(744px, calc(100vh - 18px));
  border: 0;
  padding: 0;
  background: transparent;
}

.search-dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
}

.dialog-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  height: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  overflow: hidden;
}

body.night-mode .dialog-card {
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(0, 28, 34, 0.45);
}

.dialog-card .section-head {
  padding: 10px 12px 4px;
  margin: 0;
}

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.search-results {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: none;
  overflow: auto;
  padding: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-item,
.upgrade-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: inherit;
  text-align: left;
  background: var(--panel-soft);
}

.upgrade-item {
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 64px;
  border-color: var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.result-item small,
.upgrade-item small,
.base-panel {
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
}

.base-panel {
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.weapon-panel {
  min-height: 76px;
  padding: 10px 11px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-soft);
  line-height: 1.5;
  white-space: pre-wrap;
}

.upgrade-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 253, 0.58);
}

body.night-mode .upgrade-group {
  background: rgba(18, 59, 67, 0.62);
}

body.night-mode .upgrade-item,
body.night-mode .blacksmith-roll,
body.night-mode #confirmUpgradeBtn,
body.night-mode #resetUpgradeBtn,
body.night-mode .weapon-panel {
  background: var(--panel-soft);
}

.upgrade-group h3 {
  margin: 0;
  font-size: 14px;
}

.upgrade-empty {
  opacity: 0.76;
}

.blacksmith-roll,
#confirmUpgradeBtn {
  width: auto;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff7fb;
  font-weight: 800;
}

.upgrade-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 58px;
}

#confirmUpgradeBtn,
#resetUpgradeBtn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-soft);
  font-size: 14px;
  font-weight: 800;
}

.identification-rows {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.rich-note {
  height: 132px;
  min-height: 132px;
  max-height: 132px;
  overflow: auto;
  resize: none;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fffafd;
  outline: none;
  line-height: 1.45;
  white-space: pre-wrap;
}

body.night-mode .rich-note {
  background: #092932;
}

.rich-note:empty::before {
  color: var(--muted);
  content: attr(data-placeholder);
}

.rich-note .positive {
  color: #2674c8;
}

.rich-note .negative {
  color: #d73c58;
}

body.night-mode .rich-note .positive {
  color: #7fc2ff;
}

body.night-mode .rich-note .negative {
  color: #ff8fbd;
}

.rich-note .range {
  color: var(--accent-strong);
  font-weight: 900;
}

body.night-mode .rich-note .range {
  color: #ffd166;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 143, 189, 0.55);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 250, 253, 0.96);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

body.night-mode .toast {
  border-color: rgba(95, 224, 199, 0.55);
  background: rgba(9, 41, 50, 0.96);
}

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

@media (max-width: 980px) {
  .sim-shell {
    padding: 16px;
  }

  .sim-topbar,
  .sim-grid,
  .two-cols,
  .effect-grid,
  .identification-rows,
  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .sim-topbar {
    display: grid;
  }

  .avatar-board {
    grid-template-columns: repeat(3, minmax(86px, 1fr));
    grid-template-rows: repeat(4, 92px);
  }
}
