:root {
  color-scheme: light;
  --page: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #edf1ef;
  --text: #17201d;
  --muted: #66716d;
  --line: #d7dfdb;
  --line-strong: #b9c6c0;
  --red: #b73b34;
  --red-dark: #8f2a25;
  --red-soft: #fff0ee;
  --green: #176f65;
  --green-dark: #0e554d;
  --green-soft: #e8f4f1;
  --gold: #a4792f;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(23, 32, 29, 0.1);
  --shadow-soft: 0 6px 18px rgba(23, 32, 29, 0.07);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

.login-page {
  --login-bg: #e8edf3;
  --login-text: #26364d;
  --login-muted: #5f6d80;
  --login-soft: #778397;
  --login-accent: #9f3937;
  --login-accent-dark: #7f2d2b;
  --login-accent-soft: #ead2d3;
  --login-light-shadow: rgba(255, 255, 255, 0.92);
  --login-dark-shadow: rgba(139, 153, 172, 0.34);
  position: relative;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  padding: clamp(24px, 5vw, 56px) 20px;
  background: var(--login-bg);
  color: var(--login-text);
  font-family:
    "Microsoft YaHei UI", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page::before,
.login-page::after {
  position: fixed;
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.login-page::before {
  width: min(34vw, 440px);
  aspect-ratio: 1;
  top: -18vw;
  right: -9vw;
  box-shadow:
    18px 18px 42px var(--login-dark-shadow),
    -18px -18px 42px var(--login-light-shadow);
}

.login-page::after {
  width: min(24vw, 300px);
  aspect-ratio: 1;
  bottom: -14vw;
  left: -7vw;
  box-shadow:
    inset 14px 14px 32px rgba(143, 157, 176, 0.27),
    inset -14px -14px 32px rgba(255, 255, 255, 0.75);
}

.login-shell {
  position: relative;
  width: min(460px, 100%);
}

.login-panel {
  display: grid;
  gap: 28px;
  padding: clamp(30px, 6vw, 46px);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 28px;
  background: var(--login-bg);
  box-shadow:
    22px 22px 48px var(--login-dark-shadow),
    -22px -22px 48px var(--login-light-shadow);
}

.login-panel h1 {
  margin: 0;
  color: var(--login-text);
  font-size: clamp(1.9rem, 6vw, 2.4rem);
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1.16;
}

.login-panel p {
  margin: 10px 0 0;
  color: var(--login-muted);
  line-height: 1.75;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--login-accent-dark);
  font-size: 0.92rem;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.login-mark {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  background: var(--login-bg);
  box-shadow:
    9px 9px 18px rgba(139, 153, 172, 0.3),
    -9px -9px 18px rgba(255, 255, 255, 0.88);
}

.login-mark img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100% - 12px);
  max-height: calc(100% - 12px);
  object-fit: contain;
}

.login-heading {
  max-width: 340px;
}

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

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

.login-form label {
  color: #35455c;
  font-size: 0.92rem;
  font-weight: 740;
}

.login-password-control {
  position: relative;
}

.login-form input {
  width: 100%;
  min-height: 56px;
  padding: 0 74px 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 16px;
  outline: 0;
  background: var(--login-bg);
  box-shadow:
    inset 6px 6px 12px rgba(139, 153, 172, 0.3),
    inset -6px -6px 12px rgba(255, 255, 255, 0.82);
  color: var(--login-text);
  font-size: 1rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.login-form input::placeholder {
  color: var(--login-soft);
  opacity: 1;
}

.login-form input:focus {
  border-color: rgba(159, 57, 55, 0.5);
  box-shadow:
    inset 5px 5px 10px rgba(139, 153, 172, 0.28),
    inset -5px -5px 10px rgba(255, 255, 255, 0.84),
    0 0 0 4px rgba(159, 57, 55, 0.11);
}

.login-form.has-error input {
  border-color: rgba(159, 57, 55, 0.68);
}

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: 9px;
  min-width: 54px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--login-accent-dark);
  font-size: 0.86rem;
  font-weight: 760;
  transform: translateY(-50%);
  transition:
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.login-password-toggle:hover {
  background: rgba(255, 255, 255, 0.22);
  box-shadow:
    3px 3px 7px rgba(139, 153, 172, 0.24),
    -3px -3px 7px rgba(255, 255, 255, 0.68);
}

.login-password-toggle:active {
  box-shadow:
    inset 3px 3px 6px rgba(139, 153, 172, 0.26),
    inset -3px -3px 6px rgba(255, 255, 255, 0.7);
  transform: translateY(-50%) scale(0.97);
}

.login-hint {
  color: var(--login-muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.login-page .login-form .login-submit {
  position: relative;
  min-height: 56px;
  margin-top: 2px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  background: var(--login-accent);
  box-shadow:
    8px 8px 16px rgba(129, 52, 53, 0.25),
    -8px -8px 16px rgba(255, 255, 255, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: #fffafa;
  font-weight: 760;
  letter-spacing: 0.04em;
}

.login-page .login-form .login-submit:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  background: var(--login-accent-dark);
  box-shadow:
    10px 10px 20px rgba(129, 52, 53, 0.28),
    -10px -10px 20px rgba(255, 255, 255, 0.76),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.login-page .login-form .login-submit:active:not(:disabled) {
  box-shadow:
    inset 5px 5px 10px rgba(87, 31, 31, 0.42),
    inset -4px -4px 9px rgba(255, 255, 255, 0.16);
  transform: translateY(1px) scale(0.99);
}

.login-page .login-form .login-submit:disabled {
  background: #875552;
  opacity: 0.72;
}

.login-page .login-form .login-submit[aria-busy="true"]::after {
  width: 12px;
  height: 12px;
  margin-left: 10px;
  border: 2px solid rgba(255, 250, 250, 0.42);
  border-top-color: #fffafa;
  border-radius: 50%;
  content: "";
  animation: login-spin 0.8s linear infinite;
}

.login-page button:focus-visible,
.login-customer-link:focus-visible {
  outline: 3px solid rgba(159, 57, 55, 0.28);
  outline-offset: 3px;
}

.login-error {
  min-height: 0;
  margin: -6px 0 0 !important;
  color: var(--login-accent-dark) !important;
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.5 !important;
}

.login-error:empty {
  display: none;
}

.login-customer-link {
  justify-self: center;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--login-muted);
  font-size: 0.9rem;
  font-weight: 680;
  text-align: center;
  text-decoration: none;
  transition:
    color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.login-customer-link:hover {
  color: var(--login-accent-dark);
  box-shadow:
    4px 4px 9px rgba(139, 153, 172, 0.23),
    -4px -4px 9px rgba(255, 255, 255, 0.72);
  transform: translateY(-1px);
}

.login-customer-link:active {
  box-shadow:
    inset 3px 3px 6px rgba(139, 153, 172, 0.24),
    inset -3px -3px 6px rgba(255, 255, 255, 0.68);
  transform: translateY(1px);
}

@keyframes login-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 520px) {
  .login-page {
    align-items: start;
    overflow-y: auto;
    padding: 32px 16px;
  }

  .login-page::before {
    top: -20vw;
    right: -22vw;
    width: 68vw;
  }

  .login-page::after {
    bottom: -18vw;
    left: -30vw;
    width: 74vw;
  }

  .login-panel {
    gap: 24px;
    padding: 28px 22px;
    border-radius: 24px;
    box-shadow:
      14px 14px 30px rgba(139, 153, 172, 0.31),
      -14px -14px 30px rgba(255, 255, 255, 0.88);
  }

  .login-mark {
    width: 64px;
    height: 64px;
    border-radius: 18px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .login-page *,
  .login-page *::before,
  .login-page *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
}

.admin-page {
  --admin-space-xs: 8px;
  --admin-space-sm: 12px;
  --admin-space-md: 16px;
  --admin-space-lg: 24px;
  --admin-space-xl: 32px;
}

button,
input,
select {
  font: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 36px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 78px;
  padding: 14px clamp(20px, 4vw, 52px);
  border-bottom: 1px solid rgba(215, 223, 219, 0.92);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 3px 14px rgba(23, 32, 29, 0.04);
  backdrop-filter: blur(14px);
}

.admin-page .topbar {
  border-top: 4px solid var(--red);
}

.customer-page .topbar {
  border-top: 4px solid var(--green);
}

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

.brand-mark,
.drop-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 7px;
  color: #ffffff;
}

.admin-page .brand-mark {
  background: var(--red);
}

.customer-page .brand-mark {
  width: 88px;
  height: 62px;
  padding: 3px;
  background: #ffffff;
  align-self: center;
}

.customer-page .brand-mark img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform: translateY(var(--customer-icon-offset-y, 0px)) scale(var(--customer-icon-scale, 1));
  transform-origin: center;
}

.customer-page .brand > div {
  display: grid;
  justify-content: center;
}

.brand h1,
.viewer h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.16rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand p,
.viewer p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.top-actions,
.batch-actions,
.control-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.customer-account {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 44px;
  margin-left: auto;
  padding: 5px 5px 5px 7px;
  gap: 9px;
  border: 1px solid #cfe1dc;
  border-radius: 9px;
  background: #f3f8f6;
}

.customer-account-avatar {
  display: block;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border: 1px solid #d8e2ef;
  border-radius: 50%;
  background: #ffffff;
}

.customer-account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.16);
}

