:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-toolbar: #1a1028;
    --accent-1: #e94560;
    --accent-2: #ff6b6b;
    --accent-3: #ff8c42;
    --accent-gradient: linear-gradient(135deg, var(--accent-1), var(--accent-3));
    --text-primary: #e0e0e0;
    --text-secondary: #8892b0;
    --text-muted: #5a6078;
    --border: #2a2a4a;
    --discord-bg: #313338;
    --discord-msg-bg: #313338;
    --discord-text: #dcddde;
    --discord-link: #00aff4;
    --discord-mention: rgba(88, 101, 242, 0.3);
    --discord-embed-bg: #2b2d31;
    --discord-code-bg: #2b2d31;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    --font-discord: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-discord);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    position: relative;
    z-index: 100;
}

.toolbar-home {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.toolbar-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 4px;
    transition: opacity 0.15s;
}

.toolbar-home:hover .toolbar-logo,
.toolbar-home:focus-visible .toolbar-logo {
    opacity: 0.75;
}

.toolbar-title {
    font-weight: 700;
    font-size: 14px;
    margin-right: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.btn-group {
    display: flex;
    gap: 2px;
}

.toolbar button, .toolbar .tb-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.toolbar button:hover, .toolbar .tb-btn:hover {
    background: rgba(233, 69, 96, 0.2);
    border-color: var(--accent-1);
}

.toolbar button:active {
    transform: scale(0.96);
}

.toolbar .accent-btn {
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 600;
    border: none;
}

.toolbar .accent-btn:hover {
    filter: brightness(1.15);
    background: var(--accent-gradient);
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

.dropdown-wrapper {
    position: relative;
}

.dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-height: 70vh;
    overflow-y: auto;
}

.dropdown-panel.open { display: block; }

.dropdown-panel.wide {
    width: 550px;
    max-width: 90vw;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-primary);
    font-size: 13px;
}

.dropdown-item:hover {
    background: rgba(233, 69, 96, 0.15);
}

.dropdown-item .item-label {
    font-weight: 600;
    color: var(--accent-2);
    min-width: 110px;
}

.dropdown-item .item-desc {
    color: var(--text-secondary);
}

.mdguide-panel {
    width: 620px;
    max-width: 95vw;
}

.md-guide-section {
    margin-bottom: 16px;
}

.md-guide-section h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.md-guide-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 13px;
    align-items: center;
}

.md-guide-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.md-guide-row code {
    font-family: var(--font-mono);
    background: var(--discord-code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--accent-3);
}

.md-guide-row .preview-text {
    color: var(--text-secondary);
}

.embedguide-panel {
    width: 650px;
    max-width: 95vw;
}

.embed-guide-intro {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    padding: 4px 8px;
}

.embed-guide-intro code {
    font-family: var(--font-mono);
    background: var(--discord-code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: var(--accent-3);
}

.embedguide-panel .md-guide-row {
    grid-template-columns: 180px 1fr auto;
}

.insert-prop-btn {
    background: rgba(233, 69, 96, 0.15);
    color: var(--accent-2);
    border: 1px solid rgba(233, 69, 96, 0.3);
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.insert-prop-btn:hover {
    background: var(--accent-1);
    color: #fff;
    border-color: var(--accent-1);
}

.colour-chip {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 3px;
    padding: 3px 4px;
}

.colour-chip:hover {
    background: rgba(233, 69, 96, 0.15);
}

.embed-guide-tip {
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px 8px;
    font-style: italic;
}

.colour-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 16px;
    padding: 4px 8px;
}

.colour-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 3px 0;
}

.colour-chip .chip {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.colour-chip code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

.embed-example-block {
    position: relative;
    margin: 4px 8px;
}

.embed-example-code {
    background: #1e1f22;
    border-radius: 6px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: var(--discord-text);
    overflow-x: auto;
    white-space: pre;
    max-height: 350px;
    overflow-y: auto;
}

.copy-example-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
}

.copy-example-btn:hover {
    filter: brightness(1.2);
}

.embed-layout-diagram {
    background: #1e1f22;
    border-radius: 6px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
    margin: 4px 8px;
    overflow-x: auto;
    white-space: pre;
}

.main-container {
    display: flex;
    height: calc(100vh - 48px);
}

.main-container.preview-hidden .preview-pane {
    display: none;
}

.main-container.preview-hidden .editor-pane {
    width: 100%;
}

.editor-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.line-numbers {
    width: 48px;
    padding: 12px 8px 12px 4px;
    background: var(--bg-primary);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 20px;
    text-align: right;
    overflow: hidden;
    user-select: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.line-numbers div {
    height: 20px;
}

#editor {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 20px;
    padding: 12px;
    border: none;
    outline: none;
    resize: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-y: auto;
    overflow-x: hidden;
    tab-size: 4;
}

#editor::placeholder {
    color: var(--text-muted);
}

.warnings-panel {
    height: 120px;
    min-height: 80px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    overflow-y: auto;
    font-size: 12px;
}

