:root {
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #eaf1ff;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --ink: #111827;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #d8dee8;
  --panel: #ffffff;
  --soft-panel: #f8fafc;
  --page: #f1f5f9;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar: 260px;
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
}

textarea {
  resize: vertical;
}

::selection {
  background: var(--brand-soft);
  color: var(--brand);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.2;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.category-nav {
  display: grid;
  gap: 6px;
}

.cat-btn {
  width: 100%;
  min-height: 42px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  text-align: left;
}

.cat-btn:hover {
  background: var(--soft-panel);
  color: var(--ink);
}

.cat-btn.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

.cat-btn .count {
  font-size: 12px;
  color: var(--subtle);
  font-weight: 600;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 82px;
  padding: 16px 28px;
  background: rgba(241, 245, 249, 0.92);
  border-bottom: 1px solid rgba(216, 222, 232, 0.75);
  backdrop-filter: blur(14px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--soft-panel);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
  background: #e9eef6;
}

.menu-btn {
  display: none;
}

.search-wrap {
  position: relative;
  width: min(380px, 42vw);
  flex: 0 1 380px;
}

.search-wrap > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  height: 46px;
  padding: 0 48px 0 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.search-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.clear-search {
  position: absolute;
  right: 5px;
  top: 4px;
  display: none;
  background: transparent;
}

.clear-search.show {
  display: inline-flex;
}

.main-grid {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 28px 44px;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 22px;
}

.tool-list-panel,
.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tool-list-panel {
  align-self: start;
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.panel-title strong {
  color: var(--brand);
}

.tool-list {
  display: grid;
  gap: 10px;
}

.tool-card {
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 12px;
  text-align: left;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 11px;
  align-items: center;
}

.tool-card:hover {
  border-color: #b8c4d6;
  background: var(--soft-panel);
}

.tool-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tool-card .card-icon,
.tool-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
}

.tool-card strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.tool-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tool-panel {
  min-width: 0;
  overflow: hidden;
}

.tool-head {
  min-height: 82px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.tool-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tool-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.tool-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.tool-body {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.option-label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field textarea,
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft-panel);
  color: var(--ink);
  outline: 0;
}

.field textarea {
  min-height: 260px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

.field input,
.field select {
  min-height: 42px;
  padding: 0 12px;
}

.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.readonly {
  background: #f3f6fb !important;
}

.control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.option-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0 16px;
}

.option-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 600;
}

.option-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  background: #e9eef6;
}

.btn:hover {
  background: #dce5f1;
}

.btn-primary {
  color: #fff;
  background: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-success {
  color: #fff;
  background: var(--green);
}

.btn-success:hover {
  background: #047857;
}

.btn-danger {
  color: #fff;
  background: var(--red);
}

.btn-danger:hover {
  background: #b91c1c;
}

.status-line {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.status-line.ok {
  color: var(--green);
}

.status-line.err {
  color: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft-panel);
  padding: 12px;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-box strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.preview-box {
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft-panel);
  display: grid;
  place-items: center;
  padding: 16px;
}

.color-swatch {
  width: 100%;
  min-height: 110px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.qr-box {
  min-height: 300px;
  border: 1px dashed #b8c4d6;
  border-radius: var(--radius);
  background: var(--soft-panel);
  display: grid;
  place-items: center;
  padding: 18px;
}

.qr-box canvas,
.qr-box img {
  max-width: 100%;
  height: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: var(--radius);
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.drawer-mask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(15, 23, 42, 0.36);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.site-error {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-panel {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.error-panel h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.error-panel p {
  margin: 0 0 20px;
  color: var(--muted);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(310px, 88vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .drawer-mask.show {
    display: block;
  }

  .menu-btn {
    display: inline-flex;
  }

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

@media (max-width: 780px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
  }

  .search-wrap {
    width: 100%;
    flex-basis: auto;
  }

  .main-grid {
    padding: 14px;
    gap: 14px;
  }

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

  .tool-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .form-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }

  .field textarea {
    min-height: 210px;
  }

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

@media (max-width: 460px) {
  .topbar h1 {
    font-size: 19px;
  }

  .tool-body {
    padding: 14px;
  }

  .tool-list-panel {
    padding: 12px;
  }

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

  .btn {
    width: 100%;
  }
}
