:root {
  --ink: #19251f;
  --forest: #173f34;
  --forest-soft: #274e42;
  --cream: #f4f1e8;
  --paper: #fffdf8;
  --line: #e3e3da;
  --muted: #7c857f;
  --gold: #aa8358;
  --danger: #a44a3f;
  --sans: "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "STSong", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f3f4ef;
  font-family: var(--sans);
}

body.editor-open {
  overflow: hidden;
}

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

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

button {
  color: inherit;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.brand-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  color: var(--cream);
  background: var(--forest);
  border-radius: 50% 50% 50% 11px;
  place-items: center;
}

.brand-symbol svg {
  width: 27px;
  height: 27px;
}

.admin-login {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 20px;
  background:
    radial-gradient(circle at 13% 8%, rgba(194, 216, 198, 0.38), transparent 30%),
    radial-gradient(circle at 90% 84%, rgba(225, 204, 184, 0.4), transparent 31%),
    var(--cream);
  place-items: center;
}

.login-card {
  width: min(415px, 100%);
  padding: 31px;
  background: rgba(255, 253, 248, 0.93);
  border: 1px solid white;
  box-shadow: 0 30px 80px rgba(21, 42, 33, 0.15);
}

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

.login-brand > div {
  display: flex;
  flex-direction: column;
}

.login-brand strong {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.08em;
}

.login-brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.login-kicker {
  display: block;
  margin-top: 42px;
  color: var(--gold);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.login-card h1 {
  margin: 7px 0 4px;
  font-family: var(--serif);
  font-size: 31px;
  font-weight: 500;
}

.login-card > p {
  margin: 0 0 23px;
  color: var(--muted);
  font-size: 11px;
}

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

.login-card input {
  height: 46px;
  padding: 0 13px;
  background: #fbfbf7;
  border: 1px solid #dfe2db;
  outline: none;
}

.login-card input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(23, 63, 52, 0.08);
}

.login-card button {
  height: 44px;
  color: white;
  background: var(--forest);
  border: 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}

#loginError {
  min-height: 15px;
  color: var(--danger);
  font-size: 9px;
}

.login-card > a {
  display: inline-block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 9px;
}

.admin-app {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  z-index: 30;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 235px;
  padding: 25px 17px 19px;
  flex-direction: column;
  color: rgba(255, 255, 255, 0.72);
  background: var(--forest);
}

.sidebar-brand {
  display: flex;
  padding: 0 8px 23px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand .brand-symbol {
  color: var(--forest);
  background: var(--cream);
}

.sidebar-brand > div {
  display: flex;
  flex-direction: column;
}

.sidebar-brand strong {
  color: white;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.sidebar-brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 7px;
  letter-spacing: 0.14em;
}

.admin-sidebar nav {
  display: grid;
  padding-top: 20px;
  gap: 4px;
}

.admin-sidebar nav p {
  margin: 15px 10px 5px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.admin-sidebar nav button,
.admin-sidebar nav a {
  display: flex;
  min-height: 42px;
  padding: 0 11px;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.61);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  text-align: left;
}

.admin-sidebar nav button:hover,
.admin-sidebar nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.06);
}

.admin-sidebar nav button.active {
  color: var(--forest);
  background: #e8eee3;
  font-weight: 600;
}

.admin-sidebar nav svg {
  width: 18px;
  height: 18px;
}

#caseCountBadge {
  min-width: 22px;
  margin-left: auto;
  padding: 1px 6px;
  color: inherit;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 8px;
  text-align: center;
}

.admin-sidebar nav button.active #caseCountBadge {
  color: var(--forest);
  background: rgba(23, 63, 52, 0.09);
}

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

.sidebar-footer a,
.sidebar-footer button {
  padding: 0;
  color: rgba(255, 255, 255, 0.42);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 9px;
  text-align: left;
}

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

.admin-main {
  width: calc(100% - 235px);
  min-height: 100vh;
  margin-left: 235px;
}

.admin-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  height: 80px;
  padding: 0 32px;
  align-items: center;
  justify-content: space-between;
  background: rgba(250, 250, 246, 0.92);
  border-bottom: 1px solid #e8e9e3;
  backdrop-filter: blur(14px);
}

.admin-topbar p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 9px;
}

.admin-topbar h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

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

.topbar-actions a,
.topbar-actions button,
.ghost,
.image-section-title button,
.external-image-row button,
.list-footer button,
.qr-admin-card button {
  display: inline-flex;
  min-height: 37px;
  padding: 0 14px;
  align-items: center;
  justify-content: center;
  background: white;
  border: 1px solid #dce0d9;
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
}

.topbar-actions .primary,
.section-title .primary,
.save-case {
  color: white;
  background: var(--forest);
  border-color: var(--forest);
}

.admin-view {
  width: min(1450px, 100%);
  margin: 0 auto;
  padding: 27px 32px 50px;
}

.overview-strip {
  display: grid;
  margin-bottom: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  grid-template-columns: repeat(4, 1fr);
}

.overview-strip > div {
  padding: 17px 20px;
  border-right: 1px solid var(--line);
}

.overview-strip > div:last-child {
  border-right: 0;
}

