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

:root {
    --accent: #00ff88;
    --dark: #0a0e14;
    --mid: #1a1f29;
    --light: #2d3342;
    --text: #e6edf3;
    --text-dim: #8b949e;
}

body {
    font-family: "JetBrains Mono", monospace;
    background: var(--dark);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

span[id]:empty {
    display: block;
    height: 1em;
}
span[id]:empty:first-child {
    height: 0;
}

#playground-actions {
    display: none;
}

.ace_content {
    background-color: #1a1f29;
}
.ace_active-line {
    background-color: var(--dark) !important;
}

.example-card + .section-subtitle,
.example-card + .example-card {
    margin-top: 1rem;
}

.modal-active {
    overflow: hidden;
}

.modal-active #dialog-modal:has(section:target[id="docs"]) a[href="#docs"],
.modal-active #dialog-modal:has([id^="docs-"]:target) a[href="#docs"],
.modal-active
    #dialog-modal:has(section:target[id="examples"])
    a[href="#examples"],
.modal-active
    #dialog-modal:has([id^="ex-"]:target)
    a[href="#examples"],
.modal-active
    #dialog-modal:has(section:target[id="playground"])
    a[href="#playground"],
.modal-active
    #dialog-modal:has(#playground.section-active)
    a[href="#playground"] {
    font-weight: bold;
    color: white;
}
.modal-active
    #dialog-modal:has(section:target[id="playground"])
    #playground-actions,
.modal-active
    #dialog-modal:has(#playground.section-active)
    #playground-actions {
    display: block;
}

.dialog-body > section {
    display: none;
}
.dialog-body > section:target,
.dialog-body > section.section-active {
    display: block;
}
.dialog-body:has([id^="docs-"]:target) > #docs {
    display: block;
}
.dialog-body:has([id^="ex-"]:target) > #examples {
    display: block;
}

.fraunces {
    font-family: "Fraunces", serif;
}

.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

.content-wrapper {
    position: relative;
    z-index: 2;
}

.fade-in-up {
    opacity: 0;
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.delay-1 {
    animation-delay: 0.1s;
}
.delay-2 {
    animation-delay: 0.2s;
}
.delay-3 {
    animation-delay: 0.3s;
}
.delay-4 {
    animation-delay: 0.4s;
}
.delay-5 {
    animation-delay: 0.5s;
}

.code-block {
    background: var(--mid);
    border: 1px solid var(--light);
    border-radius: 12px;
    padding: 1.5rem;
    font-size: 0.875rem;
    overflow-x: auto;
    position: relative;
    transition: all 0.3s ease;
}

.code-block:hover {
    border-color: var(--accent);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.1);
}

.code-block::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.code-block:hover::before {
    opacity: 1;
}

html,
body {
    scrollbar-color: #00ff88 rgba(0, 0, 0, .3);
    scrollbar-width: thin;
    scrollbar-gutter: stable;
}

.feature-card {
    background: linear-gradient(
        135deg,
        var(--mid) 0%,
        rgba(29, 35, 47, 0.5) 100%
    );
    border: 1px solid var(--light);
    border-radius: 16px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.feature-card::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(0, 255, 136, 0.1) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
}

.feature-card:hover::before {
    opacity: 1;
}
.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    transition: all 0.3s ease;
}

.badge:hover {
    background: rgba(0, 255, 136, 0.2);
    transform: scale(1.05);
}

.highlight {
    color: var(--accent);
    font-weight: 600;
    position: relative;
}

.highlight::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    opacity: 0.3;
}

.btn-primary {
    background: var(--accent);
    color: var(--dark);
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition:
        width 0.5s ease,
        height 0.5s ease;
}

.btn-primary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 255, 136, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid var(--light);
    cursor: pointer;
    font-family: "JetBrains Mono", monospace;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    font-family: "Fraunces", serif;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
}

.section-subtitle {
    font-size: 1.4rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: .3rem;
    color: var(--text);
}

.format-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

.format-table th,
.format-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--light);
}

.format-table th {
    background: var(--mid);
    font-weight: 600;
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.format-table tr:last-child th,
.format-table tr:last-child td {
    border-bottom: 0;
}

.example-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent);
}

.code-inline {
    font-size: 0.875rem;
    color: var(--accent);
}

.nav-link {
    color: var(--text-dim);
    font-size: 0.875rem;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--accent);
}

.text-shadow-fixed {
    text-shadow: 1px 1px 2px var(--dark) !important;
    color: var(--text);
}

.text-shadow-fixed:hover {
    color: var(--accent);
}

