:root {
    --bg-primary: #FAF9F5;
    --bg-secondary: #F4F3EE;
    --bg-sidebar: #EEECE2;
    --bg-surface: #FFFFFF;
    --bg-muted: #F0EEE6;
    --text-primary: #1F1E1D;
    --text-secondary: #3D3929;
    --text-muted: #6F6F78;
    --accent: #DA7756;
    --accent-hover: #C96442;
    --accent-active: #BD5D3A;
    --border-primary: #E5E3DB;
    --border-secondary: #D1CFC5;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-base: 1.1rem;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.7;
}

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

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

a:active {
    color: var(--accent-active);
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-sidebar);
    min-height: 100vh;
    border-right: 1px solid var(--border-primary);
    padding: 0;
}

.sidebar-inner {
    position: sticky;
    top: 0;
    padding: 2rem 1.5rem;
    max-height: 100vh;
    overflow-y: auto;
    text-align: right;
}

.sidebar-header {
    margin-bottom: 1.5rem;
}

.sidebar-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    margin-bottom: 0.25rem;
}

.sidebar-name:hover {
    color: var(--accent);
    text-decoration: none;
}

.sidebar-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.sidebar-tagline {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.sidebar-bio {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
    line-height: 1.4;
}

/* Sidebar nav */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.sidebar-nav .nav-link {
    color: var(--accent);
    padding: 0.05rem 0;
    font-size: 1.2rem;
    border: none;
}

.sidebar-nav .nav-link:hover {
    color: var(--accent-hover);
    text-decoration: none;
}

.sidebar-nav .nav-link.active {
    color: var(--accent-active);
    font-weight: 800;
}

.external-icon {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Main content */
.main-content {
    padding: 2rem 3.25rem;
}

.content-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.copy-md-btn {
    font-size: 0.75rem;
    color: var(--text-muted);
    border: 1px solid var(--border-primary);
    background: var(--bg-surface);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
}

.copy-md-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* Content typography */
article h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

article h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

article h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

article img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

article hr {
    border: none;
    border-top: 1px solid var(--border-primary);
    margin: 2rem 0;
}

/* Blog post entries */
.post-entry {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.post-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Mobile nav */
.mobile-nav {
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-primary);
}

.mobile-nav .navbar-brand {
    font-family: var(--font-body);
    font-weight: 800;
    color: var(--text-primary);
}

/* Open Training Project */
.otp-coffee-callout {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.otp-coffee-callout p {
    margin: 0;
}

.otp-format-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-primary);
}

.otp-format-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700;
}

.otp-format-buttons {
    display: flex;
    gap: 0.25rem;
}

.otp-format-btn {
    font-family: var(--font-body);
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
}

.otp-format-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

.otp-format-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.otp-download-buttons {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.otp-download-btn {
    font-size: 0.8rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    background: var(--bg-surface);
    color: var(--text-muted);
    text-decoration: none;
    display: inline-block;
}

.otp-download-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

.otp-layout {
    display: flex;
    gap: 2rem;
}

.otp-toc {
    flex: 0 0 200px;
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.otp-toc-title {
    font-size: 0.9rem;
    font-weight: 800;
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.otp-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.otp-toc-item {
    margin-bottom: 0.25rem;
}

.otp-toc-item a {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    display: block;
    padding: 0.1rem 0;
    line-height: 1.3;
}

.otp-toc-item a:hover {
    color: var(--accent);
}

.otp-toc-h3 {
    padding-left: 0.75rem;
}

.otp-body {
    flex: 1;
    min-width: 0;
}

/* Responsive embed wrappers */
.responsive-embed {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.responsive-embed iframe,
.responsive-embed embed,
.responsive-embed object,
.responsive-embed video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Ensure all iframes and embeds don't overflow */
article iframe {
    max-width: 100%;
}

/* Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-primary);
    }

    .sidebar-inner {
        position: static;
        max-height: none;
        padding: 1rem 1.5rem;
        text-align: left;
    }

    .sidebar-nav {
        text-align: left;
    }

    .main-content {
        padding: 1.5rem 1rem;
        max-width: 100%;
    }

    article h1 {
        font-size: 1.5rem;
    }

    article h2 {
        font-size: 1.2rem;
    }

    article h3 {
        font-size: 1.05rem;
    }

    /* Ensure iframes (Google Forms, Setmore, etc.) work on mobile */
    article iframe {
        width: 100% !important;
        min-height: 400px;
    }

    /* YouTube embeds: force responsive 16:9 */
    article iframe[src*="youtube"],
    article iframe[src*="youtu.be"] {
        aspect-ratio: 16 / 9;
        height: auto;
        min-height: unset;
    }

    .otp-layout {
        flex-direction: column;
    }

    .otp-toc {
        position: static;
        flex: none;
        max-height: none;
        border-bottom: 1px solid var(--border-primary);
        padding-bottom: 1rem;
        margin-bottom: 1rem;
    }

    .otp-format-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .otp-download-buttons {
        margin-left: 0;
    }

    /* Setmore button */
    #Setmore_button_iframe img {
        max-width: 100%;
        height: auto;
    }
}

/* Small phones */
@media (max-width: 479.98px) {
    .main-content {
        padding: 1rem 0.75rem;
    }

    .sidebar-inner {
        padding: 0.75rem 1rem;
    }

    article h1 {
        font-size: 1.3rem;
    }

    .otp-format-buttons {
        flex-wrap: wrap;
    }

    .otp-download-buttons {
        flex-wrap: wrap;
    }
}