.overview-strip span {
  display: block;
  color: var(--muted);
  font-size: 9px;
}

.overview-strip strong {
  display: block;
  margin-top: 3px;
  color: var(--forest);
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 500;
}

.content-toolbar {
  display: flex;
  margin-bottom: 14px;
  align-items: center;
  gap: 8px;
}

.admin-search {
  display: flex;
  width: 340px;
  height: 38px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  background: white;
  border: 1px solid #dfe2dc;
  border-radius: 6px;
}

.admin-search svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.admin-search input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 10px;
}

.content-toolbar select {
  height: 38px;
  padding: 0 27px 0 10px;
  color: #59645e;
  background: white;
  border: 1px solid #dfe2dc;
  border-radius: 6px;
  outline: none;
  font-size: 10px;
}

.content-toolbar .ghost {
  margin-left: auto;
}

.case-admin-list {
  display: grid;
  background: var(--paper);
  border: 1px solid var(--line);
}

.case-admin-row {
  display: grid;
  padding: 13px 16px;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid #eceee8;
  grid-template-columns: 72px minmax(220px, 1.4fr) minmax(130px, 0.8fr) 100px 110px 90px;
}

.case-admin-row:last-child {
  border-bottom: 0;
}

.case-admin-row:hover {
  background: #fbfbf7;
}

.case-admin-thumb {
  overflow: hidden;
  width: 72px;
  height: 58px;
  background: #dcd7cb;
}

.case-admin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-admin-thumb .thumb-placeholder {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(145deg, hsl(var(--hue) 22% 80%), hsl(calc(var(--hue) + 25) 18% 57%));
}

.case-admin-title {
  min-width: 0;
}

.case-admin-title strong {
  display: block;
  overflow: hidden;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-admin-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
}

.case-admin-location,
.case-admin-updated {
  color: #65706a;
  font-size: 9px;
}

.case-status {
  display: inline-flex;
  width: fit-content;
  padding: 4px 7px;
  color: #337458;
  background: #eaf5ef;
  border-radius: 4px;
  font-size: 8px;
}

.case-status.draft {
  color: #8b7260;
  background: #f4eee9;
}

.case-status.demo {
  color: #7a6b35;
  background: #f7f1dc;
}

.case-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.case-row-actions button {
  padding: 6px 8px;
  background: transparent;
  border: 1px solid #dfe2dc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 8px;
}

.case-row-actions button:hover {
  border-color: #9aaa9f;
}

.case-row-actions .delete:hover {
  color: var(--danger);
  border-color: #efcac4;
}

.list-footer {
  display: flex;
  padding-top: 15px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 9px;
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 15px;
}

