/* «Мой блог» — оформление по DESIGN.md (палитра, шрифты и размеры главной страницы). */
:root {
  --page: #efe9df;
  --action: rgb(86 79 77);
  --action-text: rgb(251 248 244);
  --gold: #a67c3d;
  --focus: #765529;
  --display: "Literata", Georgia, serif;
  --control: 44px;
  --gutter: 24px;
  --card-shadow: 0 3px 9px rgb(69 50 27 / .08);
}
@media (any-pointer: coarse) { :root { --control: 48px; } }
@media (max-width: 767px) { :root { --control: 48px; } }
@media (min-width: 1024px) { :root { --gutter: 40px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: hsl(var(--foreground));
  font: 400 16px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body > footer { margin-top: auto; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-underline-offset: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid hsl(var(--accent)); outline-offset: 3px; }
::selection { background: #e6d3ad; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; inset: 8px auto auto 8px; z-index: 90; padding: 10px 14px; background: hsl(var(--card)); border-radius: 10px; transform: translateY(-150%); }
.skip:focus { transform: none; }

/* ---------- Каркас ---------- */
.blog-page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 880px;
  margin-inline: auto;
  padding: 24px max(var(--gutter), env(safe-area-inset-right)) 72px max(var(--gutter), env(safe-area-inset-left));
}
.blog-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.blog-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.blog-aside { display: grid; gap: 16px; min-width: 0; }
@media (min-width: 768px) {
  .blog-layout { gap: 24px; }
  .blog-main { gap: 24px; }
  .blog-aside { gap: 24px; }
}
@media (min-width: 1024px) { .blog-layout { gap: 32px; } }

.blog-card {
  min-width: 0;
  padding: 20px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  box-shadow: var(--card-shadow);
}
@media (min-width: 768px) { .blog-card { padding: 24px; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2{ font: 700 24px/32px var(--display); }

.blog-status { font-size: 14px; color: hsl(var(--muted-foreground)); }
.blog-status:empty { display: none; }
.blog-page > .blog-status { margin-bottom: 16px; }
.blog-error { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #f7e4df; color: #7a2e1f; font-size: 14px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control); padding: 10px 20px;
  border: 1px solid hsl(var(--border)); border-radius: 999px;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  font: 500 13px/1.3 Inter, sans-serif; text-decoration: none; text-align: center;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.btn:hover { background: hsl(var(--secondary)); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--action); border-color: var(--action); color: var(--action-text); }
.btn-primary:hover, .btn-primary:focus-visible { background: hsl(var(--secondary)); color: var(--action); box-shadow: inset 0 0 0 1px rgb(86 79 77 / .35); }
.btn-danger { background: #8a3a2a; border-color: #8a3a2a; color: #fff; }
.btn-danger:hover { background: #a3473a; }
.btn-text { min-height: var(--control); padding: 0 4px; border: 0; background: none; color: var(--focus); text-decoration: underline; text-underline-offset: 4px; font: 400 13px/1.3 Inter, sans-serif; }
.btn-text:hover { background: none; color: var(--gold); }
.blog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
@media (max-width: 767px) { .blog-guest .blog-actions .btn, .messages-stub .blog-actions .btn { flex: 1 1 100%; } }

/* ---------- Профиль ---------- */
.profile { display: flex; gap: 16px; align-items: flex-start; }
.profile-avatar {
  --size: 72px; --radius: 12px;
  flex: none; width: var(--size); height: var(--size); border-radius: var(--radius, 16px);
  display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(ellipse at 20% 0%, hsl(var(--accent) / .35), transparent 60%), hsl(var(--secondary));
  box-shadow: 0 0 0 1px rgb(166 124 61 / .3);
  font: 600 calc(var(--size) * .36)/1 var(--display); color: #5d4a2c;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-body { min-width: 0; flex: 1; }
.profile-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.profile-head h2 { font: 600 28px/1.1 var(--display); overflow-wrap: anywhere; }
.profile-status { font-size: 18px; line-height: 1; }
.profile-status:empty { display: none; }
#profileAvatar { padding: 0; cursor: zoom-in; }
#profileAvatar:disabled { cursor: default; opacity: 1; }
.avatar-viewer[open] { display: grid; gap: 10px; padding: 14px; width: fit-content; }
.avatar-viewer button { justify-self: end; }
.avatar-viewer img { display: block; max-width: 100%; max-height: 75dvh; object-fit: contain; }
#avatarCrop, .profile-status-field { min-width: 0; border: 0; margin: 0; padding: 0; }
#avatarCrop:not([hidden]) { display: grid; gap: 8px; }
#avatarCanvas { display: block; width: min(100%, 260px); height: auto; touch-action: none; cursor: grab; background: #eee; }
#avatarCanvas:active { cursor: grabbing; }
.profile-status-field .emoji-status-editor { min-height: 32px; padding: 4px 0; }
.emoji-status-editor:empty::before { content: attr(data-placeholder); color: hsl(var(--muted-foreground)); }
#openComposer { justify-self: start; }
#composer .section-head h2 { font-size: 16px; line-height: 22px; }
#composer :is(.btn, .composer-link input, .composer-count), #community-share-label { font-size: 12px; line-height: 16px; }
#composer .emoji-editor {
  min-height: 90px; max-height: 50dvh; overflow: auto;
  padding: 10px 12px; border: 1px solid hsl(var(--border)); border-radius: 8px;
  background: hsl(var(--background)); font-size: 15px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere; cursor: text;
}
#composer .tool { width: 32px; height: 32px; min-height: 32px; padding: 6px; justify-content: center; }
@media (max-width: 700px) {
  #composer .emoji-editor { font-size: 16px; }
  #composer .tool { width: 40px; height: 40px; min-height: 40px; }
}
.profile-role { margin-top: 6px; font-size: 13px; color: var(--gold); letter-spacing: .02em; }
.profile-bio { margin-top: 12px; font-size: 14px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.profile-note { margin-top: 10px; font-size: 13px; color: hsl(var(--muted-foreground)); }
@media (max-width: 767px) { .profile { flex-wrap: wrap; } .profile-actions .btn { flex: 1 1 auto; } }
@media (min-width: 768px) {
  .profile { gap: 24px; padding: 32px; }
  .profile .profile-avatar { --size: 104px; --radius: 16px; }
  .profile-head h2 { font-size: 34px; }
}

/* ---------- Редактор записи ---------- */
.composer textarea, .composer input[type=url], .field input, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid hsl(var(--border)); border-radius: 10px; background: #fff;
  font: 400 16px/24px Inter, sans-serif; color: hsl(var(--foreground));
}
.composer textarea { min-height: 96px; max-height: 50vh; resize: vertical; }
.composer textarea:focus, .composer input:focus, .field :is(input, textarea):focus { outline: none; border-color: hsl(var(--accent)); box-shadow: 0 0 0 3px hsl(var(--accent) / .15); }
.composer-link { display: flex; gap: 8px; margin-top: 10px; }
.composer-link input { flex: 1; min-width: 0; }
.composer-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.composer-tools { display: flex; gap: 4px; margin-right: auto; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--control); padding: 0 12px;
  border: 0; border-radius: 999px; background: none; color: #726757; font: 400 13px/1 Inter, sans-serif; cursor: pointer;
  transition: background-color .2s, color .2s;
}
.tool:hover, .tool[aria-expanded="true"] { background: hsl(var(--secondary)); color: var(--gold); }
.tool:focus-within { outline: 2px solid hsl(var(--accent)); outline-offset: 2px; }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.composer-count { font-size: 12px; color: hsl(var(--muted-foreground)); }
.composer-count:empty { display: none; }
@media (max-width: 479px) { .composer-foot .btn-primary { flex: 1 1 100%; } .tool span { display: none; } .tool { width: var(--control); justify-content: center; padding: 0; } }
.composer.editing { box-shadow: 0 0 0 2px hsl(var(--accent)), 0 12px 28px rgba(166, 124, 61, .2); }

.attachment:empty { display: none; }
.attachment { margin-top: 12px; position: relative; }
.attachment .remove-attachment {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgb(255 255 255 / .9); box-shadow: 0 2px 6px rgb(0 0 0 / .15); display: grid; place-items: center;
}
.attachment .remove-attachment svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

/* ---------- Лента ---------- */
.feed { display: grid; gap: 16px; min-width: 0; }
.feed-list { display: grid; gap: 16px; }
.feed-more { justify-self: center; }

.post { padding: 0; overflow: hidden; scroll-margin-top: 16px; }
.post:target { box-shadow: 0 0 0 2px hsl(var(--accent)), var(--card-shadow); }
.post-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0 20px; }
.post-head .profile-avatar { --size: 44px; --radius: 10px; }
.post-author { min-width: 0; flex: 1; }
.post-author a { font: 600 18px/1.2 var(--display); text-decoration: none; overflow-wrap: anywhere; }
.post-author a:hover { color: var(--gold); }
.post-date { display: block; margin-top: 2px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.post-body { padding: 12px 20px 0; font-size: 15px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.post-body a { color: var(--focus); }
.post-body.clamped { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; }
.post-more { margin: 4px 20px 0; }
.post-media { margin-top: 14px; }
.post-media img { display: block; width: 100%; max-height: 640px; object-fit: contain; background: #f7f2e8; }
.post-media audio { width: calc(100% - 40px); margin: 0 20px; }
.post-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.post > :last-child:not(.post-foot) { margin-bottom: 20px; }
.post-foot .edited { margin-right: auto; }

.link-card {
  display: grid; grid-template-columns: minmax(0, 1fr); margin: 14px 20px 0; overflow: hidden;
  border: 1px solid hsl(var(--border)); border-radius: 12px; background: hsl(var(--background)); text-decoration: none;
  transition: border-color .2s;
}
.link-card:hover { border-color: rgb(166 124 61 / .55); }
.link-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #f7f2e8; }
.link-card-copy { padding: 12px 14px; display: grid; gap: 4px; min-width: 0; }
.link-card-host { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.link-card-title { font: 600 18px/1.25 var(--display); overflow-wrap: anywhere; }
.link-card-text { font-size: 13px; line-height: 1.5; color: hsl(var(--muted-foreground)); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.attachment .link-card { margin: 0; }
.attachment .post-media { margin: 0; border-radius: 12px; overflow: hidden; }

.post-menu { position: relative; }
.post-menu summary {
  list-style: none; width: var(--control); height: var(--control); border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: #726757;
}
.post-menu summary::-webkit-details-marker { display: none; }
.post-menu summary:hover, .post-menu[open] summary { background: hsl(var(--secondary)); }
.post-menu summary svg { width: 20px; height: 20px; fill: currentColor; }
.post-menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 220px; padding: 6px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 14px;
  box-shadow: 0 12px 32px rgb(69 50 27 / .18); display: grid;
}
.post-menu-list button {
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 14px;
}
.post-menu-list button:hover { background: hsl(var(--secondary)); }
.post-menu-list .danger { color: #8a3a2a; }


/* ---------- Друзья ---------- */
.friends-list .profile-avatar { --size: 36px; --radius: 8px; box-shadow: none; }


/* ---------- Диалоги ---------- */
.blog-dialog {
  width: min(100%, 640px);
  max-width: calc(100% - 2 * max(16px, env(safe-area-inset-left)));
  max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 0; border-radius: 20px; overflow: auto;
  background: hsl(var(--background)); color: hsl(var(--foreground));
  box-shadow: 0 24px 80px hsl(var(--foreground) / .31);
}
.blog-dialog.small { width: min(100%, 440px); }
.blog-dialog::backdrop { background: hsl(var(--foreground) / .4); backdrop-filter: blur(5px); }
@media (prefers-reduced-motion: no-preference) { .blog-dialog[open] { animation: dialog-in .22s ease-out; } }
@keyframes dialog-in { from { transform: translateY(8px); opacity: 0; } }
.dialog-top {
  display: flex; justify-content: space-between; gap: 20px; padding: 28px 32px 22px;
  border-bottom: 1px solid hsl(var(--border));
  background: radial-gradient(ellipse at 5% 0%, hsl(var(--accent) / .18), transparent 52%), hsl(var(--background));
}
.dialog-top h2 { font: 400 38px/1.1 var(--display); }
.dialog-top p { margin-top: 10px; max-width: 45ch; font-size: 13px; line-height: 1.6; color: hsl(var(--muted-foreground)); }
.dialog-close { flex: none; width: 44px; height: 44px; margin: -8px -12px 0 0; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; }
.dialog-close:hover { background: rgb(255 255 255 / .5); }
.dialog-close svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.dialog-body { display: grid; gap: 18px; padding: 26px 32px 0; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 12px; padding: 24px 32px 28px; }
.field { display: grid; gap: 8px; font: 500 13px/1.5 Inter, sans-serif; }
.field textarea { min-height: 96px; resize: vertical; }
.field-hint { font-size: 12px; color: hsl(var(--muted-foreground)); }
.avatar-edit { display: flex; align-items: center; gap: 20px; }
.avatar-edit .profile-avatar { --size: 88px; --radius: 14px; }
.avatar-edit-actions { display: grid; gap: 8px; justify-items: start; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 13px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: hsl(var(--accent)); }
@media (max-width: 767px) {
  .dialog-top { padding: 24px; }
  .dialog-top h2 { font-size: 34px; }
  .dialog-body { padding: 22px 24px 0; gap: 16px; }
  .dialog-actions { padding: 22px 24px 24px; }
  .dialog-actions .btn { flex: 1 1 100%; }
  .dialog-close { width: 48px; height: 48px; }
}

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 120; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 999px;
  background: hsl(var(--foreground)); color: hsl(var(--background)); font-size: 14px; box-shadow: 0 12px 28px rgb(0 0 0 / .2);
}
@media (max-width: 767px) { .toast { bottom: calc(80px + env(safe-area-inset-bottom)); } }

/* Скелет загрузки */
.skeleton { height: 140px; border-radius: 16px; background: linear-gradient(90deg, hsl(var(--card)) 25%, hsl(var(--secondary)) 50%, hsl(var(--card)) 75%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skeleton { animation: shimmer 1.4s linear infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Текущий раздел в общих навигациях */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* До 767 px: профиль → сторис → записи (DESIGN.md, «Компоненты в узком окне»). */
@media (max-width: 767px) {
  .blog-layout { display: flex; flex-direction: column; gap: 16px; }
  .blog-main, .blog-aside { display: contents; }
  #profileCard { order: 1; } #storiesPanel { order: 3; }
  #openComposer, #composer { order: 4; } #feedStatus, #feed, #morePosts { order: 5; } }

/* ---------- Видеосообщение (мессенджер): квадрат с мягкими углами, как в исходном проекте ---------- */
.video-message { width: 260px; max-width: 100%; margin-top: 8px; }
.video-message video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 18px; background: #171412; }
@media (max-width: 767px) { .video-message { width: 230px; } }
#profileCard { position:relative; }
.profile-portrait { display:grid; justify-items:center; gap:4px; flex:none; }
.profile-message { width:44px; height:44px; display:grid; place-items:center; border-radius:50%; color:#765529; }
.profile-message:hover,.profile-message:focus-visible { background:hsl(var(--secondary)); }
.profile-message[hidden] { display:none; }
#profileCard:has(.profile-edit:not([hidden])) .profile-head { padding-right:44px; }
.profile-edit { position:absolute; top:10px; right:10px; width:44px; height:44px; display:grid; place-items:center; padding:0; border:0; border-radius:50%; background:transparent; color:#765529; cursor:pointer; }
.profile-edit:hover,.profile-edit:focus-visible { background:hsl(var(--secondary)); }
.profile-edit[hidden],.profile-actions:not(:has(> :not([hidden]))),#feed:empty,#feedStatus:empty { display:none; }
