:root {
    --bg: #0b0f17;
    --bg-soft: #0f1420;
    --surface: #161c2b;
    --surface-2: #1e2536;
    --surface-3: #262f45;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.13);
    --text: #eef1f7;
    --text-2: #aab3c5;
    --text-muted: #6b7488;
    --accent: #6c8cff;
    --accent-soft: rgba(108, 140, 255, 0.14);
    --danger: #f2645a;
    --danger-soft: rgba(242, 100, 90, 0.13);
    --warning: #e6a94c;
    --warning-soft: rgba(230, 169, 76, 0.13);
    --success: #46c98b;
    --success-soft: rgba(70, 201, 139, 0.13);
    --radius: 16px;
    --radius-sm: 11px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.28);
    --maxw: 560px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    background:
        radial-gradient(1100px 600px at 50% -10%, #131a2b 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 16px;
}

.container {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 14px 16px 80px;
}

/* ── Верхняя навигация ─────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 -16px 18px;
    padding: 12px 16px;
    background: rgba(11, 15, 23, 0.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.nav .title { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.nav .title .dot { font-size: 22px; }
.nav-links { display: flex; gap: 6px; align-items: center; }
.nav-links a {
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 10px;
    transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); }
.nav-links a.back::before { content: '←'; margin-right: 6px; }

/* ── Секции ────────────────────────────────────────── */
.section {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 26px 4px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Карточки ──────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.card.tight { padding: 6px 18px; }
.card.summary { line-height: 1.6; color: var(--text); font-size: 15.5px; }

.empty { color: var(--text-muted); text-align: center; padding: 34px 0; font-size: 15px; }

/* ── Профиль: шапка ────────────────────────────────── */
.phead {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 2px 4px;
    margin-bottom: 8px;
}
.avatar-ring {
    --ring: var(--text-muted);
    position: relative;
    flex-shrink: 0;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(var(--ring), var(--ring));
}
.avatar-ring .av {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--surface-3);
    border: 3px solid var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-2);
    overflow: hidden;
}
.avatar-ring .av img { width: 100%; height: 100%; object-fit: cover; }
.phead h2 { margin: 0 0 3px; font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.phead .sub { color: var(--text-muted); font-size: 13.5px; }
.mood-chip {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 7px; font-size: 12.5px; font-weight: 500;
    padding: 3px 9px; border-radius: 999px;
}

/* ── Сетка фактов ──────────────────────────────────── */
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 14px;
}
.stat.wide { grid-column: 1 / -1; }
.stat .k { font-size: 12.5px; color: var(--text-muted); margin-bottom: 5px; }
.stat .v { font-size: 19px; font-weight: 640; letter-spacing: -0.01em; }
.stat .v.small { font-size: 14px; font-weight: 500; color: var(--text-2); line-height: 1.35; }
.stat .v .u { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ── Черты характера ───────────────────────────────── */
.trait {
    display: flex;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}
.trait:last-child { border-bottom: none; }
.trait .bar {
    flex-shrink: 0; width: 4px; border-radius: 4px; align-self: stretch;
    background: var(--text-muted);
}
.trait.strength .bar { background: var(--success); }
.trait.weakness .bar { background: var(--danger); }
.trait .body { min-width: 0; flex: 1; }
.trait .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.trait .name { font-size: 15px; font-weight: 600; }
.trait .conf { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.trait .why { font-size: 13.5px; color: var(--text-2); margin-top: 4px; line-height: 1.5; }
.trait .track { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.trait .track > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.trait.strength .track > i { background: var(--success); }
.trait.weakness .track > i { background: var(--danger); }

/* ── Пилюли сильных/слабых сторон ──────────────────── */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
    font-size: 13px; padding: 7px 12px; border-radius: 999px;
    border: 1px solid var(--border-strong); line-height: 1.3;
}
.pill.good { background: var(--success-soft); color: #8fe6bd; border-color: rgba(70,201,139,.25); }
.pill.bad { background: var(--danger-soft); color: #f7a49d; border-color: rgba(242,100,90,.25); }

/* ── Список дел / людей ────────────────────────────── */
.row {
    display: flex; align-items: center; gap: 13px;
    padding: 13px 0; border-bottom: 1px solid var(--border);
    text-decoration: none; color: var(--text);
}
.row:last-child { border-bottom: none; }
.rowlink { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.rowlink:hover .t1 { color: var(--accent); }
.row .ctx { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; }
.row .ctx .lnk { color: var(--accent); font-weight: 600; }
.row .av {
    width: 46px; height: 46px; border-radius: 50%;
    background: var(--surface-3); flex-shrink: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600; color: var(--text-2);
}
.row .av img { width: 100%; height: 100%; object-fit: cover; }
.row .main { min-width: 0; flex: 1; }
.row .t1 { font-size: 15px; font-weight: 550; }
.row .t2 { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.row .chev { color: var(--text-muted); font-size: 18px; }

/* ── Тэги/бейджи ───────────────────────────────────── */
.tag {
    display: inline-block; font-size: 11.5px; font-weight: 600;
    padding: 3px 9px; border-radius: 999px; vertical-align: middle;
}
.tag.danger { background: var(--danger-soft); color: #f7a49d; }
.tag.warning { background: var(--warning-soft); color: #f0c583; }
.tag.ver { background: var(--accent-soft); color: #a9bcff; }

/* ── Кнопки ────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 14px 16px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 550; font-family: inherit;
    cursor: pointer; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #7d99ff; }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; }
.btn.ghost { background: transparent; }

/* ── Разбор манипуляций ────────────────────────────── */
.finding { padding: 4px 0 14px; border-bottom: 1px solid var(--border); }
.finding:last-child { border-bottom: none; padding-bottom: 4px; }
.finding .fname { font-size: 15.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.finding .fexp { font-size: 13.5px; color: var(--text-2); line-height: 1.5; margin-bottom: 10px; }
.reply {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface-2); border-radius: 10px;
    padding: 10px 12px; margin-bottom: 6px; font-size: 13.5px;
}
.reply .rtone { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); flex-shrink: 0; width: 68px; }
.reply .rtext { flex: 1; min-width: 0; }
.reply .rcopy {
    flex-shrink: 0; background: var(--surface-3); border: none; color: var(--text-2);
    width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px;
}
.reply .rcopy:hover { background: var(--accent); color: #fff; }

/* ── Заметки ───────────────────────────────────────── */
.note {
    background: var(--warning-soft);
    border-left: 3px solid var(--warning);
    padding: 10px 13px; font-size: 13.5px; color: #f0d3a0;
    margin-bottom: 8px; border-radius: 0 9px 9px 0;
}
.note.warn { background: var(--danger-soft); border-left-color: var(--danger); color: #f4b3ac; }

textarea, input[type=text] {
    width: 100%; background: var(--bg-soft); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 12px 13px; font-size: 15px; font-family: inherit; resize: vertical;
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); }
.note-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; }
.check { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 7px; cursor: pointer; }

.loading { text-align: center; color: var(--text-muted); padding: 60px 0; font-size: 15px; }

@media (max-width: 420px) {
    .stats { grid-template-columns: 1fr; }
    .phead .avatar-ring { width: 64px; height: 64px; }
}
