:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1d2329;
  --muted: #6b7280;
  --line: #d8ddd5;
  --accent: #24745a;
  --accent-strong: #155441;
  --amber: #c9822b;
  --danger: #b33a32;
  --shadow: 0 18px 45px rgba(32, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0)),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

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

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost,
.button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button.ghost:hover,
.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button.danger {
  background: var(--danger);
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 34px 0 12px;
  background: #fff;
  color: var(--ink);
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(36, 116, 90, 0.14);
}

select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(36, 116, 90, 0.14);
}

.shell,
.visitor-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.visitor-header,
.album-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

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

h1 {
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  letter-spacing: 0;
}

.kicker {
  margin-bottom: 8px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.create-form {
  display: grid;
  grid-template-columns: minmax(180px, 280px) auto;
  gap: 10px;
  align-items: center;
}

.notice {
  margin: 18px 0;
  border: 1px solid rgba(36, 116, 90, 0.25);
  border-radius: 6px;
  padding: 12px 14px;
  background: rgba(36, 116, 90, 0.09);
  color: var(--accent-strong);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  margin-top: 24px;
  align-items: start;
}

.sidebar,
.panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 14px;
  position: sticky;
  top: 18px;
}

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

.section-title span,
.counter {
  border-radius: 999px;
  padding: 5px 10px;
  background: #e8eee9;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.album-list {
  display: grid;
  gap: 8px;
}

.album-row {
  display: grid;
  justify-items: start;
  gap: 5px;
  min-height: 62px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  white-space: normal;
}

.album-row:hover,
.album-row.is-active {
  border-color: rgba(36, 116, 90, 0.32);
  background: rgba(36, 116, 90, 0.08);
}

.album-row small,
.photo-meta small,
.selection-row small {
  color: var(--muted);
}

.workspace {
  min-width: 0;
}

.album-header {
  margin-bottom: 12px;
}

.album-title-form {
  display: grid;
  gap: 8px;
  min-width: min(100%, 460px);
}

.album-title-form > div {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
}

.album-title-form input {
  min-height: 46px;
  font-size: 24px;
  font-weight: 800;
}

.actions,
.visitor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.visitor-actions {
  align-items: center;
}

.visitor-actions input {
  width: 180px;
}

.visitor-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(108px, 1fr));
  gap: 10px;
}

.visitor-action-grid button {
  width: 100%;
}

.share-line {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tip {
  margin: 12px 0;
  border: 1px solid rgba(36, 116, 90, 0.22);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(36, 116, 90, 0.08);
  color: var(--accent-strong);
  font-size: 14px;
}

.tip.warning {
  border-color: rgba(201, 130, 43, 0.36);
  background: rgba(201, 130, 43, 0.12);
  color: #7a4c16;
}

.public-url-form {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 12px 0 14px;
}

.public-url-form label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 96px;
  margin: 14px 0;
  border: 1px dashed rgba(36, 116, 90, 0.55);
  border-radius: 8px;
  background: rgba(36, 116, 90, 0.07);
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.upload-zone input {
  display: none;
}

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

.sort-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 14px;
}

.sort-bar label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.stats strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.panel {
  margin-top: 16px;
  padding: 16px;
}

.photo-grid,
.select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.photo-card,
.select-photo {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.photo-card img,
.select-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e5e7eb;
  transition: opacity 0.18s ease;
}

.photo-card img.is-loading,
.select-photo img.is-loading {
  opacity: 0.45;
}

.photo-card img.is-retrying,
.select-photo img.is-retrying {
  opacity: 0.3;
}

.photo-card img.is-failed,
.select-photo img.is-failed {
  opacity: 0.8;
}

.photo-preview-button {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: zoom-in;
}

.photo-preview-button:hover {
  background: transparent;
}

.photo-meta {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.photo-meta span,
.caption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 30px;
  padding: 0 10px;
  background: rgba(179, 58, 50, 0.92);
  font-size: 13px;
}

.selection-list {
  display: grid;
  gap: 10px;
}

.selection-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.selection-row div {
  display: grid;
  gap: 4px;
}

.selection-row p {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  padding: 24px;
}

.visitor-shell {
  width: min(1280px, calc(100% - 32px));
}

.visitor-header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -16px 18px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(216, 221, 213, 0.82);
  background: rgba(246, 245, 241, 0.88);
  backdrop-filter: blur(14px);
}

.visitor-header h1 {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.counter {
  display: inline-flex;
  margin-bottom: 14px;
}

.select-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.select-photo {
  display: block;
  padding: 0;
  color: var(--ink);
  text-align: left;
}

.select-photo img {
  cursor: zoom-in;
}

.select-photo:hover {
  background: #fff;
}

.select-photo.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 3px rgba(36, 116, 90, 0.22);
}

.check {
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.select-photo.is-selected .check {
  background: var(--accent);
  color: #fff;
}

.caption {
  display: block;
  padding: 11px 12px;
  background: #fff;
}

.preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(18, 23, 25, 0.82);
}

.preview {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(1120px, 100%);
  height: min(820px, calc(100vh - 44px));
  border-radius: 8px;
  overflow: hidden;
  background: #111719;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
}

.preview img {
  align-self: center;
  justify-self: center;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111719;
}

.preview img.is-soft {
  filter: blur(1px);
  transform: scale(1.002);
}

.preview-loading {
  position: absolute;
  left: 50%;
  bottom: 76px;
  z-index: 2;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  transform: translateX(-50%);
}

.preview-close,
.preview-nav {
  position: absolute;
  z-index: 2;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.preview-close {
  top: 12px;
  right: 12px;
  min-height: 36px;
}

.preview-nav {
  top: 50%;
  width: 44px;
  height: 56px;
  min-height: 56px;
  padding: 0;
  transform: translateY(-50%);
  font-size: 34px;
  line-height: 1;
}

.preview-prev {
  left: 12px;
}

.preview-next {
  right: 12px;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 14px;
  background: #fff;
}

.preview-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .topbar,
  .visitor-header,
  .album-header {
    align-items: stretch;
    flex-direction: column;
  }

  .create-form,
  .album-title-form > div,
  .layout,
  .public-url-form,
  .selection-row {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .actions,
  .visitor-actions {
    justify-content: stretch;
  }

  .actions > *,
  .visitor-actions > *,
  .visitor-actions input,
  .visitor-actions select {
    width: 100%;
  }

  .visitor-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .sort-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-backdrop {
    padding: 10px;
  }

  .preview {
    height: calc(100vh - 20px);
  }

  .preview-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-footer button {
    width: 100%;
  }
}

@media (max-width: 540px) {
  .shell,
  .visitor-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  h1 {
    font-size: 36px;
  }

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