/* ---------- Design tokens ---------- */

:root {
    color-scheme: light;

    --bg: #eceff2;
    --surface: #ffffff;
    --surface-2: #f5f7f9;
    --border: #d9dee3;
    --border-strong: #b9c1c9;
    --text: #1b2127;
    --text-muted: #5b6672;

    --primary: #1a5fb4;
    --primary-hover: #154f97;
    --accent: #1a5fb4;
    --accent-soft: #e5edf8;
    --success: #1f7a3a;
    --success-soft: #e3f2e7;
    --warning: #9a5b00;
    --warning-soft: #fcf1dc;
    --danger: #b9302a;
    --danger-soft: #fbeceb;
    --danger-border: #eec3c0;

    --header-bg: #1d2329;
    --header-text: #eef1f4;
    --header-muted: #a3adb7;

    --radius: 4px;
    --radius-lg: 6px;
    --focus-ring: 0 0 0 3px rgb(26 95 180 / 0.25);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --bg: #14181c;
        --surface: #1c2126;
        --surface-2: #22282e;
        --border: #313941;
        --border-strong: #46505a;
        --text: #e2e7eb;
        --text-muted: #96a1ac;

        --primary: #2a6fc4;
        --primary-hover: #3a7fd3;
        --accent: #6aa5ea;
        --accent-soft: #1d2e44;
        --success: #5cba76;
        --success-soft: #1a2e21;
        --warning: #e0a63c;
        --warning-soft: #352a15;
        --danger: #f07a73;
        --danger-soft: #3a1f1e;
        --danger-border: #5c2d2a;

        --header-bg: #0e1114;
        --focus-ring: 0 0 0 3px rgb(106 165 234 / 0.3);
    }
}

/* ---------- Base ---------- */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, ul, dl, dd {
    margin: 0;
}

h1:focus {
    outline: none;
}

a {
    color: var(--accent);
}

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

code, kbd, .mono {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.mono {
    font-size: 0.95em;
}

kbd {
    display: inline-block;
    padding: 0 0.3125rem;
    font-size: 0.6875rem;
    line-height: 1.5;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 3px;
    background-color: var(--surface);
}

.muted {
    color: var(--text-muted);
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ---------- Icons ---------- */

.icon {
    flex: none;
    width: 1.125rem;
    height: 1.125rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    height: 2.25rem;
    padding: 0 0.875rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover:not(:disabled) {
    background-color: var(--surface-2);
    border-color: var(--text-muted);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn .icon {
    width: 1rem;
    height: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-danger {
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--danger-soft);
    border-color: var(--danger);
}

.btn-ghost {
    background-color: transparent;
    border-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.btn-sm {
    height: 1.875rem;
    padding: 0 0.625rem;
    font-size: 0.8125rem;
}

.btn-icon {
    width: 1.875rem;
    padding: 0;
}

/* ---------- Form fields ---------- */

.input {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 0.4375rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background-color: var(--surface);
    color: var(--text);
    line-height: 1.5;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

textarea.input {
    resize: vertical;
}

.field-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ---------- Panels ---------- */

.panel {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px rgb(16 24 32 / 0.04);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background-color: var(--surface-2);
}

.panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.panel-body {
    padding: 1rem;
}

.panel-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    background-color: var(--surface-2);
}

/* ---------- Feedback ---------- */

.notice {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 1rem;
    padding: 0.625rem 0.75rem 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius);
    background-color: var(--surface);
}

.notice > .icon {
    margin-top: 0.1875rem;
}

.notice-text {
    flex: 1;
    min-width: 0;
}

.notice .btn {
    margin: -0.1875rem -0.25rem -0.1875rem 0;
}

.notice-danger {
    border-color: var(--danger-border);
    border-left-color: var(--danger);
    background-color: var(--danger-soft);
}

.notice-danger > .icon {
    color: var(--danger);
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.status::before {
    content: "";
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: currentColor;
}

.status-online {
    color: var(--success);
}

.status-online::before {
    box-shadow: 0 0 0 3px var(--success-soft);
}

.status-offline {
    color: var(--text-muted);
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    border-radius: 3px;
    background-color: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.tag .icon {
    width: 0.875rem;
    height: 0.875rem;
    stroke-width: 2.5;
}

.tag-success {
    background-color: var(--success-soft);
    color: var(--success);
}

.tag-danger {
    background-color: var(--danger-soft);
    color: var(--danger);
}

.tag-progress {
    background-color: var(--accent-soft);
    color: var(--accent);
}

.spinner {
    flex: none;
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress {
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background-color: var(--border);
}

.progress-bar {
    height: 100%;
    background-color: var(--accent);
    transition: width 0.2s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 2.4s;
    }

    .progress-bar {
        transition: none;
    }
}

/* ---------- Error and not-found pages ---------- */

.status-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 32rem;
    margin: 3rem auto;
    text-align: center;
}

.status-page-code {
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.status-page h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.status-page p {
    color: var(--text-muted);
}

.status-page .btn {
    margin-top: 0.5rem;
}

/* ---------- Legal pages ---------- */

.legal {
    max-width: 48rem;
    margin: 0 auto;
    padding: 0.5rem 0 2rem;
}

.legal h1 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
}

.legal h2 {
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    font-size: 1.0625rem;
    font-weight: 600;
}

.legal h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.375rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

.legal p,
.legal ul,
.legal address {
    margin-bottom: 0.75rem;
}

.legal ul {
    padding-left: 1.25rem;
}

.legal li + li {
    margin-top: 0.25rem;
}

.legal .legal-updated {
    margin-top: 0.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.legal-address {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    font-style: normal;
}

.legal-note {
    padding: 0.75rem 1rem;
    border: 1px solid var(--danger-border);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius);
    background-color: var(--danger-soft);
}

/* ---------- Blazor error boundary ---------- */

.blazor-error-boundary {
    padding: 0.75rem 1rem;
    border: 1px solid var(--danger-border);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius);
    background-color: var(--danger-soft);
    color: var(--text);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}
