/* DesignStyles Gallery — hand-rolled, no framework */

:root {
  --bg: #f7f7f4;
  --bg-soft: #efefea;
  --surface: #ffffff;
  --surface-2: #fbfbfa;
  --ink: #17181c;
  --ink-2: #44464e;
  --muted: #71737d;
  --line: #e6e5e0;
  --line-strong: #d8d7d1;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --accent-ink: #ffffff;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05), 0 1px 6px rgba(20, 20, 30, 0.04);
  --shadow-md: 0 2px 6px rgba(20, 20, 30, 0.06), 0 12px 28px rgba(20, 20, 30, 0.09);
  --shadow-lg: 0 4px 10px rgba(20, 20, 30, 0.07), 0 20px 44px rgba(20, 20, 30, 0.14);
  --radius: 14px;
  --header-h: 60px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #101013;
  --bg-soft: #17171b;
  --surface: #17171c;
  --surface-2: #1d1d23;
  --ink: #f0f0f2;
  --ink-2: #c6c7cd;
  --muted: #93949e;
  --line: #26262d;
  --line-strong: #33333c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.45), 0 12px 28px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, 0.5), 0 20px 44px rgba(0, 0, 0, 0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

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

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.wordmark svg { width: 26px; height: 26px; }
.wordmark em { font-style: normal; background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.header-nav { display: flex; align-items: center; gap: 6px; }
.lang {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 6px 0 11px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  color: var(--muted); transition: border-color 0.15s;
}
html[dir="rtl"] .lang { padding: 0 11px 0 6px; }
.lang:hover, .lang:focus-within { border-color: var(--line-strong); }
.lang select {
  appearance: none; -webkit-appearance: none;
  border: none; outline: none; background: transparent;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--ink);
  cursor: pointer; max-width: 96px;
}
.header-nav a {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 500; color: var(--ink-2);
  padding: 8px 12px; border-radius: 9px; transition: background 0.15s, color 0.15s;
}
.header-nav a:hover { background: var(--bg-soft); color: var(--ink); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; color: var(--ink-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
.ico-sun { display: none; }
html[data-theme="dark"] .ico-sun { display: block; }
html[data-theme="dark"] .ico-moon { display: none; }

/* ---------- hero ---------- */
.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 {
  font-size: clamp(34px, 5.4vw, 58px);
  line-height: 1.08; letter-spacing: -0.03em; font-weight: 800;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { max-width: 640px; margin: 18px auto 0; font-size: clamp(15px, 2vw, 18px); color: var(--muted); }
.hero-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.hero-stats span {
  font-size: 13px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; box-shadow: var(--shadow-sm);
}
.hero-stats strong { color: var(--ink); font-weight: 700; }

/* ---------- toolbar ---------- */
.toolbar { padding: 8px 0 4px; }
.toolbar-inner { display: flex; flex-direction: column; gap: 14px; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 14px; height: 46px; color: var(--muted);
  box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.search input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink); height: 100%;
}
.search input::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.chips::-webkit-scrollbar { height: 4px; }
.chips::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }
.chip {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; transition: all 0.15s;
}
.chip count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.active count { color: color-mix(in srgb, var(--bg) 70%, transparent); }

/* ---------- gallery grid ---------- */
.gallery { padding: 22px 24px 72px; }
.result-count { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }

.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1.2), box-shadow 0.22s, border-color 0.22s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card-cover {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: linear-gradient(135deg, var(--sw1, #6366f1), var(--sw2, #a855f7) 55%, var(--sw3, #3b82f6));
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.card:hover .card-cover img { transform: scale(1.04); }
.card-cover.no-img img { display: none; }
.card-cover.no-img::after {
  content: attr(aria-label);
  content: "";
}
.card-cover.no-img::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 140% at 85% 10%, rgba(255, 255, 255, 0.25), transparent 55%);
}
.card-body { display: flex; flex-direction: column; gap: 9px; padding: 15px 16px 16px; flex: 1; }
.card-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card-fav { width: 20px; height: 20px; border-radius: 5px; object-fit: contain; flex-shrink: 0; }
.card-title h3 { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-cat { margin-left: auto; flex-shrink: 0; font-size: 11px; color: var(--muted); background: var(--bg-soft); border-radius: 6px; padding: 2px 8px; }
.card-desc {
  font-size: 13px; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: calc(13px * 1.55 * 2);
}
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 2px; }
.dots { display: flex; }
.dots i {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--surface); margin-left: -5px;
}
.dots i:first-child { margin-left: 0; }
.tags { display: flex; gap: 5px; overflow: hidden; }
.tags span {
  flex-shrink: 0; font-size: 10.5px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}

.empty { text-align: center; padding: 80px 0; color: var(--muted); }
.empty p { margin-bottom: 16px; font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 550; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 16px; transition: all 0.15s; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--muted); transform: translateY(-1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { opacity: 0.88; }

/* ---------- detail page ---------- */
.detail { padding-top: 28px; padding-bottom: 80px; }
.detail-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 30px; }
.back { font-size: 14px; font-weight: 550; color: var(--muted); transition: color 0.15s; }
.back:hover { color: var(--ink); }
.detail-pager { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.detail-pager a { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-pager a:hover { color: var(--ink); }

.detail-hero { margin-bottom: 26px; }
.detail-id { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.detail-fav { width: 48px; height: 48px; border-radius: 12px; object-fit: contain; background: var(--surface); border: 1px solid var(--line); padding: 6px; box-shadow: var(--shadow-sm); }
.detail-hero h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.025em; line-height: 1.15; }
.detail-sub { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill {
  font-size: 11.5px; font-weight: 500; color: var(--ink-2);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px;
}
.pill-cat { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.detail-desc { max-width: 760px; font-size: 15px; color: var(--ink-2); margin-bottom: 18px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.palette-strip { display: flex; border-radius: 12px; overflow: hidden; height: 64px; margin-bottom: 18px; border: 1px solid var(--line); }
.swatch {
  position: relative; flex: 1; background: var(--c);
  transition: flex 0.25s ease; min-width: 0;
}
.swatch:hover { flex: 1.9; }
.swatch span {
  position: absolute; left: 10px; bottom: 8px;
  font-family: var(--mono); font-size: 11px; color: #fff;
  mix-blend-mode: difference; white-space: nowrap; opacity: 0.9;
}
html[data-theme="dark"] .palette-strip { border-color: var(--line); }

.detail-cover {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); margin-bottom: 30px;
  aspect-ratio: 16 / 7; background: linear-gradient(135deg, var(--sw1, #6366f1), var(--sw2, #a855f7) 55%, var(--sw3, #3b82f6));
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-cover.no-img::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 140% at 85% 10%, rgba(255, 255, 255, 0.28), transparent 55%);
}

/* tabs */
.tabs {
  position: sticky; top: var(--header-h); z-index: 40;
  display: flex; gap: 4px; padding: 5px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 26px;
  width: fit-content; max-width: 100%; overflow-x: auto;
}
.tab {
  font-size: 13.5px; font-weight: 550; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; white-space: nowrap; transition: all 0.15s;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); padding: 7px 15px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.preview-frame {
  width: 100%; height: max(560px, 78vh);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow-sm);
}

/* tokens panel */
.tokens-section { margin-bottom: 34px; }
.tokens-section h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; margin-bottom: 14px; }
.tokens-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.token-color {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface); cursor: pointer; text-align: left; transition: transform 0.15s, box-shadow 0.15s;
}
.token-color:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.token-color .tc-block { height: 52px; }
.token-color .tc-meta { padding: 8px 10px; }
.token-color .tc-name { font-size: 11.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.token-color .tc-val { font-family: var(--mono); font-size: 11px; color: var(--muted); text-transform: uppercase; }
.type-sample { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 14px 16px; margin-bottom: 10px; overflow: hidden; }
.type-sample .ts-sample { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.type-sample .ts-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); margin-top: 4px; }
.scale-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.scale-row .sr-bar { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); flex-shrink: 0; }
.scale-row .sr-label { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.radius-grid { display: flex; gap: 12px; flex-wrap: wrap; }
.radius-box {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.radius-box i { width: 64px; height: 44px; border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }

.file-list { margin-top: 34px; }
.file-list h3 { font-size: 16px; font-weight: 650; margin-bottom: 14px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.file {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 12px 14px; transition: all 0.15s; display: block;
}
.file:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.file strong { display: block; font-family: var(--mono); font-size: 12.5px; }
.file span { font-size: 12px; color: var(--muted); }

/* ---------- markdown ---------- */
.md { max-width: 860px; }
.md-loading { color: var(--muted); font-size: 14px; padding: 24px 0; }
.md h1, .md h2, .md h3, .md h4 { letter-spacing: -0.015em; line-height: 1.3; margin: 1.6em 0 0.6em; }
.md > :first-child { margin-top: 0; }
.md h1 { font-size: 28px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.md h2 { font-size: 21px; margin-top: 2.2em; }
.md h3 { font-size: 16.5px; }
.md p, .md ul, .md ol { font-size: 14.5px; color: var(--ink-2); margin: 0.7em 0; }
.md li { margin: 0.3em 0 0.3em 1.3em; }
.md strong { color: var(--ink); font-weight: 600; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md blockquote {
  border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent);
  border-radius: 0 10px 10px 0; padding: 12px 16px; margin: 1em 0; color: var(--ink-2);
}
.md blockquote p { margin: 0.3em 0; }
.md code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--ink);
}
.md pre { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 1em 0; }
.md pre code { background: none; border: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.md table { border-collapse: collapse; width: 100%; margin: 1.1em 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top; }
.md th { background: var(--bg-soft); font-weight: 600; color: var(--ink); white-space: nowrap; }
.md td { color: var(--ink-2); }
.md tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-soft) 55%, transparent); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 2em 0; }

/* toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 500;
  border-radius: 9px; padding: 9px 16px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all 0.22s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- RTL (Arabic) ---------- */
html[dir="rtl"] .dots i { margin-left: 0; margin-right: -5px; }
html[dir="rtl"] .dots i:first-child { margin-right: 0; }
html[dir="rtl"] .card-cat { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .md blockquote { border-left: 0; border-right: 3px solid var(--accent); border-radius: 10px 0 0 10px; }
html[dir="rtl"] .swatch span { left: auto; right: 10px; }
html[dir="rtl"] .detail-pager a { direction: ltr; unicode-bidi: embed; }
html[dir="rtl"] .back { direction: ltr; unicode-bidi: embed; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .gallery { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 48px 0 30px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .card-body { padding: 12px; }
  .card-cat { display: none; }
  .detail-fav { width: 40px; height: 40px; }
  .detail-pager { display: none; }
  .palette-strip { height: 46px; }
  .swatch span { font-size: 9px; left: 6px; bottom: 5px; }
  .preview-frame { height: 68vh; }
  .header-nav a span { display: none; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
}