.customer-account-copy {
  display: grid;
  min-width: 0;
  line-height: 1.2;
}

.customer-account-copy strong,
.customer-account-copy span {
  overflow: hidden;
  max-width: 132px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-account-copy strong {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 750;
}

.customer-account-copy span {
  margin-top: 3px;
  color: #52635e;
  font-size: 0.7rem;
}

.customer-account-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: #e4efeb;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease;
}

.customer-account-logout:hover:not(:disabled) {
  background: #d6e7e1;
  color: #093f39;
}

.customer-account-logout:focus-visible {
  outline: 3px solid rgba(23, 111, 101, 0.22);
  outline-offset: 2px;
}

.customer-account-logout:disabled {
  cursor: wait;
  opacity: 0.55;
}

.button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  white-space: nowrap;
  text-decoration: none;
}

.button:hover:not(:disabled),
.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 7px 16px rgba(23, 32, 29, 0.09);
}

.button:focus-visible,
.icon-button:focus-visible,
.category-chip:focus-visible,
.category-open:focus-visible,
.category-position-select:focus-visible,
.name-input:focus-visible,
.text-input:focus-visible,
.category-select:focus-visible,
select:focus-visible,
.drop-zone:focus-within {
  outline: 3px solid rgba(23, 111, 101, 0.22);
  outline-offset: 2px;
}

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

.customer-page .button.primary {
  border-color: var(--green);
  background: var(--green);
}

.button.primary:hover:not(:disabled) {
  background: var(--red-dark);
}

.customer-page .button.primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.button.ghost {
  background: #f8faf9;
}

.button.danger {
  border-color: #efc8c3;
  background: var(--red-soft);
  color: var(--danger);
}

.button.compact {
  min-height: 36px;
  padding: 0 12px;
}

.button:disabled {
  opacity: 0.46;
}

