:root {
    --pw-link-color: #0645ad;
    --pw-purple: #a7aef9;
    --pw-underline: #a2a9b1;
    --pw-grey: #9a9a9a;
    --pw-dark-grey: #555555;
    --pw-light-grey: #f6f6f6;
    --pw-deadlink-color: #bf3c2c;

    /* Surface colors */
    --pw-white: #ffffff;
    --pw-black: #000000;
    --pw-surface-bg: #fbfbfb;
    --pw-table-stripe-bg: #f6f8fa;
    --pw-table-border: #c6cbd1;

    /* Callout colors */
    --pw-success-border: #8ed28e;
    --pw-success-bg: #f4ffe2;
    --pw-error-border: #d28e8e;
    --pw-error-bg: #ffe2e2;
    --pw-info-border: #8ebfd2;
    --pw-info-bg: #e2f7ff;
    --pw-neutral-border: #d7d7d7;
    --pw-neutral-bg: #f9f9f9;
    --pw-target-bg: #e0e3ff;
}

body {
    margin: 0;
    padding: 0;

    background-color: var(--pw-light-grey);
    font-family: "Helvetica", sans-serif;
    line-height: 1.1;
}

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

/* WikiLink to non-existent page (deadlink) */
a.pw-deadlink {
    color: var(--pw-deadlink-color);
}

/* Anonymous author in history/diff */
.pw-anon-author {
    border-bottom: 1px dashed var(--pw-grey);
    cursor: help;
}

#navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0.75rem 0 0.75rem;
}

#navbar #logo-link {
    display: block;
    width: 8.75rem;
    margin: 0 0.5rem;
}

#navbar #logo {
    max-width: 12rem;
    width: auto;
}

#flex-container {
    display: flex;
}

ul#login-bar {
    align-self: flex-start;
    text-align: right;
    font-size: .75rem;
    margin: 0;
}

#login-bar li {
    display: inline-block;
    margin: 0 0 0 0.75rem;
}

#login-bar form {
    display: inline;
}

#login-bar button.pw-logout-btn {
    display: inline-block;
    background: none;
    color: var(--pw-link-color);
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

#login-bar button.pw-logout-btn:hover {
    text-decoration: underline;
}

#sidebar {
    margin: 0 0.75rem;
    padding: 0.5rem;
    width: 8.75rem;
    min-width: 8.75rem;
}

#sidebar ul {
    margin: 0;
    padding: 0;

    font-size: .75rem;
    list-style: none;
}

#sidebar ul li.pw-sidebar-title {
    width: 80%;
    margin: 0.4rem 0;
    border-bottom: 1px solid var(--pw-underline);
}

#right-panel {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

#article-area {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

#article-area ul.pw-tabs {
    display: flex;
    padding: 0;
    margin: 0 0 -1px 0;

    list-style: none;
    border-left: 1px solid var(--pw-purple);
}

#article-area ul.pw-tabs li {
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem 0.8rem 0.3rem 0.8rem;

    border-top: 1px solid var(--pw-purple);
    border-right: 1px solid var(--pw-purple);
}

#article-area ul.pw-tabs li.pw-active {
    background-color: var(--pw-white);
    border-bottom: 1px solid var(--pw-white);
}

#article-area ul.pw-tabs li.pw-tab-right {
    margin-left: auto;
    border-left: 1px solid var(--pw-purple);
}

#article-area ul.pw-tabs li:last-child {
    border-right: none;
}

#article-area textarea#body-edit {
    display: block;
    width: 80%;
    min-height: 10rem;
    height: 20rem;
}

#article-area input#title-edit {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 1.8rem;
    font-weight: 400;
}

#article-area .pw-last-edited {
    font-size: 0.75rem;
    color: var(--pw-grey);
    display: block;
}

#article-area .pw-what-links-here {
    font-size: 0.75rem;
    color: var(--pw-grey);
}

/* Syntax help link on edit page */
a.pw-syntax-help {
    margin-left: 1rem;
    font-size: 0.85rem;
}

article {
    padding: 1.25rem 1.5rem 1.5rem 1.5rem;
    margin: 0 -1px 1.5rem 0;
    background-color: var(--pw-white);
    border: 1px solid var(--pw-purple);
    line-height: 1.6;
}

article h1,
article h2 {
    line-height: 1.3;
    margin: 0 0 .25rem 0;
    overflow: hidden;

    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 1.8rem;
    font-weight: 400;
    border-bottom: 1px solid var(--pw-underline);
}

article h2 {
    margin: 1rem 0 .25rem 0;
    font-size: 1.5rem;
}

article section.footnotes {
    margin: 1rem 0 0 0;
}

