:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1e2329;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --shadow: 0 12px 32px rgba(18, 24, 38, 0.08);
  --icon-size: 64px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

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

.shell {
  height: 100vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 24px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 8px;
}

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

.login-panel .primary-button {
  width: 100%;
  margin-top: 12px;
}

.login-error {
  min-height: 20px;
  margin-top: 10px;
  color: #b91c1c;
  font-size: 12px;
}

.topbar {
  height: 72px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
}

#rootPath {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.status,
.gallery-toolbar,
.toolbar-actions,
.gallery-status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gallery-status {
  flex-wrap: wrap;
  min-width: 220px;
}

.status {
  color: var(--muted);
  white-space: nowrap;
}

.header-logo {
  width: auto;
  height: 38px;
  max-width: 150px;
  object-fit: contain;
  display: block;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  background: #f8fafc;
  color: var(--accent-strong);
}

.workspace {
  min-height: 0;
  height: calc(100vh - 72px);
  flex: 1;
  display: grid;
  grid-template-columns: 280px minmax(360px, 1fr) 340px;
  overflow: hidden;
}

.filters,
.editor {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 16px;
}

.editor {
  border-right: 0;
  border-left: 1px solid var(--line);
  background: #ffffff;
  padding: 12px;
}

.gallery {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.gallery-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  justify-content: space-between;
  margin: -18px -18px 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 246, 248, 0.96);
  color: var(--muted);
}

.panel {
  margin-bottom: 16px;
}

.panel-title,
.field-label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-weight: 700;
  font-size: 13px;
}

.editor .field-label {
  margin-bottom: 5px;
}

input[type="search"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

#descriptionInput {
  min-height: 58px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.compact-label {
  margin-top: 12px;
}

.counts {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tag-group {
  margin: 0 0 14px;
}

.tag-group-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 7px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.25;
}

.chip.active {
  border-color: var(--accent);
  background: #e6fffb;
  color: var(--accent-strong);
}

.tag-editor .chip:disabled {
  opacity: 1;
  cursor: default;
}

.attribute-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-left: 5px;
}

.tag-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: #eef6f4;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.attribute-chip.active .tag-icon {
  background: var(--accent);
  color: #ffffff;
}

.color-tag-group {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.color-chip {
  position: relative;
  border-color: var(--tag-border);
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-weight: 700;
}

.color-mini-tag::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 1px solid rgba(17, 24, 39, 0.18);
  border-radius: 50%;
  background: var(--tag-dot);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.color-chip.active {
  border-color: var(--tag-fg);
  background: var(--tag-bg);
  color: var(--tag-fg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tag-border) 45%, transparent);
}

.ghost-button,
.primary-button,
.clear-button,
.download-link {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
  text-decoration: none;
}

.inline-control,
.page-info {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.toolbar-actions select {
  width: auto;
  min-height: 34px;
  padding: 6px 28px 6px 9px;
}

.icon-button {
  width: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
}

.clear-button {
  border-color: #f59e0b;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 700;
}

.clear-button:hover {
  border-color: #ea580c;
  background: #fed7aa;
  color: #7c2d12;
}

.primary-button,
.download-link {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.danger-button {
  min-height: 34px;
  border: 1px solid #dc2626;
  border-radius: 6px;
  padding: 7px 12px;
  background: #fff1f2;
  color: #b91c1c;
  cursor: pointer;
  font-weight: 800;
}

.danger-button:hover {
  border-color: #b91c1c;
  background: #fee2e2;
  color: #991b1b;
}

.compact-danger {
  width: 100%;
  min-height: 30px;
  margin-top: 6px;
  padding: 5px 10px;
  font-size: 12px;
}

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

.primary-button.is-saving {
  border-color: #0ea5e9;
  background: #0ea5e9;
}

.primary-button.is-saved {
  border-color: #16a34a;
  background: #16a34a;
}

.primary-button.is-error {
  border-color: #dc2626;
  background: #dc2626;
}

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

.primary-button:disabled {
  opacity: 0.9;
}

.guidelines pre {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #475467;
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: 12px;
}

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

.virtual-grid {
  position: relative;
  display: block;
  min-height: 240px;
}

.bottom-pager {
  min-height: 76px;
  margin: 18px 0 4px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 1px solid #99d5ce;
  border-radius: 8px;
  background: #eefaf8;
  color: #0b5f59;
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.12);
}

.bottom-pager .page-info {
  min-width: 96px;
  text-align: center;
  color: #0b5f59;
  font-size: 14px;
  font-weight: 800;
}

.bottom-pager .icon-button,
.bottom-pager .page-nav-button {
  width: auto;
  min-width: 112px;
  min-height: 42px;
  padding: 9px 18px;
  border-color: #0f766e;
  background: #ffffff;
  color: #0b5f59;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.12);
}

.bottom-pager .icon-button:hover,
.bottom-pager .page-nav-button:hover {
  background: #dff7f3;
}

.bottom-pager #bottomNextPage {
  background: var(--accent);
  color: #ffffff;
}

.bottom-pager #bottomNextPage:hover {
  background: var(--accent-strong);
}

.bottom-pager button:disabled {
  border-color: #cbd5e1;
  background: #f8fafc !important;
  color: #94a3b8 !important;
  box-shadow: none;
}

.card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  box-shadow: 0 2px 10px rgba(18, 24, 38, 0.04);
}

.virtual-card {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  will-change: transform;
}

.card:hover,
.card.selected,
.card.checked {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.select-box {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
}

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

.card-main {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.thumb {
  width: 100%;
  height: calc(var(--icon-size, 64px) + 20px);
  display: grid;
  place-items: center;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #e8edf4 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf4 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf4 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.thumb img {
  width: var(--icon-size, 64px);
  height: var(--icon-size, 64px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

.filename {
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #344054;
}

.mini-tags {
  min-height: 22px;
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mini-tag {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 4px;
  background: #eef2f6;
  color: #475467;
  padding: 2px 5px;
  font-size: 11px;
}

.color-mini-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-weight: 700;
}

.empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.preview-wrap {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.detail-header {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.compact-preview {
  width: 86px;
  margin-bottom: 0;
}

.preview-wrap img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.file-title {
  overflow-wrap: anywhere;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.35;
}

.detail-meta {
  min-width: 0;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.compact-link {
  min-height: 30px;
  margin-bottom: 0;
  padding: 5px 10px;
  font-size: 12px;
}

.tag-editor {
  margin: 9px 0;
  padding-top: 8px;
  border-top: 1px solid #eef2f6;
}

.tag-editor .chip {
  min-height: 24px;
}

.custom-tag {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.custom-tag-label {
  white-space: nowrap;
}

.custom-tag input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.custom-tag .ghost-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: -12px;
  z-index: 3;
  margin: 10px -12px -12px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.actions .primary-button,
.actions .ghost-button {
  flex: 1;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 240px minmax(300px, 1fr);
  }

  .editor {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .topbar,
  .gallery-toolbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
  }

  .filters,
  .gallery,
  .editor {
    max-height: none;
    overflow: visible;
  }

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