/* === Reset & tokens ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0d1117;
    --surface:      #161b22;
    --surface-2:    #1c2128;
    --border:       #30363d;
    --border-subtle:#21262d;
    --text:         #e6edf3;
    --text-muted:   #8b949e;
    --text-subtle:  #6e7681;
    --accent:       #58a6ff;
    --green:        #238636;
    --green-hover:  #2ea043;
    --red-text:     #ff7b72;
    --red-bg:       #1c0a0a;
    --red-border:   #6e2020;
    --radius:       6px;
    --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono:    'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

/* === Header ================================================================= */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 1rem;
}

.logo {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.03em;
}
.logo:hover { text-decoration: none; }
.logo span { color: var(--accent); }

/* === Buttons ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
    font-family: var(--font-sans);
    line-height: 1.25;
    text-decoration: none !important;
}

.btn-primary {
    background: var(--green);
    color: #fff;
    border-color: rgba(240,246,252,.1);
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    font-size: 0.9375rem;
}
.btn-primary:hover:not(:disabled) { background: var(--green-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-subtle); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
    font-size: 0.8125rem;
    padding: 0.3rem 0.65rem;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* === Main layout ============================================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.5rem 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    gap: 0.875rem;
}

/* === EasyMDE dark theme ===================================================== */
.EasyMDEContainer { display: flex; flex-direction: column; }

.editor-toolbar {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 4px 6px !important;
    opacity: 1 !important;
}