.workspace {
  width: min(1280px, calc(100% - 40px));
  margin: 24px auto 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.upload-panel {
  min-width: 0;
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: var(--admin-space-md, 16px);
  min-height: 168px;
  padding: var(--admin-space-lg, 24px);
  border: 1px dashed #aebbb5;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.drop-zone.dragging {
  transform: translateY(-2px);
  border-color: var(--green);
  background: var(--green-soft);
}

.drop-icon {
  width: 58px;
  height: 58px;
  border: 1px solid #edc4c0;
  color: var(--red);
  background: var(--red-soft);
}

.drop-icon svg {
  width: 29px;
  height: 29px;
}

.drop-copy {
  display: grid;
  gap: 6px;
}

.drop-copy strong {
  font-size: 1.04rem;
}

.drop-copy small {
  color: var(--muted);
  line-height: 1.5;
}

.category-panel,
.settings-panel {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: var(--admin-space-md, 16px);
  margin: 0;
  padding: var(--admin-space-lg, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.category-form,
.settings-form {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: var(--admin-space-sm, 12px);
  padding: var(--admin-space-sm, 12px);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
}

.settings-icon-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-avatar-setting {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
}

.settings-option-title {
  display: grid;
  gap: 3px;
}

.settings-option-title strong {
  color: var(--text);
  font-size: 0.9rem;
}

.settings-option-title span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.public-access-setting {
  display: flex;
  min-height: 92px;
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #d6ddd9;
  border-radius: 8px;
  background: #f7f9f8;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.public-access-setting.is-open {
  border-color: #89b8a1;
  background: #eef8f2;
}

.public-access-copy {
  display: grid;
  gap: 3px;
}

.public-access-copy > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.public-access-copy strong {
  color: var(--text);
  font-size: 0.98rem;
}

.public-access-setting.is-open .public-access-copy strong {
  color: var(--green-dark);
}

.public-access-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.switch-control {
  display: inline-flex;
  min-height: 48px;
  padding: 6px 8px;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

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

.switch-track {
  position: relative;
  display: block;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid #9eaaa4;
  border-radius: 999px;
  background: #dfe5e2;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.switch-track span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(23, 32, 29, 0.2);
  transition: transform 0.18s ease;
}

.switch-control input:checked + .switch-track {
  border-color: var(--green);
  background: var(--green);
}

.switch-control input:checked + .switch-track span {
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 3px solid rgba(23, 111, 101, 0.22);
  outline-offset: 3px;
}

.switch-control input:disabled + .switch-track,
.switch-control input:disabled ~ span {
  opacity: 0.58;
  cursor: wait;
}

@media (max-width: 560px) {
  .public-access-setting {
    align-items: stretch;
    flex-direction: column;
  }

  .switch-control {
    width: 100%;
    justify-content: space-between;
    padding: 8px 0 0;
  }
}

.settings-icon-preview {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 76px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.settings-icon-preview img {
  width: auto;
  height: auto;
  max-width: calc(100% - 6px);
  max-height: calc(100% - 6px);
  object-fit: contain;
  transform: translateY(var(--customer-icon-offset-y, 0px)) scale(var(--customer-icon-scale, 1));
  transform-origin: center;
}

.settings-avatar-preview {
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: 50%;
}

.settings-avatar-preview img,
.settings-history-icon.settings-history-avatar img {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  transform: scale(1.12);
}

.settings-history-avatar {
  width: 42px;
  height: 42px;
  overflow: hidden;
  padding: 0;
  border-radius: 50%;
}

.settings-icon-history {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.settings-history-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 40px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
}

.settings-history-item {
  position: relative;
  display: inline-grid;
}

.settings-history-icon:hover {
  border-color: var(--green);
}

.settings-history-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #efc8c3;
  border-radius: 50%;
  background: #ffffff;
  color: var(--danger);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.settings-history-icon img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.settings-history-empty {
  color: var(--muted);
  font-size: 0.86rem;
}

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

.settings-adjustments label {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9f8;
  color: var(--muted);
  font-size: 0.86rem;
}

.settings-adjustments input {
  width: 100%;
}

.input-label,
.select-label {
  color: var(--muted);
  font-size: 0.86rem;
}

.text-input,
.category-select,
select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

select {
  width: auto;
  padding-right: 36px;
}

.category-chips {
  display: grid;
  align-content: start;
  gap: var(--admin-space-xs, 8px);
}

.mobile-category-toggle,
.mobile-filter-row,
.mobile-viewer-nav,
.close-label {
  display: none;
}

.category-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 50px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.category-chip:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.category-label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.category-label svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: var(--gold);
}

.category-label strong {
  min-width: 0;
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.category-chip.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}

.category-chip.active .category-count {
  color: var(--green-dark);
}

.category-editor {
  display: grid;
  grid-template-columns: 82px 42px minmax(0, 1fr) auto 38px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 58px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.category-position-select {
  width: 82px;
  min-width: 82px;
  min-height: 36px;
  padding: 0 22px 0 8px;
  border: 1px solid #cfd9d4;
  border-radius: 5px;
  background: #e7ece9;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.category-position-select:hover:not(:disabled) {
  border-color: var(--line-strong);
  background-color: #ffffff;
}

.category-position-select:disabled {
  opacity: 0.55;
  cursor: wait;
}

.category-editor.active {
  border-color: var(--red);
  background: var(--red-soft);
}

.category-open {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #ffffff;
  color: var(--gold);
  cursor: pointer;
}

.category-editor.active .category-open {
  color: var(--red);
}

.category-editor-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.category-editor-name {
  display: block;
  min-width: 0;
  color: var(--text);
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-subtitle {
  color: var(--muted);
  font-size: 0.74rem;
}

.category-rename {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--red-dark);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.category-delete {
  width: 38px;
  min-height: 38px;
  color: var(--danger);
  background: #ffffff;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  flex-wrap: wrap;
}

.discovery-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-field {
  display: flex;
  flex: 1 1 320px;
  align-items: center;
  min-width: min(100%, 260px);
  min-height: 44px;
  gap: 9px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--muted);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.search-field:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(23, 111, 101, 0.12);
}

.admin-page .search-field:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(183, 59, 52, 0.11);
}

.search-field svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.search-field input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
}

.search-field input::placeholder {
  color: #5f6b67;
  opacity: 1;
}

.search-field input::-webkit-search-cancel-button {
  cursor: pointer;
}

.search-field kbd {
  display: inline-grid;
  width: 25px;
  height: 25px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  font: 700 0.78rem/1 ui-sans-serif, system-ui, sans-serif;
}

.filter-summary {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.clear-filters {
  flex: 0 0 auto;
}

.clear-filters[hidden] {
  display: none;
}

.admin-search-field {
  flex-basis: 310px;
  max-width: 420px;
}

.bulk-category-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-category-actions select {
  min-width: 132px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
}

.stats span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 5px;
  background: var(--surface-soft);
}

.stats strong {
  margin-right: 4px;
  color: var(--text);
}

.gallery-section {
  min-width: 0;
  min-height: 240px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  align-items: start;
  gap: 17px;
}

.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.image-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.image-card.selected {
  border-color: var(--red);
  box-shadow:
    0 0 0 3px rgba(183, 59, 52, 0.12),
    var(--shadow);
}

.thumb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #e5ebe8;
  overflow: hidden;
}

.thumb-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 3px 8px rgba(23, 32, 29, 0.12));
}

.customer-gallery .thumb-wrap img {
  cursor: zoom-in;
}

.customer-gallery .image-card {
  cursor: zoom-in;
}

.customer-thumb-action {
  min-width: 0;
  max-width: 100%;
  border: 0;
  color: inherit;
  cursor: zoom-in;
  text-align: inherit;
}

.customer-thumb-action:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: -3px;
}

.source-card,
.customer-gallery .source-card {
  cursor: default;
}

.admin-gallery .source-card.has-source-preview .thumb-wrap img,
.customer-gallery .source-card.has-source-preview,
.customer-gallery .source-card.has-source-preview .thumb-wrap {
  cursor: zoom-in;
}

.source-card .thumb-wrap {
  background:
    linear-gradient(135deg, rgba(242, 247, 244, 0.96), rgba(232, 239, 235, 0.94)),
    #eef4f1;
}

.source-card.has-source-preview .thumb-wrap {
  background: #e5ebe8;
}