article section.footnotes p {
    margin: 0;
}

article hr {
    border: 0;
    height: 0;
    border-bottom: 1px solid var(--pw-underline);
}

article section.footnotes ol {
    margin-bottom: 0;
}

article section.footnotes .footnote-backlink {
    font-weight: bold;
}

article section.footnotes .footnote-letter {
    font-style: italic;
}

article sup {
    line-height: 0;
}

article section.footnotes li:target,
article sup:target {
    background: var(--pw-target-bg);
}

article div.pw-article-content > table {
    margin: 1rem 0;
    border-collapse: collapse;
    border-spacing: 0;
}

article div.pw-article-content > table tr:nth-child(2n),
article div.pw-article-content > table thead {
    background-color: var(--pw-table-stripe-bg);
}

article div.pw-article-content > table td,
article div.pw-article-content > table th {
    border: 1px solid var(--pw-table-border);
    padding: 0.2rem 0.5rem;
}

article pre {
    overflow: hidden;
    border: 1px solid var(--pw-purple);
    padding: 0.75rem;
    background-color: var(--pw-surface-bg);
}

article .infobox {
    font-size: 0.95rem;
    width: 14rem;
    float: right;
    clear: right;
    margin: 0 0 0.75rem 1.0rem;
    padding: 0.3rem;
    line-height: 1.1;
}

article .infobox h1,
article .infobox h2,
article .infobox h3 {
    margin: 0.25rem 0;
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    font-family: sans-serif;
}

article .infobox ul {
    margin: 0 0.5rem 0 1rem;
}

article .infobox p {
    margin: 0.25rem 0;
}

article .infobox figure {
    margin: 0.5rem 0;
}

article .infobox figure img {
    width: 100%;
}

article .infobox figure figcaption {
    text-align: center;
}

article #toc,
article .infobox {
    border: 1px solid var(--pw-underline);
    background-color: var(--pw-surface-bg);
}

article #toc {
    padding: 0.3rem 0.5rem;
    display: inline-block;
    width: auto;
}

/* Hide the checkbox */
article #toc .toc-toggle {
    display: none;
}

article #toc .toc-header {
    display: block;
    text-align: center;
}

/* Style the brackets as plain text */
article #toc .toc-brackets {
    color: var(--pw-link-color);
    font-size: 0.85rem;
}

/* Style the label as the toggle */
article #toc .toc-header label {
    color: var(--pw-link-color);
    cursor: pointer;
    font-size: 0.85rem;
}

/* Show hide when checked, show when unchecked */
article #toc .toc-toggle:checked ~ .toc-header label::before {
    content: 'hide';
}

article #toc .toc-toggle:not(:checked) ~ .toc-header label::before {
    content: 'show';
}

/* Underline on hover */
article #toc .toc-header label:hover {
    text-decoration: underline;
}

/* Hide content when unchecked */
article #toc .toc-toggle:not(:checked) ~ ol {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

article #toc ol {
    list-style-type: none;
    counter-reset: item;
    margin: 0;
    padding: 0;
}

article #toc ol > li {
    display: table;
    counter-increment: item;
}

article #toc ol > li:before {
    content: counters(item, ".") " ";
    display: table-cell;
    padding-right: 0.6rem;
}

article #toc ol ol {
    padding-left: 1rem;
}

article #toc li ol > li {
    margin: 0;
}

article #toc li ol > li:before {
    content: counters(item, ".") " ";
}

article code {
    font-family: "Andale Mono", "Consolas", monospace;
    font-size: 1rem;
}

article code a {
    display: inline-block;
    width: 100%;
    color: var(--pw-black);
}

article code a:hover {
    text-decoration: none;
}

article pre.lineNumbers a::before {
    color: var(--pw-grey);
    content: attr(data-line-number) " ";
}

article ul {
    margin: 0.3rem 0 0 1.6rem;
    padding: 0;
}

article ul li {
    margin: 0 0 0.1rem 0;
}

article pre code.pw-diff {
    overflow-x: auto;
    max-width: 100%;
    white-space: pre-wrap;
}

article .pw-diff {
    line-height: 1;
}

article .pw-diff-info p {
    margin: 0.5rem 0;
}

article .pw-diff-comment {
    color: var(--pw-dark-grey);
    font-style: italic;
    white-space: pre;
}

article.pw-preview {
    margin: 1.5rem 0 0 0;
}

.pw-callout {
    width: 100%;
    display: inline-block;
    margin: 0.5rem 0;
    padding: 0.625rem;
    border: 1px solid;
}

.pw-green,
.pw-success {
    border-color: var(--pw-success-border);
    background-color: var(--pw-success-bg);
}

