:root {
    --bg: #f4f7f8;
    --panel: #ffffff;
    --text: #17212b;
    --muted: #657386;
    --line: #d8e0e7;
    --accent: #159a85;
    --accent-strong: #0f7d6d;
    --gold: #d99c2b;
    --danger: #b42318;
    --shadow: 0 20px 60px rgb(21 42 55 / 12%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
    font: inherit;
}

.shell {
    width: min(100% - 32px, 980px);
    margin: 0 auto;
    padding: 48px 0;
}

.masthead {
    margin-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 16px;
}

.brand-mark {
    position: relative;
    display: grid;
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 16px;
    background: #101820;
    box-shadow: var(--shadow);
}

.brand-mark span {
    width: 30px;
    height: 30px;
    border: 8px solid #f8fafc;
    border-right-color: var(--accent);
    border-bottom-color: var(--gold);
    border-radius: 8px;
}

h1 {
    margin: 0;
    font-size: 2rem;
    line-height: 1.05;
}

p {
    margin: 0;
}

#user-line {
    margin-top: 4px;
    color: var(--muted);
}

.status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
}

.status.error {
    border-color: #f0b8b2;
    background: #fff2f0;
    color: var(--danger);
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #cdd7de;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.status.error .spinner,
.status.empty .spinner {
    display: none;
}

.sites {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.site {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    min-height: 84px;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 1px 0 rgb(16 24 32 / 4%);
}

.site:focus-visible,
.site:hover {
    border-color: var(--accent);
    outline: 3px solid rgb(21 154 133 / 18%);
}

.site-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: #e3f3ef;
    color: var(--accent-strong);
    font-weight: 800;
}

.site-icon img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    opacity: 0;
}

.site-icon.has-image img {
    opacity: 1;
}

.site-icon.has-image .site-initials {
    display: none;
}

.site-name {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.site-url {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-arrow {
    color: var(--muted);
    font-size: 1.35rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 560px) {
    .shell {
        width: min(100% - 24px, 980px);
        padding: 24px 0;
    }

    .masthead {
        margin-bottom: 20px;
    }

    .brand-mark {
        width: 50px;
        height: 50px;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.7rem;
    }

    .sites {
        grid-template-columns: 1fr;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d141a;
        --panel: #16212b;
        --text: #f3f7fa;
        --muted: #a5b3bf;
        --line: #2d3b47;
        --shadow: none;
    }

    .site-icon {
        background: #123b37;
        color: #6ee0cf;
    }

    .status.error {
        border-color: #7f2d28;
        background: #2a1717;
        color: #ffc3bd;
    }
}