.warnings-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.warnings-header .count {
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.count.ok { background: #2d5a3d; color: #6ee7b7; }
.count.errors { background: #5a2d2d; color: #fca5a5; }
.count.warnings { background: #5a4a2d; color: #fcd34d; }

.no-issues {
    padding: 12px;
    color: #6ee7b7;
    text-align: center;
}

.issues-table {
    width: 100%;
    border-collapse: collapse;
}

.issues-table tr {
    cursor: pointer;
    transition: background 0.1s;
}

.issues-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.issue-line {
    padding: 4px 10px;
    color: var(--text-muted);
    white-space: nowrap;
    width: 80px;
    font-family: var(--font-mono);
}

.issue-icon {
    width: 24px;
    text-align: center;
}

.issue-message {
    padding: 4px 10px;
    color: var(--text-primary);
}

.issue-error .issue-message { color: #fca5a5; }
.issue-warning .issue-message { color: #fcd34d; }

.preview-pane {
    width: 50%;
    background: var(--discord-bg);
    overflow-y: auto;
    padding: 16px;
    font-family: var(--font-discord);
}

.preview-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    font-style: italic;
}

.discord-message {
    padding: 2px 0;
    margin-bottom: 0;
}

.msg-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.bot-name {
    font-weight: 600;
    font-size: 15px;
    color: #fff;
}

.bot-badge {
    background: #5865f2;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.msg-timestamp {
    color: #72767d;
    font-size: 12px;
}

.msg-content {
    padding-left: 48px;
}

.msg-text {
    color: var(--discord-text);
    font-size: 15px;
    line-height: 1.375;
    word-wrap: break-word;
}

.msg-text h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #fff;
}

.msg-text h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 8px 0 4px;
    color: #fff;
}

.msg-text h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 6px 0 4px;
    color: #fff;
}

.msg-text strong { color: #fff; }
.msg-text em { font-style: italic; }
.msg-text u { text-decoration: underline; }
.msg-text s { text-decoration: line-through; color: #72767d; }

.msg-text .subtext {
    font-size: 12px;
    color: #72767d;
    display: block;
}

.inline-code {
    background: var(--discord-code-bg);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 85%;
}

.code-block {
    background: #1e1f22;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 4px 0;
    overflow-x: auto;
    position: relative;
}

.code-block pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.4;
    color: var(--discord-text);
}

.code-block .code-lang {
    position: absolute;
    top: 4px;
    right: 8px;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.blockquote {
    display: flex;
    margin: 4px 0;
}

.bq-bar {
    width: 4px;
    border-radius: 4px;
    background: #4e5058;
    flex-shrink: 0;
    margin-right: 12px;
}

.bq-content {
    color: var(--discord-text);
}

.mention {
    background: var(--discord-mention);
    color: #e0e8ff;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 500;
}

.channel-mention::before { content: '#'; }
.role-mention { background: rgba(233, 69, 96, 0.3); color: #ff9eaf; }

.timestamp {
    background: rgba(255, 255, 255, 0.06);
    padding: 0 2px;
    border-radius: 3px;
}

.spoiler {
    background: #1e1f22;
    color: transparent;
    padding: 0 4px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.spoiler.revealed {
    color: var(--discord-text);
    background: rgba(255, 255, 255, 0.06);
}

.md-link {
    color: var(--discord-link);
    text-decoration: none;
}

.md-link:hover {
    text-decoration: underline;
}

.list-item {
    display: block;
    padding-left: 16px;
    position: relative;
}

.list-item::before {
    content: '•';
    position: absolute;
    left: 0;
}

.list-item.ordered::before {
    content: '';
}

.emoji {
    width: 22px;
    height: 22px;
    vertical-align: -5px;
    object-fit: contain;
}

.msg-image {
    margin: 8px 0;
    max-width: 400px;
}

.msg-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
}

.image-error {
    background: #3c1414;
    color: #fca5a5;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
}

.message-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 0;
}

.discord-embed {
    background: var(--discord-embed-bg);
    border-radius: 4px;
    border-left: 4px solid #5865f2;
    padding: 12px 16px;
    margin: 4px 0;
    max-width: 520px;
}

.embed-body {
    display: flex;
    gap: 16px;
}

.embed-content {
    flex: 1;
    min-width: 0;
}

.embed-author {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.embed-author-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.embed-author-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.embed-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
}

.embed-title a {
    color: var(--discord-link);
    text-decoration: none;
}

.embed-title a:hover {
    text-decoration: underline;
}

.embed-description {
    font-size: 14px;
    color: var(--discord-text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.embed-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.embed-field {
    min-width: 0;
    width: 100%;
}

.embed-field.inline {
    width: calc(33.33% - 6px);
    min-width: 120px;
}

.embed-field-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.embed-field-value {
    font-size: 13px;
    color: var(--discord-text);
    line-height: 1.3;
}

.embed-thumbnail {
    flex-shrink: 0;
}

.embed-thumbnail img {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
}

.embed-image {
    margin-top: 8px;
}

.embed-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

.embed-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.embed-footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.embed-insert-banner {
    background: var(--accent-gradient);
    color: #fff;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.embed-insert-banner:hover {
    filter: brightness(1.15);
}

.discord-embed.embed-selectable {
    cursor: pointer;
    outline: 2px dashed var(--accent-2);
    outline-offset: 2px;
    transition: outline-color 0.2s, box-shadow 0.2s;
}

.discord-embed.embed-selectable:hover {
    outline-color: var(--accent-3);
    box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    .editor-pane, .preview-pane {
        width: 100%;
        height: 50%;
    }
    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .toolbar { flex-wrap: wrap; }
    .toolbar-title { display: none; }
    .btn-group { display: none; }
}