:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-soft: #f8f7f4;
  --ink: #1f2528;
  --muted: #687276;
  --line: #ded9d0;
  --teal: #19766f;
  --teal-dark: #10524d;
  --brick: #9c4333;
  --shadow: 0 18px 45px rgba(42, 38, 31, 0.12);
}

* {
  box-sizing: border-box;
}

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

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

button {
  border: 0;
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-header {
  width: min(1180px, calc(100% - 28px));
  margin: 14px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(54, 47, 38, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #fff;
  background: var(--teal);
  border-radius: 8px;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  letter-spacing: 0;
}

.brand p,
.panel-title p,
.section-heading p,
.status-line,
.admin-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.header-link {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.public-layout {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 18px;
}

.work-panel,
.result-panel,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.work-panel,
.result-panel {
  padding: 18px;
}

.panel-title,
.section-heading {
  margin-bottom: 16px;
}

.panel-title h2,
.section-heading h2,
.admin-card h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 170px;
  padding: 18px;
  border: 1px dashed #b9b2a6;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.upload-zone.is-dragging {
  border-color: var(--teal);
  background: #edf7f5;
}

.upload-zone input,
.file-picker input {
  display: none;
}

.upload-zone svg {
  width: 38px;
  height: 38px;
  color: var(--teal);
}

.upload-zone strong {
  color: var(--ink);
}

.field {
  margin-top: 16px;
}

label,
.field > label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input[type="text"],
input[type="password"],
input[type="url"],
select,
textarea {
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(25, 118, 111, 0.12);
}

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

.lock-card {
  min-height: 142px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
  color: var(--ink);
}

.lock-card.is-selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.lock-card img {
  display: block;
  width: 100%;
  height: 96px;
  object-fit: contain;
  margin-bottom: 8px;
  filter: drop-shadow(0 8px 10px rgba(45, 42, 38, 0.22));
}

.lock-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  margin-top: 18px;
  color: #fff;
  background: var(--teal);
}

.primary-button:hover {
  background: var(--teal-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.secondary-button {
  width: max-content;
  margin-top: 14px;
  color: var(--ink);
  background: #ece8df;
  text-decoration: none;
}

.status-line {
  margin-top: 10px;
}

.status-line.is-error {
  color: var(--brick);
}

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

.preview-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 640px;
  background:
    linear-gradient(45deg, rgba(31, 37, 40, 0.045) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(31, 37, 40, 0.045) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(31, 37, 40, 0.045) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(31, 37, 40, 0.045) 75%);
  background-size: 26px 26px;
  background-position: 0 0, 0 13px, 13px -13px, -13px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.preview-box img {
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 58px;
  height: 58px;
  color: #9f9789;
}

.admin-page {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto;
}

.login-card {
  width: min(420px, 100%);
  padding: 20px;
}

.admin-dashboard {
  display: grid;
  gap: 18px;
}

.admin-card {
  padding: 18px;
}

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

.wide-label {
  margin-top: 14px;
}

.file-picker span {
  display: grid;
  place-items: center;
  min-height: 43px;
  margin-top: 7px;
  color: var(--ink);
  background: #ece8df;
  border-radius: 8px;
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.admin-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-list-item.lock-row {
  grid-template-columns: 64px minmax(0, 1fr) auto auto;
}

.admin-list-item img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
}

.admin-list-item strong,
.admin-list-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-list-item small {
  margin-top: 3px;
  color: var(--muted);
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.danger-button {
  min-height: 34px;
  padding: 0 11px;
  color: #fff;
  background: var(--brick);
  border-radius: 8px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .public-layout,
  .form-grid,
  .model-editor,
  .lock-editor {
    grid-template-columns: 1fr;
  }

  .preview-box {
    min-height: 440px;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .admin-list-item,
  .admin-list-item.lock-row {
    grid-template-columns: 1fr;
  }
}
