:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: #111315;
    color: #eceef0;
    --surface: #191c20;
    --line: #343a42;
    --muted: #a8afb9;
    --accent: #a3d8b5;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
}

button,
input {
    font: inherit;
}

button {
    min-height: 42px;
    padding: 9px 17px;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition:
        background-color 120ms,
        border-color 120ms;
}

button:disabled {
    opacity: 0.45;
    cursor: default;
}

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

input {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #4a515c;
    border-radius: 5px;
    background: #111315;
    color: #eceef0;
    caret-color: var(--accent);
}

input::placeholder {
    color: #929ba7;
    opacity: 1;
}

input:disabled {
    opacity: 0.6;
}

input[type='checkbox'] {
    width: 20px;
    height: 20px;
    min-height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}

::selection {
    color: #111315;
    background: var(--accent);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 29px;
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.6px;
}

h2 {
    font-size: 19px;
}

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

.primary {
    background: var(--accent);
    color: #15251b;
}

.primary:hover:not(:disabled) {
    background: #bde6cb;
}

.secondary {
    color: #eceef0;
    background: #24282e;
    border-color: #454d58;
}

.secondary:hover:not(:disabled),
.quiet:hover:not(:disabled) {
    background: #30363e;
}

.quiet {
    background: transparent;
    color: #b9c1cb;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 650;
    letter-spacing: -0.3px;
}

.brand-mark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--accent);
    border-radius: 4px;
    position: relative;
}

.brand-mark::after {
    content: '';
    position: absolute;
    inset: 0 6px;
    border-left: 2px solid var(--accent);
}

.shell {
    width: min(1180px, calc(100% - 64px));
    margin-inline: auto;
}

.topbar {
    border-bottom: 1px solid #2b3037;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.workspace {
    padding-top: 42px;
    padding-bottom: 36px;
    min-height: calc(100vh - 192px);
}

.heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.heading p {
    margin-top: 11px;
    max-width: 660px;
}

.source-status {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin-top: 26px;
    color: var(--muted);
    font-size: 13px;
}

#published-count {
    color: var(--accent);
}

.notice {
    margin-top: 18px;
    padding: 12px 15px;
    border: 1px solid #3b5945;
    border-radius: 6px;
    background: #1a2720;
    color: #c4e2ce;
}

.notice[data-kind='error'],
.error {
    color: #ffc4bb;
}

.notice[data-kind='error'] {
    background: #2a201f;
    border-color: #76524b;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-block: 24px;
}

.search {
    position: relative;
    flex: 1;
}

.search input {
    padding-left: 41px;
}

.search svg {
    position: absolute;
    width: 19px;
    height: 19px;
    left: 14px;
    top: 13px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
}

.filters {
    display: flex;
    padding: 3px;
    border-radius: 6px;
    background: #1f2328;
}

.filter {
    min-height: 38px;
    padding: 6px 13px;
    color: var(--muted);
    background: transparent;
}

.filter.active {
    background: #343b44;
    color: #f2f3f5;
}