.source-preview-action {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(14, 85, 77, 0.26);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 12px rgba(23, 32, 29, 0.13);
  color: var(--green-dark);
  font: 760 0.78rem/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.source-preview-action:hover {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(23, 32, 29, 0.18);
}

.source-preview-action:focus-visible {
  outline: 3px solid rgba(23, 111, 101, 0.28);
  outline-offset: 2px;
}

.source-preview-action:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.source-file-icon {
  display: grid;
  place-items: center;
  width: min(48%, 118px);
  aspect-ratio: 0.78;
  border: 1px solid rgba(23, 111, 101, 0.18);
  border-radius: 8px;
  background: #ffffff;
  color: var(--green-dark);
  box-shadow: 0 12px 24px rgba(23, 32, 29, 0.1);
}

.source-file-icon span {
  display: grid;
  place-items: center;
  width: 72%;
  min-height: 34px;
  border-radius: 6px;
  background: var(--green);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.gallery.category-transition .image-card {
  animation: gallery-category-in 0.14s ease-out;
}

@keyframes gallery-category-in {
  from {
    opacity: 0.72;
    transform: translateY(6px) scale(0.995);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.select-box {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(215, 223, 219, 0.9);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 5px 14px rgba(23, 32, 29, 0.14);
}

.select-box input {
  width: 19px;
  height: 19px;
  accent-color: var(--red);
}

.category-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 9px;
  border-radius: 5px;
  background: rgba(15, 24, 21, 0.82);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ratio-badge,
.long-thumb-label {
  display: none;
}

.image-info {
  display: grid;
  gap: 9px;
  padding: 13px;
}

.image-name {
  display: block;
  min-width: 0;
  margin: 0;
  font-weight: 760;
  line-height: 1.38;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-field {
  display: grid;
  gap: 6px;
}

.name-field span {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1;
}

.name-input {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
}

.image-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.image-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--surface-soft);
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 40px;
  gap: 8px;
  padding-top: 2px;
}

.customer-card-actions {
  grid-template-columns: 1fr 1fr;
}

.cdr-card:not(.has-source-preview) .customer-card-actions {
  grid-template-columns: 1fr;
}

.card-actions .button,
.card-actions .icon-button {
  min-height: 38px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  gap: 14px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  padding: 28px;
  text-align: center;
}

.empty-state p {
  margin: 0;
  color: var(--text);
  font-weight: 760;
}

.empty-state > span {
  max-width: 42ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty-state[hidden] {
  display: none;
}

.empty-art {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  align-items: end;
  gap: 7px;
}

.empty-art span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.empty-art span:nth-child(1) {
  height: 70px;
  border-top: 6px solid var(--red);
}

.empty-art span:nth-child(2) {
  height: 90px;
  border-top: 6px solid var(--green);
}

.empty-art span:nth-child(3) {
  height: 62px;
  border-top: 6px solid var(--gold);
}

.viewer {
  width: min(980px, calc(100% - 24px));
  height: min(820px, calc(100dvh - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.viewer::backdrop {
  background: rgba(17, 24, 39, 0.68);
}

.viewer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(17, 24, 39, 0.3);
}

.viewer-header,
.viewer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
}

.viewer-header {
  border-bottom: 1px solid var(--line);
}

.viewer-header > div {
  min-width: 0;
}

.viewer-heading {
  display: grid;
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  gap: 4px;
  overflow: hidden;
}

.viewer-category {
  display: none;
  width: fit-content;
  max-width: min(260px, 55vw);
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-page .viewer-category {
  display: block;
}

.viewer-header h2 {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-header > .icon-button {
  flex: 0 0 auto;
}

.viewer-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.viewer-footer.single-action {
  justify-content: flex-end;
}

.customer-viewer-footer .button {
  min-width: 132px;
}

.viewer-save-guidance {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  gap: 10px;
  color: var(--green-dark);
  text-align: left;
  overflow: hidden;
}

.viewer-save-target {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0.001;
  object-fit: cover;
  -webkit-touch-callout: default;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-save-guidance > svg,
.viewer-save-guidance > span {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.viewer-save-guidance > span {
  display: grid;
  gap: 2px;
}

.viewer-save-guidance strong {
  font-size: 0.92rem;
}

.viewer-save-guidance small {
  color: var(--muted);
  font-size: 0.76rem;
}

.wechat-download-guide {
  width: min(420px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.28);
}

.wechat-download-guide::backdrop {
  background: rgba(17, 24, 39, 0.62);
}

.wechat-guide-shell {
  display: grid;
  justify-items: stretch;
  gap: 16px;
  padding: 22px;
}

.wechat-guide-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.wechat-guide-shell h2 {
  margin: 0;
  font-size: 1.08rem;
}

.wechat-guide-shell p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  word-break: break-word;
}

.wechat-guide-shell ol {
  margin: 14px 0 0;
  padding-left: 1.4em;
  color: #3f4b47;
  font-size: 0.9rem;
  line-height: 1.8;
}

.mobile-save-hint {
  display: none;
  margin: 0;
  font-weight: 750;
  text-align: center;
}

.viewer-body {
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  background: #111827;
  overflow: hidden;
}

.viewer-body img {
  grid-column: 2;
  justify-self: center;
  display: block;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer.image-loading .viewer-body img {
  visibility: hidden;
}

.viewer.image-loading .viewer-body::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid rgba(255, 255, 255, 0.24);
  border-top-color: #ffffff;
  border-radius: 50%;
  content: "";
  animation: viewer-loading 0.8s linear infinite;
}

@keyframes viewer-loading {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer.image-loading .viewer-body::after {
    animation: none;
  }
}

.customer-page .viewer-body img {
  user-select: auto;
  -webkit-user-drag: auto;
  -webkit-touch-callout: default;
}

.viewer-resolution {
  position: absolute;
  left: 18px;
  bottom: 16px;
  z-index: 2;
  max-width: calc(100% - 36px);
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(7, 12, 10, 0.76);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  pointer-events: none;
}

.viewer-nav {
  justify-self: center;
  width: 40px;
  min-height: 40px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #17201d;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-bar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 30;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.mobile-bar span {
  font-weight: 750;
}

@media (prefers-reduced-motion: reduce) {
  .category-editor {
    transition: none;
  }

  .gallery.category-transition .image-card {
    animation: none;
  }
}

@media (min-width: 861px) {
  .admin-page .workspace {
    display: grid;
    grid-template-columns: minmax(300px, 0.78fr) minmax(480px, 1.22fr);
    align-items: start;
    gap: var(--admin-space-lg);
  }

  .admin-page .upload-panel {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
  }

  .admin-page .settings-panel {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  .admin-page .category-panel {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .admin-page .message-board {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .admin-page .controls,
  .admin-page .gallery-section {
    grid-column: 1 / -1;
  }

  .admin-page .category-chips {
    grid-template-columns: 1fr;
  }

  .admin-page .controls {
    margin-top: 2px;
  }

  .customer-page .workspace {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 24px;
    row-gap: 18px;
  }

  .customer-page .customer-category-panel {
    position: sticky;
    top: 102px;
    grid-column: 1;
    grid-row: 1 / 4;
    align-self: start;
    max-height: calc(100vh - 126px);
    overflow: auto;
    border-top: 5px solid var(--green);
  }

  .customer-page .customer-discovery-bar {
    grid-column: 2;
    grid-row: 1;
  }

  .customer-page .customer-controls {
    grid-column: 2;
    grid-row: 2;
  }

  .customer-page .gallery-section {
    grid-column: 2;
    grid-row: 3;
  }

  .customer-page .category-chip {
    width: 100%;
    min-height: 56px;
  }

  .customer-page .gallery {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (min-width: 1180px) {
  .admin-page .settings-panel {
    grid-template-columns: minmax(300px, 1.25fr) minmax(240px, 0.75fr);
  }

  .admin-page .settings-panel .section-title {
    grid-column: 1 / -1;
  }

  .admin-page .settings-form {
    grid-column: 1;
    grid-row: 2;
  }

  .admin-page .settings-icon-row {
    grid-column: 1;
    grid-row: 3;
  }

  .admin-page .settings-adjustments {
    grid-column: 2;
    grid-row: 2 / 4;
    grid-template-columns: 1fr;
    align-content: start;
  }

  .admin-page .public-access-setting {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  .admin-page .settings-avatar-setting {
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .admin-page .category-chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 640px;
    padding-right: 4px;
    overflow-y: auto;
  }

  .admin-page .category-all {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  body {
    background: #ffffff;
  }

  .app-shell {
    padding-bottom: 92px;
  }

  .topbar {
    position: relative;
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 15px 14px;
    border-top: 0;
    box-shadow: none;
  }

  .customer-page .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 10px 12px;
    border-top: 3px solid var(--red);
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(44, 35, 34, 0.08);
  }

  .customer-page .customer-account {
    grid-row: 2;
    grid-column: 1 / -1;
    width: 100%;
    min-height: 42px;
    margin: 2px 0 0;
    padding: 5px 5px 5px 6px;
    border-color: #dce8e4;
    background: #f6faf8;
  }

  .customer-page .customer-account-avatar {
    width: 30px;
    height: 30px;
  }

  .customer-page .customer-account-copy {
    flex: 1 1 auto;
  }

  .customer-page .customer-account-copy strong,
  .customer-page .customer-account-copy span {
    max-width: none;
  }

  .customer-page .customer-account-logout {
    min-height: 30px;
    padding: 0 12px;
  }

  .customer-page .brand {
    min-width: 0;
    gap: 10px;
  }

  .customer-page .brand > div {
    min-width: 0;
  }

  .customer-page .brand h1,
  .customer-page .brand p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer-page .brand-mark {
    width: 66px;
    height: 52px;
    padding: 3px;
    border-radius: 0;
    background: transparent;
    align-self: center;
  }

  .customer-page .brand h1 {
    display: block;
    color: #76272b;
    font-size: 1.02rem;
    line-height: 1.25;
  }

  .customer-page .brand p {
    display: block;
    margin-top: 3px;
    color: #8b8585;
    font-size: 0.76rem;
    line-height: 1.2;
  }

  .customer-page .top-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
  }

  .customer-page .top-actions .button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    border-color: #d8e4df;
    background: #f1f7f4;
    color: var(--green-dark);
  }

  .customer-page .top-actions .action-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .brand h1 {
    font-size: 1.25rem;
  }

  .brand p {
    font-size: 0.9rem;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .top-actions .button {
    width: 100%;
    min-height: 50px;
    font-size: 1rem;
    font-weight: 700;
  }

  .workspace {
    width: 100%;
    margin: 0;
  }

  .admin-page .workspace {
    display: flex;
    flex-direction: column;
  }

  .admin-page .message-board { order: 1; }
  .admin-page .upload-panel { order: 1; }
  .admin-page .controls { order: 2; }
  .admin-page .gallery-section { order: 3; }
  .admin-page .settings-panel { order: 4; }
  .admin-page .category-panel { order: 5; }

  .upload-panel,
  .category-panel,
  .controls,
  .gallery-section {
    margin: 0;
  }

  .upload-panel,
  .category-panel,
  .controls {
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }

  .drop-zone {
    min-height: 118px;
    padding: 18px 16px;
    border-width: 0 0 1px;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .drop-icon {
    width: 54px;
    height: 54px;
  }

  .drop-copy strong {
    font-size: 1.08rem;
  }

  .drop-copy small {
    font-size: 0.86rem;
  }

  .category-panel {
    padding: 20px 14px;
  }

  .customer-page .customer-category-panel {
    gap: 8px;
    padding: 10px 12px;
    background: #f7faf8;
  }

  .customer-page .customer-category-panel .section-title {
    display: none;
  }

  .mobile-category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #b8d3c9;
    border-radius: 999px;
    background: #ffffff;
    color: var(--text);
    text-align: left;
  }

  .mobile-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }

  .mobile-sort-control {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: 44px;
    gap: 5px;
    padding: 4px 7px 4px 9px;
    border: 1px solid #b8d3c9;
    border-radius: 999px;
    background: #ffffff;
    color: var(--green-dark);
    font-size: 0.78rem;
    font-weight: 750;
    min-width: 142px;
  }

  .mobile-sort-control select {
    width: auto;
    min-width: 94px;
    min-height: 34px;
    padding: 0 22px 0 5px;
    border: 0;
    background-color: transparent;
    color: var(--green-dark);
    font-size: 0.8rem;
    font-weight: 750;
    max-width: 104px;
  }

  .mobile-category-toggle span {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
  }

  .mobile-category-toggle small {
    color: var(--green-dark);
    font-size: 0.78rem;
    font-weight: 750;
  }

  .mobile-category-toggle strong {
    min-width: 0;
    max-width: 48vw;
    color: var(--green-dark);
    font-size: 0.84rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-category-toggle svg {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    color: var(--green);
    transition: transform 0.18s ease;
  }

  .mobile-category-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .section-title h2 {
    font-size: 1.18rem;
  }

  .section-title p {
    font-size: 0.9rem;
  }

  .category-form,
  .settings-form {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .settings-adjustments {
    grid-template-columns: 1fr;
  }

  .category-form .button,
  .settings-form .button,
  .text-input,
  .category-select,
  select {
    min-height: 50px;
    font-size: 1rem;
  }

  .category-form .button,
  .settings-form .button {
    width: 100%;
  }

  .customer-page .category-chips {
    display: none;
    flex-wrap: wrap;
    gap: 7px;
  }

  .customer-page .category-chips.mobile-open {
    display: flex;
  }

  .customer-page .category-chip {
    display: inline-flex;
    width: auto;
    min-height: 44px;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
  }

  .customer-page .category-label {
    gap: 5px;
  }

  .customer-page .category-label svg {
    display: none;
  }

  .customer-page .category-label strong {
    max-width: 34vw;
    font-size: 0.82rem;
  }

  .customer-page .category-count {
    display: none;
  }

  .admin-page .category-chips {
    grid-template-columns: 1fr;
  }

  .admin-page .category-chip,
  .category-editor {
    width: 100%;
    min-height: 62px;
  }

  .category-editor {
    grid-template-columns: 82px 48px minmax(0, 1fr) 46px;
  }

  .category-position-select,
  .category-open {
    grid-row: 1 / span 2;
  }

  .category-position-select {
    grid-column: 1;
    width: 82px;
    min-width: 82px;
    min-height: 46px;
  }

  .category-editor-main {
    grid-column: 3;
    grid-row: 1;
  }

  .category-rename {
    grid-column: 3;
    grid-row: 2;
    justify-self: start;
  }

  .category-delete {
    grid-column: 4;
    grid-row: 1 / span 2;
  }

  .category-open,
  .category-delete {
    width: 46px;
    min-height: 46px;
  }

  .category-editor-name {
    font-size: 1rem;
  }

  .category-subtitle {
    font-size: 0.82rem;
  }

  .controls {
    align-items: stretch;
    gap: 12px;
    padding: 16px 14px;
  }

  .discovery-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 10px;
    padding: 12px;
    border-width: 0 0 1px;
    border-radius: 0;
  }

  .search-field {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .search-field kbd {
    display: none;
  }

  .filter-summary {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .clear-filters {
    min-height: 42px;
  }

  .admin-search-field {
    max-width: none;
  }

  .bulk-category-actions {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
  }

  .stats,
  .control-group,
  .batch-actions {
    width: 100%;
  }

  .customer-page .customer-controls .stats {
    display: none;
  }

  .customer-page .customer-controls {
    display: none;
  }

  .customer-page .customer-controls .control-group {
    width: auto;
    margin-left: auto;
  }

  .customer-page .customer-controls .control-group select {
    flex: 0 0 auto;
    min-width: 112px;
  }

  .stats span {
    min-height: 40px;
    font-size: 0.95rem;
  }

  .control-group {
    justify-content: space-between;
  }

  .control-group label {
    font-size: 1rem;
    font-weight: 700;
  }

  .control-group select {
    flex: 1;
  }

  .batch-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .batch-actions .button {
    min-height: 48px;
    padding-inline: 7px;
    font-weight: 700;
  }

  .gallery-section {
    padding: 14px;
  }

  .customer-page .gallery {
    display: block;
    columns: 2;
    column-gap: 10px;
  }

  .customer-page .gallery.category-transition .image-card {
    animation: mobile-gallery-category-in 0.2s ease-out;
  }

  @keyframes mobile-gallery-category-in {
    from {
      opacity: 0.45;
      transform: translateY(14px) scale(0.985);
    }

    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }

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

  .customer-page .image-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 10px;
    break-inside: avoid;
    vertical-align: top;
    border-radius: 7px;
    border-color: #cbd5d0;
    box-shadow: 0 5px 18px rgba(23, 32, 29, 0.09);
    transition:
      transform 0.12s ease,
      border-color 0.12s ease,
      box-shadow 0.12s ease;
  }

  .customer-page .image-card:active {
    transform: scale(0.992);
    border-color: #9eb0a8;
    box-shadow: 0 2px 9px rgba(23, 32, 29, 0.1);
  }

  .customer-page .thumb-wrap {
    display: block;
    aspect-ratio: auto;
    padding: 0;
    border-bottom: 0;
    background: #e7ece9;
  }

  .customer-page .thumb-wrap img {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    filter: none;
  }

  .customer-page .source-card .thumb-wrap {
    display: grid;
    place-items: center;
    min-height: 168px;
    padding: 16px;
  }

  .customer-page .source-card.has-source-preview .thumb-wrap {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .customer-page .source-card .source-file-icon {
    width: min(50%, 96px);
  }

  .customer-page .source-card:active {
    transform: none;
  }

  .customer-page .long-thumb .thumb-wrap {
    max-height: 360px;
  }

  .customer-page .long-thumb .thumb-wrap::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 88px;
    background: linear-gradient(to bottom, transparent, rgba(10, 18, 15, 0.76));
    content: "";
    pointer-events: none;
  }

  .customer-page .long-thumb .thumb-wrap img {
    width: 100%;
    height: auto;
    object-fit: initial;
    object-position: top;
  }

  .customer-page .ratio-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    /* 比例标记暂时隐藏；保留样式便于后续恢复。 */
    display: none;
    max-width: calc(100% - 16px);
    padding: 4px 7px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 5px;
    background: rgba(14, 25, 21, 0.72);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
  }

  .customer-page .long-thumb-label {
    position: absolute;
    right: 8px;
    bottom: 9px;
    left: auto;
    z-index: 2;
    display: inline-block;
    max-width: calc(100% - 92px);
    padding: 4px 7px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 5px;
    background: rgba(14, 25, 21, 0.72);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer-page .image-info {
    display: block;
    align-items: center;
    min-height: 0;
    padding: 10px;
  }

  .customer-page .category-badge {
    top: auto;
    right: auto;
    bottom: 8px;
    left: 8px;
    z-index: 2;
    display: block;
    max-width: calc(100% - 16px);
    padding: 4px 7px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(14, 25, 21, 0.72);
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .customer-page .long-thumb .category-badge {
    max-width: calc(100% - 118px);
  }

  .customer-page .image-name {
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .customer-page .image-meta {
    display: none;
  }

  .customer-page .image-meta span {
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid #d7dfdb;
    background: #f1f4f2;
    white-space: nowrap;
  }

  .customer-page .image-meta span:nth-child(2) {
    display: none;
  }

  .customer-card-actions {
    display: none;
  }

  .customer-page .cdr-card .customer-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 9px;
  }

  .customer-page .cdr-card .customer-card-actions .preview-button {
    display: none;
  }

  .admin-page .image-info {
    padding: 11px;
  }

  .admin-page .card-actions {
    grid-template-columns: 1fr 44px;
  }

  .admin-page .card-actions .preview-button {
    display: none;
  }

  .viewer {
    width: calc(100% - 14px);
    height: auto;
    max-height: calc(100dvh - 14px);
    margin: auto;
    border-radius: 8px;
  }

  .viewer-shell {
    width: 100%;
    height: auto;
    max-height: calc(100dvh - 14px);
    border-radius: 8px;
  }

  .viewer-header {
    min-height: 0;
    padding: 12px;
    border-color: var(--line);
    background: #ffffff;
  }

  .viewer-header h2 {
    max-width: calc(100vw - 88px);
    color: var(--text);
    font-size: 1.04rem;
  }

  .viewer-header p {
    max-width: calc(100vw - 88px);
    color: var(--muted);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .viewer-header .icon-button {
    width: 44px;
    min-height: 44px;
    color: var(--text);
    border-color: var(--line);
    background: #ffffff;
  }

  .viewer-header .icon-button svg {
    width: 22px;
    height: 22px;
  }

  .viewer-body {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    min-height: 310px;
    max-height: calc(100dvh - 154px);
    padding: 8px;
  }

  .viewer-body img {
    grid-column: 2;
    max-width: 100%;
    max-height: calc(100dvh - 178px);
  }

  .viewer-nav {
    position: static;
    width: 40px;
    min-height: 48px;
    transform: none;
    background: rgba(255, 255, 255, 0.14);
  }

  .viewer-resolution {
    left: 12px;
    bottom: 12px;
    max-width: calc(100% - 24px);
    padding: 9px 11px;
    font-size: 0.88rem;
  }

  .viewer-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    padding: 12px;
    border-color: var(--line);
    background: #ffffff;
  }

  .viewer-footer.single-action {
    grid-template-columns: 1fr;
  }

  .viewer-footer .button {
    width: 100%;
    min-height: 48px;
    font-size: 0.96rem;
    font-weight: 700;
  }

  .customer-page .topbar .customer-download-action {
    display: none;
  }

  .customer-page .viewer .customer-download-action {
    display: inline-flex;
  }

  .mobile-save-hint {
    display: block;
    color: var(--muted);
    font-size: 1rem;
  }

  .customer-page .viewer {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .customer-page .viewer-shell {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-radius: 0;
    background: #090e0c;
  }

  .customer-page .viewer-header {
    min-height: 78px;
    padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    border-color: rgba(255, 255, 255, 0.1);
    background: #090e0c;
  }

  .customer-page .viewer-header h2 {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    color: #ffffff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .customer-page .viewer-header p {
    color: #bac6c1;
  }

  .customer-page .viewer-category {
    max-width: calc(100vw - 112px);
    background: rgba(23, 111, 101, 0.36);
    color: #dff5f0;
  }

  .customer-page .viewer-header .icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 72px;
    min-height: 48px;
    gap: 4px;
    padding: 0 10px;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.1);
  }

  .customer-page .close-label {
    display: inline;
    font-size: 0.94rem;
    font-weight: 700;
  }

  .customer-page .viewer-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    padding: 10px;
    background: #090e0c;
    overflow: hidden;
  }

  .customer-page .viewer-body img {
    grid-column: 1;
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
  }

  .customer-page .viewer.long-image .viewer-body {
    display: block;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .customer-page .viewer.long-image .viewer-body img {
    width: 100%;
    height: auto;
    min-height: auto;
    max-height: none;
    object-fit: fill;
  }

  .customer-page .viewer-body .viewer-nav {
    display: none;
  }

  .customer-page .viewer-resolution {
    bottom: 14px;
    font-size: 0.84rem;
  }

  .customer-page .customer-viewer-footer {
    display: grid;
    grid-template-columns: minmax(88px, 1fr) auto minmax(88px, 1fr);
    grid-template-areas:
      "previous position next"
      "guidance guidance guidance";
    gap: 8px;
    min-height: 142px;
    padding: 12px 10px max(12px, env(safe-area-inset-bottom));
    border-color: rgba(255, 255, 255, 0.1);
    background: #121a17;
  }

  #mobilePrevBtn { grid-area: previous; }
  #viewerPosition { grid-area: position; }
  #mobileNextBtn { grid-area: next; }
  .viewer-source-download { grid-area: download; }
  .viewer-save-guidance { grid-area: guidance; }

  .customer-page .customer-viewer-footer.has-source-download {
    grid-template-areas:
      "previous position next"
      "download download download"
      "guidance guidance guidance";
    min-height: 202px;
  }

  .customer-page .customer-viewer-footer .button {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
  }

  .customer-page .customer-viewer-footer .button.primary {
    border-color: var(--green);
    background: var(--green);
  }

  .customer-page .viewer-save-guidance {
    min-height: 54px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
  }

  .customer-page .viewer-save-guidance small {
    color: rgba(255, 255, 255, 0.72);
  }

  .customer-page .mobile-save-hint {
    align-self: center;
    color: #ffffff;
    font-size: 0.94rem;
    white-space: nowrap;
  }

  .mobile-viewer-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 54px;
    gap: 4px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 0.94rem;
    font-weight: 700;
  }

  .mobile-viewer-nav svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
  }

  .mobile-bar:not([hidden]) {
    display: flex;
  }
}

@media (max-width: 540px) {
  .admin-page .gallery {
    grid-template-columns: 1fr;
  }

  .customer-page .category-chip {
    min-height: 44px;
  }

  .image-card:hover {
    transform: none;
  }
}

@media (max-width: 370px) {
  .customer-page .category-chips {
    grid-template-columns: 1fr;
  }

  .batch-actions {
    grid-template-columns: 1fr;
  }
}

.message-unread-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: #fff;
  background: var(--red);
  font-size: 0.72rem;
  line-height: 1;
}

.message-unread-badge[hidden] {
  display: none;
}

.admin-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  width: 100%;
  gap: 0;
  padding-top: 12px;
  padding-bottom: 0;
}

.admin-topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 20px;
  padding-bottom: 12px;
}

.admin-function-nav {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding: 10px 0;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: none;
}

.admin-function-nav::-webkit-scrollbar {
  display: none;
}

.admin-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.admin-nav-link:hover,
.admin-nav-link:focus-visible {
  border-color: rgba(159, 57, 55, 0.42);
  color: var(--red-dark);
  outline: none;
}

.admin-nav-link[aria-current="page"] {
  border-color: var(--red);
  color: #fff;
  background: var(--red);
}

.messages-page .brand-mark svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-workspace {
  align-content: start;
}

.message-board {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  scroll-margin-top: 96px;
}

.message-board-heading {
  align-items: flex-start;
}

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

.message-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 58px;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #f7f9f8;
  text-align: left;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.message-summary-item:hover,
.message-summary-item:focus-visible {
  border-color: rgba(159, 57, 55, 0.42);
  color: var(--text);
  outline: none;
}

.message-summary-item.is-active {
  border-color: rgba(159, 57, 55, 0.35);
  color: var(--red-dark);
  background: var(--red-soft);
}

.message-summary-item span {
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-summary-item strong {
  color: currentColor;
  font-size: 1.3rem;
  line-height: 1;
}

.message-search {
  display: flex;
  align-items: center;
  min-height: 46px;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fff;
}

.message-search:focus-within {
  border-color: rgba(159, 57, 55, 0.48);
  box-shadow: 0 0 0 3px rgba(159, 57, 55, 0.1);
}

.message-search svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.message-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  outline: none;
}

.message-search input::placeholder,
.message-actions textarea::placeholder {
  color: #6f7773;
  opacity: 1;
}

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

.message-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.72fr);
  gap: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  transition: opacity 0.16s ease, border-color 0.16s ease;
}

.message-item.message-status-new {
  border-color: rgba(159, 57, 55, 0.34);
  background: linear-gradient(135deg, rgba(159, 57, 55, 0.035), #fff 42%);
}

.message-item.is-saving {
  opacity: 0.55;
  pointer-events: none;
}

.message-contact,
.message-actions {
  min-width: 0;
}

.message-contact-heading,
.message-contact-links,
.message-action-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.message-contact-heading {
  justify-content: space-between;
}

.message-contact-heading strong {
  color: var(--text);
  font-size: 1.05rem;
}

.message-contact-heading span,
.message-contact-links,
.message-contact p {
  color: var(--muted);
  font-size: 0.84rem;
}

.message-contact-links {
  margin-top: 10px;
}

.message-contact-links a {
  color: var(--red-dark);
  font-weight: 760;
  text-decoration: none;
}

.message-contact p {
  max-width: 70ch;
  margin: 16px 0 0;
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-contact .is-muted {
  color: #727a76;
}

.message-actions {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(180px, 1fr);
  align-items: end;
  gap: 10px;
}

.message-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.message-actions select,
.message-actions textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #f9fbfa;
  font: inherit;
  outline: none;
}

.message-actions textarea {
  min-height: 68px;
  resize: vertical;
}

.message-actions select:focus,
.message-actions textarea:focus {
  border-color: rgba(159, 57, 55, 0.48);
  box-shadow: 0 0 0 3px rgba(159, 57, 55, 0.1);
}

.message-action-buttons {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.message-action-buttons .button {
  min-height: 38px;
}

.message-empty {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 30px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.message-empty strong {
  color: var(--text);
}

.message-empty[hidden] {
  display: none;
}

@media (max-width: 860px) {
  .admin-topbar {
    display: grid;
    padding: 14px 14px 0;
  }

  .admin-topbar-main {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 12px;
  }

  .admin-function-nav {
    padding: 10px 0 12px;
  }

  .admin-nav-link {
    min-height: 44px;
    padding: 0 15px;
  }

  .message-board {
    width: 100%;
    padding: 20px 14px;
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }

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

  .message-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .message-board-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .message-board-heading .button {
    width: 100%;
  }

  .message-actions {
    grid-template-columns: 1fr;
  }

  .message-action-buttons {
    grid-column: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .message-action-buttons .button {
    width: 100%;
  }
}

/* Customer message workbench */
.messages-page .message-board {
  gap: 18px;
  padding: 0 0 28px;
  overflow: hidden;
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.messages-page .message-board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 26px 28px;
  color: var(--text);
  background: var(--red-soft);
  border-bottom: 1px solid #efc8c3;
}

.message-heading-copy {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 16px;
}

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

.message-heading-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-page .message-board-heading h2 {
  margin: 0;
  color: var(--red-dark);
  font-size: 1.32rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.messages-page .message-board-heading p {
  max-width: 62ch;
  margin: 6px 0 0;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}

.message-heading-guide {
  display: grid;
  flex: 0 0 auto;
  gap: 4px;
  padding-left: 24px;
  border-left: 1px solid #efc8c3;
  text-align: right;
}

.message-heading-guide strong {
  color: var(--red-dark);
  font-size: 0.82rem;
}

.message-heading-guide span {
  color: var(--text);
  font-size: 0.76rem;
}

.messages-page .message-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0 28px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.messages-page .message-summary-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 72px;
  gap: 11px;
  padding: 12px 16px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  color: var(--muted);
  background: #fff;
}

.messages-page .message-summary-item:last-child {
  border-right: 0;
}

.messages-page .message-summary-item:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.messages-page .message-summary-item:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(183, 59, 52, 0.2);
  outline-offset: -3px;
}

.messages-page .message-summary-item.is-active {
  color: var(--red-dark);
  background: var(--red-soft);
  box-shadow: inset 0 -3px 0 var(--red);
}

.messages-page .message-summary-item[data-message-filter="contacted"].is-active {
  color: var(--green-dark);
  background: var(--green-soft);
  box-shadow: inset 0 -3px 0 var(--green);
}

.messages-page .message-summary-item[data-message-filter="closed"].is-active {
  color: var(--text);
  background: var(--surface-soft);
  box-shadow: inset 0 -3px 0 var(--muted);
}

.messages-page .message-summary-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}

.messages-page [data-message-filter="new"] .message-summary-dot {
  background: var(--red);
}

.messages-page [data-message-filter="contacted"] .message-summary-dot {
  background: var(--green);
}

.messages-page [data-message-filter="closed"] .message-summary-dot {
  background: var(--muted);
}

.messages-page .message-summary-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  overflow: visible;
  white-space: normal;
}

.messages-page .message-summary-copy b {
  overflow: hidden;
  color: currentColor;
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-page .message-summary-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-page .message-summary-item strong {
  min-width: 2ch;
  color: currentColor;
  font-size: 1.48rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.message-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 28px;
}

.messages-page .message-search {
  min-height: 48px;
  flex: 1 1 auto;
  padding: 0 15px;
  border-color: var(--line-strong);
  background: #fff;
}

.messages-page .message-search svg {
  fill: currentColor;
}

.message-sort-note {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.message-sort-note svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-page .message-list {
  gap: 14px;
  margin: 0 28px;
}

.messages-page .message-item {
  display: grid;
  grid-template-columns: minmax(200px, 0.46fr) minmax(320px, 1fr) minmax(430px, 0.95fr);
  gap: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(23, 32, 29, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.messages-page .message-item:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.messages-page .message-item.message-status-new {
  border-color: rgba(183, 59, 52, 0.42);
  background: #fff;
}

.message-item-profile {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 13px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #f7f9f8;
}

.message-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--red-dark);
  background: var(--red-soft);
  font-size: 1.05rem;
  font-weight: 800;
}

.message-status-contacted .message-avatar {
  color: var(--green-dark);
  background: var(--green-soft);
}

.message-status-closed .message-avatar {
  color: var(--muted);
  background: var(--surface-soft);
}

.message-profile-copy {
  display: grid;
  min-width: 0;
  gap: 8px;
  padding-top: 1px;
}

.messages-page .message-contact-heading {
  justify-content: flex-start;
  gap: 8px;
}

.messages-page .message-contact-heading strong {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--red-dark);
  background: var(--red-soft);
  font-size: 0.68rem;
  font-weight: 750;
  white-space: nowrap;
}

.message-status-contacted .message-status-tag {
  color: var(--green-dark);
  background: var(--green-soft);
}

.message-status-closed .message-status-tag {
  color: var(--muted);
  background: var(--surface-soft);
}

.message-profile-copy time {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.messages-page .message-contact {
  padding: 22px;
  border-right: 1px solid var(--line);
}

.messages-page .message-contact-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

.message-contact-method {
  display: grid;
  min-width: 0;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: #f7f9f8;
  text-decoration: none;
}

a.message-contact-method:hover,
a.message-contact-method:focus-visible {
  border-color: rgba(183, 59, 52, 0.45);
  color: var(--red-dark);
  outline: none;
}

.message-contact-method small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 650;
}

.message-contact-method strong {
  overflow: hidden;
  color: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-request {
  display: grid;
  gap: 7px;
  margin-top: 20px;
}

.message-request > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.messages-page .message-request p {
  max-width: 65ch;
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
}

.messages-page .message-contact .is-muted {
  color: var(--muted);
  font-weight: 500;
}

.messages-page .message-actions {
  display: grid;
  grid-template-columns: minmax(118px, 0.38fr) minmax(190px, 1fr);
  align-items: end;
  gap: 11px;
  padding: 20px;
  background: #f7f9f8;
}

.message-actions-heading {
  display: flex;
  grid-column: 1 / -1;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.message-actions-heading strong {
  color: var(--text);
  font-size: 0.84rem;
}

.message-actions-heading span {
  color: var(--muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.messages-page .message-actions label {
  gap: 7px;
  color: var(--muted);
  font-size: 0.72rem;
}

.messages-page .message-actions select,
.messages-page .message-actions textarea {
  min-height: 42px;
  border-color: var(--line-strong);
  background: #fff;
}

.messages-page .message-actions textarea {
  min-height: 74px;
}

.messages-page .message-action-buttons {
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 2px;
}

.messages-page .message-action-buttons .button {
  min-height: 40px;
}

.messages-page .message-empty {
  margin: 0 28px;
  padding: 38px 20px;
  background: #f7f9f8;
}

@media (max-width: 1180px) {
  .messages-page .message-item {
    grid-template-columns: minmax(210px, 0.42fr) minmax(0, 1fr);
  }

  .messages-page .message-contact {
    border-right: 0;
  }

  .messages-page .message-actions {
    grid-column: 1 / -1;
    grid-template-columns: minmax(150px, 0.3fr) minmax(250px, 1fr);
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 860px) {
  .messages-page .message-board {
    padding-bottom: 22px;
    overflow: hidden;
    border-width: 0 0 1px;
  }

  .messages-page .message-board-heading {
    padding: 24px 18px;
  }

  .messages-page .message-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0 18px;
  }

  .messages-page .message-summary-item:nth-child(2) {
    border-right: 0;
  }

  .messages-page .message-summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .message-toolbar,
  .messages-page .message-list,
  .messages-page .message-empty {
    margin-right: 18px;
    margin-left: 18px;
  }

  .messages-page .message-item {
    grid-template-columns: 1fr;
  }

  .message-item-profile,
  .messages-page .message-contact {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .message-item-profile {
    align-items: center;
    padding: 18px;
  }

  .message-profile-copy {
    width: 100%;
  }

  .messages-page .message-actions {
    grid-column: auto;
    border-top: 0;
  }
}

@media (max-width: 620px) {
  .messages-page .message-board-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
  }

  .message-heading-guide {
    width: 100%;
    padding: 14px 0 0;
    border-top: 1px solid #efc8c3;
    border-left: 0;
    text-align: left;
  }

  .message-sort-note {
    display: none;
  }

  .messages-page .message-contact-links,
  .messages-page .message-actions {
    grid-template-columns: 1fr;
  }

  .message-status-field,
  .message-note-field,
  .messages-page .message-action-buttons,
  .message-actions-heading {
    grid-column: 1;
  }
}

@media (max-width: 440px) {
  .messages-page .message-summary {
    margin-right: 14px;
    margin-left: 14px;
  }

  .messages-page .message-summary-item {
    min-height: 64px;
    padding: 10px 11px;
  }

  .messages-page .message-summary-copy small {
    display: none;
  }

  .message-toolbar,
  .messages-page .message-list,
  .messages-page .message-empty {
    margin-right: 14px;
    margin-left: 14px;
  }

  .messages-page .message-contact,
  .messages-page .message-actions {
    padding: 18px 16px;
  }
}
