:root {
  color-scheme: dark;
  --bg: #111315;
  --surface: #191c1f;
  --surface-2: #22262a;
  --surface-3: #2b3035;
  --text: #f4f5f6;
  --muted: #939aa1;
  --line: #2c3136;
  --accent: #ff8b3d;
  --accent-strong: #ff7424;
  --accent-soft: rgba(255, 139, 61, 0.13);
  --danger: #ff5f5f;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

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

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(220px, 760px) auto;
  gap: 20px;
  align-items: center;
  min-height: 78px;
  padding: 14px 28px;
  border-top: 3px solid var(--accent);
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 21, 0.92);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: #17120e;
  font-family: Georgia, serif;
  font-size: 20px;
}

.search {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--muted);
  transition: border-color 160ms ease, background 160ms ease;
}

.search:focus-within {
  border-color: rgba(255, 139, 61, 0.55);
  background: #252a2f;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search kbd {
  padding: 3px 7px;
  border: 1px solid #3d4349;
  border-radius: 6px;
  color: #858c93;
  font-size: 12px;
  white-space: nowrap;
}

.top-actions { display: flex; gap: 14px; align-items: center; justify-content: flex-end; }
.result-count { color: var(--muted); font-size: 14px; white-space: nowrap; }

.primary-button, .ghost-button, .icon-button {
  border: 0;
  cursor: pointer;
  transition: transform 120ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button {
  min-height: 42px;
  padding: 0 17px;
  border-radius: 11px;
  background: var(--accent);
  color: #24160c;
  font-weight: 700;
}

.primary-button:hover { background: #ff9b58; transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: 0.55; transform: none; }

.ghost-button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
}

main { padding: 0 28px 60px; }

.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 22px 0 14px;
  scrollbar-width: none;
}

.category-bar::-webkit-scrollbar { display: none; }

.filter-button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: #c8cdd1;
  cursor: pointer;
  white-space: nowrap;
}

.filter-button[aria-pressed="true"] {
  border-color: rgba(255, 139, 61, 0.5);
  background: var(--accent-soft);
  color: #ffae76;
}

.filter-button small { margin-left: 6px; color: #70777e; }

.tag-panel {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(25, 28, 31, 0.66);
}

.tag-label { padding-top: 5px; color: var(--muted); font-size: 14px; }
.tag-bar { display: flex; flex-wrap: wrap; gap: 6px; }

.tag-button {
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: #bec4c9;
  cursor: pointer;
  font-size: 14px;
}

.tag-button.active { background: var(--accent-soft); color: #ffae76; }

.gallery {
  columns: 6 230px;
  column-gap: 16px;
}

.asset-card {
  position: relative;
  display: inline-block;
  width: 100%;
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  break-inside: avoid;
  cursor: zoom-in;
  transition: transform 180ms ease, border-color 180ms ease;
}

.asset-card:hover { transform: translateY(-2px); border-color: #464d53; }

.asset-card img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  background: var(--surface-2);
}

.card-info { padding: 11px 12px 12px; }

.card-title {
  margin: 0 0 8px;
  overflow: hidden;
  color: #e8eaec;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  display: inline-flex;
  padding: 4px 7px;
  border: 0;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.chip.category { background: var(--accent-soft); color: #f6a56c; }
.card-filter { cursor: pointer; }
.card-filter:hover { color: var(--text); }

.empty-state {
  min-height: 56vh;
  padding: 80px 20px;
  text-align: center;
}

.empty-orbit {
  display: grid;
  width: 86px;
  height: 86px;
  margin: 0 auto 24px;
  place-items: center;
  border: 1px dashed #555d64;
  border-radius: 50%;
  color: var(--accent);
  font-size: 32px;
}

.empty-state h1 { margin: 0 0 10px; font-size: clamp(24px, 3vw, 38px); }
.empty-state p { margin: 0 0 24px; color: var(--muted); }

.dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: auto;
  border: 1px solid #3b4147;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.6);
}

.dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(4px); }
.dialog form { padding: 24px; }

.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.dialog-header h2 { margin: 3px 0 0; font-size: 25px; }
.eyebrow { margin: 0; color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.08em; }

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 24px;
}

.upload-layout { display: grid; grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.1fr); gap: 22px; }

.drop-zone {
  display: grid;
  min-height: 430px;
  padding: 0;
  overflow: hidden;
  place-items: center;
  border: 1px dashed #4a5259;
  border-radius: 15px;
  background: #131619;
  color: var(--text);
  cursor: pointer;
}

.drop-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone img { width: 100%; height: 100%; max-height: 560px; object-fit: contain; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone small { margin-top: 8px; color: var(--muted); font-size: 13px; }

.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: grid; gap: 7px; }
.field > span { color: #cbd0d4; font-size: 14px; font-weight: 600; }
.field small { color: #777f86; font-size: 12px; }

.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #141719;
  color: var(--text);
  padding: 11px 12px;
  resize: vertical;
}

.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(255, 139, 61, 0.65); }
.instruction-field { padding: 12px; border: 1px solid #3d342e; border-radius: 12px; background: rgba(255, 139, 61, 0.05); }

.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.form-message { min-height: 22px; margin: 14px 0 -5px; color: var(--muted); font-size: 14px; }
.form-message.error { color: #ff8c8c; }

.detail-dialog { width: min(1100px, calc(100vw - 28px)); }
.detail-shell { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr); min-height: 560px; }
.detail-image { display: grid; min-height: 520px; place-items: center; background: #090a0b; }
.detail-image img { max-width: 100%; max-height: calc(100vh - 80px); object-fit: contain; }
.detail-sidebar { padding: 24px; }
.detail-sidebar h2 { margin: 10px 0 18px; font-size: 22px; }
.detail-sidebar p { color: var(--muted); line-height: 1.65; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.danger-button { color: #ff9191; }

.toast {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  max-width: min(380px, calc(100vw - 44px));
  padding: 12px 15px;
  border: 1px solid #41484e;
  border-radius: 11px;
  background: #24282c;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 780px) {
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding: 12px 14px; }
  .brand span:last-child, .result-count { display: none; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .top-actions { grid-column: 2; grid-row: 1; }
  main { padding: 0 14px 44px; }
  .category-bar { padding-top: 16px; }
  .gallery { columns: 2 145px; column-gap: 10px; }
  .asset-card { margin-bottom: 10px; border-radius: 12px; }
  .upload-layout, .detail-shell { grid-template-columns: 1fr; }
  .drop-zone { min-height: 280px; }
  .dialog form { padding: 18px; }
  .detail-image { min-height: 320px; }
}

@media (max-width: 420px) {
  .primary-button { padding: 0 12px; }
  .gallery { columns: 2 132px; }
  .card-info { padding: 9px; }
}
