:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1d2633;
  --text: #f0f6fc;
  --muted: #8b949e;
  --line: #30363d;
  --accent: #2f81f7;
  --accent-2: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(47, 129, 247, 0.14), transparent 300px), var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 13px;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

.controls {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: rgba(21, 27, 35, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 170px 120px 120px;
  gap: 10px;
}

input,
select,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 0 12px;
}

button {
  cursor: pointer;
}

.icon-button {
  min-width: 76px;
  padding: 0 14px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  color: var(--muted);
  font-size: 14px;
}

.push-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.push-row span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.push-row button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--panel-2);
  font-weight: 700;
}

.stats strong {
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.file-item {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  object-fit: contain;
  object-position: center;
}

.cover-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.file-item h2 {
  margin: 0;
  min-width: 0;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.file-meta {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.file-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.path-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tag-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c9d1d9;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tag.mc4 {
  color: #bae6fd;
  border-color: #0ea5e9;
}

.tag.shn {
  color: #bbf7d0;
  border-color: #22c55e;
}

.actions {
  align-items: center;
  margin-top: auto;
}

.actions a,
.actions button,
.pagination button {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  line-height: 34px;
}

.actions a.primary {
  background: var(--accent);
  border-color: var(--accent);
}

.actions button.push-btn {
  border-color: var(--accent-2);
  color: #bbf7d0;
}

.empty {
  grid-column: 1 / -1;
  padding: 44px 16px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
}

dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: min(780px, calc(100vh - 24px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.dialog-body {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 22px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  font-size: 24px;
}

.dialog-body h2,
.dialog-body h3 {
  margin: 0;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.meta-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #0d1117;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.meta-grid span {
  color: var(--muted);
  font-size: 12px;
}

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

.cheat-row {
  padding: 10px 12px;
  background: #0d1117;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
}

.settings-form label span {
  color: var(--muted);
  font-size: 13px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-button {
  min-height: 40px;
  padding: 0 16px;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

pre {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  background: #05070a;
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .push-row {
    align-items: stretch;
    flex-direction: column;
  }

  .file-item {
    grid-template-rows: auto auto auto 1fr auto;
  }

  .cover {
    width: 100%;
  }
}