.settings-form {
  padding: 23px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.section-title {
  display: flex;
  margin-bottom: 22px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-title span,
.editor-head span {
  color: var(--gold);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.section-title h2 {
  margin: 3px 0 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.form-grid label {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.form-grid label.full {
  grid-column: 1 / -1;
}

.form-grid label > span {
  color: #68736c;
  font-size: 9px;
  font-weight: 500;
}

.form-grid input,
.form-grid textarea,
.external-image-row input {
  width: 100%;
  padding: 9px 10px;
  color: var(--ink);
  background: #fbfbf7;
  border: 1px solid #dfe3dc;
  border-radius: 4px;
  outline: none;
  font-size: 10px;
}

.form-grid textarea {
  resize: vertical;
  line-height: 1.65;
}

.form-grid input:focus,
.form-grid textarea:focus,
.external-image-row input:focus {
  background: white;
  border-color: #7c9e8b;
}

.qr-admin-card {
  align-self: start;
  padding: 22px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--line);
}

.qr-admin-card > span {
  color: var(--gold);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.qr-admin-card h3 {
  margin: 5px 0 19px;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
}

.qr-admin-canvas {
  width: 205px;
  height: 205px;
  margin: 0 auto;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
}

.qr-admin-canvas canvas {
  width: 180px !important;
  height: 180px !important;
}

.qr-admin-card p {
  margin: 14px 0 16px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.7;
}

.qr-admin-card button {
  width: 100%;
  color: white;
  background: var(--forest);
  border-color: var(--forest);
}

.qr-admin-card a {
  display: block;
  margin-top: 11px;
  color: var(--forest);
  font-size: 9px;
}

.qr-admin-divider {
  height: 1px;
  margin: 24px 0 19px;
  background: var(--line);
}

.qr-admin-card .qr-admin-divider + span {
  color: var(--gold);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.case-editor {
  width: min(1090px, calc(100% - 34px));
  max-height: calc(100vh - 34px);
  padding: 0;
  color: var(--ink);
  background: #f7f7f2;
  border: 0;
  box-shadow: 0 35px 100px rgba(16, 31, 24, 0.32);
}

.case-editor::backdrop {
  background: rgba(17, 31, 25, 0.54);
  backdrop-filter: blur(3px);
}

.editor-head {
  display: flex;
  height: 70px;
  padding: 0 24px;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.editor-head h2 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
}

.editor-head button {
  display: grid;
  width: 33px;
  height: 33px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 23px;
  place-items: center;
}

#caseForm {
  overflow-y: auto;
  max-height: calc(100vh - 104px);
}

.editor-layout {
  display: grid;
  padding: 22px;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 20px;
}

.editor-main {
  min-width: 0;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.image-section {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

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

.image-section-title > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.image-section-title strong {
  font-size: 11px;
}

.image-section-title span {
  color: var(--muted);
  font-size: 8px;
}

.image-section-title button {
  min-height: 32px;
}

.upload-progress {
  margin-top: 12px;
  padding: 8px 10px;
  color: #53655b;
  background: #edf3ed;
  border-radius: 4px;
  font-size: 9px;
}

.image-grid {
  display: grid;
  margin-top: 13px;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.image-item {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  background: #dfdbd0;
  cursor: zoom-in;
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-item-actions {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  display: flex;
  gap: 4px;
}

.image-item-actions button {
  min-height: 24px;
  padding: 0 6px;
  color: white;
  background: rgba(16, 29, 23, 0.78);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 7px;
  backdrop-filter: blur(5px);
}

.image-item .cover-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 3px 6px;
  color: white;
  background: var(--gold);
  border-radius: 2px;
  font-size: 7px;
}

.external-image-row {
  display: flex;
  margin-top: 10px;
  gap: 7px;
}

.external-image-row input {
  flex: 1;
}

.editor-side {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.status-panel {
  padding: 17px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.status-panel > strong {
  display: block;
  margin-bottom: 14px;
  font-size: 11px;
}

.switch-row {
  display: flex;
  margin-top: 10px;
  align-items: center;
  justify-content: space-between;
  color: #5f6d65;
  font-size: 9px;
}

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch-row i {
  position: relative;
  width: 31px;
  height: 17px;
  background: #d8ddd7;
  border-radius: 999px;
  transition: background 150ms ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  background: white;
  border-radius: 50%;
  transition: transform 150ms ease;
}

.switch-row input:checked + i {
  background: var(--forest);
}

.switch-row input:checked + i::after {
  transform: translateX(14px);
}

.status-panel p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.65;
}

.editor-preview {
  display: grid;
  overflow: hidden;
  min-height: 230px;
  background:
    linear-gradient(145deg, hsl(var(--preview-hue, 80) 20% 80%), hsl(calc(var(--preview-hue, 80) + 20) 15% 58%));
  place-items: center;
}

.editor-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.editor-preview span {
  padding: 10px;
  color: rgba(255, 255, 255, 0.73);
  font-family: var(--serif);
  font-size: 16px;
  text-align: center;
}

.save-case {
  height: 43px;
  border: 0;
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
}

.delete-case {
  height: 38px;
  color: var(--danger);
  background: transparent;
  border: 1px solid #efcbc5;
  border-radius: 4px;
  cursor: pointer;
  font-size: 9px;
}

.admin-toast {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  padding: 11px 15px;
  color: white;
  background: var(--forest);
  border-radius: 3px;
  box-shadow: 0 12px 30px rgba(19, 37, 28, 0.18);
  font-size: 10px;
  opacity: 0;
  transform: translateY(7px);
  transition: 180ms ease;
}

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

@media (max-width: 980px) {
  .admin-sidebar {
    width: 205px;
  }

  .admin-main {
    width: calc(100% - 205px);
    margin-left: 205px;
  }

  .case-admin-row {
    grid-template-columns: 64px minmax(170px, 1fr) 90px 88px;
  }

  .case-admin-location,
  .case-admin-updated {
    display: none;
  }

  .settings-layout,
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .admin-sidebar {
    position: static;
    width: 100%;
    padding: 14px;
  }

  .sidebar-brand {
    padding-bottom: 12px;
  }

  .admin-sidebar nav {
    display: flex;
    overflow-x: auto;
    padding-top: 10px;
  }

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

  .admin-sidebar nav button,
  .admin-sidebar nav a {
    white-space: nowrap;
  }

  .admin-app {
    display: block;
  }

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

  .admin-topbar {
    height: 70px;
    padding: 0 15px;
  }

  .topbar-actions a {
    display: none;
  }

  .admin-view {
    padding: 18px 14px 40px;
  }

  .overview-strip {
    grid-template-columns: 1fr 1fr;
  }

  .overview-strip > div:nth-child(2) {
    border-right: 0;
  }

  .content-toolbar {
    flex-wrap: wrap;
  }

  .admin-search {
    width: 100%;
  }

  .content-toolbar .ghost {
    margin-left: 0;
  }

  .case-admin-row {
    padding: 11px;
    grid-template-columns: 55px minmax(0, 1fr) 44px;
    gap: 10px;
  }

  .case-admin-thumb {
    width: 55px;
    height: 48px;
  }

  .case-admin-row > .case-status {
    display: none;
  }

  .case-row-actions {
    display: grid;
  }

  .case-row-actions button:first-child {
    display: none;
  }

  .settings-form,
  .editor-main {
    padding: 16px;
  }

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

  .form-grid label.full {
    grid-column: auto;
  }

  .editor-side {
    display: flex;
  }

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

  .case-editor {
    width: calc(100% - 14px);
    max-height: calc(100vh - 14px);
  }
}
