:root {
  --bg: #0b0810;
  --panel: #15101c;
  --panel-soft: #100c16;
  --primary: #8b3dff;
  --primary-strong: #b96cff;
  --text: #f2eff5;
  --muted: #928a9c;
  --border: #2a2133;
  --danger: #ff5f7a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background:
    radial-gradient(circle at 12% 12%, rgba(139, 61, 255, 0.16), transparent 24rem),
    linear-gradient(180deg, #08060c 0%, #0b0810 100%);
}

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

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

button {
  cursor: pointer;
}

button:disabled,
input[type="submit"]:disabled {
  cursor: wait;
  opacity: 0.66;
}

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

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--border);
  background: rgba(8, 6, 12, 0.84);
}

.admin-brand {
  display: block;
  margin-bottom: 28px;
  color: #f6edff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(185, 108, 255, 0.7);
}

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

.brand-mark {
  position: relative;
  display: block;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid rgba(255, 232, 183, 0.62);
  border-radius: 50%;
  background: linear-gradient(145deg, #fff2be, #ff4d97 48%, #4d4aff);
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.07),
    0 10px 26px rgba(255, 77, 151, 0.28);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.brand-name {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: #fff;
  font-family: "STXingkai", "KaiTi", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 26px;
  font-weight: 800;
  line-height: 0.88;
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.56),
    0 0 14px rgba(255, 255, 255, 0.14);
}

.brand-main {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  white-space: nowrap;
}

.brand-char {
  display: inline-block;
  transform-origin: center bottom;
}

.brand-char-large {
  margin: 0 -0.04em;
  font-size: 1.54em;
}

.brand-char-small {
  font-size: 0.66em;
  transform: translateY(-0.08em);
}

.admin-brand-logo {
  display: inline-flex;
  margin-bottom: 28px;
}

.login-brand-logo {
  margin-bottom: 20px;
}

.login-brand-logo .brand-mark {
  width: 48px;
  height: 48px;
}

.login-brand-logo .brand-name {
  font-size: 31px;
}

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

.admin-sidebar nav a,
.admin-sidebar button {
  display: flex;
  align-items: center;
  min-height: 44px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #d8d1df;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.admin-sidebar nav a.active,
.admin-sidebar nav a:hover,
.admin-sidebar button:hover {
  border-color: rgba(185, 108, 255, 0.38);
  background: rgba(139, 61, 255, 0.16);
}

.admin-sidebar form {
  margin-top: 28px;
}

.admin-main {
  min-width: 0;
  padding: 30px clamp(18px, 3vw, 44px) 44px;
}

.admin-topbar {
  margin-bottom: 22px;
}

.admin-topbar p,
.eyebrow {
  margin: 0 0 7px;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 3px;
}

.admin-topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}

.flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
}

.flash.success {
  border: 1px solid rgba(105, 220, 166, 0.35);
  background: rgba(105, 220, 166, 0.12);
  color: #bff7da;
}

.flash.error {
  border: 1px solid rgba(255, 95, 122, 0.35);
  background: rgba(255, 95, 122, 0.12);
  color: #ffc0ca;
}

.admin-card,
.stats-grid article,
.login-panel {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(21, 16, 28, 0.88);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.admin-card {
  margin-bottom: 22px;
  padding: 22px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stats-grid article {
  padding: 18px;
}

.stats-grid span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats-grid strong {
  font-size: 34px;
  line-height: 1;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quick-links a,
.link-action,
.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid rgba(185, 108, 255, 0.72);
  background: linear-gradient(180deg, rgba(139, 61, 255, 0.92), rgba(102, 38, 190, 0.92));
  color: var(--text);
  box-shadow: 0 0 18px rgba(139, 61, 255, 0.28);
}

.secondary-action,
.quick-links a {
  border: 1px solid rgba(146, 138, 156, 0.36);
  background: rgba(9, 7, 14, 0.64);
  color: var(--text);
}

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

.section-head h2,
.admin-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

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

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(146, 138, 156, 0.32);
  border-radius: 7px;
  background: rgba(7, 5, 12, 0.72);
  color: var(--text);
  outline: none;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(185, 108, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(139, 61, 255, 0.14);
}

.readonly-stat {
  display: grid;
  align-content: center;
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(146, 138, 156, 0.28);
  border-radius: 7px;
  background: rgba(9, 7, 14, 0.54);
}

.readonly-stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.readonly-stat strong {
  margin-top: 6px;
  font-size: 26px;
}

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

.form-divider {
  height: 1px;
  background: var(--border);
}

.form-actions {
  display: flex;
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(42, 33, 51, 0.86);
  text-align: left;
  vertical-align: middle;
}

.admin-table tbody tr,
.image-admin-item {
  cursor: grab;
}

.admin-table tbody tr.dragging,
.image-admin-item.dragging {
  opacity: 0.55;
}

.admin-table tbody tr.drag-over,
.image-admin-item.drag-over {
  outline: 2px solid rgba(185, 108, 255, 0.58);
  outline-offset: -2px;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1px;
}

.admin-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.album-title-link {
  display: inline-flex;
  color: var(--text);
}

.album-title-link:hover {
  color: var(--primary-strong);
}

.thumb {
  width: 92px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.status.on {
  background: rgba(105, 220, 166, 0.14);
  color: #bff7da;
}

.status.off {
  background: rgba(146, 138, 156, 0.14);
  color: #beb6c8;
}

.album-number,
.unlisted-number {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.album-number {
  padding: 0 9px;
  border: 1px solid rgba(185, 108, 255, 0.36);
  border-radius: 6px;
  background: rgba(139, 61, 255, 0.12);
  color: var(--primary-strong);
}

.unlisted-number {
  color: var(--muted);
}

.sort-input {
  max-width: 90px;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions a,
.row-actions button,
.image-admin-item button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(146, 138, 156, 0.34);
  border-radius: 6px;
  background: rgba(9, 7, 14, 0.58);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.row-actions form {
  display: inline;
  margin: 0;
}

.danger {
  border-color: rgba(255, 95, 122, 0.4) !important;
  color: #ffc0ca !important;
}

.cover-preview img {
  width: min(420px, 100%);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.upload-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.image-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.image-admin-item {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(9, 7, 14, 0.54);
}

.image-admin-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.empty-note {
  color: var(--muted);
}

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

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

.login-panel form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .admin-brand-logo .brand-mark {
    width: 36px;
    height: 36px;
  }

  .admin-brand-logo .brand-name {
    font-size: 22px;
  }

  .admin-main {
    padding: 22px 16px 36px;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .section-head,
  .upload-box,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
