:root {
    color-scheme: light;
    --bg: #e9eef8;
    --surface: #ffffff;
    --surface-soft: #f4f7ff;
    --line: #cfd7e6;
    --text: #151a2b;
    --text-soft: #5d6680;
    --accent: #2f4df7;
}
html.dark .btn.primary {
    color: #0a0a0a;
}

html.dark {
    color-scheme: dark;
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-soft: #1a1a1a;
    --line: #2a2a2a;
    --text: #f0f0f0;
    --text-soft: #a3a3a3;
    --accent: #e5e5e5;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
.page { min-height: 100vh; padding: 0; }
.app-shell {
    width: 100%;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    transition: grid-template-columns .3s ease;
}
.app-shell.sidebar-open {
    grid-template-columns: 280px minmax(0, 1fr);
}
.sidebar {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border: 1px solid var(--line);
    border-radius: 0;
    margin-right: 0;
    overflow: hidden;
    transition: width .3s ease, transform .3s ease, border-color .2s ease;
}
.sidebar-head {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--line);
}
.sidebar-nav {
    display: grid;
    gap: 6px;
    padding: 10px;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    padding: 12px;
    color: var(--text-soft);
}
.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: var(--surface-soft);
    color: var(--text);
}
.sidebar-nav span {
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .2s ease, transform .2s ease;
    white-space: nowrap;
}
.app-shell.sidebar-open .sidebar-nav span {
    opacity: 1;
    transform: translateX(0);
}
.main-area {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.topbar {
    border: 1px solid var(--line);
    border-radius: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    min-height: 66px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-title {
    font-weight: 600;
    color: var(--text);
}
.topbar-title-wrap {
    display: grid;
    justify-items: center;
    gap: 2px;
}
.topbar-subtitle {
    color: var(--text-soft);
    font-size: .8rem;
}
.topbar-actions {
    display: flex;
    gap: 8px;
    position: relative;
}
.icon-btn {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 10px;
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-sizing: border-box;
}
.avatar-chip {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #fff;
    border: 1px solid var(--line);
}
.avatar-btn { cursor: pointer; }
.avatar-chip-img-tb {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    object-fit: cover;
    display: block;
}
.topbar-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(320px, 92vw);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 18px 40px rgba(10, 15, 29, .2);
    padding: 12px;
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
    z-index: 60;
}
.topbar-popover.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.popover-title {
    margin: 0 0 10px;
    font-size: .86rem;
    color: var(--text-soft);
}
.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.apps-grid a {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 8px;
    display: grid;
    justify-items: center;
    gap: 5px;
    font-size: .78rem;
    color: var(--text-soft);
    background: var(--surface-soft);
}
.apps-grid a:hover { color: var(--text); }
.account-popover { width: min(360px, 92vw); }
.account-email {
    margin: 0 0 10px;
    font-size: .85rem;
    color: var(--text-soft);
}
.account-main {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.account-avatar {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
}
.account-avatar.account-avatar--photo {
    padding: 0;
    overflow: hidden;
    background: transparent !important;
    color: transparent;
}
.account-avatar.account-avatar--photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}
.account-actions {
    display: flex;
    gap: 8px;
}
.btn.tiny { padding: 6px 10px; font-size: .78rem; }
.content-wrap {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 0;
}
.profile-card {
    width: min(760px, 100%);
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    border: 1px solid var(--line);
    border-radius: 0;
    box-shadow: 0 16px 44px rgba(12, 20, 44, .16);
    padding: 28px;
}
.profile-head {
    display: flex;
    align-items: center;
    gap: 14px;
}
.avatar {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.8rem;
    background: var(--surface-soft);
    border: 1px solid var(--line);
}
.avatar.avatar--photo {
    padding: 0;
    overflow: hidden;
    background: transparent !important;
    color: transparent;
}
.avatar.avatar--photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}
h1 { margin: 16px 0 6px; font-size: clamp(1.8rem, 5vw, 2.5rem); letter-spacing: -.03em; }
.lead { margin: 0 0 22px; color: var(--text-soft); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); padding: 16px; min-height: 132px; }
.muted { color: var(--text-soft); }
.links { margin-top: 16px; display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-soft); }
.guest { text-align: center; padding: 38px 28px; }
.guest-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); color: var(--text); padding: 10px 14px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
/* Поля загрузки файлов — в стиле MY */
input[type="file"] {
    width: 100%;
    max-width: 100%;
    min-height: 46px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-soft);
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}
input[type="file"]:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}
input[type="file"]:focus,
input[type="file"]:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    color: #ffffff;
    background: var(--accent);
}
input[type="file"]::-webkit-file-upload-button {
    margin-right: 12px;
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    color: #ffffff;
    background: var(--accent);
}

@media (max-width: 900px) {
    .page { padding: 0; }
    .app-shell,
    .app-shell.sidebar-open {
        grid-template-columns: 1fr;
    }
    .sidebar {
        margin-right: 0;
        max-height: 0;
        border-width: 0;
        transform: translateY(-6px);
    }
    .app-shell.sidebar-open .sidebar {
        max-height: 360px;
        border-width: 1px;
        transform: translateY(0);
        margin-bottom: 0;
    }
    .sidebar-nav span,
    .app-shell.sidebar-open .sidebar-nav span {
        opacity: 1;
        transform: translateX(0);
    }
    .topbar-title-wrap {
        justify-items: start;
    }
    .profile-head {
        align-items: flex-start;
    }
    .stats { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
    .profile-card {
        padding: 20px 14px;
    }
    .guest {
        padding: 28px 16px;
    }
}
@media (max-width: 350px) {
    .profile-card {
        padding: 18px 12px;
    }
    .topbar {
        padding-inline: 10px;
    }
}
