:root {
  --ink: #17202a;
  --muted: #66717d;
  --line: #dfe4e8;
  --brand: #223f63;
  --accent: #b78b43;
  --soft: #f6f8fa;
  --white: #fff;
  --admin-header-offset: 72px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-bottom: 72px;
  color: var(--ink);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: var(--soft);
}

a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 28px;
  color: #fff;
  background: #162435;
  box-shadow: 0 8px 24px rgba(17, 27, 38, .14);
}

.admin-header h1,
.admin-header p {
  margin: 0;
}

.admin-header p {
  margin-top: 3px;
  color: #d7e0e8;
  font-size: 14px;
}

.admin-header h1 {
  font-size: 25px;
  line-height: 1.15;
}

.admin-header nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.admin-header a {
  color: #fff;
}

.admin-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 10px auto 96px;
  padding-top: 58px;
}

.admin-section,
.login-card,
.sub-card {
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(17, 27, 38, .08);
}

.admin-section {
  margin-bottom: 16px;
}

.admin-section h2,
.sub-card h3 {
  margin: 0 0 12px;
}

.sub-card {
  margin: 12px 0;
  box-shadow: none;
  background: #fbfdfd;
}

.sub-card--new {
  border-style: dashed;
  background: #fff;
}

.sub-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.sub-card__head h3 {
  margin: 0;
}

.sub-card__head span,
.field-note {
  color: var(--muted);
  font-size: 13px;
}

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

label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 700;
}

input,
textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-weight: 400;
  background: #fff;
}

textarea {
  resize: vertical;
}

input[type="file"] {
  padding: 9px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  margin-top: 23px;
}

.check-row input {
  width: auto;
  margin: 0;
}

button,
.sticky-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 4px;
  color: #111a24;
  background: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.notice {
  margin-bottom: 18px;
  padding: 13px 16px;
  border-radius: 6px;
  font-weight: 700;
}

.notice--success {
  color: #0f4f3e;
  background: #dff4ec;
}

.notice--error {
  color: #8c241b;
  background: #ffe2df;
}

.image-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.image-preview img {
  width: 132px;
  height: 78px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.image-preview span {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: #f3f6f8;
}

.rich-toolbar button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-weight: 700;
}

.rich-image-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -4px 0 14px;
  padding: 9px 10px;
  border: 1px solid #e1d0a8;
  border-radius: 6px;
  background: #fffaf0;
  box-shadow: 0 10px 22px rgba(34, 63, 99, .08);
}

.rich-image-toolbar[hidden] {
  display: none;
}

.rich-image-toolbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.rich-image-toolbar button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--brand);
  background: #fff;
  border: 1px solid #dccda9;
  border-radius: 4px;
  font-weight: 800;
}

.rich-image-toolbar button.is-active {
  color: #111a24;
  background: var(--accent);
  border-color: var(--accent);
}

.rich-image-toolbar [data-image-remove] {
  color: #fff;
  background: #b44a3f;
  border-color: #b44a3f;
}

.rich-editor {
  min-height: 180px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 4px 4px;
  outline: 0;
  line-height: 1.7;
}

.rich-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(34, 63, 99, .12);
}

.rich-editor h3 {
  margin: 16px 0 8px;
}

.rich-editor p {
  margin: 0 0 10px;
}

.rich-editor p.rich-empty-paragraph {
  min-height: 30px;
  margin: 8px 0 12px;
  border-radius: 4px;
}

.rich-editor p.rich-empty-paragraph:focus {
  outline: 1px dashed rgba(34, 63, 99, .2);
  outline-offset: 4px;
}

.rich-editor figure {
  margin: 14px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.rich-editor figure.rich-figure {
  width: 100%;
}

.rich-editor figure.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(183, 139, 67, .16);
}

.rich-editor figure.size-small {
  width: 42%;
}

.rich-editor figure.size-medium {
  width: 62%;
}

.rich-editor figure.size-large {
  width: 82%;
}

.rich-editor figure.size-full {
  width: 100%;
}

.rich-editor figure.align-left {
  margin-right: auto;
  margin-left: 0;
}

.rich-editor figure.align-center {
  margin-right: auto;
  margin-left: auto;
}

.rich-editor figure.align-right {
  margin-right: 0;
  margin-left: auto;
}

.rich-editor figure img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 4px;
  cursor: default;
}

.rich-editor figcaption {
  margin-top: 8px;
  padding-top: 8px;
  color: #637789;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.65;
  border-top: 1px solid #e9eef2;
}

.rich-editor figcaption,
.rich-editor figcaption * {
  color: #637789 !important;
  font-size: 13px !important;
  font-style: normal !important;
  font-weight: 400 !important;
  line-height: 1.65 !important;
}

.is-hidden {
  display: none;
}

.sticky-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 32;
  width: min(1080px, calc(100% - 40px));
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(246, 248, 250, .96);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 -10px 26px rgba(17, 27, 38, .12);
  backdrop-filter: blur(8px);
}

.sticky-actions button,
.sticky-actions a {
  min-height: 38px;
  padding: 0 18px;
}

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

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

.login-card h1 {
  margin-top: 0;
}

.login-card p {
  color: var(--muted);
}

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

