:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262b36;
  --text: #e7eaf0;
  --muted: #99a1b3;
  --accent: #7aa2f7;
  --checker: #1c2029;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f8fa;
    --panel: #ffffff;
    --line: #e3e6ec;
    --text: #1a1d23;
    --muted: #626b7d;
    --accent: #2f6feb;
    --checker: #eef0f4;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  color: var(--text);
}

main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 80px; }

h1 { font-size: 28px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

#search {
  flex: 1 1 260px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: inherit;
  font: inherit;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.sizes { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.sizes button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.sizes button.on { background: var(--accent); color: #fff; }

.grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(var(--tile) + 48px), 1fr));
  gap: 10px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}
.card:hover { background: var(--panel); border-color: var(--line); text-decoration: none; color: var(--text); }

.thumb { display: grid; place-items: center; height: var(--tile); }
.card img { max-width: var(--tile); max-height: var(--tile); image-rendering: auto; }

.label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty { color: var(--muted); margin-top: 40px; text-align: center; }
.hidden { display: none; }

/* detail page */
.back { display: inline-block; margin-bottom: 16px; font-size: 14px; }

.stage {
  display: grid;
  place-items: center;
  padding: 32px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    conic-gradient(var(--checker) 25%, transparent 0 50%, var(--checker) 0 75%, transparent 0)
    0 0 / 20px 20px,
    var(--panel);
  margin-bottom: 26px;
}
.stage img { max-width: 256px; max-height: 256px; }

.sizes-table { width: 100%; border-collapse: collapse; }
.sizes-table th, .sizes-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.sizes-table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.sizes-table tbody th { font-variant-numeric: tabular-nums; width: 90px; }
.cell-preview { width: 280px; }
/* width/height stay auto so a scaled-down preview keeps its aspect ratio. */
.cell-preview img { max-width: 256px; max-height: 128px; width: auto; height: auto; vertical-align: middle; }
.url { color: var(--muted); word-break: break-all; }
.cell-actions { white-space: nowrap; }

.copy, .btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: inline-block;
}
.copy:hover, .btn:hover { border-color: var(--accent); text-decoration: none; }

@media (max-width: 700px) {
  .cell-preview { display: none; }
  .sizes-table thead th:nth-child(2) { display: none; }
}
