:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #a78bfa;
    --background: #eef2ff;
    --background-soft: #e0e7ff;
    --foreground: #1f2937;
    --muted: #6b7280;
    --border: rgba(0,0,0,0.08);
    --card-bg: rgba(255,255,255,0.7);
    --radius: 1rem;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #ddd6fe 100%);
    color: var(--foreground);
    min-height: 100vh;
    line-height: 1.6;
}

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

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Hero */
.hero {
    padding-top: 80px;
    padding-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    z-index: -1;
}

.blob-1 {
    width: 250px;
    height: 250px;
    background: var(--secondary);
    bottom: -50px;
    left: -80px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--accent);
    top: 80px;
    right: -100px;
}

.hero-content {
    text-align: center;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.hero-title {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-description {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 1rem;
}

/* Search */
.search-box {
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--muted);
}

/* Main Content */
main {
    padding: 1.5rem 0 3rem;
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
}

.filter-tab {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    background: white;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-color: transparent;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: 10px;
    background: rgba(0,0,0,0.1);
    font-size: 0.7rem;
    font-weight: 600;
}

.filter-tab.active .filter-count {
    background: rgba(255,255,255,0.25);
}

/* Formula card expandable */
.formula-card {
    cursor: pointer;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: all 0.2s;
}

.formula-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.formula-card.hidden {
    display: none;
}

/* Hidden - details shown in modal */
.formula-detail,
.expand-icon {
    display: none !important;
}

.formula-example {
    background: var(--background-soft);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.formula-example-content {
    font-size: 0.8125rem;
    color: var(--foreground);
    line-height: 1.6;
}

.formula-graph {
    margin-top: 0.75rem;
    background: white;
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.formula-graph canvas {
    width: 100% !important;
    height: 150px !important;
}

.graph-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.graph-input-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.graph-input-group label {
    font-size: 0.75rem;
    color: var(--muted);
}

.graph-input-group input {
    width: 60px;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.75rem;
}


/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-body {
    padding: 1.5rem;
}

.modal-formula {
    background: var(--background-soft);
    border-radius: 0.75rem;
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1.25rem;
}

.modal-formula .katex {
    font-size: 1.4rem;
}

.modal-desc {
    font-size: 0.9375rem;
    color: var(--muted);
    text-align: center;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}

.modal-tag {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.modal-section {
    background: var(--background);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

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

.modal-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-section-content {
    font-size: 0.875rem;
    color: var(--foreground);
    line-height: 1.8;
}

.modal-graph {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.modal-graph canvas {
    width: 100% !important;
    height: 200px !important;
}

.modal-graph .graph-inputs {
    margin-bottom: 0.75rem;
}

/* Language selector */
.lang-selector {
    display: flex;
    gap: 0.25rem;
}

.lang-btn {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

/* Category Section */
.category-section {
    margin-bottom: 2rem;
}

.category-section.hidden {
    display: none;
}

.category-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--foreground);
}

.category-icon {
    font-size: 1.5rem;
}

/* Formula Cards Grid */
.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.formula-name {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--foreground);
}

.formula-content {
    background: white;
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    margin-bottom: 0.75rem;
    overflow-x: auto;
}

.formula-content .katex {
    font-size: 1.1rem;
}

.formula-desc {
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.5;
}

.formula-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--background-soft);
    border-radius: 4px;
    font-size: 0.6875rem;
    color: var(--primary);
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
    .hero-title { font-size: 1.5rem; }
    .formula-grid { grid-template-columns: 1fr; }
    .filter-tabs { gap: 0.375rem; }
    .filter-tab { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
    .lang-btn { padding: 0.25rem 0.5rem; font-size: 0.7rem; }
}

/* Footer Wrapper */
.footer-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

footer {
    background: var(--card-bg) !important;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, sans-serif !important;
    padding: 10px !important;
}

footer .max-w-6xl {
    max-width: 100% !important;
    padding: 0 !important;
}

footer a {
    color: var(--primary) !important;
}

footer select,
#siteSelect {
    background: white !important;
    border: 1px solid var(--border) !important;
    border-radius: 9999px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    color: var(--foreground) !important;
}
