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

/* GitHub Dark */
:root, [data-theme="dark"] {
    --header-height: 48px;
    --footer-height: 32px;
    --pane-header-height: 32px;
    --toolbar-height: 40px;
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #7d8590;
    --accent: #58a6ff;
    --code-bg: #161b22;
    --blockquote-border: #3b434b;
}

/* GitHub Light */
[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --border: #d0d7de;
    --text: #1f2328;
    --text-muted: #656d76;
    --accent: #0969da;
    --code-bg: #f6f8fa;
    --blockquote-border: #d0d7de;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 18px;
    font-weight: 600;
}

header .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    flex: 1;
}

#theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.15s;
}

#theme-toggle:hover {
    background: var(--border);
}

main {
    display: flex;
    height: calc(100% - var(--header-height) - var(--toolbar-height) - var(--footer-height));
}

footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
    border-top: 1px solid var(--border);
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
}

footer a:hover {
    color: var(--accent);
}

/* Toolbar */
.toolbar {
    height: var(--toolbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    height: 28px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s;
}

.toolbar-btn:hover {
    background: var(--border);
}

/* Dropdowns */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 100;
}

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

.settings-menu {
    left: auto;
    right: 0;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.dropdown-item:hover {
    background: var(--border);
}

.dropdown-label {
    padding: 6px 12px 2px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.toolbar-btn .toast-check {
    color: #2da44e;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.setting-item:hover {
    background: var(--border);
}

.setting-item input[type="checkbox"] {
    accent-color: var(--accent);
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-pane {
    border-right: 1px solid var(--border);
}

.pane-header {
    height: var(--pane-header-height);
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

#editor {
    flex: 1;
    overflow: hidden;
}

#preview {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: var(--bg);
    font-size: 15px;
    line-height: 1.7;
}

/* Preview content styling */
#preview h1, #preview h2, #preview h3,
#preview h4, #preview h5, #preview h6 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    font-weight: 600;
}

#preview h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
#preview h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
#preview h3 { font-size: 1.25em; }

#preview p { margin-bottom: 1em; }

#preview a { color: var(--accent); text-decoration: none; }
#preview a:hover { text-decoration: underline; }

#preview code {
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.9em;
}

#preview pre {
    background: var(--surface);
    padding: 12px 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1em;
}

#preview pre code {
    padding: 0;
    background: none;
}

#preview blockquote {
    border-left: 3px solid var(--blockquote-border);
    padding-left: 12px;
    color: var(--text-muted);
    margin-bottom: 1em;
}

#preview ul, #preview ol {
    padding-left: 24px;
    margin-bottom: 1em;
}

#preview li { margin-bottom: 0.3em; }

#preview table {
    border-collapse: collapse;
    margin-bottom: 1em;
    width: 100%;
}

#preview th, #preview td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}

#preview th {
    background: var(--surface);
    font-weight: 600;
}

#preview img {
    max-width: 100%;
}

#preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}
