@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --font-body: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --bg: #f0f2f5;
    --bg-top: #e6e9ee;
    --panel: #f8f9f8;
    --text: #14181c;
    --muted: #5a6472;
    --subtle: #8e97a2;
    --line: #d3d9d6;
    --section-line: rgba(211, 217, 214, 0.7);
    --accent: #1d5fc4;
    --accent-light: #eaf1fd;
    --accent-mid: #b9d1f7;
    --note-bg: #eef3f9;
    --tip-bg: #f8f9f8;
    --tip-border: #d3d9d6;
    --code-bg: #edf0f3;
    --code-text: #1a3a4a;
    --card-shadow:
        0 26px 34px -30px rgba(0, 0, 0, 0.72),
        0 12px 18px -16px rgba(0, 0, 0, 0.36),
        0 2px 5px rgba(0, 0, 0, 0.12),
        inset 0 0 10px rgba(100, 110, 108, 0.14),
        inset 0 0 0 1px rgba(255, 255, 255, 0.9);
    --sidebar-active-bg: rgba(29, 95, 196, 0.08);
    --section-gap: 1.65rem;
    --section-pad: 1.35rem;
    --section-card-follow-gap: 2.15rem;

    --tag-cpp-bg: #dbeafe; --tag-cpp-text: #1e40af;
    --tag-qt-bg: #dcfce7; --tag-qt-text: #166534;
    --tag-linux-bg: #fef3c7; --tag-linux-text: #92400e;
    --tag-js-bg: #fef9c3; --tag-js-text: #713f12;
    --tag-webbt-bg: #cffafe; --tag-webbt-text: #164e63;
    --tag-pwa-bg: #f3e8ff; --tag-pwa-text: #6b21a8;
    --tag-python-bg: #e0e7ff; --tag-python-text: #3730a3;
    --tag-ha-bg: #fce7f3; --tag-ha-text: #9d174d;
    --tag-iot-bg: #d1fae5; --tag-iot-text: #065f46;
    --tag-firmware-bg: #e2e8f0; --tag-firmware-text: #334155;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151a;
        --bg-top: #1a1e24;
        --panel: #181c22;
        --text: #e6edf3;
        --muted: #9aa4b0;
        --subtle: #6b7480;
        --line: #2a2f36;
        --section-line: rgba(255, 255, 255, 0.08);
        --accent: #5b9bf5;
        --accent-light: #142334;
        --accent-mid: #1f3a5c;
        --note-bg: #131c26;
        --tip-bg: #181c22;
        --tip-border: #2a2f36;
        --code-bg: #1c2129;
        --code-text: #8fc0ff;
        --card-shadow:
            0 26px 34px -30px rgba(0, 0, 0, 0.9),
            0 12px 18px -16px rgba(0, 0, 0, 0.6),
            inset 0 0 0 1px rgba(255, 255, 255, 0.04);
        --sidebar-active-bg: rgba(91, 155, 245, 0.12);

        --tag-cpp-bg: #1e3a5f; --tag-cpp-text: #93c5fd;
        --tag-qt-bg: #14532d; --tag-qt-text: #86efac;
        --tag-linux-bg: #451a03; --tag-linux-text: #fcd34d;
        --tag-js-bg: #422006; --tag-js-text: #fde68a;
        --tag-webbt-bg: #0c3a4a; --tag-webbt-text: #67e8f9;
        --tag-pwa-bg: #3b0764; --tag-pwa-text: #d8b4fe;
        --tag-python-bg: #312e81; --tag-python-text: #c7d2fe;
        --tag-ha-bg: #500724; --tag-ha-text: #f9a8d4;
        --tag-iot-bg: #064e3b; --tag-iot-text: #6ee7b7;
        --tag-firmware-bg: #1e293b; --tag-firmware-text: #cbd5e1;
    }
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text);
    background: linear-gradient(to bottom, var(--bg-top) 0%, var(--bg) 320px) var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

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

a:hover {
    text-decoration: underline;
}

a[href*="github.com"]::before {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.2em;
    vertical-align: -0.125em;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z'/%3E%3C/svg%3E") no-repeat center;
    mask-size: contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask-size: contain;
}

