:root {
    color-scheme: dark;
    --font-ui: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --canvas: #080c13;
    --surface: #101721;
    --text: #f4f7fc;
    --muted: #b6c2d3;
    --dimmed: #9aa8ba;
    --line: #343f51;
    --blue: #53b7ff;
    --cyan: #55cefa;
    --green: #60e598;
    --red: #ff9b9b;
    --radius-card: 15px;
    --radius-button: 9px;
    --radius-badge: 999px;
    --gutter: clamp(16px, 5vw, 30px);
    --space-8: 8px;
    --space-12: 12px;
    --space-16: 16px;
    --space-24: 24px;
    --space-32: 32px;
    --icon-box: clamp(44px, 12vw, 52px);
    --glyph-size: clamp(26px, 7.5vw, 32px);
    --touch: 44px;
    --ease: 150ms ease-out;
    --panel-shadow: inset 0 1px 1px rgb(176 203 249 / 8%), 0 4px 16px rgb(0 0 0 / 14%);
    --card-fill: radial-gradient(ellipse at 12% 0%, rgb(39 60 87 / 29%), transparent 79%),
        linear-gradient(135deg, #111822, #0c1119 76%);
    --primary-fill: linear-gradient(155deg, #2695e8 4%, #175cce 56%, #1945a7 100%);
}

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

[hidden] {
    display: none !important;
}

html {
    background: var(--canvas);
}

body {
    position: relative;
    isolation: isolate;
    margin: 0;
    min-height: 100vh;
    min-height: 100svh;
    font: 400 1rem/1.45 var(--font-ui);
    color: var(--text);
    background: radial-gradient(ellipse at 76% 14%, #0c1420, transparent 55%), var(--canvas);
}

.ambient {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.ambient::before,
.ambient::after {
    position: absolute;
    content: "";
    width: clamp(355px, 78vw, 920px);
    aspect-ratio: 1.55;
    border-radius: 50%;
    transform: rotate(36deg);
    border: 1px solid rgb(60 126 218 / 37%);
    background: radial-gradient(ellipse at 51% 104%, rgb(21 85 167 / 42%), transparent 68%),
        linear-gradient(135deg, #070c16, #101c2d);
    box-shadow: 0 0 28px rgb(15 99 209 / 30%), inset 0 -3px 22px rgb(52 134 231 / 28%),
        0 0 0 34px rgb(9 22 39 / 35%), 0 0 0 64px rgb(12 22 35 / 19%);
}

.ambient::before {
    inset-block-start: clamp(-370px, -23vw, -112px);
    inset-inline-end: clamp(-520px, -45vw, -179px);
}

.ambient::after {
    inset-block-end: clamp(-380px, -22vw, -128px);
    inset-inline-start: clamp(-420px, -48vw, -165px);
    transform: rotate(-143deg);
}

.dashboard .ambient::before {
    inset-block-start: clamp(-450px, -34vw, -165px);
    inset-inline-end: clamp(-430px, -37vw, -154px);
}

.dashboard .ambient::after {
    inset-inline-start: auto;
    inset-inline-end: clamp(-480px, -39vw, -151px);
    inset-block-end: clamp(-460px, -30vw, -162px);
    transform: rotate(149deg);
}

h1, h2, h3, p {
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}

.icon {
    display: inline-block;
    flex: 0 0 auto;
    width: var(--icon-size, 1.25rem);
    height: var(--icon-size, 1.25rem);
    background: currentColor;
    mask: var(--icon-mask) center / contain no-repeat;
}

.icon--arrow { --icon-mask: url("./arrow-right.svg"); }
.icon--layers { --icon-mask: url("./layers.svg"); }
.icon--bars { --icon-mask: url("./chart-no-axes-column-increasing.svg"); }
.icon--clock { --icon-mask: url("./clock.svg"); }
.icon--monitor { --icon-mask: url("./monitor.svg"); }
.icon--chart { --icon-mask: url("./chart-no-axes-combined.svg"); }
.icon--user { --icon-mask: url("./user-round.svg"); }
.icon--logout { --icon-mask: url("./log-out.svg"); }

.brand {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(9px, 3vw, 14px);
}

.brand img {
    flex: 0 0 auto;
    width: var(--brand-size, 38px);
    height: var(--brand-size, 38px);
    filter: drop-shadow(0 0 1px rgb(74 158 224 / 72%)) drop-shadow(0 0 3px rgb(49 137 217 / 25%));
}

.brand h1 {
    font-size: var(--title-size, clamp(24px, 6.7vw, 40px));
    font-weight: 760;
    letter-spacing: -.035em;
    line-height: 1.08;
}

.landing {
    display: grid;
    align-items: center;
    padding: clamp(38px, 7svh, 100px) var(--gutter);
}

.landing-content {
    width: min(100%, 580px);
    margin-inline: auto;
    text-align: center;
    --brand-size: clamp(39px, 11.5vw, 62px);
    --title-size: clamp(27px, 7.4vw, 49px);
}

.landing-description {
    max-width: 33ch;
    margin: clamp(var(--space-16), 3svh, var(--space-24)) auto 0;
    font-size: clamp(15px, 4.1vw, 20px);
    line-height: 1.38;
    color: var(--muted);
    text-wrap: pretty;
}

.sign-in {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: clamp(49px, 12vw, 60px);
    margin: clamp(var(--space-24), 4svh, var(--space-32)) auto 0;
    padding: 8px clamp(19px, 6.2vw, 32px);
    border: 1px solid #e8f3ff;
    border-radius: clamp(15px, 4.5vw, 21px);
    background: linear-gradient(155deg, #fcfdff, #d5e6fa);
    color: #101821;
    font-size: clamp(17px, 4.4vw, 22px);
    font-weight: 750;
    box-shadow: 0 2px 0 #52c6f6, 0 8px 25px rgb(25 111 197 / 27%);
    transition: box-shadow var(--ease), background-color var(--ease);
}

.sign-in .icon { --icon-size: 1.35rem; }

.sign-in:hover {
    box-shadow: 0 2px 0 #66d6ff, 0 8px 30px rgb(44 149 250 / 43%);
}

.features {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(var(--space-8), 2vw, var(--space-12));
    margin: var(--space-32) 0 0;
    padding: 0;
    list-style: none;
}

.features li {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-8);
    min-height: clamp(83px, 20vw, 112px);
    padding: var(--space-12) var(--space-8);
    border: 1px solid #283447;
    border-radius: var(--radius-card);
    background: var(--card-fill);
    box-shadow: var(--panel-shadow);
}

.feature-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    color: var(--blue);
    background: linear-gradient(145deg, #1b3854, #101d2d);
}

.feature-icon .icon { --icon-size: 17px; }

.features strong {
    font-size: clamp(12px, 3.25vw, 16px);
    line-height: 1.2;
}

.feature-caption {
    font-size: clamp(10px, 2.7vw, 13px);
    line-height: 1.22;
    color: var(--muted);
}

@media (max-width: 600px) {
    .landing {
        padding-block-end: calc(clamp(38px, 7svh, 100px) + var(--space-32) + var(--space-24));
    }
    .features li {
        min-height: 72px;
        padding-block: var(--space-8);
    }
    .feature-caption { display: none; }
}

.dashboard-content {
    width: min(100%, 690px);
    margin-inline: auto;
    padding: clamp(17px, 4.1vw, 35px) var(--gutter) 27px;
}

.dashboard-header {
    margin-bottom: var(--space-24);
}

.identity {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-8);
    margin-top: 5px;
    font-size: clamp(13px, 3.6vw, 15px);
    color: var(--muted);
    overflow-wrap: anywhere;
    text-align: center;
}

.status-dot,
.state-badge::before {
    display: inline-block;
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-dot {
    color: var(--green);
    box-shadow: 0 0 10px rgb(38 209 112 / 46%);
}

.service-section-label,
.zero-title {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    margin: 0 0 var(--space-12);
    font-size: clamp(18px, 4.8vw, 25px);
    line-height: 1.25;
    letter-spacing: -.02em;
}

.service-section-label .icon {
    --icon-size: clamp(18px, 4.7vw, 22px);
    color: var(--blue);
}

.home-services,
.service-actions {
    display: grid;
    gap: var(--space-8);
}

.service-actions:not(:empty):not(:first-child) {
    margin-block-start: var(--space-8);
}

.service-card,
.service-actions .action-btn {
    min-width: 0;
    min-height: calc(var(--icon-box) + var(--space-24) + 2px);
    padding: var(--space-12);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--card-fill);
    box-shadow: var(--panel-shadow);
}

.service-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-12);
}

.service-entry {
    position: relative;
    display: grid;
    grid-template-columns: var(--icon-box) minmax(0, 1fr);
    align-items: center;
    gap: var(--space-12);
    min-height: var(--touch);
}

[data-service-link][href]::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: var(--radius-button);
}

[data-service-link]:focus-visible {
    outline: none;
}

[data-service-link]:focus-visible::after {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}

.service-icon,
.service-actions .action-btn::before {
    width: var(--icon-box);
    height: var(--icon-box);
    border-radius: 11px;
    box-shadow: inset 0 1px 1px rgb(220 240 255 / 8%);
}

.service-icon {
    display: grid;
    place-items: center;
    color: var(--cyan);
    background: linear-gradient(145deg, #16374d, #0d1c29 72%);
    --icon-size: var(--glyph-size);
}

.service-icon img {
    width: calc(var(--glyph-size) + 4px);
    height: calc(var(--glyph-size) + 4px);
    object-fit: contain;
}

.service-icon--grafana {
    color: #ffb352;
    background: linear-gradient(145deg, #39291e, #201a1a 78%);
}

.service-icon--immich {
    background: linear-gradient(145deg, #30283e, #13252b 80%);
}

.service-info {
    min-width: 0;
    overflow-wrap: anywhere;
}

.service-info h3,
.service-actions .action-btn {
    font-size: clamp(15px, 4.25vw, 21px);
    font-weight: 720;
    line-height: 1.17;
    letter-spacing: -.012em;
}

.state-badge {
    --state-color: var(--dimmed);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    border: 1px solid rgb(154 168 186 / 19%);
    border-radius: var(--radius-badge);
    background: rgb(121 142 169 / 15%);
    color: var(--muted);
    padding: 2px 6px;
    font-size: clamp(10px, 2.9vw, 12px);
    line-height: 1.18;
}

.service-status {
    position: relative;
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin-top: 4px;
}

.state-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    color: var(--state-color);
}

[data-visual-state="running"] .state-badge {
    --state-color: var(--green);
    color: #c4f7d6;
    background: rgb(27 135 83 / 16%);
}

[data-visual-state="error"] .state-badge {
    --state-color: var(--red);
    color: var(--red);
}

[data-visual-state="starting"] .state-badge,
[data-visual-state="stopping"] .state-badge,
[data-visual-state="checking"] .state-badge {
    color: #b1ddff;
}

[data-visual-state="starting"] .state-badge::before,
[data-visual-state="stopping"] .state-badge::before {
    width: 9px;
    height: 9px;
    background: none;
    border: 1.5px solid var(--blue);
    border-right-color: transparent;
    animation: status-spin 850ms linear infinite;
}

@keyframes status-spin {
    to { transform: rotate(1turn); }
}

.service-controls {
    display: flex;
    justify-content: end;
    gap: var(--space-8);
}

.service-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: clamp(4px, 1.4vw, 8px);
    height: var(--touch);
    width: clamp(56px, 17vw, 78px);
    padding: 5px 7px;
    border: 1px solid #3f88dd;
    border-radius: var(--radius-button);
    background: var(--primary-fill);
    box-shadow: inset 0 1px 1px rgb(224 243 255 / 19%);
    font-size: clamp(12px, 3.4vw, 14px);
    line-height: 1.2;
}

.service-button:disabled {
    background: linear-gradient(145deg, #242c38, #19212c);
    border-color: #353e4d;
    color: #a0acbe;
    box-shadow: inset 0 1px 1px rgb(224 243 255 / 6%);
    cursor: default;
}

.service-button:not(:disabled):hover {
    border-color: #7ebdff;
}

.action-symbol {
    display: inline-block;
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    background: currentColor;
}

.action-symbol--start { clip-path: polygon(0 0, 100% 50%, 0 100%); }
.action-symbol--stop { border-radius: 1px; }

.service-status:has(.feedback-trigger:not([hidden])) .state-badge {
    padding-inline-end: 18px;
}

.feedback-trigger {
    position: absolute;
    inset: 50% auto auto 0;
    width: max(100%, var(--touch));
    height: var(--touch);
    translate: 0 -50%;
    border: 0;
    border-radius: var(--radius-button);
    padding: 0;
    background: transparent;
}

.feedback-trigger::after {
    content: "";
    position: absolute;
    inset: calc(50% - 4px) 7px auto auto;
    width: 6px;
    height: 6px;
    border: solid var(--muted);
    border-width: 0 1px 1px 0;
    rotate: 45deg;
}

.service-message,
#home-services-warning {
    color: var(--red);
    font-size: .8rem;
    overflow-wrap: anywhere;
}

.service-message {
    inset: auto 0 var(--space-16);
    width: min(48ch, calc(100% - 2 * var(--gutter)));
    max-height: 40vh;
    margin: 0 auto;
    padding: var(--space-12) var(--space-16);
    border: 1px solid var(--line);
    border-radius: var(--radius-button);
    background: var(--surface);
    box-shadow: var(--panel-shadow);
}

#home-services-warning:not(:empty) { margin-top: var(--space-8); }

.service-message:empty,
#home-services-warning:empty,
.service-actions:empty { display: none; }

.service-actions .action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-12);
    transition: border-color var(--ease), box-shadow var(--ease);
    overflow-wrap: anywhere;
}

