:root {
  color-scheme: light;
  --layout-gap: 16px;
  --nav-width: 268px;
  --main-width: 1092px;
  --output-width: 458px;
  --layout-width: calc(var(--nav-width) + var(--main-width) + var(--output-width) + var(--layout-gap) * 2);
  --top-bg: #d2f3ff;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f9ff;
  --ink: #243246;
  --muted: #7a8ca5;
  --line: #dbe5f1;
  --line-strong: #c6d6e8;
  --green: #4b95ef;
  --green-2: #337fdc;
  --blue: #4879c7;
  --blue-soft: #eaf3ff;
  --panel-shadow: 0 14px 34px rgba(81, 117, 165, 0.12);
  --amber: #a56617;
  --red: #ad3737;
  --shadow: 0 16px 36px rgba(81, 117, 165, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  background: #ffffff;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 860px;
  background: linear-gradient(
    180deg,
    #d2f3ff 0,
    #cef5ff 220px,
    #f3fdff 620px,
    #ffffff 860px
  );
  pointer-events: none;
  z-index: 0;
}

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

button {
  border: 0;
}

button,
a,
input,
select,
textarea {
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}

.app-header {
  padding: 18px 0 20px;
  background: rgba(210, 243, 255, 0.78);
  border-bottom: 1px solid rgba(197, 229, 241, 0.72);
  box-shadow: 0 4px 18px rgba(122, 168, 191, 0.08);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(0, calc(var(--nav-width) + var(--main-width) + var(--layout-gap))) minmax(320px, var(--output-width));
  gap: var(--layout-gap);
  align-items: center;
  width: min(var(--layout-width), calc(100% - 36px));
  margin: 0 auto;
}

.header-brand {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.brand-media {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 12px 30px rgba(91, 129, 178, 0.18);
}

.brand-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 2px;
}

.eyebrow {
  margin: 0;
  color: #1887f6;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

.brand-copy h1,
.brand-copy h2 {
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 800;
  line-height: 1.16;
}

h2 {
  font-size: 18px;
  font-weight: 800;
}

h3 {
  font-size: 18px;
  font-weight: 800;
}

.brand-copy p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.header-actions,
.dialog-actions,
.output-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-actions {
  justify-self: end;
  justify-content: flex-end;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 38px;
  border-radius: 10px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.primary-btn {
  background: linear-gradient(180deg, #5aa2f5, #3e88e6);
  color: #fff;
  box-shadow: 0 10px 22px rgba(69, 131, 211, 0.24);
  margin-top: 0 !important; 
}

.primary-btn:hover {
  background: linear-gradient(180deg, #69adf8, #4a93eb);
  transform: translateY(-1px);
}

.ghost-btn,
.icon-btn {
  background: rgba(255, 255, 255, 0.76);
  color: #4a6488;
  border: 1px solid #cfe0f0;
  text-decoration: none;
}

.ghost-btn:hover,
.icon-btn:hover {
  border-color: #98bbe2;
  color: var(--green-2);
  background: #fff;
  transform: translateY(-1px);
}

.header-link {
  text-transform: none;
}

.compact {
  min-height: 34px;
  padding-inline: 12px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
}

.btn-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.btn-icon-16 {
  width: 16px;
  height: 16px;
}

.btn-icon-20 {
  width: 20px;
  height: 20px;
}

.btn-icon-24 {
  width: 24px;
  height: 24px;
}

.primary-btn .btn-icon {
  border-radius: 5px;
  /* background: rgba(255, 255, 255, 0.18); */
}

.ghost-btn .btn-icon {
  /* background: #eff5fd; */
}

.icon-btn {
  width: 36px;
  padding: 0;
  font-size: 22px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, var(--nav-width)) minmax(0, var(--main-width)) minmax(320px, var(--output-width));
  gap: var(--layout-gap);
  width: min(var(--layout-width), calc(100% - 36px));
  margin: 0 auto;
  padding: 16px 0 20px;
  align-items: start;
  position: relative;
  z-index: 1;
}

.nav-panel,
.output-panel {
  position: sticky;
  top: 119px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
}

.nav-panel {
  padding: 14px;
}

.search-block {
  display: grid;
  gap: 7px;
}

.search-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-label span:last-child,
.template-head .eyebrow,
.output-title .eyebrow {
  color: #222222;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

label {
  font-size: 12px;
  font-weight: 800;
  color: #516b90;
}

.search-input-wrap {
  position: relative;
}

.search-input-icon {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.85;
}

#searchInput {
  padding-right: 40px;
}

#searchInput::placeholder {
  font-size: 12px;
  line-height: 20px;
  color: #a4b1c0;
}

input[type="search"],
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fbfdff;
  color: var(--ink);
  border-radius: 10px;
  min-height: 38px;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 20px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(75, 149, 239, 0.12);
}

.group-nav {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  overflow: visible;
}

.group-nav button {
  width: 100%;
  justify-content: space-between;
  min-height: 44px;
  border-radius: 12px;
  background: #f8fbff;
  border: 1px solid #edf3fa;
  color: #6f7f95;
  padding: 0 13px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  text-align: left;
  position: relative;
}

.group-nav button:hover,
.group-nav button.active {
  background: #f1f5f9;
  border-color: #e1eaf4;
  color: #2c88f2;
  box-shadow: none;
}

.group-nav button.active::after {
  display: none;
}

.group-nav span {
  color: #7a8ca5;
  font-size: 12px;
  font-weight: 800;
  min-width: 38px;
  height: 32px;
  border-radius: 10px;
  padding: 0 12px;
  background: #edf3fb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.group-nav button.active span {
  color: #fff;
  background: linear-gradient(180deg, #66a9ff, #428ef0);
  box-shadow: 0 8px 18px rgba(66, 142, 240, 0.24);
}

.mini-status {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #6781a2;
  font-size: 12px;
}

.mini-status span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.main-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.template-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--panel-shadow);
  overflow: visible;
}

.template-panel::after {
  content: "";
  position: absolute;
  top: -14px;
  right: -10px;
  width: 154px;
  height: 154px;
  background: url("../assets/background.png") center / contain no-repeat;
  pointer-events: none;
  z-index: 0;
}

.template-head {
  display: flex;
  justify-content: flex-start;
  gap: 16px;
  align-items: center;
  padding: 15px 18px 0px 18px;
  /* background: linear-gradient(180deg, #f8fbff, #f3f8fe);
  border-bottom: 1px solid var(--line); */
}

.panel-title {
  display: grid;
  gap: 6px;
}

.panel-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.template-head .eyebrow,
.output-title .eyebrow {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}

.template-head h2 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.template-head > p {
  display: none;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  padding: 16px;
  position: relative;
  z-index: 1;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: space-between;
  min-height: 180px;
  padding: 14px 14px 12px;
  border: 1px solid #dbe7f4;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  box-shadow: 0 8px 20px rgba(106, 141, 185, 0.08);
}

.template-card:hover {
  border-color: #bfd5ef;
  box-shadow: 0 12px 28px rgba(106, 141, 185, 0.12);
  transform: translateY(-1px);
}

.template-card h3 {
  font-size: 15px;
}

.template-copy {
  display: grid;
  gap: 8px;
}

.template-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.template-cover {
  margin: 0;
  color: #8d98aa;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.template-cover strong {
  color: #00b055;
  font-weight: 800;
}

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

.template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.template-tags span {
  border-radius: 999px;
  background: #edf4fd;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.template-card .primary-btn {
  margin-top: auto;
  width: 100%;
  min-height: 34px;
  font-size: 13px;
}

.editor {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.group-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  scroll-margin-top: 132px;
  box-shadow: var(--panel-shadow);
}

.group-head {
  display: block;
  padding: 18px 18px 10px;
  background: transparent;
  border-bottom: 0;
  position: relative;
  z-index: 1;
}

.group-head-copy {
  display: grid;
  gap: 7px;
}

.group-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.group-title-row h3 {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.group-head p {
  margin: 0;
  color: #9aa5b5;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.group-count {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 6px;
  background: linear-gradient(180deg, #6eb2ff, #559cf3);
  box-shadow: 0 4px 10px rgba(74, 149, 239, 0.14);
}

.field-list {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(260px, 1fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid #eef3f9;
  border-radius: 12px;
  background: #fbfdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.field-row.is-changed {
  background: #f6fbff;
  box-shadow: inset 3px 0 0 #64a7f2;
}

.field-row.is-missing {
  background: #ffe4e6;
  box-shadow: inset 4px 0 0 #dc2626;
}

.field-meta {
  min-width: 0;
}

.field-title {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.field-title strong {
  font-size: 15px;
  font-weight: 800;
}

.key-chip {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  background: #edf4fd;
  color: var(--blue);
  padding: 3px 8px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.field-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.control-wrap {
  display: grid;
  gap: 8px;
  align-content: start;
}

.toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: min(260px, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.toggle button {
  min-height: 38px;
  background: #fff;
  color: #6f7f93;
  cursor: pointer;
  font-weight: 800;
}

.toggle button.active {
  background: linear-gradient(180deg, #61a6f6, #4b95ef);
  color: #fff;
}

.range-line {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  align-items: center;
}

.array-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  outline: none;
  box-shadow: none;
}

input[type="range"]:focus {
  outline: none;
  box-shadow: none;
}

input[type="range"]::-moz-focus-outer {
  border: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #56a2f7 0,
    #56a2f7 var(--range-progress, 0%),
    #e4ecf3 var(--range-progress, 0%),
    #e4ecf3 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #61a6f6, #4b95ef);
  box-shadow: 0 4px 10px rgba(75, 149, 239, 0.22);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: #e4ecf3;
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: #56a2f7;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #61a6f6, #4b95ef);
  box-shadow: 0 4px 10px rgba(75, 149, 239, 0.22);
}

.input-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}

.output-panel {
  padding: 16px;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8eef6;
}

.output-title {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.output-title h2 {
  margin-top: 2px;
  color: #9aa7b8;
  font-size: 12px;
  font-weight: 700;
}

.output-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.output-actions .primary-btn {
  min-height: 36px;
  padding-inline: 14px;
  border-radius: 8px;
  box-shadow: none;
}

.output-actions #copyBtn {
  background: #fff;
  color: #4a95ef;
  border: 1px solid #74aff4;
}

.output-actions #copyBtn:hover {
  background: #f5faff;
  color: #2f84ea;
  border-color: #5d9ff1;
  transform: translateY(-1px);
}

.output-actions #downloadBtn {
  background: linear-gradient(180deg, #5ca5f6, #418eea);
  color: #fff;
  border: 1px solid #4d95ee;
}

.output-actions #downloadBtn:hover {
  background: linear-gradient(180deg, #6cb0f8, #4d98ef);
  border-color: #4a93eb;
  transform: translateY(-1px);
}

.output-guidance {
  margin: 0 0 12px;
  padding: 11px 12px;
  border: 1px solid #FFE2A1;
  border-radius: 10px;
  background: #fff6e9;
  color: #C96409;
  font-size: 12px;
  line-height: 1.5;
}

.output-guidance code {
  font-family: Consolas, "SFMono-Regular", monospace;
  color: #C96409;
}

#outputText {
  height: 360px;
  min-height: 360px;
  max-height: 42vh;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  background: #fbfdff;
}

.output-tools {
  margin-top: 10px;
}

.note {
  margin: 12px 0 0;
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

.toast {
  min-height: 22px;
  margin-top: 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.toast.is-floating {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 120;
  min-height: 0;
  margin: 0;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(34, 34, 34, 0.88);
  color: #ffffff !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

dialog {
  width: min(820px, calc(100vw - 28px));
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

dialog::backdrop {
  background: rgba(20, 27, 24, 0.44);
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.tech-dialog-body {
  max-height: min(820px, calc(100vh - 32px));
}

.tech-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.selected-tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 34px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbf9;
}

.selected-tech-list:empty::before {
  content: "尚未选择科技";
  color: var(--muted);
  font-size: 13px;
}

.selected-tech-list button {
  border: 1px solid #d39d38;
  border-radius: 6px;
  background: #fff0c2;
  color: #684200;
  padding: 4px 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.technology-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  max-height: 430px;
  overflow-y: auto;
  padding: 2px;
}

.technology-item {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.technology-item:hover {
  border-color: var(--green);
}

.technology-item.active {
  background: #e0f2ea;
  border-color: var(--green);
}

.technology-item strong {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  color: var(--blue);
  overflow-wrap: anywhere;
}

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

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

  .output-panel {
    position: static;
    grid-column: 1 / -1;
  }

  #outputText {
    min-height: 260px;
    height: 320px;
  }
}

@media (max-width: 860px) {
  .app-header {
    position: static;
  }

  .header-inner {
    grid-template-columns: 1fr;
  }

  .header-brand {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand-media {
    width: 58px;
    height: 58px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    width: calc(100% - 24px);
    padding: 12px 0;
  }

  .nav-panel {
    position: static;
  }

  .group-nav {
    grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .app-header {
    padding: 14px 0;
  }

  .header-inner {
    width: calc(100% - 24px);
  }

  .header-actions,
  .dialog-actions,
  .output-tools,
  .output-actions {
    align-items: stretch;
  }

  .output-head,
  .template-title-row {
    align-items: start;
    flex-direction: column;
  }

  .header-actions > *,
  .dialog-actions > *,
  .output-tools > *,
  .output-actions > * {
    flex: 1 1 auto;
  }

  .group-head {
    align-items: start;
    flex-direction: column;
  }

  .template-head {
    align-items: start;
    flex-direction: column;
  }

  .range-line {
    grid-template-columns: 1fr;
  }

  .array-picker {
    grid-template-columns: 1fr;
  }

  .tech-toolbar {
    grid-template-columns: 1fr;
  }
}
