:root {
    --font-sans: 'Inter', -apple-system, sans-serif;
    --bg: #0D1117;
    --surface: #161B22;
    --surface-2: #21262D;
    --border: rgba(48, 54, 61, .6);
    --border-hover: rgba(88, 166, 255, .4);
    --primary: #58A6FF;
    --primary-glow: rgba(88, 166, 255, .1);
    --accent: #3FB950;
    --text: #C9D1D9;
    --text-muted: #8B949E;
    --text-dim: #484F58;
    --radius: 6px;
    --radius-sm: 4px
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6
}

.header {
    padding: .7rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between
}

.logo {
    display: flex;
    align-items: center;
    gap: .5rem
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem
}

.logo-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text)
}

.header-actions {
    display: flex;
    gap: .3rem
}

.main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: .75rem
}

.section-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: .5rem
}

.template-gallery {
    display: flex;
    gap: .5rem;
    overflow-x: auto;
    padding: .25rem 0
}

.tmpl-card {
    min-width: 140px;
    padding: .6rem;
    background: var(--surface-2);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0
}

.tmpl-card:hover {
    border-color: var(--text-dim)
}

.tmpl-card.active {
    border-color: var(--primary);
    background: rgba(88, 166, 255, .05)
}

.tmpl-name {
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: .15rem
}

.tmpl-desc {
    font-size: .65rem;
    color: var(--text-dim)
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .75rem;
    align-items: start
}

.split-pane {
    overflow-y: auto;
    max-height: 70vh
}

.form-fields {
    display: flex;
    flex-direction: column;
    gap: .4rem
}

.field {
    display: flex;
    flex-direction: column;
    gap: .15rem
}

.field label {
    font-size: .68rem;
    color: var(--text-muted);
    font-weight: 500
}

.field input,
.field textarea {
    padding: .3rem .45rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .78rem;
    outline: none
}

.field input:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow)
}

.badge-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem
}

.badge-check {
    font-size: .72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: .25rem;
    cursor: pointer
}

.md-preview {
    padding: .75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .82rem;
    line-height: 1.7;
    overflow-y: auto;
    max-height: 60vh
}

.md-preview h1 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .3rem;
    margin-bottom: .5rem
}

.md-preview h2 {
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .2rem;
    margin: 1rem 0 .4rem
}

.md-preview h3 {
    font-size: .95rem;
    margin: .6rem 0 .3rem
}

.md-preview code {
    background: var(--surface-2);
    padding: .1rem .3rem;
    border-radius: 3px;
    font-size: .75rem
}

.md-preview pre {
    background: var(--surface-2);
    padding: .5rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: .5rem 0
}

.md-preview pre code {
    background: none;
    padding: 0
}

.md-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: .5rem 0
}

.md-preview th,
.md-preview td {
    border: 1px solid var(--border);
    padding: .3rem .5rem;
    text-align: left;
    font-size: .75rem
}

.md-preview th {
    background: var(--surface-2)
}

.md-preview img {
    max-width: 100%;
    border-radius: var(--radius)
}

.md-preview a {
    color: var(--primary);
    text-decoration: none
}

.md-preview ul,
.md-preview ol {
    padding-left: 1.5rem;
    margin: .3rem 0
}

.md-preview blockquote {
    border-left: 3px solid var(--border);
    padding-left: .75rem;
    color: var(--text-muted);
    margin: .3rem 0
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s ease
}

.btn--primary {
    background: var(--accent);
    color: #fff;
    padding: .4rem .7rem
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    padding: .3rem .5rem;
    border: 1px solid var(--border)
}

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

.btn--sm {
    font-size: .72rem;
    padding: .25rem .4rem
}

.hidden {
    display: none !important
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .5rem .85rem;
    border-radius: var(--radius);
    font-size: .78rem;
    font-weight: 500;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .4);
    opacity: 0;
    pointer-events: none;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
    z-index: 100
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

@media(max-width:700px) {
    .split {
        grid-template-columns: 1fr
    }

    .header {
        padding: .7rem 1rem
    }

    .main {
        padding: 1rem
    }
}