/* Reset and Base Styles */
body,
html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    bottom: 0;
    left: 0;
    overflow: hidden;
    position: absolute;
    right: 0;
    top: 0;
    background: #f5f5f5;
}

/* Editor Panel */
.ui-editor {
    float: left;
    height: 100%;
    position: relative;
    width: 50%;
    background: #fff;
}

.ui-resizer {
    background: #ddd;
    border: solid #fff;
    border-width: 0 1px;
    bottom: 0;
    cursor: ew-resize;
    position: absolute;
    right: 0;
    top: 0;
    width: 2px;
    z-index: 10;
}

.resizing,
.resizing:hover,
.ui-resizer:hover {
    background: #999;
    border-color: #999;
}

.ui-field {
    border: 0;
    box-sizing: border-box;
    color: #333;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    height: 100%;
    line-height: 1.6;
    margin: 0;
    min-width: 0;
    outline: 0;
    overflow: auto;
    padding: 20px;
    resize: none;
    width: 100%;
    width: calc(100% - 2px);
}

.ui-field:focus {
    color: #000;
}

.ui-field::placeholder {
    color: #999;
    font-style: italic;
}

/* Preview Panel */
.ui-aside {
    background: #fff;
    height: 100%;
    overflow: auto;
    position: relative;
}

.ui-preview {
    padding: 20px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Empty State */
.empty-state {
    color: #999;
    font-style: italic;
    padding: 40px 20px;
    text-align: center;
}

.error-state {
    color: #c00;
    padding: 20px;
    background: #fee;
    border-left: 3px solid #c00;
}

/* Menu */
.ui-menu {
    height: 40px;
    position: fixed;
    right: 20px;
    width: 40px;
    z-index: 100;
}

.ui-menu::before {
    background: url(img/gear.svg) no-repeat 50% 50% / 25px;
    content: '';
    display: block;
    height: 40px;
    opacity: .5;
    position: fixed;
    transform: rotate(-45deg);
    transition: opacity 350ms ease, transform 100ms ease;
    width: 40px;
    cursor: pointer;
}

.ui-menu:hover::before {
    opacity: 1;
    transform: rotate(0);
}

.ui-menu-dropdown {
    display: none;
    padding: 15px;
    position: absolute;
    right: -18px;
    top: 20px;
    user-select: none;
}

.ui-menu:hover .ui-menu-dropdown {
    display: block;
}

.ui-menu-panel {
    background: #fff;
    border: solid 1px #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
    border-radius: 4px;
    color: #555;
    display: block;
    font-size: 13px;
    padding: 4px;
    position: relative;
    white-space: nowrap;
}

.ui-menu-panel::before {
    background: #fff;
    border: solid #ddd;
    border-radius: 0 0 20px;
    border-width: 1px 0 0 1px;
    content: '';
    display: block;
    height: 8px;
    position: absolute;
    right: 24px;
    top: -5px;
    transform: rotate(45deg);
    width: 8px;
}

.ui-menu-item {
    color: inherit;
    cursor: pointer;
    display: block;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 3px;
    transition: all 150ms ease;
}

.ui-menu-item:hover {
    background-color: #1e90ff;
    color: #fff;
}

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #4caf50;
    color: #fff;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .2);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 300ms ease;
    z-index: 1000;
    font-size: 14px;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* Markdown Rendered Styles */
.ui-preview h1,
.ui-preview h2,
.ui-preview h3,
.ui-preview h4,
.ui-preview h5,
.ui-preview h6 {
    margin: 20px 0 12px 0;
    font-weight: 600;
    line-height: 1.3;
    color: #222;
}

.ui-preview h1 {
    font-size: 2em;
    border-bottom: 2px solid #eee;
    padding-bottom: 8px;
}

.ui-preview h2 {
    font-size: 1.6em;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.ui-preview h3 {
    font-size: 1.3em;
}

.ui-preview h4 {
    font-size: 1.1em;
}

.ui-preview h5 {
    font-size: 1em;
}

.ui-preview h6 {
    font-size: 0.9em;
    color: #666;
}

.ui-preview p {
    margin: 0 0 12px 0;
    line-height: 1.6;
    color: #333;
}

.ui-preview a {
    color: #1e90ff;
    text-decoration: none;
}

.ui-preview a:hover {
    text-decoration: underline;
}

.ui-preview strong {
    font-weight: 600;
}

.ui-preview em {
    font-style: italic;
}

.ui-preview code {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #c7254e;
}

.ui-preview pre {
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.ui-preview pre code {
    background: none;
    border: none;
    padding: 0;
    color: #333;
    font-size: 0.9em;
}

.ui-preview blockquote {
    border-left: 4px solid #1e90ff;
    margin: 12px 0;
    padding: 8px 16px;
    background: #f9f9f9;
    color: #666;
}

.ui-preview blockquote p {
    margin: 0;
}

.ui-preview ul,
.ui-preview ol {
    margin: 12px 0;
    padding-left: 28px;
}

.ui-preview ul {
    list-style-type: disc;
}

.ui-preview ol {
    list-style-type: decimal;
}

.ui-preview li {
    margin: 4px 0;
    line-height: 1.6;
}

.ui-preview ul ul,
.ui-preview ol ol,
.ui-preview ul ol,
.ui-preview ol ul {
    margin: 4px 0;
}

.ui-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    overflow: auto;
    display: block;
}

.ui-preview table th,
.ui-preview table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.ui-preview table th {
    background: #f5f5f5;
    font-weight: 600;
}

.ui-preview table tr:nth-child(even) {
    background: #fafafa;
}

.ui-preview hr {
    border: 0;
    border-top: 2px solid #eee;
    margin: 20px 0;
}

.ui-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px 0;
}

/* Show HTML Source Mode */
.show-html .ui-preview {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ui-editor {
        float: none;
        height: 50%;
        width: 100%;
    }

    .ui-field {
        height: calc(100% - 2px);
        width: 100%;
        padding: 15px;
    }

    .ui-resizer {
        border-width: 1px 0;
        bottom: 0;
        cursor: ns-resize;
        height: 2px;
        left: 0;
        top: auto;
        width: 100%;
    }

    .ui-aside {
        height: 50%;
    }

    .ui-preview {
        padding: 15px;
    }
}
