:root {
  color-scheme: light;
  --bg: #f1f4f7;
  --panel: #ffffff;
  --panel-strong: #e8edf2;
  --text: #101820;
  --muted: #66727d;
  --line: #d6dee5;
  --accent: #1478ff;
  --accent-strong: #075fcf;
  --cyan: #25bdd8;
  --danger: #dc2626;
  --ink: #09131f;
  --shadow: 0 22px 60px rgba(9, 19, 31, 0.13);
  --radius: 8px;
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10131a;
  --panel: #171b24;
  --panel-strong: #202634;
  --text: #f2f5fb;
  --muted: #9aa6b8;
  --line: #2b3445;
  --accent: #55a0ff;
  --accent-strong: #81b9ff;
  --cyan: #43d2e9;
  --danger: #fb7185;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}

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

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

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

img {
  display: block;
  max-width: 100%;
}

.site-header {
  padding: 24px clamp(16px, 4vw, 48px) 18px;
}

.topbar,
.page-shell,
.intro-panel,
.detail-hero {
  width: min(1440px, 100%);
  margin: 0 auto;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 850;
  color: var(--text);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent);
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px 7px;
  border-top: 2px solid #fff;
  border-bottom: 2px solid rgba(255, 255, 255, 0.72);
  transform: skewY(-12deg);
}

.nav-actions,
.form-actions,
.gallery-toolbar,
.toolbar-line,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button,
.admin-link,
.text-button,
.primary-button,
.copy-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.admin-link,
.text-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.primary-button {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
}

.icon-button:hover,
.admin-link:hover,
.text-button:hover,
.copy-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.intro-panel,
.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 24px;
  align-items: end;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 3.4rem;
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.25;
}

h3 {
  font-size: 1.05rem;
  line-height: 1.35;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.04rem;
}

.search-shell {
  display: grid;
  gap: 8px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

.search-box input {
  border: 0;
  background: transparent;
  padding: 0;
}

input:focus,
textarea:focus,
select:focus,
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.page-shell {
  padding: 18px clamp(16px, 4vw, 48px) 48px;
}

.toolbar-line,
.gallery-toolbar {
  margin: 4px 0 18px;
  color: var(--muted);
}

.toolbar-line p,
.gallery-toolbar p {
  margin: 0;
}

.style-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.style-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 10px 32px rgba(9, 19, 31, 0.07);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.style-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  box-shadow: var(--shadow);
}

.style-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.style-card a {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.75fr);
  height: 100%;
  min-height: 344px;
}

.preview-mosaic {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  align-content: center;
  align-items: start;
  overflow: hidden;
  min-width: 0;
  background: var(--panel-strong);
}

.preview-mosaic img:first-child {
  grid-row: auto;
}

.preview-mosaic img {
  aspect-ratio: 3 / 4;
  width: 100%;
  height: auto;
  min-height: 0;
  object-fit: cover;
  transition: transform 420ms ease, filter 220ms ease;
}

.style-card:hover .preview-mosaic img {
  filter: saturate(1.04) contrast(1.02);
  transform: scale(1.025);
}

.card-body {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 14px;
  min-width: 0;
  padding: 26px 28px;
  border-left: 1px solid var(--line);
}

.card-body h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.12;
  font-weight: 850;
}

