* { box-sizing: border-box; margin: 0; padding: 0; }
    
:root {
  --primary: #2563eb;
  --success: #16a34a;
  --bg-light: #f8fafc;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --code-bg: #f1f5f9;
  --header-offset: 120px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: white;
}

header {
  background: var(--primary);
  color: white;
  padding: 1.25rem 0.75rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 120;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  opacity: 0.9;
  font-size: 1.1rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 2rem;
}

.right-panel {
  position: sticky;
  top: calc(var(--header-offset) + 12px);
  height: fit-content;
}

nav {
  position: sticky;
  top: calc(var(--header-offset) + 12px);
  height: fit-content;
}

.nav-section {
  margin-bottom: 1.5rem;
}

.nav-title {
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.5rem;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.nav-link:hover {
  background: var(--bg-light);
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

main {
  min-height: 100vh;
}

.category {
  margin-bottom: 3rem;
  scroll-margin-top: var(--header-offset);
}

.category-title {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.function-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.function-name {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.function-syntax {
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  margin: 1rem 0;
  border-left: 3px solid var(--primary);
}

.function-description {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.catalog-source {
  color: var(--text-secondary);
  margin: -0.75rem 0 1.5rem;
}

.catalog-group summary {
  cursor: pointer;
}

.catalog-function-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.5rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.catalog-function-name {
  background: var(--code-bg);
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
}

.examples-section {
  margin-top: 1.5rem;
}

.example-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.example-item {
  margin-bottom: 1rem;
}

.example-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.copy-button {
  background: #94a3b8;
  color: white;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.example-code {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  overflow-x: auto;
  white-space: pre;
}

.try-button {
  background: var(--success);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.try-button:hover {
  opacity: 0.9;
}

.try-button:active {
  transform: translateY(1px);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 3000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 600;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.editor-container {
  margin-bottom: 1rem;
}

.editor-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#modalEditor {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  resize: vertical;
}

.editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn:hover {
  opacity: 0.9;
}

#modalResult {
  background: var(--bg-light);
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  min-height: 200px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  overflow-x: auto;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.result-table th,
.result-table td {
  padding: 0.5rem;
  text-align: left;
  border: 1px solid var(--border);
}

.result-table th {
  background: var(--bg-light);
  font-weight: 600;
}

.search-box {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
  }
  
  nav {
    position: static;
  }
  
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }
}
