/* IP Addr.es. Colours follow the visitor's system setting unless they picked a theme with the
   switcher (data-theme="light" or "dark" on <html>); dark values are defined once, below. */
:root {
    color-scheme: light dark;
    --bg: #fff;
    --text: #222;
    --muted: #767676;
    --link: #0645ad;
    --link-hover: #ff4d00;
    --header-bg: #f5f5f5;
    --logo: #484848;
    --rule: #ccc;
    --box-bg: #d7e1ec;
    --panel-border: #aaa;
    --tab-bg: #e6e6e6;
    --tab-active: #fff;
    --field-bg: #fff;
    --field-border: #999;
    --pre-bg: #f6f6f6;
    --banner: #23b000;
    --banner-text: #fff;
    --bad: #c00;
    --good: #1b7f00;
    --button-bg: #efefef;
    --button-text: #222;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #16181b;
        --text: #e3e5e8;
        --muted: #a9aeb5;
        --link: #7db8ff;
        --link-hover: #ff8a4d;
        --header-bg: #1f2226;
        --logo: #d6d8dc;
        --rule: #3d4249;
        --box-bg: #1f2a36;
        --panel-border: #3d4249;
        --tab-bg: #262a2f;
        --tab-active: #16181b;
        --field-bg: #1f2226;
        --field-border: #5a6068;
        --pre-bg: #1f2226;
        --banner: #1d8a00;
        --banner-text: #fff;
        --bad: #ff7b72;
        --good: #5fd068;
        --button-bg: #2f343a;
        --button-text: #eceef1;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #16181b;
    --text: #e3e5e8;
    --muted: #a9aeb5;
    --link: #7db8ff;
    --link-hover: #ff8a4d;
    --header-bg: #1f2226;
    --logo: #d6d8dc;
    --rule: #3d4249;
    --box-bg: #1f2a36;
    --panel-border: #3d4249;
    --tab-bg: #262a2f;
    --tab-active: #16181b;
    --field-bg: #1f2226;
    --field-border: #5a6068;
    --pre-bg: #1f2226;
    --banner: #1d8a00;
    --banner-text: #fff;
    --bad: #ff7b72;
    --good: #5fd068;
    --button-bg: #2f343a;
    --button-text: #eceef1;
}

:root[data-theme="light"] {
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: helvetica, arial, "hiragino kaku gothic pro", osaka, "ms pgothic", sans-serif;
    line-height: 1.45;
}

a {
    color: var(--link);
}

a:hover {
    color: var(--link-hover);
}

.wrap {
    max-width: 940px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Header */
.site-header {
    background: var(--header-bg);
    margin-bottom: 35px;
}

.site-header .wrap {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 70px;
}

#logo {
    margin: 0;
    font-size: 3em;
    font-weight: bold;
    line-height: 1.2;
    text-shadow: rgba(0, 0, 0, .25) 0 1px 3px;
}

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

#logo a:hover {
    color: var(--link-hover);
}

.tiny {
    font-size: .5em;
}

/* Layout: tools menu on the left, the page on the right */
.layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 20px 30px;
    align-items: start;
}

.tools-title {
    font-size: 1.2em;
    margin: 0 0 5px;
}

.tools ul {
    margin: 0 0 20px;
    padding-left: 15px;
}

.tools a[aria-current="page"] {
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
}

.ad-side {
    margin-top: 20px;
}

.content h1 {
    font-size: 1.8em;
    margin: 0 0 12px;
    text-shadow: rgba(0, 0, 0, .25) 0 1px 3px;
}

.content h2 {
    font-size: 1.3em;
    margin: 1.4em 0 .4em;
}

.content p {
    margin: 0 0 1em;
}