.editor-toolbar button {
    color: var(--text-muted) !important;
    border: 1px solid transparent !important;
    background: transparent !important;
    border-radius: 4px !important;
    margin: 1px !important;
}
.editor-toolbar button:hover,
.editor-toolbar button.active {
    background: var(--surface-2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
.editor-toolbar i.separator {
    border-left: 1px solid var(--border) !important;
    border-right: none !important;
    margin: 0 4px !important;
}

.CodeMirror {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-top: none !important;
    border-radius: 0 !important;
    font-family: var(--font-mono) !important;
    font-size: 0.9125rem !important;
    line-height: 1.65 !important;
    height: calc(100vh - 268px) !important;
    min-height: 380px !important;
    padding: 0.5rem 0 !important;
}

.CodeMirror-scroll { padding-bottom: 0 !important; }
.CodeMirror-cursor { border-left: 2px solid var(--text) !important; }
.CodeMirror-selected { background: #264f78 !important; }
.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection { background: #264f78 !important; }

.CodeMirror-gutters {
    background: var(--surface) !important;
    border-right: 1px solid var(--border-subtle) !important;
}
.CodeMirror-linenumber { color: var(--text-subtle) !important; }

.editor-preview,
.editor-preview-side {
    background: var(--bg) !important;
    border-left: 1px solid var(--border) !important;
    color: var(--text) !important;
    font-family: var(--font-sans) !important;
    font-size: 0.9375rem !important;
    line-height: 1.7 !important;
    padding: 1.25rem 1.5rem !important;
}

.editor-preview h1, .editor-preview h2, .editor-preview h3,
.editor-preview-side h1, .editor-preview-side h2, .editor-preview-side h3 {
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.3em;
    margin-bottom: 0.75em;
    margin-top: 1.5em;
}
.editor-preview h1:first-child,
.editor-preview-side h1:first-child { margin-top: 0; }

.editor-preview pre, .editor-preview-side pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1em 1.25em;
    overflow-x: auto;
    margin: 0.75em 0;
}

.editor-preview code, .editor-preview-side code {
    background: var(--surface-2);
    border-radius: 3px;
    padding: 0.2em 0.45em;
    font-family: var(--font-mono);
    font-size: 0.875em;
}

.editor-preview pre code, .editor-preview-side pre code {
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.editor-preview blockquote, .editor-preview-side blockquote {
    border-left: 3px solid var(--border);
    padding-left: 1em;
    color: var(--text-muted);
    margin: 0.75em 0;
}

.editor-preview table, .editor-preview-side table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.75em 0;
}
.editor-preview th, .editor-preview td,
.editor-preview-side th, .editor-preview-side td {
    border: 1px solid var(--border);
    padding: 0.4em 0.75em;
}
.editor-preview th, .editor-preview-side th {
    background: var(--surface);
}

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

.editor-statusbar {
    background: var(--surface) !important;
    color: var(--text-subtle) !important;
    border: 1px solid var(--border) !important;
    border-top: 1px solid var(--border-subtle) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    padding: 3px 12px !important;
    font-size: 0.8rem !important;
}

/* Fullscreen adjustments */
.CodeMirror-fullscreen { background: var(--bg) !important; }
.editor-preview-active-side .CodeMirror { height: 100% !important; }

/* === Publish bar ============================================================ */
.publish-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.publish-options {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.option-group label {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.option-group select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    cursor: pointer;
}
.option-group select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.option-group select option { background: var(--surface); }

.vanity-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.vanity-group:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }

.vanity-prefix {
    background: var(--surface-2);
    color: var(--text-subtle);
    padding: 0.375rem 0.6rem;
    font-size: 0.8125rem;
    border-right: 1px solid var(--border);
    font-family: var(--font-mono);
    white-space: nowrap;
    user-select: none;
}

.vanity-input {
    background: var(--surface);
    border: none !important;
    color: var(--text);
    padding: 0.375rem 0.625rem;
    font-size: 0.875rem;
    font-family: var(--font-mono);
    width: 150px;
    outline: none !important;
}
.vanity-input::placeholder { color: var(--text-subtle); }

/* === Alerts ================================================================= */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.alert-success {
    background: #0d2114;
    border: 1px solid #2ea04360;
}

.alert-error {
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    color: var(--red-text);
}

.alert-url {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.hidden { display: none !important; }

/* === View page ============================================================== */
.paste-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.meta-sep { color: var(--border); }

.meta-link {
    color: var(--text-muted);
}
.meta-link:hover { color: var(--text); text-decoration: none; }

.meta-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.paste-content {
    padding: 2rem 0 1.5rem;
    max-width: 860px;
    width: 100%;
}

/* GitHub markdown dark overrides */
.markdown-body {
    background: transparent !important;
    color: var(--text) !important;
    font-family: var(--font-sans) !important;
    font-size: 1rem !important;
    line-height: 1.75 !important;
}

.markdown-body h1, .markdown-body h2 {
    border-bottom: 1px solid var(--border) !important;
}

.markdown-body pre {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    position: relative;
    overflow: visible !important;
}

.markdown-body pre code {
    background: none !important;
    padding: 0 !important;
    font-size: 0.875em !important;
    white-space: pre;
    overflow-x: auto;
    display: block;
}

.markdown-body code:not(pre code) {
    background: var(--surface) !important;
    border-radius: 3px !important;
    padding: 0.2em 0.4em !important;
    font-size: 0.875em !important;
    color: #ff7b72 !important;
    border: 1px solid var(--border-subtle) !important;
}

.markdown-body blockquote {
    border-left: 3px solid var(--border) !important;
    color: var(--text-muted) !important;
}

.markdown-body table { display: block; overflow-x: auto; }
.markdown-body th, .markdown-body td { border-color: var(--border) !important; }
.markdown-body tr:nth-child(even) { background: var(--surface) !important; }
.markdown-body tr { background: transparent !important; }

.markdown-body hr { border-color: var(--border) !important; }

.markdown-body a { color: var(--accent) !important; }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }

/* Code copy button */
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.2rem 0.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: var(--font-sans);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.1s;
    line-height: 1.5;
    z-index: 1;
}
.markdown-body pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--text); background: var(--surface); }

.view-footer {
    display: flex;
    gap: 0.625rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* === 404 page =============================================================== */
.not-found {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    padding: 3rem 1.5rem;
}
.not-found h1 { font-size: 3rem; color: var(--text-subtle); }
.not-found p { color: var(--text-muted); }