.filter span {
    padding-left: 5px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.list-heading,
.server-row {
    display: grid;
    grid-template-columns: 36px minmax(200px, 1fr) minmax(220px, 0.9fr);
    align-items: center;
    column-gap: 16px;
    padding-inline: 18px;
}

.list-heading {
    padding-block: 10px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

.server-row {
    min-height: 92px;
    padding-block: 16px;
    border-bottom: 1px solid #2c3239;
}

.server-row.selected {
    background: #17201b;
}

.server-info {
    min-width: 0;
}

.server-name {
    display: block;
    overflow-wrap: anywhere;
    font-weight: 550;
}

.server-id {
    margin-top: 5px;
    color: #929ba7;
    font-size: 11px;
    overflow-wrap: anywhere;
}

.missing-label {
    display: block;
    color: #e7b989;
    margin-top: 4px;
    font-size: 12px;
}

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

.reset-name {
    min-width: 40px;
    padding: 8px;
}

.reset-name svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

.empty {
    padding: 62px 20px;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

.empty p {
    max-width: 540px;
    margin: 10px auto 0;
}

.savebar {
    position: sticky;
    bottom: 0;
    background: #191c20;
    border-top: 1px solid #454d58;
}

.savebar-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px 20px;
    padding-block: 18px;
}

.savebar strong {
    font-size: 15px;
    font-weight: 600;
}

#save-status {
    font-size: 12px;
    margin-top: 3px;
}

.save-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.save-hint {
    grid-column: 1 / -1;
    font-size: 12px;
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-form {
    width: min(100%, 390px);
}

.login-form .brand {
    margin-bottom: 38px;
}

.login-form h1 {
    font-size: 27px;
}

.login-form > p {
    margin-top: 12px;
}

.login-form label {
    display: block;
    margin: 28px 0 8px;
    font-size: 14px;
}

.login-form .primary {
    width: 100%;
    margin-top: 20px;
}

@media (max-width: 760px) {
    .shell {
        width: calc(100% - 32px);
    }

    .workspace {
        padding-top: 28px;
    }

    h1 {
        font-size: 25px;
    }

    .heading {
        flex-direction: column;
        gap: 18px;
    }

    .heading p {
        font-size: 14px;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 12px;
    }

    .search {
        flex-basis: 100%;
    }

    #clear {
        margin-left: auto;
        padding-inline: 8px;
    }

    .list-heading {
        display: none;
    }

    .servers {
        border-top: 1px solid var(--line);
    }

    .server-row {
        grid-template-columns: 24px minmax(0, 1fr);
        gap: 14px;
        padding: 19px 9px;
    }

    .rename {
        grid-column: 2;
    }

    .savebar-inner {
        gap: 12px;
    }

    .save-actions {
        gap: 6px;
    }

    .save-actions button {
        padding-inline: 11px;
    }

    .save-hint {
        font-size: 11px;
    }
}

@media (max-width: 360px) {
    .savebar-inner {
        grid-template-columns: minmax(0, 1fr);
    }

    .savebar-inner > div:first-child {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 12px;
    }

    #save-status {
        margin-top: 0;
    }

    .save-actions button {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    button {
        transition: none;
    }
}
.sources-section {
    margin-top: 24px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
}

summary {
    cursor: pointer;
    font-weight: 600;
    min-height: 28px;
}

summary:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

#sources-count {
    margin-left: 8px;
    color: var(--muted);
    font-size: 13px;
}

.sources-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 14px 0;
}

.sources-intro p {
    max-width: 600px;
    font-size: 13px;
}

.source-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 18px;
    align-items: center;
    border-top: 1px solid var(--line);
    padding: 16px 0;
}

.source-item:last-child {
    padding-bottom: 0;
}

.source-item strong {
    display: block;
    overflow-wrap: anywhere;
}

.source-item p {
    font-size: 12px;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.source-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.source-filter-label {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 13px;
}

select,
textarea {
    font: inherit;
    color: #eceef0;
    background: #111315;
    border: 1px solid #4a515c;
    border-radius: 5px;
    padding: 10px 12px;
    min-height: 44px;
    max-width: 100%;
}

textarea {
    width: 100%;
    resize: vertical;
    line-height: 1.5;
}

select {
    min-width: 0;
}

.partner-label {
    display: block;
    color: var(--accent);
    font-size: 12px;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

dialog {
    width: min(650px, calc(100% - 32px));
    max-height: calc(100dvh - 48px);
    padding: 24px;
    border: 1px solid #4a515c;
    border-radius: 8px;
    background: var(--surface);
    color: #eceef0;
    overflow-y: auto;
}

dialog::backdrop {
    background: rgb(0 0 0 / 72%);
}

.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

#source-form label:not(.show-secret) {
    display: block;
    margin: 18px 0 7px;
    font-size: 13px;
}

.show-secret {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--muted);
}

.source-advanced {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 18px;
}

.source-advanced > p,
.field-hint {
    margin-top: 10px;
    font-size: 12px;
}

.device-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

#source-form-error,
#source-form-status {
    margin-top: 16px;
    font-size: 13px;
}

@media (max-width: 760px) {
    .sources-intro {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

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

    .source-item-actions button {
        padding-inline: 10px;
        font-size: 13px;
    }

    .source-filter-label select {
        flex: 1;
    }
}

@media (max-width: 440px) {
    dialog {
        padding: 18px;
    }

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

    .dialog-actions {
        flex-wrap: wrap;
    }

    .dialog-actions button {
        flex: 1;
    }
}
