:root {
  --ink: #17233c;
  --muted: #63718a;
  --line: #dfe6f2;
  --paper: #f4f8fd;
  --panel: #ffffff;
  --blue: #266fd8;
  --deep: #123b68;
  --danger: #d94c5f;
  --shadow: 0 18px 46px rgba(18, 59, 104, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial,
    sans-serif;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 179, 33, 0.22), transparent 28%),
    linear-gradient(135deg, #fff7e4 0%, #eaf7ff 56%, #ffe6ed 100%);
}

.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 44px;
  height: 44px;
  padding: 8px;
  border-radius: 8px;
  background: var(--deep);
  object-fit: contain;
}

.login-card p {
  margin: 18px 0 4px;
  color: var(--muted);
}

.login-card h1 {
  margin: 0 0 22px;
}

.login-card form {
  display: grid;
  gap: 16px;
}

.login-card .primary-button {
  width: 100%;
}

#loginMessage {
  display: block;
  min-height: 24px;
  margin-top: 14px;
  color: var(--danger);
  font-weight: 800;
}

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

button {
  cursor: pointer;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  padding: 22px;
  background: #101b31;
  color: #ffffff;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  color: #ffffff;
  font-weight: 900;
  text-decoration: none;
}

.admin-brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

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

.admin-sidebar a:not(.admin-brand) {
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
}

.admin-sidebar a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.admin-main {
  width: min(1180px, calc(100% - 236px));
  margin-left: 236px;
  padding: 28px clamp(18px, 4vw, 44px) 60px;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -28px calc(clamp(18px, 4vw, 44px) * -1) 22px;
  padding: 22px clamp(18px, 4vw, 44px);
  background: rgba(244, 248, 253, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.admin-topbar p,
.panel-title p {
  margin: 0;
  color: var(--muted);
}

.admin-topbar h1,
.panel-title h2 {
  margin: 4px 0 0;
}

.topbar-actions,
.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  margin-bottom: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(18, 59, 104, 0.06);
}

.panel-title {
  margin-bottom: 20px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #334462;
  font-size: 14px;
  font-weight: 800;
}

label.wide {
  grid-column: 1 / -1;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(38, 111, 216, 0.12);
}

.list-head,
.nested-title {
  margin-top: 26px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.list-head h3 {
  margin: 0;
}

.repeat-list {
  display: grid;
  gap: 12px;
}

.repeat-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbff;
}

.repeat-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.repeat-toolbar strong {
  color: var(--muted);
}

.repeat-actions {
  display: flex;
  gap: 8px;
}

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

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

.primary-button,
.ghost-button,
.danger-button,
.file-button,
[data-add],
.repeat-actions button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  font-weight: 900;
  text-decoration: none;
}

.primary-button {
  background: var(--deep);
  color: #ffffff;
}

.ghost-button,
[data-add],
.repeat-actions button,
.file-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--deep);
}

.danger-button,
.repeat-actions .delete {
  background: #fff1f3;
  border-color: #ffd3da;
  color: var(--danger);
}

.file-button input {
  display: none;
}

.image-preview {
  width: min(520px, 100%);
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf3fb;
}

.logo-preview {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101b31;
}

.logo-preview img {
  max-width: 74px;
  max-height: 74px;
  object-fit: contain;
}

.image-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.field-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.rich-editor-wrap {
  display: grid;
  gap: 10px;
}

.rich-toolbar,
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rich-toolbar button,
.toolbar-upload,
.share-row button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--deep);
  padding: 7px 10px;
  font-weight: 900;
}

.toolbar-upload input {
  display: none;
}

.rich-editor {
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  outline: none;
  line-height: 1.75;
}

.rich-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(38, 111, 216, 0.12);
}

.rich-editor img {
  max-width: 100%;
  border-radius: 8px;
}

.share-row input {
  flex: 1 1 360px;
}

.json-box {
  min-height: 260px;
  margin-top: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101b31;
  color: #ffffff;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: static;
    width: auto;
  }

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

  .admin-main {
    width: 100%;
    margin-left: 0;
  }

  .admin-topbar,
  .form-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    position: static;
    display: grid;
  }
}

@media (max-width: 560px) {
  .form-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .tool-row,
  .repeat-toolbar {
    flex-direction: column;
  }
}
