#size-chart-library {
  --chart-orange: #ed5b20;
  --chart-ink: #24252a;
  --chart-muted: #756c64;
  --chart-line: #eee4dc;
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1100px, calc(100vw - 48px));
  height: min(880px, 88dvh);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #efe0d3;
  border-radius: 18px;
  background: #fffdfa;
  color: var(--chart-ink);
  font: 16px/1.5 Arial, "Microsoft YaHei", sans-serif;
  box-shadow: 0 26px 100px #39231733;
}
#size-chart-library[open] { display: flex; flex-direction: column; }
#size-chart-library::backdrop { background: #312c2880; backdrop-filter: blur(3px); }
#size-chart-library [hidden] { display: none !important; }
#size-chart-library button, #size-chart-library a { font-family: inherit; }
#size-chart-library :is(button, a):focus-visible { outline: 2px solid var(--chart-orange); outline-offset: 3px; }
.chart-library-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 20px;
  flex: none;
  padding: 20px 28px;
  border-bottom: 1px solid var(--chart-line);
  background: #fff;
}
.chart-library-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; }
.chart-library-head h2 { margin: 0; font-size: 28px; font-weight: 700; line-height: 1.4; }
#chart-count { font-size: 14px; color: var(--chart-muted); white-space: nowrap; }
#size-chart-library #chart-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--chart-line);
  border-radius: 50%;
  background: #fff;
  color: #6b625b;
  line-height: 1;
}
#chart-close svg { display: block; width: 20px; height: 20px; }
#chart-close:hover { border-color: #e7b39a; color: var(--chart-orange); background: #fff6ee; }
.chart-list-view, .chart-detail-view { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.chart-toolbar { position: sticky; top: 0; z-index: 1; padding: 16px 28px; background: #fffdfa; border-bottom: 1px solid var(--chart-line); }
#chart-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.chart-filter {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #665d55;
  font-size: 16px;
  line-height: 1.5;
}
.chart-filter:hover { background: #fff0e5; }
.chart-filter[aria-pressed=true] { background: #ffecdc; border-color: #f1d1ba; color: #a94620; font-weight: 600; }
.chart-filter-count { font-size: 13px; opacity: .8; }
#chart-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; padding: 22px 28px 28px; }
.chart-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid var(--chart-line); border-radius: 11px; background: #fff; }
.chart-preview { position: relative; display: block; width: 100%; aspect-ratio: 1.58; overflow: hidden; padding: 12px; border: 0; border-bottom: 1px solid var(--chart-line); background: #f7f5f2; cursor: zoom-in; }
.chart-preview img { position: absolute; inset: 12px; display: block; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; }
.chart-preview-label { position: absolute; bottom: 8px; right: 9px; padding: 3px 8px; border: 1px solid #eee5db; border-radius: 5px; background: #fffefaee; color: #61564d; font-size: 12px; opacity: 0; }
.chart-preview:hover .chart-preview-label, .chart-preview:focus-visible .chart-preview-label { opacity: 1; }
.chart-card-body { display: flex; flex-direction: column; flex: 1; padding: 16px; }
.chart-tags { display: flex; flex-wrap: wrap; gap: 5px; min-height: 24px; }
.chart-tags span { padding: 3px 7px; border-radius: 4px; background: #f5f2ee; color: #716458; font-size: 12px; line-height: 1.5; }
.chart-tags .chart-recommended { color: #a74d24; background: #fff0e3; }
.chart-tags .chart-needs-review { color: #856010; background: #fff3d9; }
.chart-card h3 { margin: 10px 0 5px; font-size: 18px; font-weight: 600; line-height: 1.5; }
.chart-material { margin: 0; color: var(--chart-muted); font-size: 14px; line-height: 1.6; }
.chart-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 18px; }
.chart-sizes { color: #665b51; font-size: 14px; white-space: nowrap; }
.chart-download { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 13px; border: 1px solid #f2d7c3; border-radius: 6px; background: #fff5eb; color: #ae441b; font-size: 14px; font-weight: 600; line-height: 1.5; text-decoration: none; white-space: nowrap; }
.chart-download:hover { background: #ffead9; border-color: #eaa982; }
.chart-download:disabled { opacity: .55; cursor: not-allowed; }
#chart-status { flex: none; margin: 0; font-size: 14px; color: #a75b2b; }
#chart-status:empty { display: none; }
#chart-status:not(:empty) { padding: 10px 28px; border-top: 1px solid var(--chart-line); }
.chart-retry { margin-left: 10px; padding: 6px 10px; border: 1px solid #f2d7c3; border-radius: 4px; background: transparent; color: #bc4e22; }
.chart-image-error { font-size: 14px; color: #8b6e5a; }
.chart-detail-view { display: flex; flex-direction: column; padding: 18px 28px 22px; }
.chart-detail-bar { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 15px; margin-bottom: 14px; }
#chart-back, #chart-fit { min-height: 42px; padding: 8px 13px; border: 1px solid var(--chart-line); border-radius: 6px; background: #fff; color: #665b51; font-size: 14px; line-height: 1.5; }
#chart-detail-title { flex: none; margin: 0 0 5px; font-size: 20px; line-height: 1.5; }
#chart-detail-meta { flex: none; margin: 0 0 14px; color: var(--chart-muted); font-size: 14px; }
.chart-original-stage { position: relative; flex: 1; min-height: 120px; overflow: auto; border: 1px solid var(--chart-line); border-radius: 8px; background: #f4f2ef; }
#chart-original { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.is-zoomed #chart-original { position: static; width: auto; height: auto; max-width: none; max-height: none; }
.chart-detail-bottom { display: flex; align-items: center; justify-content: flex-end; flex: none; gap: 20px; margin-top: 16px; }
#chart-detail-note { margin: 0 auto 0 0; color: var(--chart-muted); font-size: 14px; line-height: 1.6; }
#chart-detail-note:empty { display: none; }
#chart-detail-download .chart-download { min-width: 115px; background: var(--chart-orange); border-color: var(--chart-orange); color: #fff; }
@media (max-width: 850px) {
  #chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  #size-chart-library { width: calc(100vw - 20px); height: 94dvh; max-height: calc(100dvh - 20px); border-radius: 13px; }
  .chart-library-head { padding: 16px 18px; }
  .chart-library-head h2 { font-size: 24px; }
  .chart-toolbar { padding: 12px 18px; }
  .chart-filter { padding: 8px 11px; gap: 6px; font-size: 15px; }
  #chart-grid { grid-template-columns: minmax(0, 1fr); padding: 16px 18px 20px; gap: 14px; }
  .chart-preview { aspect-ratio: 1.7; }
  .chart-card h3 { font-size: 18px; }
  .chart-detail-view { padding: 14px 18px 18px; }
  .chart-detail-bottom { flex-wrap: wrap; gap: 12px; }
  #chart-detail-download { margin-left: auto; }
}
@media (max-height: 500px) {
  #size-chart-library { inset: 12px 0; margin: 0 auto; height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
  .chart-library-head { padding-top: 10px; padding-bottom: 10px; }
  .chart-library-head h2 { font-size: 24px; }
}