.section .download-list {
    list-style: none;
    padding-left: 0;
}

.download-list a::before {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: 0.3em;
    vertical-align: -0.15em;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2' /%3E%3Cpath d='M7 11l5 5l5 -5' /%3E%3Cpath d='M12 4l0 12' /%3E%3C/svg%3E") no-repeat center;
    mask-size: contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2' /%3E%3Cpath d='M7 11l5 5l5 -5' /%3E%3Cpath d='M12 4l0 12' /%3E%3C/svg%3E") no-repeat center;
    -webkit-mask-size: contain;
}

/* ---- top nav (site-wide) ---- */

nav.top {
    padding-top: clamp(1.5rem, 4vw, 2.5rem);
    padding-bottom: 1rem;
    font-size: 0.9rem;
}

nav.top a {
    margin-right: 1rem;
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
}

nav.top a:hover {
    color: var(--accent);
}

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

/* ---- homepage project list ---- */

.home {
    width: min(100% - 3rem, 1040px);
    margin: 0 auto;
    padding-bottom: clamp(3rem, 10vw, 7rem);
}

h1 {
    font-size: clamp(1.6rem, 5vw, 2.1rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 1.25rem;
}

.project-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-top: 1.5rem;
}

@media (max-width: 720px) {
    .project-list {
        grid-template-columns: 1fr;
    }
}

.project-card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    background: var(--panel);
    transition: border-color 0.15s ease;
    display: flex;
    flex-direction: column;
}

.project-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: var(--card-shadow);
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
}

.project-card:hover {
    border-color: var(--accent);
}

.project-card:hover::after {
    opacity: 0.5;
}

.project-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.5rem;
}

.project-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-icon {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    flex-shrink: 0;
}

.project-card h2 {
    margin: 0;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
}

.project-links {
    display: flex;
    gap: 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.project-tags {
    margin-bottom: 0.6rem;
}

.project-description {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.tag {
    display: inline-block;
    background: var(--code-bg);
    color: var(--muted);
    border-radius: 4px;
    padding: 0.15rem 0.55rem;
    font-size: 0.8rem;
    margin-right: 0.3rem;
    font-weight: 500;
}

.tag[data-tag="C++"] { background: var(--tag-cpp-bg); color: var(--tag-cpp-text); }
.tag[data-tag="Qt"] { background: var(--tag-qt-bg); color: var(--tag-qt-text); }
.tag[data-tag="Linux"] { background: var(--tag-linux-bg); color: var(--tag-linux-text); }
.tag[data-tag="JavaScript"] { background: var(--tag-js-bg); color: var(--tag-js-text); }
.tag[data-tag="Web Bluetooth"] { background: var(--tag-webbt-bg); color: var(--tag-webbt-text); }
.tag[data-tag="PWA"] { background: var(--tag-pwa-bg); color: var(--tag-pwa-text); }
.tag[data-tag="Python"] { background: var(--tag-python-bg); color: var(--tag-python-text); }
.tag[data-tag="Home Assistant"] { background: var(--tag-ha-bg); color: var(--tag-ha-text); }
.tag[data-tag="IoT"] { background: var(--tag-iot-bg); color: var(--tag-iot-text); }
.tag[data-tag="Firmware"] { background: var(--tag-firmware-bg); color: var(--tag-firmware-text); }

footer.home-footer {
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--subtle);
    border-top: 1px solid var(--section-line);
    padding-top: 1rem;
}

/* ---- docs-style project pages ---- */

.page {
    width: min(100% - 3rem, 680px);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 2.5rem) 0 clamp(3rem, 10vw, 7rem);
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.back:hover {
    text-decoration: underline;
}

.back svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.back:hover svg {
    transform: translateX(-3px);
}

.back--footer {
    margin-top: 3rem;
    margin-bottom: 0;
}

.hero {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--section-line);
    margin-bottom: 1.5rem;
}

.hero h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.08;
}

.hero h1 img {
    width: clamp(1.5rem, 5vw, 2rem);
    height: clamp(1.5rem, 5vw, 2rem);
    border-radius: 5px;
    flex-shrink: 0;
}

.lede {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.65;
    color: var(--muted);
    font-weight: 400;
    max-width: 56ch;
}

