/*
 * draw.io 场景模板库 — static gallery styles.
 * Plain CSS only: no framework, no external fonts, no CDN.
 */

:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-line: #dbeafe;
  --ink: #1f2937;
  --ink-strong: #111827;
  --text: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-line: #fecaca;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.03);
  --shadow-hover: 0 12px 24px -8px rgba(16, 24, 40, 0.14), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main.container {
  flex: 1 0 auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.1em 0.32em;
  border-radius: 4px;
  background: #eef2f7;
  color: #334155;
}

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

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.top-accent {
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed 55%, #06b6d4);
}

/* ---------- Header ---------- */

.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border-bottom: 1px solid var(--line);
  padding: 30px 0 26px;
}

.header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 11px;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8 55%, #4f46e5);
  box-shadow: 0 6px 14px -6px rgba(37, 99, 235, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.site-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 12px;
  row-gap: 2px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
}

.site-title-en {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--faint);
}

.tagline {
  margin-top: 7px;
  font-size: 15px;
  color: var(--muted);
}

.gh-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  margin-top: 5px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.gh-link svg {
  width: 16px;
  height: 16px;
}

.gh-link:hover {
  border-color: var(--faint);
  background: var(--surface-muted);
  color: var(--ink);
  text-decoration: none;
}

/* ---------- Toolbar ---------- */

.toolbar {
  margin: 26px 0 10px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 320px;
  max-width: 540px;
  height: 46px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-icon {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--faint);
}

.search-field input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
}

.search-field input[type="search"]::placeholder {
  color: var(--faint);
}

.search-field input[type="search"]::-webkit-search-cancel-button,
.search-field input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.search-clear svg {
  width: 15px;
  height: 15px;
}

.search-clear:hover {
  background: #f1f3f6;
  color: var(--ink);
}

.match-count {
  flex: none;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.chip {
  flex: none;
  padding: 6px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: #4b5563;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.chip:hover {
  border-color: #bfdbfe;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 5px -1px rgba(37, 99, 235, 0.35);
}

.chip[aria-pressed="true"]:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #ffffff;
}

/* ---------- Gallery ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin: 22px 0 64px;
}

@media (max-width: 1023px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}

@media (max-width: 679px) {
  .gallery {
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 18px 0 44px;
  }
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card:hover {
    transform: none;
    transition: none;
  }
}

.card-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background-color: #f8fafc;
  background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
}

.preview-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background-color: #f8fafc;
  background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: center;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.card-preview.has-error .spinner {
  display: none;
}

.card-preview.has-error .preview-placeholder {
  color: var(--danger);
}

.preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 9px;
  padding: 17px 20px 20px;
}

.card-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 22px;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.55;
  white-space: nowrap;
}

.card-id {
  overflow: hidden;
  color: #b3bac4;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-title {
  color: var(--ink);
  font-size: 17.5px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.card-subtitle {
  margin-top: -4px;
  color: var(--faint);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.card-desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  color: #4b5563;
  font-size: 13.5px;
  line-height: 1.65;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  padding: 2px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-icon {
  display: inline-flex;
  flex: none;
}

.btn-icon svg {
  width: 15px;
  height: 15px;
}

.btn-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-primary {
  grid-column: 1 / -1;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}

.btn-primary[aria-disabled="true"] {
  cursor: progress;
  opacity: 0.85;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-muted);
  border-color: var(--faint);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: #f1f3f6;
  color: var(--ink);
}

.btn-ghost.is-copied {
  background: #ecfdf5;
  color: #047857;
}

/* ---------- Error banner / empty state / toast ---------- */

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

.error-banner .error-icon {
  flex: none;
  width: 19px;
  height: 19px;
  margin-top: 1px;
}

.error-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#error-detail {
  color: #7f1d1d;
}

.noscript-note {
  margin-top: 18px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 22px 0 64px;
  padding: 60px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 4px;
  color: var(--line-strong);
}

.empty-state h2 {
  color: var(--ink);
  font-size: 19px;
  font-weight: 700;
}

.empty-state p {
  color: var(--muted);
  font-size: 14px;
}

.empty-state .btn {
  margin-top: 10px;
  padding: 0 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  max-width: min(88vw, 560px);
  padding: 10px 18px;
  border-radius: 999px;
  background: #111827;
  color: #f9fafb;
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: 0 12px 28px -8px rgba(17, 24, 39, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  background: #7f1d1d;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: auto;
  padding: 30px 0 38px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
}

.footer-sep {
  color: var(--line-strong);
}

.footer-note {
  max-width: 860px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.footer-note code {
  background: #f3f4f6;
  color: #4b5563;
}

/* ---------- Small screens ---------- */

@media (max-width: 679px) {
  .container {
    padding: 0 16px;
  }

  .site-header {
    padding: 22px 0 20px;
  }

  .brand {
    gap: 12px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .brand-mark svg {
    width: 22px;
    height: 22px;
  }

  .site-title {
    font-size: 23px;
    line-height: 1.3;
  }

  .site-title-en {
    flex-basis: 100%;
    font-size: 13px;
  }

  .tagline {
    margin-top: 6px;
    font-size: 13.5px;
  }

  .gh-link {
    display: none;
  }

  .toolbar {
    margin-top: 20px;
  }

  .search-field {
    flex-basis: 100%;
    max-width: none;
  }

  .match-count {
    font-size: 13px;
  }

  .chips {
    gap: 7px;
    margin-top: 12px;
  }

  .chip {
    padding: 5px 12px;
    font-size: 13px;
  }

  .card-preview {
    aspect-ratio: 3 / 2;
  }

  .card-body {
    padding: 15px 16px 17px;
  }

  .empty-state {
    padding: 44px 20px;
  }
}
