 

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #1f2937;
    line-height: 1.6;
    overflow: hidden;
}

#reference-container {
    width: 100%;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
}

 
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-wrap: wrap;
    overflow: visible;
    white-space: normal;
}

.toolbar-block {
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-right: 6px;
    margin-bottom: 6px;
    min-width: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.toolbar-block.actions-block {
    margin-left: 0;
    margin-right: 6px;
    align-self: center;
    flex-basis: auto;
}

.toolbar-block.actions-block .block-content { align-items: center; justify-content: flex-start; padding: 4px 6px; gap: 4px; }

.block-title {
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-bottom: 1px solid #f3f4f6;
    background: #f8f9fa;
    border-radius: 5px 5px 0 0;
}

.block-content {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 6px;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.tool-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.tool-btn:active {
    background: #e5e7eb;
    transform: scale(0.95);
}

 
.tool-btn.active {
    background: #eef2ff;
    border-color: #c7d2fe;
    box-shadow: inset 0 0 0 1px #8677c4;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #374151;
    width: 16px;
    height: 16px;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.format-select {
    min-width: 110px;
    height: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    padding: 0 6px;
    font-size: 12px;
    margin-right: 6px;
    flex: 0 0 auto;
}

.size-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.size-input {
    width: 40px;
    height: 24px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
}

.size-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

.color-content { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; padding: 8px; }
.color-content.compact { grid-template-columns: repeat(2, auto); gap: 6px; padding: 6px 8px; }

.color-group { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; position: relative; }
.color-group.compact { gap: 2px; }

.color-label {
    font-size: 10px;
    color: #6b7280;
    font-weight: 500;
    margin-top: 2px;
}

.color-trigger { width: 26px; height: 26px; border: 1px solid #e5e7eb; border-radius: 6px; background: white; cursor: pointer; padding: 2px; transition: all 0.15s ease; position: relative; display: inline-flex; align-items: center; justify-content: center; }

.color-trigger:hover {
    border-color: #8677c4;
    box-shadow: 0 0 0 2px rgba(134, 119, 196, 0.1);
}

.color-preview {
    width: 100%; height: 100%;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.1);
}

.color-badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #111827; pointer-events: none; }
.color-group.compact .color-badge { font-size: 12px; }
.color-group.compact .color-label { display: none; }

.color-popup {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    padding: 12px;
    z-index: 10000;
    min-width: 220px;
}

.color-popup-header {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.color-hex-input {
    flex: 1;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.color-picker-input {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
}

.color-swatches {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-swatch:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toolbar-spacer {
    flex: 1;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid #e5e7eb;
    margin-right: 6px;
    min-width: 0;
    white-space: nowrap;
    flex: 0 0 auto;
}
.action-btn .action-text { display: none; }
.action-btn.show-text .action-text { display: inline; }
.action-btn.is-saving { opacity: 0.7; pointer-events: none; }
.action-btn.is-saved {
    background: #10b981;
    color: #ffffff;
    border-color: #10b981;
}
.action-btn.is-saved:hover {
    background: #0ea371;
    border-color: #0ea371;
}

.action-btn.primary {
    background: #8677c4;
    color: white;
    border-color: #8677c4;
}

.action-btn.primary:hover {
    background: #7568b5;
    border-color: #7568b5;
}

.action-btn.secondary {
    background: white;
    color: #6b7280;
}

.action-btn.secondary:hover {
    background: #f9fafb;
    color: #374151;
}

.action-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.action-text {
    font-size: 13px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .editor-toolbar {
        padding: 8px;
        gap: 6px;
    }
    
    .toolbar-block {
        margin-right: 6px;
        margin-bottom: 6px;
    }
    
    .format-select {
        min-width: 120px;
    }
}

 
.reference-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
}

.reference-content > .formatted-text { padding-right: 0; }

 

 
.message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    text-align: center;
    color: #6b7280;
}

 
#no-data-message { display: none; }

.message svg {
    margin-bottom: 16px;
    opacity: 0.7;
}

.message h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.message p {
    font-size: 0.875rem;
    max-width: 300px;
    line-height: 1.5;
}

 
.formatted-text {
    width: 100%;
    height: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    outline: none;
}
.formatted-text * { box-sizing: border-box; }

 
.formatted-text h1,
.formatted-text h2,
.formatted-text h3,
.formatted-text h4,
.formatted-text h5,
.formatted-text h6 {
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.formatted-text p {
    margin-bottom: 1em;
    line-height: 1.6;
}

.formatted-text ul,
.formatted-text ol {
    margin-bottom: 1em;
    padding-left: 1.5em;
}

.formatted-text li {
    margin-bottom: 0.25em;
}

.formatted-text blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 4px solid #e5e7eb;
    font-style: italic;
}

.formatted-text code {
    background: #f3f4f6;
    padding: 0.125em 0.25em;
    border-radius: 0.25em;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.875em;
    color: #111827;
}

 


.formatted-text pre {
    background: #0f172a;
    color: #e5e7eb;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1em;
    border: 1px solid rgba(255,255,255,0.08);
}

.formatted-text pre code {
    background: none;
    padding: 0;
}
.symbol-popup {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    z-index: 1000;
}

.symbols-wrapper {
    position: relative;
    display: inline-block;
}

.symbol-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.symbol-tab {
    padding: 4px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 12px;
}

.symbol-tab.active {
    background: #eef2ff;
    border-color: #c7d2fe;
}

.symbol-grid {
    display: grid;
    grid-template-columns: repeat(8, 32px);
    gap: 6px;
}

.symbol-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 16px;
}

.symbol-btn:hover {
    background: #f3f4f6;
}

 
.formatted-text .tok-field {
    color: #f59e0b;
    font-weight: 600;
}

.formatted-text .tok-func {
    color: #2563eb;
    font-weight: 600;
}

 
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #8677c4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: #6b7280;
    font-size: 0.875rem;
}

 
@media (max-width: 768px) {
    .reference-content {
        padding: 16px;
    }
    .formatted-text img.rt-img-xl { width: 100%; }
    
    .message h3 {
        font-size: 1.125rem;
    }
    
    .message p {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .reference-content {
        padding: 12px;
    }
    .formatted-text img.rt-img-xl { width: 100%; }
    
    .formatted-text ul,
    .formatted-text ol {
        padding-left: 1.25em;
    }
}

 
#status {
    position: fixed;
    top: 10px;
    left: 10px;
    background: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 9999;
}

 
.formatted-text details {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0;
    background: #fff;
    margin: 10px 0;
}
.formatted-text summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #374151;
    padding: 10px 12px;
}
.formatted-text summary::-webkit-details-marker { display: none; }
.formatted-text summary:before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: rotate(-45deg);
    transition: transform .2s ease;
    margin-right: 4px;
}
.formatted-text details[open] summary:before {
    transform: rotate(45deg);
}
.formatted-text details > div { padding: 10px 12px; background: #f3f4f6; border-top: 1px solid #e5e7eb; }

 
.formatted-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}
.formatted-text th,
.formatted-text td {
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
    text-align: left;
}
.formatted-text th {
    background: #f9fafb;
    color: #374151;
}

 
.reference-content {
    scroll-behavior: smooth;
}
.formatted-text a { text-decoration: none; }
.formatted-text a:hover { text-decoration: underline; }
.formatted-text .rt-link { color: #0066cc; cursor: pointer; text-decoration: none; }
.formatted-text .rt-link:hover { text-decoration: underline; }

 
.formatted-text.mapping-mode .rt-link { outline: 1px dashed #8677c4; border-radius: 4px; padding: 0 2px; }
.formatted-text .rt-link.map-pending { background: #eef2ff; }

 
.action-btn.mapping-active { background: #8677c4; color: #fff; border-color: #8677c4; }
.mapping-badge { margin-left: 6px; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 4px; background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 600; }

 
.rt-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .2s ease;
    z-index: 10000;
}
.rt-toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

 
@keyframes rt-flash-bg {
    0% { background: #fef9c3; }
    100% { background: transparent; }
}
.rt-flash-hit { animation: rt-flash-bg 1200ms ease-out; }


 
.formatted-text .callout {
    border: 1px solid #e5e7eb;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 12px 0;
    background: #ffffff;
}
.formatted-text .callout-title { font-weight: 600; margin-bottom: 6px; color: #374151; }
.formatted-text .callout-content { color: #374151; }
.formatted-text .callout-info { border-left-color: #60a5fa; background: #eff6ff; }
.formatted-text .callout-warning { border-left-color: #f59e0b; background: #fff7ed; }
.formatted-text .callout-note { border-left-color: #a78bfa; background: #f5f3ff; }
.formatted-text .callout-tip { border-left-color: #34d399; background: #ecfdf5; }


.formatted-text img {
    max-width: 100%;
    height: auto;
}
.formatted-text img.rt-img { display: block; margin: 10px 0; }
.formatted-text img.rt-img-sm { max-width: 25%; }
.formatted-text img.rt-img-md { max-width: 50%; }
.formatted-text img.rt-img-lg { max-width: 75%; }
.formatted-text img.rt-img-xl { 
    max-width: 100%;
    width: 100%;
}