/* "Your IP address is ..." */
.ip-banner {
    background: var(--banner);
    color: var(--banner-text);
    font-family: "Times New Roman", Times, serif;
    font-size: 2.4em;
    line-height: 1.2;
    text-align: center;
    text-shadow: rgba(0, 0, 0, .25) 0 1px 3px;
    padding: 10px 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.ip-banner.bad {
    background: var(--bad);
}

/* The tools' forms */
.tool-form {
    background: var(--box-bg);
    padding: 14px;
    margin: 0 0 20px;
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tool-form label {
    font-weight: bold;
    font-size: 1.3em;
}

.tool-form input[type="text"] {
    font-size: 1.3em;
    padding: 4px 6px;
    width: 18em;
    max-width: 100%;
    background: var(--field-bg);
    color: var(--text);
    border: 1px solid var(--field-border);
    border-radius: 4px;
}

.tool-form input.short {
    width: 11em;
}

button, .button {
    font: inherit;
    font-size: 1.1em;
    padding: 5px 16px;
    background: var(--button-bg);
    color: var(--button-text);
    border: 1px solid var(--field-border);
    border-radius: 4px;
    cursor: pointer;
}

button:hover, button:focus-visible {
    border-color: var(--link);
}

/* The green GO image button on the original tool forms */
.tool-form button.go {
    border: 0;
    background: transparent;
    padding: 0;
    line-height: 0;
    border-radius: 6px;
}

.tool-form button.go:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

/* Results */
.data {
    border-collapse: collapse;
    margin: 0 0 20px;
}

.data th {
    text-align: right;
    padding: 5px 10px 5px 3px;
    vertical-align: top;
    white-space: nowrap;
}

.data td {
    padding: 5px 3px;
}

/* Two-column label/value tables (IP lookup, compression test) */
.cell-label {
    font-weight: bold;
    text-align: right;
    padding-right: 8px;
    white-space: nowrap;
    vertical-align: top;
}

.cell-data {
    min-width: 8em;
}

pre {
    background: var(--pre-bg);
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 10px;
    overflow-x: auto;
    font-size: .9em;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.good {
    color: var(--good);
    font-weight: bold;
}

.bad-text {
    color: var(--bad);
    font-weight: bold;
}

.source, .source a, .note {
    color: var(--muted);
    font-size: .9em;
}

.source {
    text-align: right;
}

.map {
    width: 100%;
    height: 420px;
    border: 1px solid var(--rule);
    border-radius: 6px;
}

/* Tabs on the front page (all sections show when JavaScript is off) */
.tabs {
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    font-size: .9em;
}

.tab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 6px 0;
    background: var(--tab-bg);
    border-bottom: 1px solid var(--panel-border);
    border-radius: 6px 6px 0 0;
}

.tab-list button {
    font-size: 1em;
    border-radius: 5px 5px 0 0;
    border-bottom: 0;
    background: transparent;
    padding: 6px 12px;
}

.tab-list button[aria-selected="true"] {
    background: var(--tab-active);
    font-weight: bold;
}

.tab-panel {
    padding: 14px 16px 4px;
}

.tab-panel h2 {
    margin-top: 0;
}

.js .tab-panel h2 {
    display: none;
}

/* Speed test */
.speed {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 20px 0;
}

.speed div {
    background: var(--box-bg);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.speed strong {
    display: block;
    font-size: 1.9em;
}

/* Bottom ad and footer */
.ad-bottom {
    text-align: right;
    margin-top: 25px;
    margin-bottom: 10px;
}

.site-footer .wrap {
    border-top: 1px solid var(--rule);
    padding-top: 10px;
    padding-bottom: 20px;
    text-align: center;
    color: var(--muted);
    font-size: .8em;
}

/* Ads are light-scheme pages in frames. In dark mode the browser would paint a white backdrop
   behind them (visible beside ads narrower than their slot); matching schemes keeps it transparent. */
.adsbygoogle, .adsbygoogle iframe {
    color-scheme: light;
}

/* Theme switcher: right end of the header; a moon in light mode and a sun in dark mode */
#theme-toggle {
    margin-left: auto;
    width: 36px;
    height: 36px;
    padding: 7px;
    border: 1px solid var(--field-border);
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    line-height: 0;
}

#theme-toggle[hidden] {
    display: none;
}

#theme-toggle svg {
    width: 20px;
    height: 20px;
}

#theme-toggle .icon-sun {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) #theme-toggle .icon-sun { display: inline; }
    :root:not([data-theme="light"]) #theme-toggle .icon-moon { display: none; }
}

:root[data-theme="dark"] #theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] #theme-toggle .icon-moon { display: none; }

/* The 728x90 ad is a fixed-size unit: hidden where it can't fit (no ad is requested) */
@media (max-width: 780px) {
    .ad-bottom {
        display: none;
    }
}

/* Phones and small tablets: the tools menu above the page, as a row of links */
@media (max-width: 700px) {
    .site-header {
        margin-bottom: 16px;
    }

    #logo {
        font-size: 2.2em;
    }

    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .tools ul {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0;
        list-style: none;
        margin-bottom: 0;
    }

    .tools li a {
        display: block;
        padding: 5px 9px;
        border: 1px solid var(--rule);
        border-radius: 14px;
        text-decoration: none;
        font-size: .92em;
    }

    .tools a[aria-current="page"] {
        border-color: var(--text);
    }

    .tools-title {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    /* the 200x200 ad goes under the page instead of beside the menu */
    .tools {
        display: contents;
    }

    .tools ul {
        order: 1;
    }

    .content {
        order: 2;
    }

    .ad-side {
        order: 3;
        text-align: center;
        margin-top: 0;
    }

    .ip-banner {
        font-size: 1.7em;
    }

    /* label on its own line; the box and its button share the next one */
    .tool-form label {
        flex-basis: 100%;
        text-align: center;
    }

    .tool-form input[type="text"], .tool-form input.short {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
    }

    .data th {
        white-space: normal;
    }

    .map {
        height: 300px;
    }

    /* label/value pairs stacked, two to a row instead of four */
    #two-col-data tr {
        display: grid;
        grid-template-columns: max-content minmax(0, 1fr);
    }

    .cell-label {
        text-align: left;
    }
}
