:root {
    --bg: #f5f5f3;
    --card: #ffffff;
    --fg: #17171a;
    --fg-2: #4a4a50;
    --muted: #66666e;
    --line: #e6e6e2;
    --line-strong: #d4d4cf;
    --accent: #ff5a1f;
    --accent-hover: #f04e14;
    --accent-soft: #fff0e9;
    --accent-text: #9a3412;
    --accent-ink: #21110b;
    --chip: #f0f0ed;
    --green: #1f9d62;
    --green-soft: #e4f6ec;
    --red: #d92d20;
    --red-soft: #fdecea;
    --radius: 16px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1012;
        --card: #18191c;
        --fg: #f1f1ef;
        --fg-2: #c6c6c3;
        --muted: #8a8a91;
        --line: #26272b;
        --line-strong: #36373c;
        --accent: #ff6a33;
        --accent-hover: #ff7d4d;
        --accent-soft: #2a1912;
        --accent-text: #ffb391;
        --chip: #222327;
        --green: #4ccf8e;
        --green-soft: #13261c;
        --red: #ff6b5e;
        --red-soft: #2c1513;
        color-scheme: dark;
    }
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 14.5px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.top {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: var(--profile-top); padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--card);
    position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; }
.brand svg { width: 28px; height: 28px; }
.brand span { color: var(--muted); font-weight: 500; }
.ghost-btn { color: var(--fg-2); text-decoration: none; font-weight: 500; font-size: 14px; padding: 6px 10px; border-radius: 8px; }
.ghost-btn:hover { background: var(--chip); }

.top-nav { display: flex; align-items: center; gap: 4px; }
.top-nav button.ghost-btn { border: 0; background: transparent; cursor: pointer; }
.top-nav button.ghost-btn:hover { background: var(--chip); }
.brand { text-decoration: none; color: inherit; }

body { --profile-top: 56px; }
.layout {
    display: grid; grid-template-columns: 216px minmax(0, 1fr); align-items: start;
    min-height: calc(100dvh - var(--profile-top));
}
.profile-nav {
    display: grid; align-content: start; gap: 6px; padding: 16px 12px;
    position: sticky; top: var(--profile-top); z-index: 4;
    height: calc(100dvh - var(--profile-top));
    background: var(--card); border-right: 1px solid var(--line);
}
.profile-link {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px;
    border-radius: 10px; color: var(--fg-2); font-weight: 600; text-decoration: none;
}
.profile-link svg { width: 20px; height: 20px; flex: none; }
.profile-link:hover { background: var(--chip); }
.profile-link[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); }
.review-count {
    margin-left: auto; padding: 1px 6px; min-width: 24px; text-align: center;
    background: var(--accent-soft); color: var(--accent-text); border-radius: 7px;
    font-size: 12px; font-variant-numeric: tabular-nums;
}
.profile-link[aria-current="page"] .review-count { background: var(--card); }
.main { width: 100%; padding: 28px 30px 40px; min-width: 0; max-width: 1280px; margin: 0 auto; }