.main-container {
    min-height: 0;
    display: flex;
    flex-direction: row;
    height: calc(87dvh - 130px);
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.output-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel-header {
    gap: 1rem;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    position: relative;
}

.panel-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.editor-container {
    flex: 1;
    position: relative;
}

.ace_editor {
    width: 100% !important;
    height: 100% !important;
}

.tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.tab {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-name {
    outline: none;
    background: transparent;
    border: none;
    color: inherit;
    font: inherit;
    min-width: 2ch;
    max-width: 160px;
    cursor: pointer;
}

.tab-name:focus {
    cursor: text;
    border-bottom: 1px solid var(--accent);
}

.tab-ext {
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
    user-select: none;
}

.tab-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}

.tab:hover .tab-close,
.tab.active .tab-close {
    display: inline;
}

.tab-close:hover {
    color: var(--text-primary);
}

.tab-add {
    padding: 6px 12px;
    font-size: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    align-self: center;
}

.tab-add:hover {
    color: var(--accent);
}

.toc-active {
    color: var(--accent) !important;
    font-weight: 600;
}

/* ─── Gist UI ─────────────────────────────────────────────────────────────── */

.gist-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
}

.gist-toolbar.hidden,
.gist-load-panel.hidden {
    display: none;
}

.gist-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    font-size: 11px;
    font-family: inherit;
    background: none;
    border: 1px solid var(--light);
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 3px;
    line-height: 1.4;
    transition: all 0.15s;
    white-space: nowrap;
}

.gist-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

.gist-btn-danger:hover {
    color: #f85149;
    border-color: #f85149;
}

.gist-load-panel {
    position: absolute;
    top: calc(100% + 2px);
    z-index: 50;
    background: var(--mid);
    border: 1px solid var(--light);
    border-radius: 6px;
    padding: 8px;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gist-load-row {
    display: flex;
    gap: 4px;
}

.gist-id-input {
    flex: 1;
    padding: 4px 8px;
    background: var(--dark);
    border: 1px solid var(--light);
    border-radius: 4px;
    color: var(--text);
    font-size: 12px;
    font-family: inherit;
    outline: none;
}

.gist-id-input:focus {
    border-color: var(--accent);
}

.gist-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    background: var(--light);
    border: 1px solid var(--light);
    color: var(--text);
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.15s;
    white-space: nowrap;
}

.gist-action-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.gist-list {
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gist-list-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--dark);
    border: 1px solid var(--light);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-dim);
    transition: all 0.15s;
}

.gist-list-item:hover {
    color: var(--text);
    border-color: var(--accent);
}

.gist-list-item-body {
    flex: 1;
    cursor: pointer;
    min-width: 0;
}

.gist-list-item .gist-item-id {
    font-size: 10px;
    color: var(--text-dim);
    opacity: 0.6;
    margin-top: 2px;
}

.gist-list-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.4;
    padding: 2px 4px;
    color: inherit;
    transition: opacity 0.15s;
}

.gist-list-delete:hover {
    opacity: 1;
    color: #f87171;
}

.gist-user-info {
    font-size: 11px;
    color: var(--accent);
    white-space: nowrap;
}

.format-toggle {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    padding: 0 8px;
}

.format-btn {
    padding: 3px 8px;
    font-size: 10px;
    font-family: inherit;
    background: none;
    border: 1px solid var(--light);
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 3px;
    line-height: 1.4;
    transition: all 0.15s;
}

.format-btn:hover {
    color: var(--text);
    border-color: var(--text-dim);
}

.format-btn.active {
    background: var(--light);
    color: var(--accent);
    border-color: var(--accent);
}

.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--bg-secondary);
    font-size: 11px;
    color: var(--text-secondary);
}

.status-left {
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-icon {
    display: inline-flex;
    align-items: center;
}

.status-bar .error {
    color: #f85149;
}

.status-bar .success {
    color: var(--accent);
}

.options-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    max-height: 75%;
    overflow-y: auto;
    z-index: 10;
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
}

.options-panel.open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0s;
}


.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px 24px;
    padding: 4px 0 8px;
}

.options-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.options-block-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    opacity: 0.6;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}

.option-card + .option-card {
    margin-top: 2rem;
}

.option-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.option-row label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
}

.option-row input[type="number"],
.option-row input[type="text"],
.option-row input[type="password"] {
    width: 72px;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    text-align: right;
    transition: border-color 0.1s;
}

.option-row input[type="number"]:focus,
.option-row input[type="text"]:focus,
.option-row input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
}

.option-row input[type="text"].wide {
    width: 140px;
    text-align: left;
}

.option-row.checkbox {
    grid-template-columns: auto 1fr;
}

.option-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.main-container {
    overflow: hidden;
}

@media (max-width: 768px) {
    span[id]:empty {
        transform: translateY(-13em);
    }

    .main-container {
        flex-direction: column;
    }

    .editor-panel,
    .output-panel {
        border-right: none;
    }

    .modal-active
        #dialog-modal:has(section:target[id="playground"])
        #close-dialog,
    .modal-active
        #dialog-modal:has(#playground.section-active)
        #close-dialog {
        display: none;
    }
}
