:root {
  color-scheme: light;
  --page: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --text: rgba(0, 0, 0, 0.87);
  --muted: rgba(0, 0, 0, 0.54);
  --muted-dark: rgba(0, 0, 0, 0.67);
  --border: rgba(0, 0, 0, 0.12);
  --border-dark: rgba(0, 0, 0, 0.24);
  --accent: #3f51b5;
  --accent-dark: #303f9f;
  --accent-soft: #e8eaf6;
  --success: #19735c;
  --success-soft: #e7f6f0;
  --danger: #b34b3f;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--page);
  color: var(--text);
  font-family: Roboto, "Noto Sans SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: inline-flex;
  align-items: center;
}

.brand-copy {
  display: grid;
  gap: 0;
}

.brand-copy strong {
  font-size: 14px;
  font-weight: 700;
}

.brand-copy small {
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
}

.header-link {
  color: var(--accent);
  font-weight: 650;
}

.header-link:hover,
.header-link:focus-visible {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.library {
  padding: 38px 0 76px;
}

.library-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.section-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.library-toolbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.toolbar-hint {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
}

.category-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  gap: 0;
  width: 100%;
  padding: 0;
  margin-bottom: 42px;
  overflow-x: auto;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.14);
}

.category-tab {
  position: relative;
  display: inline-flex;
  flex: 1 0 120px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 120px;
  min-height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease;
}

.category-name-short {
  display: none;
}

.category-tab:hover,
.category-tab:focus-visible {
  color: var(--accent);
  background: rgba(63, 81, 181, 0.06);
}

.category-tab.active {
  color: var(--accent);
  background: transparent;
}

.category-tab.active::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  content: "";
}

.category-tab b {
  color: currentColor;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.72;
}

.category-section {
  scroll-margin-top: 70px;
  margin-bottom: 62px;
}

.category-section:last-child {
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-heading > div {
  display: flex;
  align-items: baseline;
  gap: 11px;
}

.section-number {
  display: none;
}

.section-heading h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.section-count {
  color: var(--muted);
  font-size: 11px;
}

.icon-grid {
  column-count: 4;
  column-gap: 14px;
}

.icon-card {
  display: inline-block;
  width: 100%;
  margin: 0 0 14px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  break-inside: avoid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  outline: none;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.icon-card:hover,
.icon-card:focus-visible {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

.artboard {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 156px;
  padding: 18px 14px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.artboard img {
  display: block;
  width: auto;
  height: auto;
  max-width: 82%;
  max-height: 280px;
  object-fit: contain;
}

.format-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  padding: 3px 6px;
  border-radius: 2px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.ime-presets-card .format-tag {
  color: #246c63;
  background: #e5f6f0;
}

.recommended-static-card .format-tag {
  color: #5b42a8;
  background: #f0ecff;
}

.recommended-animated-card .format-tag {
  color: #a25b1e;
  background: #fff0df;
}

.copy-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 7px;
  border-radius: 6px;
  color: #ffffff;
  background: rgba(29, 32, 40, 0.82);
  font-size: 9px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.icon-card:hover .copy-overlay,
.icon-card:focus-visible .copy-overlay {
  opacity: 1;
}

.card-body {
  padding: 12px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.card-title-row h4 {
  overflow: hidden;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-kind {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.card-meta {
  overflow: hidden;
  margin: 0 0 11px;
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 31px;
  padding: 6px 9px;
  border: 1px solid var(--border-dark);
  border-radius: 4px;
  color: var(--accent);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.copy-button:hover,
.copy-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.copy-overlay svg,
.copy-button svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 23px 0 28px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

.footer p {
  margin: 0;
}

.footer a {
  color: var(--accent);
}

.footer a:hover,
.footer a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px 9px 9px;
  border: 1px solid #b8d9cd;
  border-radius: 8px;
  color: var(--success);
  background: #f7fffb;
  box-shadow: 0 5px 18px rgba(24, 65, 53, 0.12);
  font-size: 12px;
}

.toast[hidden] {
  display: none;
}

.toast.error {
  border-color: #edc0ba;
  color: var(--danger);
  background: #fff9f8;
}

.toast-check {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
  color: #ffffff;
  background: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.toast.error .toast-check {
  background: var(--danger);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .icon-grid {
    column-count: 3;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: calc(100vw - 30px);
    max-width: 560px;
  }

  .topbar {
    min-height: 60px;
  }

  .topbar-actions {
    display: none;
  }

  .brand-copy strong {
    font-size: 13px;
  }

  .library {
    padding: 27px 0 58px;
  }

  .library-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 17px;
  }

  .library-toolbar h1 {
    font-size: 24px;
  }

  .category-nav {
    display: flex;
    width: 100%;
    margin-bottom: 34px;
    overflow-x: auto;
  }

  .category-tab {
    flex: 1 0 25%;
    min-width: 0;
    gap: 5px;
    min-height: 48px;
    padding: 0 4px;
    font-size: 10px;
  }

  .category-name-full {
    display: none;
  }

  .category-name-short {
    display: inline;
  }

  .category-tab b {
    font-size: 9px;
  }

  .category-section {
    margin-bottom: 49px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading > div {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 3px 9px;
  }

  .section-heading h3 {
    font-size: 18px;
  }

  .section-heading p {
    flex-basis: 100%;
    margin-left: 0;
    font-size: 11px;
  }

  .icon-grid {
    column-count: 2;
    column-gap: 10px;
  }

  .artboard {
    min-height: 126px;
    padding: 14px 10px;
  }

  .artboard img {
    max-width: 88%;
    max-height: 220px;
  }

  .copy-overlay {
    display: none;
  }

  .card-body {
    padding: 10px;
  }

  .card-title-row h4 {
    font-size: 11px;
  }

  .card-kind {
    font-size: 8px;
  }

  .card-meta {
    margin-bottom: 9px;
    font-size: 8px;
  }

  .copy-button {
    min-height: 29px;
    font-size: 10px;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