/* ---------- мой профиль: все приложения карточками ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head h1 { margin: 0; font-size: 30px; letter-spacing: -.03em; line-height: 1.1; }
.home-sub { margin: 6px 0 0; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.app {
    display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 4px 16px; align-items: start;
    padding: 18px; border-radius: 18px; border: 1px solid var(--line); background: var(--card);
    text-decoration: none; color: inherit; min-width: 0;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.app:hover { border-color: var(--line-strong); box-shadow: 0 10px 28px rgb(0 0 0 / .08); }
.app:active { transform: scale(.99); }
.app .mini { grid-row: span 3; }
.app-name { font-weight: 650; font-size: 16.5px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.app-tag { color: var(--fg-2); font-size: 13.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pill { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.pill.on { background: var(--green-soft); color: var(--green); }
.pill.off { background: var(--chip); color: var(--muted); }
.mini { width: 64px; height: 64px; border-radius: 16px; overflow: hidden; background: var(--chip); display: grid; place-items: center; font-weight: 700; font-size: 24px; color: var(--muted); }
.mini img { width: 100%; height: 100%; object-fit: cover; }

.review-page { max-width: 884px; }
.profile-filters {
    display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin-bottom: 16px;
    background: var(--chip); border-radius: 11px;
}
.profile-filters a {
    display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px;
    border-radius: 8px; color: var(--fg-2); text-decoration: none;
}
.profile-filters a:hover { color: var(--fg); }
.profile-filters a[aria-current="page"] { background: var(--card); color: var(--fg); font-weight: 650; }
.review-status { margin-bottom: 12px; }
.review-status p { margin: 0; color: var(--fg-2); overflow-wrap: anywhere; }
.review-status button { justify-self: start; }
.reviews { display: grid; gap: 14px; }
.review {
    min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
    padding: 16px; display: grid; gap: 10px;
}
.review-top { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.review-top .hint { margin: 0; }
.review-text { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.review .file-btns { flex-wrap: wrap; gap: 8px; }

.stats-page { max-width: 1000px; }
.stats-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stats-toolbar .profile-filters { margin-bottom: 0; }
.stats-toolbar select {
    min-height: 44px; max-width: 100%; padding: 6px 10px;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.stats-status { margin: 10px 0 14px; color: var(--muted); overflow-wrap: anywhere; }
.stats-content { display: grid; gap: 14px; }
#statsRetry { margin-bottom: 14px; }
.stats-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.stats-metric { gap: 4px; }
.stats-metric dt { color: var(--muted); }
.stats-metric dd { margin: 0; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats-chart {
    display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); gap: clamp(2px, .7vw, 8px);
    padding: 4px 0; min-height: 126px;
}
.stats-bar {
    position: relative; display: grid; grid-template-rows: 100px 18px; align-items: end;
    gap: 5px; min-width: 0; min-height: 118px; padding: 0; border: 0; border-radius: 5px;
    background: transparent; font-size: 11px; color: var(--muted); cursor: pointer;
}
.stats-bar i { height: max(2px, var(--bar)); background: var(--accent); border-radius: 4px; opacity: .78; }
.stats-bar:hover i, .stats-bar[aria-pressed="true"] i { opacity: 1; }
.stats-bar.is-untracked i { background: var(--line-strong); }
.stats-bar span { position: absolute; left: 0; bottom: 0; color: var(--muted); }
.stats-bar:last-child span { left: auto; right: 0; }
.stats-caption { color: var(--muted); margin: 0; }
.stats-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; table-layout: fixed; }
.stats-table th, .stats-table td { padding: 9px 5px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.stats-table th { color: var(--muted); font-weight: 600; }
.stats-table :is(th,td):first-child { width: 50%; }
.stats-table :is(th,td):not(:first-child) { text-align: right; }
.stats-table tr:last-child td { border-bottom: 0; }
.stats-signals { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.stats-signals li { border-top: 1px solid var(--line); padding-top: 10px; overflow-wrap: anywhere; }
.stats-signals li > span { display: block; color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; margin: 0 0 16px; }
.back:hover { color: var(--fg); }

.editor { max-width: 820px; margin: 0 auto; display: grid; gap: 14px; }
#back { max-width: 820px; margin-left: auto; margin-right: auto; display: flex; }
.ed-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ed-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ed-icon { width: 64px; height: 64px; border-radius: 16px; overflow: hidden; background: var(--chip); flex: none; display: grid; place-items: center; font-size: 26px; font-weight: 700; color: var(--muted); }
.ed-icon img { width: 100%; height: 100%; object-fit: cover; }
.ed-title h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; overflow-wrap: anywhere; }
.link { color: var(--muted); font-size: 13px; text-decoration: none; }
.link:hover { color: var(--accent); }

.ed-actions { display: grid; gap: 4px; }
.visibility-status { color: var(--muted); font-size: 13px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch input:disabled + .track { opacity: .6; }
.track { width: 44px; height: 26px; border-radius: 13px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .2); transition: transform .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .thumb { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; min-width: 0; }
.card h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 13px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > :is(span, label) { font-size: 13px; font-weight: 500; color: var(--fg-2); }
.field small { color: var(--muted); font-size: 12px; }
input:not([type]), input[type="text"], input[type="password"], textarea, .slug {
    width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    padding: 9px 12px; outline: none; transition: border-color .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, .slug:focus-within { border-color: var(--accent); }
.slug { display: flex; align-items: center; padding: 0 0 0 12px; }
.slug span { color: var(--muted); white-space: nowrap; }
.slug input { border: 0; background: transparent; padding: 9px 12px 9px 0; }

.drop {
    border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 18px;
    display: flex; align-items: center; gap: 14px; color: var(--fg-2); cursor: pointer;
    transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop small { color: var(--muted); }
.drop-icon { width: 72px; height: 72px; border-radius: 18px; overflow: hidden; background: var(--chip); flex: none; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.drop-icon img { width: 100%; height: 100%; object-fit: cover; }
.drop-cover { width: 60px; height: 90px; border-radius: 8px; }

.files { display: grid; gap: 8px; }
.file { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-meta { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.file input { grid-column: 1 / -1; }
.file-btns { display: flex; gap: 4px; }
.icon-btn { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 4px 9px; cursor: pointer; color: var(--fg-2); font-size: 13px; }
.icon-btn:hover { border-color: var(--line-strong); color: var(--fg); }
.icon-btn.del:hover { border-color: var(--red); color: var(--red); }
.icon-btn:disabled { opacity: .35; cursor: default; }

.progress { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; }
.bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.shot { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); display: grid; }
.shot img { width: 100%; height: 110px; object-fit: cover; display: block; }
.shot .file-btns { padding: 6px; justify-content: space-between; }

.savebar {
    position: sticky; bottom: 12px; z-index: 4;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 12px 12px 18px; border-radius: 14px; border: 1px solid var(--line);
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 24px rgb(0 0 0 / .08);
    color: var(--muted); font-size: 13.5px;
}
.savebar.dirty { color: var(--fg); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--card); font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.wide { width: 100%; }
.danger { border-color: var(--red-soft); }
.danger-btn { color: var(--red); justify-self: start; }
.danger-btn:hover { border-color: var(--red); background: var(--red-soft); }

.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--card); color: var(--fg); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog form { padding: 22px; display: grid; gap: 14px; }
.dialog h2 { margin: 0; font-size: 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.delete-summary { margin: 0; color: var(--fg-2); overflow-wrap: anywhere; }
.error { color: var(--red); margin: 0; font-size: 13.5px; }

.auth-main {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    align-items: center;
    padding: clamp(16px, 5vw, 48px);
}
.auth-card {
    width: min(100%, 424px);
    margin-inline: auto;
    padding: clamp(20px, 7vw, 32px);
    gap: 18px;
}
.auth-card .brand { justify-self: start; }
.auth-card h1 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: -.025em; }
.auth-card form { display: grid; gap: 14px; }
.auth-card input { min-height: 44px; font-size: 16px; }
.auth-card input:focus-visible { outline: 2px solid var(--accent); }
.auth-card .btn { min-height: 44px; color: #21110b; }
.auth-card .field small { color: var(--fg-2); }
.auth-help { color: var(--fg-2); margin: 0; }
.auth-back { justify-self: start; margin-left: -10px; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
    background: var(--fg); color: var(--card); padding: 10px 16px; border-radius: 10px;
    font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
    max-width: calc(100vw - 32px); z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--red); color: #fff; }

@media (max-width: 760px) {
    .layout { display: block; }
    .profile-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr)); height: auto;
        padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line);
    }
    .profile-link { gap: 7px; padding-inline: 9px; }
    .main { padding: 18px 16px 32px; }
    .section-head h1 { font-size: 26px; }
    .cards { grid-template-columns: minmax(0, 1fr); }
    .row2 { grid-template-columns: minmax(0, 1fr); }
    .stats-metrics { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .stats-metric { grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 12px; }
    .stats-metric dd { font-size: 23px; }
}

@media (max-width: 500px) {
    .profile-link { justify-content: center; gap: 4px; padding-inline: 3px; font-size: 13.5px; }
    .profile-link svg { display: none; }
    .review-count { margin-left: 0; min-width: 18px; padding-inline: 4px; }
    .stats-table { font-size: 12px; }
    .stats-chart[data-days="7"] .stats-bar:not(:first-child):not(:last-child):not(:nth-child(4)) span { display: none; }
}

@media (max-width: 420px) {
    .top { padding-inline: 16px; }
    .top .brand span { display: none; }
}
