/* =========================================
   Editor Panel & Syntax Highlighting
   ========================================= */

.js-playground-editor-container {
    flex: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

.js-playground-line-numbers {
    width: 45px;
    background-color: var(--editor-gutter-bg);
    color: #888;
    text-align: right;
    
    padding: 10px 8px 10px 0 !important;
    font-family: var(--code-font-family) !important;
    font-size: var(--code-font-size) !important;
    font-weight: var(--code-font-weight) !important;
    line-height: 1.5 !important;
    
    user-select: none;
    border-right: 1px solid var(--editor-border);
    overflow: hidden;
    z-index: 5;
    box-sizing: border-box;
}

.line-number-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap; 
    overflow: hidden;
}

.js-playground-code-wrapper {
    position: relative;
    flex: 1;
    height: 100%;
    overflow: hidden;
    background-color: var(--editor-bg);
}

.js-playground-editor-font {
    font-family: var(--code-font-family) !important;
    font-size: var(--code-font-size) !important;
    font-weight: var(--code-font-weight) !important;
    line-height: 1.5 !important;
    
    font-feature-settings: "liga" 0, "calt" 0 !important;
    font-variant-ligatures: none !important;
    text-rendering: optimizeSpeed !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    
    padding: 10px !important;
    margin: 0 !important;
    border: none !important;
    
    display: block !important;
    
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-all !important;
    
    tab-size: 2 !important;
    width: 100% !important;
    height: 100% !important;
    box-sizing: border-box !important;
    letter-spacing: 0px !important;
}

.js-playground-highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    color: var(--app-text);
    pointer-events: none;
    background-color: transparent;
    overflow: hidden; 
}

.js-playground-highlight-layer code {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    white-space: inherit;
    word-wrap: inherit;
    overflow-wrap: inherit;
    word-break: inherit;
    display: block;
    min-height: 100%;
    background-color: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    width: 100% !important;
}

.view-line {
    display: block;
    width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    box-sizing: border-box;
}

.js-playground-textarea {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    background-color: transparent;
    color: transparent;
    caret-color: var(--editor-caret);
    resize: none;
    outline: none;
    overflow-y: auto; 
    overflow-x: hidden;
    vertical-align: top;
}

.js-playground-textarea::selection {
    background-color: rgba(20, 158, 255, 0.3); /* Accent with opacity */
    color: transparent;
}

/* Syntax Highlighting */
.token-comment { color: var(--sh-comment); font-style: italic; }
.token-keyword { color: var(--sh-keyword); font-weight: bold; }
.token-string { color: var(--sh-string); }
.token-number { color: var(--sh-number); }
.token-function { color: var(--sh-function); }
.token-operator { color: var(--sh-operator); }

/* [NEW] Regex & Punctuation Styles */
.token-regex { color: #e06c75; /* Red/Pink for Regex */ }
.token-punctuation { color: #abb2bf; /* Neutral/White for Brackets */ }
/* Dark Mode Override for Punctuation if needed in base.css or here */
/* In light mode, override to black/dark gray */
@media (prefers-color-scheme: light) {
    body:not(.dark-mode) .token-punctuation { color: #383a42; }
}

/* JsDoc Specific Highlights */
.token-jsdoc-tag {
    color: #c678dd; /* Purple for tags like @param */
    font-weight: bold;
}
.token-jsdoc-type {
    color: #56b6c2; /* Cyan for types like {string} */
}

/* Suggest Widget */
.js-playground-suggest-widget {
    position: absolute;
    z-index: 100;
    background-color: var(--suggest-bg);
    border: 1px solid var(--editor-border);
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    max-height: 200px;
    width: 300px;
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
    display: none;
}

.js-playground-suggest-item {
    padding: 4px 8px;
    cursor: pointer;
    color: var(--suggest-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 2px solid transparent;
}

.js-playground-suggest-item.selected,
.js-playground-suggest-item:hover {
    background-color: var(--suggest-hover);
    color: var(--suggest-hover-text);
    border-left: 2px solid var(--accent-color-solid);
}

.js-playground-suggest-label { font-weight: 600; margin-right: 8px; }
.js-playground-suggest-desc {
    font-size: 0.85em;
    color: var(--suggest-desc);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}
.js-playground-suggest-item.selected .js-playground-suggest-desc,
.js-playground-suggest-item:hover .js-playground-suggest-desc {
    color: rgba(255,255,255,0.8);
}

/* Snippet Indicator */
.js-playground-panel.snippet-active .js-playground-editor-container::after {
    content: "Snippet Mode: Press Tab"; position: absolute; bottom: 5px; right: 25px;
    font-size: 0.7rem; background-color: var(--accent-color-solid); color: white;
    padding: 2px 6px; border-radius: 4px; opacity: 0.8; pointer-events: none; z-index: 10;
    animation: pulse-opacity 2s infinite ease-in-out;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 0.4; }
}