.body {
    display: flex;
    flex-direction: column;
    gap: var(--section-gap);
}

.body p {
    font-size: 0.9875rem;
    line-height: 1.75;
    color: var(--text);
    margin: 0;
}

.section-intro {
    margin-bottom: 0.75rem;
    color: var(--muted);
}

.section {
    padding-top: var(--section-gap);
    border-top: 1px solid var(--section-line);
}

.section:first-child {
    padding-top: 0;
    border-top: 0;
}

.section--card {
    padding-top: 0;
    border-top: 0;
}

.section--card + .section {
    padding-top: 0;
    border-top: 0;
    margin-top: calc(var(--section-card-follow-gap) - var(--section-gap));
}

.section h2 {
    margin: 0 0 0.55rem;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.01em;
}

.section h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.section ul,
.section ol {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-left: 1.2rem;
    margin: 0;
}

.section li {
    color: var(--text);
    font-size: 0.9875rem;
    line-height: 1.7;
}

.section li::marker {
    color: var(--accent);
    font-weight: 700;
}

.note {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-top: 0.85rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--tip-border);
    border-radius: 8px;
    background: var(--note-bg);
    box-shadow: 0 10px 24px -22px rgba(0, 0, 0, 0.45);
}

.note::before {
    content: "i";
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.15rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.note p {
    color: var(--text);
    font-size: 0.925rem;
    line-height: 1.6;
}

.doc-card {
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--tip-bg);
    border: 1px solid var(--tip-border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
}

.doc-card + * {
    margin-top: 1rem;
}

.step-list {
    list-style: none !important;
    padding: 0 !important;
    gap: 0.75rem !important;
}

.step-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.step-list li::marker {
    content: none;
}

.tip-num {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 0.15em;
    border-radius: 50%;
    background: var(--accent-mid);
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

figure {
    margin: 0;
}

figure + figure {
    margin-top: 1.5rem;
}

figcaption {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

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

img.screenshot {
    display: block;
    width: 100%;
    box-shadow: var(--card-shadow);
    cursor: zoom-in;
}

img.screenshot-diskvu {
    border: 1px solid var(--line);
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    overflow: auto;
    z-index: 1000;
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
}

.lightbox-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay img {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    margin: auto;
}

pre,
code {
    font-family: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, monospace;
    font-size: 0.875rem;
}

pre {
    background: var(--code-bg);
    border-radius: 6px;
    padding: 1rem;
    overflow-x: auto;
    line-height: 1.45;
}

code {
    display: inline;
    padding: 0.1em 0.4em;
    background: var(--code-bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    overflow-wrap: break-word;
    color: var(--code-text);
}

pre code {
    background: none;
    border: none;
    padding: 0;
}

footer.doc-footer {
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--subtle);
    border-top: 1px solid var(--section-line);
    padding-top: 1rem;
}

/* ---- sidebar (docs pages, wide viewports only) ---- */

.sidebar {
    position: fixed;
    top: calc(50% + var(--drift, 0px));
    transform: translateY(-50%);
    right: calc(50% + 340px + 3rem);
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.sidebar a {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--subtle);
    text-decoration: none;
    padding: 0.25rem 0.6rem 0.25rem 0.5rem;
    border-right: 3px solid transparent;
    line-height: 1.35;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar-home {
    font-size: 0.9875rem !important;
    font-weight: 700 !important;
    color: var(--text) !important;
    border-right-color: transparent !important;
    background: none !important;
    margin-bottom: 0.6rem;
}

.sidebar a:hover {
    color: var(--muted);
}

.sidebar a.active {
    color: var(--accent);
    border-right-color: var(--accent);
    font-weight: 600;
    background: var(--sidebar-active-bg);
}

.sidebar::after {
    content: '';
    position: absolute;
    left: calc(100% - 2.25px);
    top: -80px;
    bottom: -80px;
    width: 1.5px;
    border-radius: 1px;
    background: linear-gradient(to bottom, transparent, var(--accent) 30%, var(--accent) 70%, transparent);
    opacity: 0.5;
}

@media (max-width: 1260px) {
    .sidebar { display: none; }
}

@media (max-width: 740px) {
    .doc-card {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }
}
