:root {
    --primary: #0366d6;
    --primary-hover: #005cc5;
    --bg: #ffffff;
    --sidebar-bg: #f6f8fa;
    --border: #e1e4e8;
    --text-main: #24292e;
    --text-muted: #586069;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(27, 31, 35, 0.12);
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.app-container.preview-hidden .preview-area {
    display: none;
}

.app-container.preview-hidden .sidebar {
    width: 100% !important;
    margin: 0;
    border-right: none;
}

/* Sidebar / Config Area */
#skillsSearch {
    width: 100%;
    margin-bottom: 0.1rem;
}

#socialStyle {
    width: 15%;
    padding: 0.25rem 0.5rem;
    margin-bottom: 2rem;
    margin-top: 1rem;
    margin-left: 0.5rem;
    /* Clear line space before socials grid */
}

.sidebar {
    width: 50%;
    padding: 2rem 1.5rem;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border);
}

.header {
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.github-star-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    box-shadow: 0 1px 0 rgba(27, 31, 35, 0.04);
    transition: var(--transition);
    cursor: pointer;
}

.github-star-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5da;
    transform: translateY(-1px);
}

.github-star-btn svg {
    color: #586069;
}

.preview-toggle-container.preview-toggle {
    position: sticky;
    top: 1rem;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
    height: 0;
    overflow: visible;
    pointer-events: none;
    margin-bottom: 0.9rem;
    /* Push content down slightly */
}

.btn-toggle-preview {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    /* Pill shape */
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    margin-right: 1.5rem;
    white-space: nowrap;
}

.btn-toggle-preview:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.config-section {
    margin-bottom: 4rem;
    padding: 2rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Form Elements */
.work-grid {
    display: grid;
    gap: 1.5rem;
}

.work-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.work-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

input,
select,
textarea {
    padding: 0.5rem 0.25rem;
    border: none;
    border-bottom: 2px solid var(--border);
    border-radius: 0;
    background: transparent;
    font-size: 0.95rem;
    width: 100%;
    color: var(--text-main);
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-bottom-color: var(--primary);
    background: transparent;
}

input::placeholder {
    color: #959da5;
}

/* Tech Stack Grid */
.skills-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.search-container {
    position: relative;
    width: 300px;
}

.search-container input {
    padding-left: 2.5rem;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.tech-category {
    margin-bottom: 2.5rem;
}

.tech-category h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.tech-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: #fff;
}

.tech-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.tech-item.selected {
    background: #f1f8ff;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.tech-item img {
    width: 20px;
    height: 20px;
}

.tech-item span {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Social Grid */
.social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.social-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafbfc;
}

.social-row:focus-within {
    border-color: var(--primary);
    background: #fff;
}

.social-row img {
    width: 20px;
    height: 20px;
}

.social-row input {
    border: none;
    padding: 0.25rem 0;
    background: transparent;
    font-size: 0.9rem;
}

.social-row input:focus {
    box-shadow: none;
}

/* Add-ons */
.addons-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fafbfc;
    transition: var(--transition);
}

.checkbox-item:hover {
    border-color: var(--primary);
    background: #fff;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.checkbox-item span {
    font-weight: 500;
    font-size: 0.85rem;
}

/* Resizer */
.resizer {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 10;
}

.resizer:hover,
.resizer.dragging {
    background: var(--primary);
}

/* Preview Area */
.markdown-body {
    line-height: 1.6;
    word-wrap: break-word;
}

.markdown-body h1 {
    font-size: 2em;
    margin-bottom: 16px;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.markdown-body h2 {
    font-size: 1.5em;
    margin-top: 24px;
    margin-bottom: 16px;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.markdown-body h3 {
    font-size: 1.25em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.markdown-body h4 {
    font-size: 1em;
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
}

.markdown-body p {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-body ul {
    padding-left: 2em;
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-body li {
    margin-top: 0.25em;
}

.preview-area {
    width: 50%;
    background: #f6f8fa;
    border-left: none;
    display: flex;
    flex-direction: column;
}

.markdown-body a {
    color: #0366d6;
    text-decoration: none !important;
}

.markdown-body a:hover {
    text-decoration: underline !important;
}

.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    vertical-align: middle;
    margin-bottom: 8px;
    /* Extra breathing room for logos/badges */
}

/* Ensure align="left" on p tags works properly in preview */
.markdown-body p[align="left"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.preview-header {
    padding: 1rem 2rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-tabs {
    display: flex;
    gap: 0.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
}

.tab:hover {
    background: #f3f4f6;
}

.tab.active {
    background: var(--primary);
    color: #fff;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 3rem;
    scrollbar-width: thin;
}

.sidebar {
    scrollbar-width: thin;
}

pre {
    background: #fff;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    overflow-x: auto;
}

.btn-primary {
    background: #2ea44f;
    color: #fff;
    border: 1px solid rgba(27, 31, 35, 0.15);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: #2c974b;
}

.btn-outline {
    background: #fafbfc;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.btn-toggle-preview {
    background: var(--primary);
    color: #fff;
    border: 1px solid rgba(27, 31, 35, 0.15);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar,
    .preview-area {
        width: 100% !important;
    }

    .social-grid,
    .addons-list {
        grid-template-columns: 1fr;
    }
}