:root {
  color-scheme: light;
  --ink: #10182b;
  --muted: #69758a;
  --line: #dfe5ef;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --navy: #0a1630;
  --blue: #326dff;
  --blue-dark: #2459dc;
  --green: #18a86b;
  --danger: #c64050;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: #748096;
  background: #f5f7fb;
  font-size: 14px;
}

.loading-screen img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(50, 109, 255, 0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(50, 109, 255, 0.04) 1px, transparent 1px) 0 0 / 40px 40px,
    #f3f6fa;
}

.login-panel {
  width: min(100%, 420px);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(29, 48, 82, 0.1);
}

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

.login-brand img,
.sidebar-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.login-brand span,
.sidebar-brand span {
  display: grid;
  gap: 2px;
}

.login-brand strong,
.sidebar-brand strong {
  font-size: 19px;
  font-weight: 800;
}

.login-brand small,
.sidebar-brand small {
  color: var(--muted);
  font-size: 12px;
}

.login-panel h1 {
  margin: 36px 0 24px;
  font-size: 28px;
  line-height: 1.2;
}

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

.login-form label,
.field-label {
  color: #344057;
  font-size: 13px;
  font-weight: 700;
}

.login-form label:not(:first-child) {
  margin-top: 8px;
}

.login-form input,
.field-control {
  width: 100%;
  border: 1px solid #d8dfeb;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-form input {
  height: 48px;
  padding: 0 14px;
}

.login-form input:focus,
.field-control:focus {
  border-color: #5a86ff;
  box-shadow: 0 0 0 3px rgba(50, 109, 255, 0.11);
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 750;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.button-primary {
  color: #fff;
  background: var(--blue);
}

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

.button-secondary {
  border-color: #cad4e4;
  color: #334057;
  background: #fff;
}

.button-secondary:hover {
  border-color: #91a3bf;
  background: #f8faff;
}

.button-danger {
  border-color: #edcbd0;
  color: var(--danger);
  background: #fff;
}

.button-danger:hover {
  background: #fff6f7;
}

.login-submit {
  width: 100%;
  margin-top: 16px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.back-link {
  display: table;
  margin: 18px auto 0;
  color: #667289;
  font-size: 13px;
}

.back-link:hover {
  color: var(--blue);
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  color: #fff;
  background: var(--navy);
}

.sidebar-brand {
  padding: 0 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand small {
  color: rgba(255, 255, 255, 0.56);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.sidebar-nav button {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.66);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.sidebar-nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-nav button.is-active {
  color: #fff;
  background: #1b3b80;
}

.nav-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 10px;
  opacity: 0.75;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer a,
.sidebar-footer button {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border: 0;
  color: rgba(255, 255, 255, 0.66);
  background: transparent;
  font-size: 13px;
}

.sidebar-footer a:hover,
.sidebar-footer button:hover {
  color: #fff;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.topbar-kicker {
  margin: 0 0 3px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
}

.topbar h1 {
  margin: 0;
  font-size: 23px;
}

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

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #59657a;
  font-size: 12px;
}

.connection-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.workspace-content {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 32px;
}

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

.summary-item {
  min-height: 150px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px solid #dce4f1;
  border-top: 3px solid #7d8ba3;
  border-radius: var(--radius);
  background: #fff;
}

.summary-item span {
  color: #657187;
  font-size: 13px;
  font-weight: 700;
}

.summary-item strong {
  font-size: 36px;
  line-height: 1;
}

.summary-item small {
  color: #8993a5;
}

.summary-blue {
  border-top-color: var(--blue);
}

.summary-green {
  border-top-color: var(--green);
}

.overview-section,
.editor-section {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.section-heading span,
.editor-section-head p {
  color: #7c8799;
  font-size: 12px;
}

.section-heading h2,
.editor-section-head h2 {
  margin: 3px 0 0;
  font-size: 18px;
}

.publish-badge {
  padding: 6px 10px;
  border: 1px solid #bce6d2;
  border-radius: 999px;
  color: #138154 !important;
  background: #effbf5;
  font-weight: 750;
}

.status-list {
  margin: 0;
  padding: 4px 22px;
}

.status-list div {
  min-height: 58px;
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  border-bottom: 1px solid #edf0f5;
}

.status-list div:last-child {
  border-bottom: 0;
}

.status-list dt {
  color: #737e91;
  font-size: 13px;
}

.status-list dd {
  margin: 0;
  color: #2b364c;
  font-size: 14px;
  font-weight: 650;
}

.overview-actions {
  display: flex;
  gap: 10px;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
}

.text-editor,
.image-editor {
  display: grid;
  gap: 20px;
}

.editor-section {
  margin-top: 0;
}

.editor-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.editor-section-head p {
  margin: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 22px;
}

.field {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
}

.field.is-wide {
  grid-column: 1 / -1;
}

.field-control {
  min-height: 44px;
  padding: 10px 12px;
  line-height: 1.55;
}

textarea.field-control {
  min-height: 92px;
  resize: vertical;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 20px;
}

.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.image-preview {
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(45deg, #eef2f8 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #eef2f8 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #eef2f8 75%) 8px -8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #eef2f8 75%) -8px 0 / 16px 16px,
    #f8faff;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-card-body {
  padding: 15px;
}

.image-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.image-card p {
  min-height: 38px;
  margin: 7px 0 14px;
  color: #7b8698;
  font-size: 12px;
  line-height: 1.55;
}

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

.image-actions .button {
  min-height: 38px;
  flex: 1;
  padding: 0 10px;
  font-size: 12px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 120;
  max-width: min(380px, calc(100% - 48px));
  padding: 13px 16px;
  border: 1px solid #cfd9e7;
  border-radius: 6px;
  color: #243049;
  background: #fff;
  box-shadow: 0 14px 36px rgba(23, 39, 67, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast[data-tone="success"] {
  border-color: #aee1c8;
  color: #116b47;
}

.toast[data-tone="error"] {
  border-color: #efbec5;
  color: #9f2737;
}

@media (max-width: 1020px) {
  .admin-app {
    grid-template-columns: 206px minmax(0, 1fr);
  }

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

@media (max-width: 760px) {
  .admin-app {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .sidebar-brand {
    padding: 0 4px 14px;
  }

  .sidebar-brand img {
    width: 40px;
    height: 40px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 14px;
  }

  .sidebar-nav button {
    min-width: 0;
    justify-content: center;
    padding: 0 6px;
    font-size: 12px;
  }

  .nav-mark,
  .sidebar-footer {
    display: none;
  }

  .topbar {
    position: static;
    min-height: 76px;
    padding: 14px 18px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .connection-status {
    display: none;
  }

  .workspace-content {
    padding: 18px;
  }

  .summary-grid,
  .field-grid,
  .image-grid {
    grid-template-columns: 1fr;
  }

  .summary-item {
    min-height: 118px;
  }

  .field.is-wide {
    grid-column: auto;
  }

  .overview-actions {
    flex-direction: column;
  }

  .status-list div {
    grid-template-columns: 110px 1fr;
  }

  .login-panel {
    padding: 28px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
