:root {
    color-scheme: light;
    --primary: #6d4aff;
    --primary-hover: #5334d6;
    --on-primary: #fff;
    --text: #18181b;
    --muted: #52525b;
    --border: #e4e4e7;
    --background: #fff;
    --surface: #fff;
    --soft: #f7f7f9;
    --link: #6040e8;
    --accent: #6d4aff;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --text: #f4f4f5;
    --muted: #b9b9c3;
    --border: #52525b;
    --background: #18181b;
    --surface: #27272a;
    --soft: #303037;
    --link: #c4b8ff;
    --accent: #ad9aff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 16px/1.5 system-ui, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button, .button { display: inline-block; border: 1px solid var(--primary); border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 700; padding: 10px 20px; cursor: pointer; text-align: center; }
button:hover, .button:hover { background: var(--primary-hover); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button-secondary:hover { background: var(--soft); }
.header { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--background); z-index: 1; }
.header-inner { max-width: 760px; margin: auto; padding: 14px 20px; display: flex; align-items: center; gap: 16px; }
.brand { color: var(--text); font-size: 1.65rem; font-weight: 800; letter-spacing: -.06em; }
.brand span { color: var(--accent); }
.nav { display: flex; flex: 1; justify-content: flex-end; gap: 18px; font-size: .92rem; font-weight: 650; }
.nav a, .author { color: var(--text); }
.nav a[aria-current="page"] { box-shadow: inset 0 -3px var(--accent); padding-bottom: 5px; }
.theme-form, .header-form { flex: 0 0 auto; margin: 0; }
.theme-toggle, .icon-button { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.theme-toggle:hover, .icon-button:hover { background: var(--soft); }
.theme-toggle svg, .icon-button svg { width: 20px; height: 20px; }
.container { max-width: 680px; margin: 0 auto; padding: 24px 20px 60px; min-height: 75vh; }
h1 { font-size: 1.55rem; margin: 0 0 20px; line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 26px 0 12px; }
p { margin: 10px 0; }
.section-heading, .profile-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-heading h1 { margin-bottom: 0; }
.section-heading { margin-bottom: 20px; }
.muted, small, time { color: var(--muted); }
.form { display: grid; gap: 16px; }
label { display: grid; gap: 8px; font-weight: 650; }
input, textarea, select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
textarea { resize: vertical; }
small { font-weight: 400; }
.field { display: grid; gap: 8px; }
.field label { display: block; }
.password-field { position: relative; }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.password-toggle:hover { background: var(--soft); color: var(--text); }
.password-toggle[hidden] { display: none; }
.password-toggle svg { width: 20px; height: 20px; }
.password-toggle .eye-closed, .password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-closed { display: block; }
.narrow { max-width: 420px; margin: 0 auto; }
.notice { background: var(--soft); border-left: 4px solid var(--accent); padding: 12px; margin-bottom: 20px; }
.composer { padding: 18px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.composer-heading, .settings-heading { display: flex; align-items: center; gap: 12px; }
.composer-heading { margin-bottom: 10px; }
.settings-heading { margin-bottom: 20px; }
.settings-heading h1 { margin: 0; }
.composer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 8px; color: var(--muted); font-size: .9rem; }
.bipp { display: flex; gap: 12px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.bipp-content { min-width: 0; flex: 1; }
.avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--soft); color: var(--link); font-weight: 750; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-large { width: 72px; height: 72px; flex-basis: 72px; font-size: 1.4rem; }
.avatar-editor { display: grid; gap: 8px; }
.avatar-editor[hidden] { display: none; }
.avatar-editor p { color: var(--muted); margin: 0; }
.avatar-editor canvas { width: min(240px, 100%); height: auto; aspect-ratio: 1; border-radius: 50%; cursor: grab; touch-action: none; background: #fff; }
.avatar-editor canvas:active { cursor: grabbing; }
.avatar-editor input[type="range"] { padding: 0; accent-color: var(--primary); }
.author { font-weight: 750; }
.bipp-heading { overflow-wrap: anywhere; }
.bipp-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 12px; }
.bipp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; font-size: .83rem; }
.bipp-actions form { margin: 0; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--link); font-size: inherit; font-weight: 400; }
.text-button:hover { background: transparent; text-decoration: underline; }
.favorite-selected { color: var(--link); }
.empty { padding: 20px 0; color: var(--muted); }
.profile { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.profile h1 { margin: 14px 0 0; }
.profile-counts { display: flex; gap: 18px; margin-top: 18px; font-size: .9rem; }
.search { margin: 20px 0; }
.search div { display: flex; gap: 8px; margin-top: 8px; }
.search .search-heading { align-items: center; gap: 12px; margin-top: 0; }
.user-row { display: flex; gap: 12px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.more { display: block; padding: 20px 0; font-weight: 650; }
.logout { margin-top: 28px; }
.back { display: inline-block; margin-bottom: 16px; }
.footer { max-width: 680px; margin: auto; padding: 20px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (max-width: 480px) {
    .header-inner { padding: 12px; gap: 8px; }
    .nav { gap: 8px; font-size: .82rem; }
    .theme-toggle, .icon-button { width: 34px; height: 34px; padding: 7px; }
    .container { padding: 20px 12px 50px; }
}
@media (max-width: 374px) {
    .header-inner { flex-wrap: wrap; }
    .nav { order: 3; flex-basis: 100%; justify-content: space-between; }
    .theme-form { margin-left: auto; }
}