.service-actions .action-btn::before {
    flex: 0 0 auto;
    content: "";
    background-image: var(--service-image), var(--service-color);
    background-size: var(--service-art-size), 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

#storybook-link {
    --service-image: url("./icon-storybook.svg");
    --service-color: linear-gradient(145deg, #462138, #271728 76%);
    --service-art-size: auto calc(var(--glyph-size) + 1px);
}

#mihomo-link {
    --service-image: url("./icon-metacubexd.svg");
    --service-color: linear-gradient(145deg, #18374d, #0d1b2b 78%);
    --service-art-size: calc(var(--glyph-size) - 3px) auto;
}

.zero-copy {
    color: var(--muted);
}

.account-actions {
    display: grid;
    gap: var(--space-8);
    margin: var(--space-24) 0 0;
}

.account-button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-8);
    min-height: var(--touch);
    padding: 6px var(--space-12);
    border: 1px solid #455165;
    border-radius: var(--radius-button);
    background: var(--card-fill);
    box-shadow: var(--panel-shadow);
    font-size: clamp(14px, 3.7vw, 16px);
    transition: border-color var(--ease);
}

.service-actions .action-btn:active {
    border-color: #68a8ee;
    box-shadow: inset 0 0 0 1px rgb(83 183 255 / 22%);
}

@media (hover: hover) {
    .service-actions .action-btn:hover,
    .account-button:hover { border-color: #68a8ee; }
    [data-service-link][href]:hover { color: #b9dfff; }
}

@media (max-width: 344px) {
    .service-card,
    .service-actions .action-btn {
        padding-inline: var(--space-8);
        gap: var(--space-8);
    }

    .service-entry { gap: var(--space-8); }
}

@media (max-width: 300px) {
    .service-card {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0s !important;
        transition-duration: 0s !important;
    }
}
