body {
    margin: 0;
    background: var(--uw-bg);
    color: var(--uw-ink);
    font-family: var(--font-sans);

    --env-banner-h: 0px;
}

body.has-env-banner {
    --env-banner-h: 34px;
}

h1, h2, h3, h4, h5, h6,
p, ul, ol, li,
blockquote, dl, dt, dd,
figure, figcaption, pre {
    margin: 0;
    padding: 0;
}

.app-shell-body {
    display: flex;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    right: var(--space-300);
    bottom: var(--space-300);
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    gap: var(--space-150);
    max-width: min(360px, calc(100vw - 40px));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-150);
    padding: var(--space-200);
    background: var(--uw-surface);
    border: 1px solid var(--uw-border);
    border-left: 4px solid var(--uw-ink-muted);
    border-radius: var(--radius-200);
    box-shadow: var(--uw-shadow-modal);
    font-family: var(--font-sans);
    font-size: var(--font-size-400);
    color: var(--uw-ink);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-leaving {
    opacity: 0;
}

.toast-message {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.toast-close {
    flex: 0 0 auto;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    color: var(--uw-ink-faint);
    padding: 0;
}

.toast-close:hover {
    color: var(--uw-ink);
}

.toast-success {
    border-left-color: var(--uw-positive);
}

.toast-error {
    border-left-color: var(--uw-negative);
}

.toast-warning {
    border-left-color: var(--uw-warning);
}

.toast-info {
    border-left-color: var(--uw-primary);
}

.app-toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-200) var(--space-200);
    background: var(--uw-surface);
    border-right: 1px solid var(--uw-border);
    position: sticky;
    top: var(--env-banner-h);
    z-index: var(--z-sticky);
    height: calc(100vh - var(--env-banner-h));
    box-sizing: border-box;
    flex-shrink: 0;
}

.app-main {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--env-banner-h));
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    padding: 1.25rem;
    box-sizing: border-box;
}

.app-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-200);
    background: var(--uw-primary);
    color: var(--uw-ink-invert);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: var(--font-size-600);
    text-decoration: none;
}

.app-toolbar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: var(--space-400);
}

.theme-toggle-btn {
    margin-bottom: var(--space-200);
    background: var(--uw-fill-1);
    color: var(--uw-ink-muted);
}

.theme-toggle-btn:hover {
    background: var(--uw-fill-2);
    color: var(--uw-ink);
}

/* Scoped to the button so it outranks Font Awesome's own .fa-solid display rule. */
.theme-toggle-btn .theme-toggle-icon-light,
[data-theme="dark"] .theme-toggle-btn .theme-toggle-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-toggle-btn .theme-toggle-icon-light {
    display: inline-block;
}

.admin-nav-btn {
    background: var(--uw-primary-tint);
    color: var(--uw-primary-ink);
}

.admin-nav-btn:hover {
    background: var(--uw-primary-soft);
}

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    margin-left: var(--space-150);
    padding: var(--space-75) var(--space-150);
    border-radius: var(--radius-300);
    background: var(--uw-tooltip-bg);
    color: var(--uw-tooltip-ink);
    font-family: var(--font-sans);
    font-size: var(--uw-text-xs);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-50%) translateX(-4px);
    pointer-events: none;
    transition: opacity .13s ease, transform .13s ease;
    z-index: var(--z-popover);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.app-user {
    position: relative;
}

.app-user-bubble {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--uw-fill-1);
    color: var(--uw-ink);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--font-size-500);
}

.app-user-bubble:hover {
    background: var(--uw-fill-2);
}

.app-user-popover {
    position: absolute;
    z-index: var(--z-popover);
    left: 100%;
    bottom: 0;
    margin-left: var(--space-150);
    width: 220px;
    padding: var(--space-200);
    background: var(--uw-surface);
    border: 1px solid var(--uw-border);
    border-radius: var(--radius-300);
    box-shadow: var(--shadow-300);
}

.app-user-email {
    font-size: var(--font-size-400);
    font-weight: 600;
    color: var(--uw-ink-strong);
    overflow-wrap: break-word;
}

.app-user-role {
    margin-top: var(--space-25);
    font-size: var(--font-size-300);
    color: var(--uw-ink-muted);
}

.app-user-settings-link {
    display: block;
    margin-top: var(--space-200);
    font-size: var(--font-size-400);
    color: var(--uw-ink);
    text-decoration: none;
}

.app-user-settings-link:hover {
    color: var(--uw-primary);
    text-decoration: underline;
}

.app-user-signout {
    display: block;
    width: 100%;
    margin-top: var(--space-200);
    padding: var(--space-100) var(--space-150);
    border: 1px solid var(--uw-border-2);
    border-radius: var(--radius-200);
    background: var(--uw-surface);
    color: var(--uw-ink);
    font-family: var(--font-sans);
    font-size: var(--font-size-400);
    font-weight: 500;
    cursor: pointer;
    text-align: center;
}

.app-user-signout:hover {
    background: var(--uw-surface-2);
}

.form-scope label {
    display: block;
    margin-bottom: var(--space-75);
    font-size: var(--font-size-300);
    font-weight: 600;
    letter-spacing: var(--letter-spacing-wide);
    text-transform: uppercase;
    color: var(--uw-ink-muted);
}

.helptext {
    display: block;
    margin-top: var(--space-75);
    font-size: var(--font-size-300);
    line-height: var(--line-height-400);
    color: var(--uw-ink-muted);
}

.errorlist {
    list-style: none;
    margin: 0 0 var(--space-100);
    padding: var(--space-150) var(--space-200);
    background: var(--uw-negative-tint);
    color: var(--uw-ink);
    border-radius: var(--radius-200);
    font-size: var(--font-size-400);
}

.helptext ul {
    margin: var(--space-50) 0 0;
    padding-left: 18px;
}

.helptext li {
    margin-bottom: 2px;
}

.app-dialog {
    width: min(420px, calc(100vw - 40px));
    padding: var(--space-500);
    border: 1px solid var(--uw-border);
    border-radius: var(--radius-400);
    background: var(--uw-surface);
    box-shadow: var(--uw-shadow-modal);
    color: var(--uw-ink);
    font-family: var(--font-sans);
}

.app-dialog::backdrop {
    background: rgb(0 0 0 / 40%);
}

.app-dialog h2 {
    margin: 0 0 var(--space-100);
    font-size: var(--font-size-600);
    font-weight: 600;
    color: var(--uw-ink-strong);
}

.app-dialog p {
    margin: 0 0 var(--space-300);
    font-size: var(--font-size-400);
    color: var(--uw-ink-muted);
}

.app-dialog p:empty,
.app-dialog h2:empty {
    display: none;
}

.app-dialog-field {
    margin-bottom: var(--space-200);
}

.app-dialog-field-error {
    margin-top: var(--space-75);
    font-size: var(--font-size-300);
    color: var(--uw-negative);
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-150);
    margin-top: var(--space-400);
}
