:root {
    --bg: #f1f1f3;
    --card: #ffffff;
    --border: #ddd;
    --border-soft: #dedede;
    --ink: #1a1a1a;
    --muted: #6b7177;
    --muted-2: #9097a0;
    --black: #0A0A0A;
    --black-hover: #000;
    --green: #007755;
    --green-hover: #178049;
    --red: #BA1A1A;
    --red-hover: #b42318;
    --blue: #2f6df6;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .05);
    --font-sans: 'Inter', sans-serif;
}

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

html,
body,
button,
input,
select,
textarea {
    font-family: var(--font-sans);
}

body {
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[hidden] {
    display: none !important;
}

.is-hidden {
    display: none !important;
}

.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px 22px 40px;

    .page-support {
        margin: 0 0 12px;
        text-align: right;
        font-size: 12px;
        line-height: 1.45;
        color: var(--muted);

        a {
            color: var(--ink);
            font-weight: 600;
            text-underline-offset: 2px;
        }
    }

    @media (max-width: 640px) {
        padding: 14px 14px 32px;

        .page-support {
            text-align: left;
        }
    }
}

.page-head {
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.page-subtitle {
    color: #616161;
    font-size: 12px;
    margin-top: 2px;
    line-height: 1;
}

.btn {
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    line-height: 1.2;
    transition: background .3s, border-color .3s, color .3s;

    &:disabled {
        opacity: .5;
        cursor: default;
    }

    &.btn-dark {
        background: var(--black);
        color: #fff;

        &:hover:not(:disabled) {
            background: var(--black-hover);
        }
    }

    &.btn-outline {
        background: #fff;
        color: #303030;
        border-color: #d6d9dd;

        &:hover:not(:disabled) {
            background: #f6f7f9;
        }
    }

    &.btn-gray {
        background: #EEEEEF;
        color: #303030;
        border-color: #EEEEEF;

        &:hover:not(:disabled) {
            background: #000;
            color: #fff;
        }
    }

    &.btn-green {
        background: var(--green);
        color: #fff;

        &:hover:not(:disabled) {
            background: var(--green-hover);
        }
    }

    &.btn-red {
        background: var(--red);
        color: #fff;

        &:hover:not(:disabled) {
            background: var(--red-hover);
        }
    }

    &.btn-ghost {
        background: transparent;
        color: var(--muted);
        padding: 6px 8px;

        &:hover {
            color: var(--ink);
        }
    }

    &.btn-small {
        padding: 7px 12px;
        font-size: 13px;
    }

    i[class^="ri-"] {
        font-size: 1.05em;
        line-height: 1;
    }
}

.icon-fw {
    width: 1.05em;
    text-align: center;
    display: inline-block;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    &.card-pad {
        padding: 20px;
    }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;

    .modal-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        cursor: pointer;
    }

    .modal-card {
        position: relative;
        background: #fff;
        border-radius: 14px;
        box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
        padding: 22px 24px 20px;
        width: 100%;
        max-width: 420px;

        h3 {
            margin: 0 0 10px;
            font-size: 18px;
        }

        label {
            display: block;
            font-size: 13px;
            font-weight: 600;
            margin-bottom: 6px;
            color: #444;
        }

        input[type="text"],
        select {
            width: 100%;
            padding: 9px 11px;
            border: 1px solid #d6d9dd;
            border-radius: 8px;
            font-size: 14px;
            margin-bottom: 16px;
            background: #fff;
            color: var(--ink);
        }
    }

    .modal-hint {
        font-size: 13px;
        color: var(--muted);
        margin: 0 0 14px;
        line-height: 1.45;
    }

    .modal-actions {
        display: flex;
        justify-content: flex-start;
        gap: 8px;
    }
}

.toast-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(380px, calc(100vw - 40px));
    pointer-events: none;

    @media (max-width: 640px) {
        top: 12px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

.toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 10px 13px 12px;
    background: var(--toast-bg);
    border: 1px solid var(--toast-border);
    border-radius: 12px;
    box-shadow: 0 14px 30px -12px rgba(16, 24, 40, .24), 0 2px 6px -2px rgba(16, 24, 40, .08);
    color: var(--toast-ink);
    overflow: hidden;
    pointer-events: auto;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    transition: transform .3s cubic-bezier(.21, 1.02, .73, 1), opacity .3s ease;

    &.toast--success {
        --toast-bg: #f0fdf4;
        --toast-border: #bbf7d0;
        --toast-ink: #14532d;
        --toast-accent: #16a34a;
        --toast-icon-bg: #dcfce7;
        --toast-ring: rgba(22, 163, 74, .1);
        --toast-progress: #22c55e;
    }

    &.toast--error {
        --toast-bg: #fef2f2;
        --toast-border: #fecaca;
        --toast-ink: #7f1d1d;
        --toast-accent: #dc2626;
        --toast-icon-bg: #fee2e2;
        --toast-ring: rgba(220, 38, 38, .1);
        --toast-progress: #f87171;
    }

    &.toast--warning {
        --toast-bg: #fefce8;
        --toast-border: #fde68a;
        --toast-ink: #713f12;
        --toast-accent: #ca8a04;
        --toast-icon-bg: #fef3c7;
        --toast-ring: rgba(202, 138, 4, .12);
        --toast-progress: #eab308;
    }

    &.is-dragging {
        transition: none;
        cursor: grabbing;
    }

    &.is-leaving {
        pointer-events: none;
    }

    .toast__icon {
        flex: none;
        display: grid;
        place-items: center;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: var(--toast-icon-bg);
        box-shadow: 0 0 0 4px var(--toast-ring);
        color: var(--toast-accent);
        font-size: 18px;
        line-height: 1;
    }

    .toast__message {
        flex: 1;
        min-width: 0;
        padding-top: 6px;
        font-size: 14px;
        font-weight: 500;
        line-height: 20px;
        overflow-wrap: anywhere;
    }

    .toast__close {
        flex: none;
        display: grid;
        place-items: center;
        width: 28px;
        height: 28px;
        margin-top: 2px;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: inherit;
        font-size: 18px;
        line-height: 1;
        opacity: .5;
        cursor: pointer;
        transition: opacity .15s, background .15s;

        &:hover {
            opacity: 1;
            background: var(--toast-ring);
        }

        &:focus-visible {
            opacity: 1;
            outline: 2px solid var(--toast-accent);
            outline-offset: 1px;
        }
    }

    .toast__progress {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 3px;
        background: var(--toast-progress);
        opacity: .65;
        transform-origin: left center;
        animation: toast-progress var(--toast-duration, 4s) linear forwards;
    }

    .toast-stack:hover & .toast__progress,
    &:focus-within .toast__progress,
    &.is-paused .toast__progress {
        animation-play-state: paused;
    }

    @media (prefers-reduced-motion: reduce) {
        transition: opacity .2s ease;
    }
}

@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

.ss-notice {
    font-family: var(--font-sans), system-ui, sans-serif;
    padding: 2rem;
}

.ss-fatal {
    font-family: var(--font-sans), sans-serif;

    h2 {
        color: #c0392b;
    }

    code {
        font-family: ui-monospace, monospace;
    }

    pre {
        font-family: ui-monospace, monospace;
        background: #f8f8f8;
        padding: 12px;
    }
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 36px;
    padding: 16px 72px 0 0;
    border-top: 1px solid #ddd;

    a {
        color: var(--muted);
        font-size: 13px;
        font-weight: 600;
        text-decoration: none;

        &:hover {
            color: var(--ink);
            text-decoration: underline;
            text-underline-offset: 2px;
        }

        &[aria-current="page"] {
            color: var(--ink);
        }
    }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