.pw-red,
.pw-error {
    border-color: var(--pw-error-border);
    background-color: var(--pw-error-bg);
}

.pw-blue,
.pw-info {
    border-color: var(--pw-info-border);
    background-color: var(--pw-info-bg);
}

.pw-neutral {
    border-color: var(--pw-neutral-border);
    background-color: var(--pw-neutral-bg);
}

/* Content tree (admin content page) */
.pw-content-tree {
    font-family: "Andale Mono", "Consolas", monospace;
    font-size: 0.85rem;
    line-height: 1.6;
}

.pw-content-tree ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1.2rem;
}

.pw-content-tree > ul {
    padding-left: 0;
}

.pw-content-tree details > summary {
    cursor: pointer;
}

.pw-content-tree details > summary:hover {
    text-decoration: underline;
}

.pw-source-badge {
    font-family: "Helvetica", sans-serif;
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    vertical-align: middle;
}

.pw-source-embedded {
    border: 1px solid var(--pw-neutral-border);
    background-color: var(--pw-neutral-bg);
    color: var(--pw-dark-grey);
}

.pw-source-disk {
    border: 1px solid var(--pw-info-border);
    background-color: var(--pw-info-bg);
    color: var(--pw-link-color);
}

.pw-register-form fieldset {
    border: none;
    margin: 0;
    padding: 0;
}

.pw-form-disabled fieldset[disabled] {
    opacity: 0.5;
}

.hidden {
    display: none;
}

#footer {
    text-align: center;
    margin: 1rem 0;
    color: var(--pw-grey);
}

#footer small.pw-powered-by {
    font-size: 0.75rem;
}

#footer .pw-powered-by .pw-heart {
    color: var(--pw-purple);
    font-size: 1.4rem;
    margin: 0 0 0 1px;
    display: inline-block;
    transform: rotate(35deg);
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

/* Tablet Breakpoint (768px) */
@media screen and (max-width: 768px) {
    /* Navbar: adjust for mobile, smaller logo */
    #navbar {
        width: auto;
        margin: 0.5rem 0.75rem;
        padding: 0;
    }

    #navbar #logo {
        max-width: 8rem;
    }

    #navbar #logo-link {
        margin-left: 0;
    }

    /* Last edited timestamp: add padding on mobile */
    #article-area .pw-last-edited,
    #article-area .pw-what-links-here {
        padding: 0 1rem;
    }

    /* Stack layout vertically */
    #flex-container {
        flex-direction: column;
    }

    /* Hide sidebar */
    #sidebar {
        display: none;
    }

    /* Login bar: slightly larger font on tablet */
    #login-bar {
        font-size: 0.85rem;
    }

    /* Tabs: keep left-justified, remove left border */
    #article-area ul.pw-tabs {
        border-left: none;
    }

    /* Article: Remove left/right borders, adjust padding */
    article {
        margin-right: 0;
        padding: 1rem;
        border-left: none;
        border-right: none;
    }

    /* Infobox: Full width, stack above content */
    article .infobox {
        float: none;
        width: 100%;
        margin: 0 0 1rem 0;
    }

    /* TOC: Full width */
    article #toc {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    /* Textarea: Full width */
    #article-area textarea#body-edit {
        width: 100%;
        box-sizing: border-box;
    }

    /* Tables: Horizontal scroll */
    article div.pw-article-content > table {
        display: block;
        overflow-x: auto;
    }

    /* Code blocks: Horizontal scroll */
    article pre {
        overflow-x: auto;
    }
}

/* Mobile Breakpoint (480px) */
@media screen and (max-width: 480px) {
    /* Smaller tabs */
    #article-area ul.pw-tabs li {
        padding: 0.5rem 0.4rem 0.3rem 0.4rem;
        font-size: 0.75rem;
    }

    /* Tighter article padding */
    article {
        padding: 0.75rem;
    }

    /* Match tighter padding for last-edited */
    #article-area .pw-last-edited,
    #article-area .pw-what-links-here {
        padding: 0 0.75rem;
    }

    /* Smaller headings */
    article h1 {
        font-size: 1.4rem;
    }

    article h2 {
        font-size: 1.2rem;
    }

    /* Edit form adjustments */
    #article-area textarea#body-edit {
        height: 12.5rem;
        min-height: 7.5rem;
    }

    #article-area input#title-edit {
        width: 100%;
        box-sizing: border-box;
        font-size: 1.4rem;
    }

    /* Stack form table cells */
    article table td {
        display: block;
        width: 100%;
    }

    article table input[type="text"],
    article table input[type="password"] {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 0.5rem;
    }
}
