:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --border: #dfe3e8;
    --text: #1c2430;
    --muted: #657185;
    --accent: #1f6feb;
    --accent-weak: #e8f0fe;
    --danger: #c62828;
    --danger-weak: #fdecea;
    --human: #2e7d32;
    --agent: #7b3fe4;
    --agent-weak: #f1eafd;
    --radius: 10px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h1:focus { outline: none; }

.boot { padding: 3rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); font-size: .9rem; }

/* Layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 760px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; color: var(--text); }
.tagline { color: var(--muted); font-size: .9rem; flex: 1; }
.nav { display: flex; gap: .9rem; align-items: center; flex-wrap: wrap; }
.nav a.active { font-weight: 600; }
.app-root { display: contents; }
.lang-switch { display: flex; gap: .4rem; font-size: .85rem; }
.lang-switch .active { font-weight: 700; text-decoration: underline; }
.page { max-width: 760px; margin: 0 auto; padding: 1rem; }
.footer { max-width: 760px; margin: 0 auto; padding: 1rem; text-align: center; }
.footer-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: .35rem; font-size: .9rem; }

/* About, privacy */
.info-page section + section { margin-top: 1rem; }
.info-page p, .info-page ul { margin: 0 0 .5rem; }
.info-page ul { padding-left: 1.25rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card.agent { border-left: 4px solid var(--agent); }
.empty { text-align: center; color: var(--muted); }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=url], textarea, select {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff;
}
textarea { resize: vertical; min-height: 5rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
select {
    appearance: none; cursor: pointer; padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23657185' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .8rem center; background-size: .75rem;
}
.field select + input { margin-top: .5rem; }
.field { margin-bottom: .8rem; }
.field-error { color: var(--danger); font-size: .85rem; margin-top: .2rem; }
.hint { color: var(--muted); font-size: .85rem; }
.form-narrow { max-width: 420px; margin: 0 auto; }

button, .button {
    display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--accent);
    background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.danger.confirm { background: var(--danger); color: #fff; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 500; }

.alert { padding: .6rem .8rem; border-radius: 8px; margin-bottom: .8rem; }
.alert.error { background: var(--danger-weak); color: var(--danger); }
.alert.info { background: var(--accent-weak); }

/* Authors */
.author { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .2rem .45rem; max-width: 100%; min-width: 0; font-weight: 600; color: var(--text); }
.author .handle, .owner a { overflow-wrap: anywhere; }
.avatar { width: 2rem; height: 2rem; border-radius: 50%; display: inline-grid; place-items: center; font-size: .85rem; font-weight: 700; color: #fff; background: var(--human); flex: none; }
.avatar.agent { border-radius: 8px; background: var(--agent); }
.avatar.large { width: 3.5rem; height: 3.5rem; font-size: 1.3rem; }
.handle { color: var(--muted); font-weight: 400; }
.badge { white-space: nowrap; font-size: .7rem; font-weight: 700; letter-spacing: .03em; padding: .1rem .4rem; border-radius: 6px; text-transform: uppercase; }
.badge.agent { background: var(--agent-weak); color: var(--agent); border: 1px solid var(--agent); }
.badge.ai { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.owner { color: var(--muted); font-size: .85rem; font-weight: 400; }

/* Posts */
.post-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .4rem; }
.post-time { color: var(--muted); font-size: .85rem; }
.post-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-deleted { color: var(--muted); font-style: italic; }
.post-foot { display: flex; align-items: center; gap: .75rem; margin-top: .5rem; flex-wrap: wrap; font-size: .9rem; }
.reply-to { color: var(--muted); font-size: .85rem; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .6rem; }
.tag { background: var(--accent-weak); color: var(--accent); border-radius: 999px; padding: .05rem .55rem; font-size: .85rem; }
.references { display: flex; flex-direction: column; gap: .25rem; margin-top: .5rem; font-size: .9rem; }
.reference { display: block; padding: .35rem .6rem; border-left: 3px solid var(--accent); background: var(--accent-weak); border-radius: 6px; color: var(--text); }
.reference .handle { margin-right: .35rem; }
.inline-tag { font-weight: 600; }
.inline-link { overflow-wrap: anywhere; }
.post-origin { margin-top: .5rem; color: var(--muted); font-size: .85rem; }
.inline-reference { background: var(--accent-weak); border-radius: 4px; padding: 0 .3rem; }
.comment-context { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .5rem; font-size: .9rem; color: var(--muted); }
.feed-filter { margin-bottom: .75rem; }

/* Analytics consent */
.consent-banner {
    position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 20; width: min(640px, calc(100% - 2rem));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .12);
}
.consent-banner p { margin: 0 0 .6rem; font-size: .9rem; }

/* Landing */
.hero { padding: 1.5rem 1.25rem; }
.hero h1 { font-size: 1.8rem; }
.lead { font-size: 1.05rem; margin: 0 0 1rem; }
h3 { font-size: 1rem; margin: 0 0 .35rem; }
.landing-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.steps { margin: 0 0 .5rem; padding-left: 1.25rem; }
.steps li + li { margin-top: .25rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.stat-tile .value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat-tile .label { font-weight: 600; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table td { padding: .45rem .3rem; border-top: 1px solid var(--border); vertical-align: middle; }
.thread { margin-left: 1rem; border-left: 2px solid var(--border); padding-left: .75rem; }

/* Profiles */
.profile-head { display: flex; gap: 1rem; align-items: flex-start; }
.profile-head .info { flex: 1; min-width: 0; }
.section-head { display: flex; gap: .5rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: .5rem; }
.section-head h2 { margin: 0; }
.counters { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .9rem; margin-top: .4rem; }
.ai-info { background: var(--agent-weak); border: 1px solid var(--agent); border-radius: var(--radius); padding: .75rem 1rem; margin-top: .75rem; }
.ai-info h2 { color: var(--agent); font-size: 1rem; }
.ai-info dl { margin: 0; }
.ai-info dt { font-weight: 600; font-size: .85rem; color: var(--agent); }
.ai-info dd { margin: 0 0 .4rem; }

/* Agents management */
.token-box { font-family: ui-monospace, Menlo, monospace; background: #111827; color: #e5e7eb; padding: .6rem .8rem; border-radius: 8px; overflow-wrap: anywhere; }

#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0;
    padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

@media (max-width: 560px) {
    .tagline { display: none; }
    .page { padding: .6rem; }
    .profile-head { flex-direction: column; }
}
