/* ─── Tokens ────────────────────────────────────────── */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --surface-hover: #F0EFEB;
  --text: #1A1A1A;
  --text-muted: #7A7A76;
  --accent: #E63B2E;
  --accent-hover: #CC2E22;
  --accent-bg: #FEF0EE;
  --border: #E4E3DF;
  --border-focus: #C8C7C3;
  --code-bg: #1E1E1E;
  --code-text: #E8E4E0;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-brand: 'Archivo Black', 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'Fira Code', ui-monospace, monospace;
}

/* ─── Reset ─────────────────────────────────────────── */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; }
a { color: inherit; }

/* ─── Layout ────────────────────────────────────────── */
.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ─── Header ────────────────────────────────────────── */
.header {
  padding: 3.5rem 0 1.5rem;
  text-align: center;
  animation: fadeUp 0.6s ease;
}
.brand {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand a { text-decoration: none; color: inherit; }
.brand-dot { color: var(--accent); }
.tagline {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 500;
  animation: fadeUp 0.6s ease 0.1s both;
}

/* ─── Controls ──────────────────────────────────────── */
.controls {
  margin-bottom: 1.25rem;
  animation: fadeUp 0.5s ease 0.2s both;
}
.control-row {
  display: flex;
  gap: 0.625rem;
}
.family-select-wrap {
  flex-shrink: 0;
}
.family-select {
  appearance: none;
  padding: 0.625rem 2rem 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A7A76' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") right 0.75rem center / 12px no-repeat;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
}
.family-select:focus {
  outline: none;
  border-color: var(--accent);
}

.search-wrap {
  flex: 1;
  position: relative;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 0.625rem 2rem 0.625rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  opacity: 0;
  pointer-events: none;
}
.search-clear.visible {
  opacity: 1;
  pointer-events: all;
}
.search-clear:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-count {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Icon Grid ─────────────────────────────────────── */
.grid-container {
  position: relative;
  min-height: 200px;
  animation: fadeUp 0.5s ease 0.3s both;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 2px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  max-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.grid::-webkit-scrollbar { width: 6px; }
.grid::-webkit-scrollbar-track { background: transparent; }
.grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.grid-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 0.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
  gap: 0.25rem;
  min-height: 72px;
  user-select: none;
}
.grid-cell:hover {
  background: var(--surface-hover);
}
.grid-cell:active {
  transform: scale(0.95);
}
.grid-cell.selected {
  background: var(--accent-bg);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.grid-cell-icon {
  font-size: 22px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  line-height: 1;
  overflow: hidden;
}
.grid-cell-icon .material-symbols-outlined {
  font-size: 24px;
}
.grid-cell-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  padding: 0 2px;
  font-weight: 500;
}

.grid-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}
.grid-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius);
  z-index: 2;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Preview Panel ─────────────────────────────────── */
.panel {
  margin-top: 1.5rem;
  animation: slideDown 0.3s ease;
}
.panel-inner {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  box-shadow: var(--shadow-md);
}
.panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.panel-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.panel-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
}

/* Preview Area */
.preview-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.preview-checkerboard {
  width: 200px;
  height: 200px;
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(-45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8e8 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border: 1.5px solid var(--border);
  transition: background-color 0.2s;
}
.preview-checkerboard.has-bg {
  background-image: none;
}
.preview-img {
  max-width: 180px;
  max-height: 180px;
  image-rendering: auto;
}
.preview-name {
  font-weight: 700;
  font-size: 1rem;
}
.preview-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 200px;
}

/* Panel Controls */
.panel-controls {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}
.control-group { }
.control-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

/* Style buttons */
.style-buttons {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.style-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.style-btn:hover { border-color: var(--border-focus); color: var(--text); }
.style-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

/* Size */
.size-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.size-presets {
  display: flex;
  gap: 0.25rem;
}
.size-btn {
  padding: 0.25rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.7rem;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
}
.size-btn:hover { border-color: var(--border-focus); color: var(--text); }
.size-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}
.size-input {
  width: 64px;
  padding: 0.25rem 0.375rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
  color: var(--text);
  background: var(--surface);
}
.size-input:focus { outline: none; border-color: var(--accent); }
.size-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Color */
.color-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.color-native {
  width: 36px;
  height: 32px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: none;
}
.color-native::-webkit-color-swatch-wrapper { padding: 2px; }
.color-native::-webkit-color-swatch { border: none; border-radius: 3px; }
.color-hex {
  width: 84px;
  padding: 0.3rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface);
}
.color-hex:focus { outline: none; border-color: var(--accent); }

