:root {
    --bg: #14121a;
    --surface: #1e1b26;
    --border: #2e2a3a;
    --text: #ece8f4;
    --muted: #9c95ad;
    --accent: #c86b98;
    --error: #ff7a7a;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.brand { color: var(--text); font-weight: 600; text-decoration: none; }

.page { max-width: 960px; margin: 0 auto; padding: 24px 16px; }

.auth {
    max-width: 380px;
    margin: 48px auto;
    padding: 0 16px;
}

.stack { display: flex; flex-direction: column; gap: 14px; }

label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); }

input[type=text], input[type=email], input[type=password], textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

button {
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    color: #fff;
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; }

form.inline { margin: 0; }

.error { color: var(--error); font-size: 14px; }
.notice { color: var(--muted); }

.nav { display: flex; align-items: center; gap: 18px; font-size: 15px; }
.nav a { color: var(--muted); text-decoration: none; }
.nav a:hover { color: var(--text); }

.narrow { max-width: 680px; }
.muted { color: var(--muted); font-size: 14px; }
small { color: var(--muted); font-weight: 400; }

.button {
    display: inline-block;
    background: var(--accent);
    border-radius: 8px;
    color: #fff;
    padding: 10px 16px;
    font-weight: 600;
    text-decoration: none;
}
.button.secondary, button.secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
button.danger { background: #8a2f3f; }
button:disabled { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.toolbar h1 { margin: 0; flex: 1; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 8px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.tabs a.active { background: var(--surface); color: var(--text); }
.search { flex: 1; min-width: 180px; }
.search input { width: 100%; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    color: var(--text);
    text-decoration: none;
}
.card .avatar { width: 100%; height: auto; aspect-ratio: 1; border-radius: 0; }
.card-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; min-width: 0; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; color: var(--accent); font-size: 13px; }

.avatar { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; max-width: 100%; }
.avatar.large { width: 100%; height: auto; aspect-ratio: 1; }
.avatar.placeholder {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3a2d4a, #5a2f4a);
    color: var(--text); font-size: 24px; font-weight: 600;
}
.card .avatar.placeholder { font-size: 56px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
    display: flex; align-items: center; gap: 12px; padding: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    color: var(--text); text-decoration: none;
}
.row.plain { background: none; border: 0; padding: 0; }

.badge { display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--border); color: var(--muted); }
.badge .ok { color: #7fd49a; }
.badge .wait { color: #e8c26a; }
.badge .bad { color: var(--error); }

.profile-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.profile-head .avatar { width: 160px; height: 160px; border-radius: 16px; }
.profile-head .avatar.placeholder { font-size: 64px; }
.profile-head h1 { margin: 0 0 4px; }
.prose { white-space: pre-line; }
section h2 { font-size: 18px; margin: 28px 0 8px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.reject { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.reject input { flex: 1; }
.two { display: grid; grid-template-columns: 1fr 120px; gap: 12px; }
.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }

select, input[type=number], input[type=file] {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); padding: 10px 12px; font: inherit;
}
textarea { width: 100%; resize: vertical; }

@media (max-width: 560px) {
    .topbar { flex-wrap: wrap; gap: 8px; }
    .nav { gap: 12px; flex-wrap: wrap; }
    .grid { grid-template-columns: repeat(2, 1fr); }
    .two { grid-template-columns: 1fr; }
}

.preview { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }

.chat { max-width: 820px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; height: calc(100dvh - 58px); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.chat-head a { color: var(--text); text-decoration: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.bubble.mine { align-self: flex-end; background: #3a2540; border-color: #4f3057; }
.bubble.theirs { align-self: flex-start; }
.bubble.failed { border-color: var(--error); }
.bubble .author { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bubble .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble .text em { color: var(--muted); }
.bubble .typing { color: var(--muted); font-style: italic; }
.bubble .action { margin-top: 6px; font-size: 13px; }
.composer { display: flex; gap: 10px; padding: 12px 0 16px; border-top: 1px solid var(--border); }
.composer textarea { flex: 1; min-height: 48px; max-height: 200px; }
#chat-error { margin: 8px 0 0; }

.composer-actions { display: flex; flex-direction: column; gap: 6px; }
.photo { margin-top: 8px; }
.photo img { display: block; max-width: min(320px, 100%); border-radius: 10px; cursor: zoom-in; }
.photo.pending {
    display: flex; align-items: center; justify-content: center; text-align: center;
    width: min(240px, 100%); aspect-ratio: 832 / 1216; padding: 12px;
    border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 13px;
}

.telegram-login { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 12px 0 20px; }
.code { font-size: 40px; font-weight: 700; letter-spacing: 10px; margin: 16px 0; }
.panel h2 { margin-top: 0; }