.login-card a {
  display: inline-block;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .admin-header,
  .form-grid,
  .sticky-actions,
  .sub-card__head,
  .image-preview {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}

.admin-wrap {
  overflow-x: hidden;
}

.image-preview {
  max-width: 560px;
  overflow: hidden;
}

.image-preview a {
  display: block;
  flex: 0 0 160px;
}

.image-preview img {
  width: 160px !important;
  height: 92px !important;
  max-width: 160px !important;
  object-fit: cover !important;
}

.inquiry-list {
  display: grid;
  gap: 14px;
}

.inquiry-item {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.inquiry-item__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.inquiry-item__head time {
  color: var(--muted);
  font-size: 13px;
}

.inquiry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.inquiry-item p {
  margin: 12px 0 0;
  line-height: 1.7;
}

.admin-tabs {
  position: fixed;
  left: 50%;
  top: var(--admin-header-offset);
  z-index: 31;
  width: min(1080px, calc(100% - 40px));
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 7px;
  background: rgba(246, 248, 250, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(17, 27, 38, .08);
  backdrop-filter: blur(8px);
}

.admin-tabs button {
  min-height: 32px;
  padding: 0 12px;
  color: var(--brand);
  background: #fff;
  border: 1px solid var(--line);
}

.admin-tabs button.is-active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

[data-admin-section] {
  display: none;
}

[data-admin-section].is-active {
  display: block;
}

.section-help {
  margin: -6px 0 18px;
  color: var(--muted);
}

.form-grid--compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-field {
  margin: 12px 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-field__title {
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 800;
}

.image-field__controls {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, .6fr);
  gap: 10px;
  margin-top: 10px;
}

.image-preview {
  max-width: none;
  margin: 0;
  align-items: flex-start;
}

.image-preview a {
  flex: 0 0 150px;
}

.image-preview img {
  width: 150px !important;
  height: 88px !important;
  max-width: 150px !important;
}

.image-preview div {
  min-width: 0;
}

.image-preview strong {
  display: block;
  margin: 4px 0 6px;
}

.image-preview--empty {
  min-height: 88px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-style: dashed;
}

.gallery-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 10px 0 16px;
}

.gallery-preview__item,
.image-preview--editable {
  position: relative;
}

.gallery-preview__item {
  cursor: grab;
  transition: opacity .18s ease, transform .18s ease, box-shadow .18s ease;
}

.gallery-preview__item:active {
  cursor: grabbing;
}

.gallery-preview__item.is-dragging {
  opacity: .45;
  transform: scale(.98);
  box-shadow: 0 10px 22px rgba(17, 27, 38, .18);
}

.drag-handle {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 2;
  padding: 3px 7px;
  color: #fff;
  background: rgba(22, 36, 53, .78);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.gallery-preview a {
  display: block;
  overflow: hidden;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.gallery-preview img {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}

.gallery-preview span {
  display: block;
  padding: 8px;
  overflow-wrap: anywhere;
}

.preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 24px;
  min-width: 0;
  min-height: 24px;
  height: 24px;
  padding: 0;
  color: #fff;
  background: #b44a3f;
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(17, 27, 38, .22);
  font-size: 18px;
  line-height: 1;
}

.replace-image-button {
  width: 100%;
  min-height: 30px;
  padding: 0 8px;
  color: #fff;
  background: var(--brand);
  border-radius: 0 0 6px 6px;
  font-size: 13px;
}

.image-preview--editable {
  padding-right: 42px;
}

.image-preview--editable .replace-image-button {
  align-self: end;
  width: 120px;
  border-radius: 4px;
}

.upload-helper {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: -4px 0 14px;
}

.pending-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.pending-preview figure {
  width: 132px;
  margin: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.pending-preview img {
  width: 100%;
  height: 78px;
  object-fit: cover;
  border-bottom: 1px solid var(--line);
}

.pending-preview figcaption {
  padding: 6px 8px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.upload-action {
  min-height: 34px;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
}

.upload-action:disabled {
  cursor: wait;
  opacity: .72;
}

.upload-status {
  color: var(--muted);
  font-size: 13px;
}

.upload-status.is-error {
  color: #8c241b;
}

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

.delete-control input {
  display: none;
}

.delete-toggle {
  min-height: 30px;
  padding: 0 12px;
  color: #fff;
  background: #b44a3f;
}

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

.contact-method-card {
  padding: 16px;
}

.contact-method-card .contact-qr-field .image-field {
  margin-top: 4px;
  padding: 10px;
}

.contact-method-card .image-field__title {
  font-size: 14px;
}

.contact-method-card .image-preview {
  min-height: 76px;
}

.contact-method-card .image-preview a {
  flex-basis: 96px;
}

.contact-method-card .image-preview img {
  width: 96px !important;
  height: 72px !important;
  max-width: 96px !important;
}

.contact-method-card .image-preview--editable .replace-image-button {
  width: 96px;
}

.sub-card.is-marked-delete {
  border-color: #d39088;
  background: #fff7f5;
  opacity: .72;
}

textarea.is-hidden {
  display: none !important;
}

.rich-editor {
  min-height: 230px;
}

@media (max-width: 960px) {
  :root {
    --admin-header-offset: 104px;
  }

  .form-grid--compact,
  .image-field__controls {
    grid-template-columns: 1fr;
  }

  .rich-editor figure.size-small,
  .rich-editor figure.size-medium,
  .rich-editor figure.size-large {
    width: 100%;
  }
}