.color-palette {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}
.palette-swatch {
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
  min-width: 0;
}
.palette-swatch:hover {
  transform: scale(1.2);
  z-index: 1;
}
.palette-swatch.active {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--surface);
}

/* Transparent toggle */
.transparent-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.transparent-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.bg-controls { margin-top: 0.5rem; }

/* Actions */
.panel-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.125rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-focus); }

/* API URL display */
.api-url-display {
  margin-top: 1.25rem;
  padding: 0.625rem 0.875rem;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.api-url-display code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--code-text);
  white-space: nowrap;
}

/* ─── API Docs ──────────────────────────────────────── */
.api-docs {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1.5px solid var(--border);
  animation: fadeUp 0.5s ease 0.4s both;
}
.api-docs h2 {
  font-family: var(--font-brand);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.api-docs > p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.api-example {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.api-endpoint {
  padding: 1rem 1.25rem;
  background: var(--code-bg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow-x: auto;
}
.api-method {
  padding: 0.2rem 0.5rem;
  background: #2E7D32;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.03em;
}
.api-example .api-endpoint code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: #fff;
  background: none;
  padding: 0;
  white-space: nowrap;
}
.api-method { flex-shrink: 0; }
.api-method.mcp-method { background: #7C3AED; }
.api-params {
  padding: 1.25rem;
}
.api-params h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}
.api-params h3:first-child { margin-top: 0; }
.api-params table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.api-params td {
  padding: 0.375rem 0.75rem 0.375rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.api-params td:first-child {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  width: 90px;
}
.api-params td:last-child {
  color: var(--text-muted);
}
.api-params code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface-hover);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.api-params pre {
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-top: 0.25rem;
}
.api-params pre code {
  background: none;
  padding: 0;
  color: var(--code-text);
  font-size: 0.8rem;
}
.api-families {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.api-family-tag {
  padding: 0.2rem 0.625rem;
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: var(--font-mono);
}

/* ─── Footer ────────────────────────────────────────── */
.footer {
  margin-top: 4rem;
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1.5px solid var(--border);
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
}
.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.footer a:hover { color: var(--accent); }

/* ─── Content Pages (docs, legal) ───────────────────── */
.page-header {
  padding: 2rem 0 1rem;
}
.page-header .brand {
  font-size: 1.5rem;
}
.page-content {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-top: 1rem;
}
.page-content h2 {
  font-family: var(--font-brand);
  font-size: 1.3rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}
.page-content h2:first-child { margin-top: 0; }
.page-content h3 {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.page-content p {
  margin-bottom: 0.75rem;
  color: var(--text);
  line-height: 1.7;
}
.page-content p.muted { color: var(--text-muted); }
.page-content ul {
  margin: 0.5rem 0 0.75rem 1.25rem;
  color: var(--text);
  line-height: 1.7;
}
.page-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.page-content a:hover { color: var(--accent-hover); }
.page-content pre {
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.5rem 0 0.75rem;
}
.page-content pre code {
  background: none;
  padding: 0;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre;
}
.page-content code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--surface-hover);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}

/* ─── Toast ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── Animations ────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Responsive ────────────────────────────────────── */
@media (max-width: 640px) {
  .header { padding-top: 2.5rem; }
  .panel-layout {
    grid-template-columns: 1fr;
  }
  .preview-area { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .preview-checkerboard { width: 120px; height: 120px; }
  .preview-img { max-width: 100px; max-height: 100px; }
  .panel-actions { flex-direction: column; }
  .btn { justify-content: center; }
  .size-presets { flex-wrap: wrap; }
  .color-palette { grid-template-columns: repeat(8, 1fr); }
  .grid { max-height: 320px; }
}