.card-body p {
  margin: 0;
  color: var(--muted);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.style-index {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 850;
}

.view-cue {
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 750;
}

.view-cue span {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  transition: transform 180ms ease;
}

.style-card:hover .view-cue span {
  transform: translateX(4px);
}

.style-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.prompt-block {
  align-self: end;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.prompt-block > span {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.prompt-chip {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 9px;
  background: var(--panel-strong);
}

.gallery-home .home-header {
  padding-top: 22px;
  padding-bottom: 34px;
  background: var(--ink);
  color: #f5f8fb;
}

.gallery-home .topbar {
  margin-bottom: 42px;
}

.gallery-home .brand {
  color: #ffffff;
  font-size: 1.08rem;
}

.gallery-home .icon-button,
.gallery-home .admin-link {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: #f5f8fb;
}

.gallery-home .home-intro {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  align-items: end;
  padding: 0 0 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.gallery-home .intro-copy {
  max-width: 860px;
}

.gallery-home .eyebrow {
  margin-bottom: 14px;
  color: #6fb1ff;
}

.gallery-home h1 {
  max-width: 850px;
  margin-bottom: 20px;
  color: #ffffff;
  font-size: 4.7rem;
  line-height: 1.02;
  font-weight: 850;
}

.gallery-home h1 span {
  display: block;
  color: #6fb1ff;
}

.gallery-home .lead {
  max-width: 650px;
  color: #aebdca;
  font-size: 1.08rem;
}

.gallery-home .search-shell label {
  color: #c1ccd6;
}

.gallery-home .search-box {
  min-height: 58px;
  border-color: rgba(255, 255, 255, 0.22);
  background: #ffffff;
  color: #101820;
}

.gallery-home .search-box input {
  color: #101820;
}

.gallery-home .page-shell {
  padding-top: 28px;
}

.gallery-summary {
  min-height: 44px;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.gallery-summary p {
  color: var(--text);
  font-weight: 750;
}

.gallery-home #resetData {
  display: none;
}

.gallery-detail .site-header {
  padding-bottom: 34px;
  background: var(--ink);
  color: #f5f8fb;
}

.gallery-detail .brand {
  color: #ffffff;
}

.gallery-detail .icon-button,
.gallery-detail .admin-link {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: #f5f8fb;
}

.gallery-detail .detail-hero {
  align-items: end;
  padding: 14px 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.gallery-detail .detail-copy h1 {
  color: #ffffff;
  font-size: 3.8rem;
}

.gallery-detail .detail-copy .lead {
  color: #aebdca;
}

.gallery-detail .detail-copy .pill {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #dce5ed;
}

.gallery-detail .prompt-text {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #f5f8fb;
}

.gallery-detail .prompt-panel .copy-button {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.gallery-detail .page-shell {
  padding-top: 28px;
}

.detail-header {
  padding-bottom: 8px;
}

.detail-hero {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.detail-copy {
  display: grid;
  gap: 10px;
}

.detail-copy h1,
.detail-copy p {
  margin: 0;
}

.prompt-panel {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.prompt-text {
  max-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.94rem;
}

.masonry-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.art-card {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.art-card button {
  display: block;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.art-card img {
  display: block;
  aspect-ratio: 3 / 4;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  background: var(--panel-strong);
}

.art-card footer {
  padding: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.lightbox {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.lightbox::backdrop {
  background: rgba(5, 8, 13, 0.74);
}

.lightbox img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #05080d;
}

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
}

.lightbox-caption {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.lightbox-caption p {
  margin: 0;
  color: var(--muted);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}

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

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

.admin-body {
  background: var(--bg);
}

.admin-layout {
  min-height: 100vh;
}

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

.login-card {
  width: min(460px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.stacked-form,
.editor-form {
  display: grid;
  gap: 14px;
}

.form-note,
.sort-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.image-selection-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.select-all-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.select-all-control input,
.gallery-select input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--text);
  cursor: pointer;
}

.selection-count {
  color: var(--muted);
  font-size: 0.88rem;
}

.image-selection-toolbar .danger-button {
  margin-left: auto;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

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

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 22px;
}

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

.admin-tab {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  padding: 0 12px;
}

.admin-tab.is-active,
.admin-tab:hover {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.admin-main {
  min-width: 0;
  padding: 28px;
}

.admin-panel {
  display: grid;
  gap: 20px;
}

.panel-heading h1 {
  margin: 0;
}

.editor-form,
.image-manager-head {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

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

.image-manager-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

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

.admin-list,
.admin-gallery {
  display: grid;
  gap: 12px;
}

.style-row,
.gallery-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.row-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  overflow: hidden;
  height: 92px;
  border-radius: 6px;
  background: var(--panel-strong);
}

.row-preview img,
.gallery-row img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-copy {
  min-width: 0;
}

.row-copy h3,
.row-copy p {
  margin: 0;
}

.row-copy p {
  color: var(--muted);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.danger-button {
  min-height: 38px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--radius);
  background: transparent;
  color: var(--danger);
  padding: 0 12px;
  cursor: pointer;
}

.gallery-row {
  grid-template-columns: 120px minmax(0, 1fr) auto;
}

.gallery-row[draggable="true"] {
  cursor: grab;
}

.gallery-thumb {
  position: relative;
  height: 110px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--panel-strong);
}

.gallery-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.94);
  cursor: pointer;
}

.gallery-row.is-selected {
  border-color: var(--text);
  box-shadow: inset 4px 0 0 var(--text);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  padding: 12px 14px;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1060px) {
  .style-card a {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  }

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

  .preview-mosaic img:nth-child(4) {
    display: none;
  }

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

  .admin-app {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .intro-panel,
  .detail-hero {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .gallery-home .home-intro {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 0 0 6px;
  }

  .gallery-home h1 {
    font-size: 3.7rem;
  }

  .style-card a {
    grid-template-columns: 1fr;
  }

  .preview-mosaic {
    min-height: 0;
  }

  .preview-mosaic img {
    min-height: 0;
  }

  .card-body {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .style-row,
  .gallery-row,
  .form-grid,
  .image-manager-head {
    grid-template-columns: 1fr;
  }

  .row-preview,
  .gallery-thumb {
    height: 180px;
  }

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

  .panel-heading,
  .toolbar-line,
  .gallery-toolbar,
  .image-selection-toolbar,
  .lightbox-caption {
    align-items: stretch;
    flex-direction: column;
  }

  .image-selection-toolbar .danger-button {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .site-header {
    padding: 16px;
  }

  .gallery-home .home-header {
    padding-top: 16px;
    padding-bottom: 28px;
  }

  .gallery-home .topbar {
    margin-bottom: 34px;
  }

  .gallery-home h1 {
    font-size: 2.65rem;
  }

  .gallery-detail .detail-copy h1 {
    font-size: 2.65rem;
  }

  .gallery-home .lead {
    font-size: 1rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions {
    width: 100%;
  }

  .admin-link {
    flex: 1;
  }

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

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

  .preview-mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: auto;
    min-height: 0;
  }

  .preview-mosaic img {
    min-height: 0;
  }

  .preview-mosaic img:nth-child(4) {
    display: block;
  }

  .card-body {
    padding: 22px 20px;
  }

  .card-body h2 {
    font-size: 1.7rem;
  }

  .admin-main {
    padding: 18px;
  }
}
