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

html {
    min-width: 320px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    scrollbar-gutter: stable;
}

body {
    color-scheme: var(--ui-color-scheme, light);
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: var(--ui-page);
    color: var(--ui-ink);
    font-family: var(--ui-font);
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: 0;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

button,
input,
select,
textarea {
    max-width: 100%;
    margin: 0;
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button,
select {
    cursor: pointer;
}

button {
    overflow-wrap: anywhere;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    cursor: not-allowed;
}

a {
    color: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

img,
video,
iframe {
    max-width: 100%;
}

img {
    display: block;
    height: auto;
}

svg {
    display: block;
}

h1,
h2,
h3,
h4,
p {
    overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
    color: var(--ui-heading);
    text-wrap: balance;
}

p {
    text-wrap: pretty;
}

::selection {
    background: var(--ui-primary-soft);
    color: var(--ui-heading);
}

:where(a, button, input, select, textarea, [role="button"]):focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

[hidden] {
    display: none !important;
}

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

.text-good,
.text-success {
    color: var(--ui-success);
}

.text-bad,
.text-danger {
    color: var(--ui-danger);
}

.line-1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-2 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.line-2.expanded {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
}

.ui-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    pointer-events: none;
}

button,
[role="button"],
input,
select,
textarea {
    touch-action: manipulation;
}

@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

.lazy-img {
    background: linear-gradient(90deg, var(--ui-skeleton) 0%, var(--ui-skeleton-highlight) 48%, var(--ui-skeleton) 100%);
    background-size: 220% 100%;
    opacity: .78;
    animation: ui-image-loading 1.25s ease-in-out infinite;
    transition: opacity var(--ui-duration) var(--ui-ease-out);
}

.lazy-img.loaded {
    background: transparent;
    opacity: 1;
    animation: none;
}

.rich-content {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.rich-content > :first-child {
    margin-top: 0;
}

.rich-content > :last-child {
    margin-bottom: 0;
}

.rich-content p,
.rich-content ul,
.rich-content ol,
.rich-content blockquote {
    margin: 0 0 12px;
}

.rich-content ul,
.rich-content ol {
    padding-left: 1.5em;
}

.rich-content a {
    color: var(--ui-primary);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.rich-content img,
.rich-content video,
.rich-content iframe {
    width: 100%;
    margin-top: 14px;
    border-radius: var(--ui-radius-md);
}

.rich-content video,
.rich-content iframe {
    background: #111827;
}

.rich-content iframe {
    min-height: 320px;
    border: 0;
}

.rich-preview-img {
    cursor: zoom-in;
}

@keyframes ui-image-loading {
    from { background-position: 110% 0; }
    to { background-position: -110% 0; }
}
