@font-face {
  font-family: 'PressStart2P';
  src: url('/static/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-weight: normal; font-style: normal;
}

:root {
  --c-text: #e8e6e3;
  --c-accent: #d4a574;
  --c-bg: #111118;
  --c-surface: rgba(255,255,255,0.035);
  --c-border: rgba(255,255,255,0.06);
  --c-hover: rgba(255,255,255,0.07);
  --c-dim: rgba(255,255,255,0.38);
  --font-main: 'Outfit', system-ui, sans-serif;
  --font-retro: 'PressStart2P', monospace;
  --blur: 0px;
  --font-size: 16px;
  --sidebar-w: 340px;
  --avatar-border: #d4a574;
  --shell-max-w: 1200px;
}

*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size: var(--font-size); scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh; min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.font-retro {
  font-family: var(--font-retro);
  font-size: 0.82em;
  line-height: 1.8;
  letter-spacing: 0.5px;
}

/* ═══ Background ═══ */
.bg-layer {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
  pointer-events: none;
}
.bg-blur {
  position: fixed; inset: 0; z-index: 0;
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  pointer-events: none;
}

/* ═══ Top Controls (font size only) ═══ */
.top-controls {
  position: fixed; top: 0.75rem; right: 0.75rem;
  z-index: 100;
  display: flex; align-items: center; gap: 0.4rem;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 0.3rem 0.55rem;
}
.font-ctl-label {
  font-size: 0.58rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--c-dim); white-space: nowrap;
}
.font-ctl-btns { display: flex; gap: 0.1rem; }
.fs-btn {
  border: none; background: transparent;
  color: var(--c-dim); cursor: pointer;
  border-radius: 6px; padding: 0.2rem 0.35rem;
  font-family: inherit; transition: all 0.2s; line-height: 1;
}
.fs-btn[data-size="small"] { font-size: 0.68rem; }
.fs-btn[data-size="medium"] { font-size: 0.88rem; }
.fs-btn[data-size="large"] { font-size: 1.1rem; }
.fs-btn:hover { color: var(--c-text); background: var(--c-hover); }
.fs-btn.active { color: var(--c-accent); background: rgba(255,255,255,0.08); font-weight: 700; }

/* ═══ Shell — Desktop ═══ */
.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh; min-height: 100dvh;
  max-width: var(--shell-max-w);
  margin: 0 auto;
  transition: max-width 0.3s ease;
}
.shell.expanded { max-width: 100%; }

/* Hide content area if no visible panels */
.content:empty { display: none; }
.content.no-content { display: none; }

/* When no content, sidebar takes full width */
.shell.profile-only {
  grid-template-columns: 1fr;
  max-width: 600px;
}
.shell.profile-only .sidebar {
  border-right: none;
  height: auto;
  position: relative;
}

/* ═══ Sidebar ═══ */
.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  overflow-y: auto;
  border-right: 1px solid var(--c-border);
  padding: 2.5rem 1.5rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.sidebar-inner {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
}

/* Avatar */
.av-wrap { margin-bottom: 1.2rem; }
.av-frame {
  width: 110px; height: 110px;
  border: 3px solid var(--avatar-border);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.3s;
}
.av-frame.circle { border-radius: 50%; }
.av-frame.square { border-radius: 14px; }
.av-frame img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.22,1,0.36,1);
}
.av-frame:hover img { transform: scale(1.05); }

/* Name / Subtitle */
.pname {
  font-size: 1.35rem; font-weight: 700;
  line-height: 1.3; margin-bottom: 0.3rem;
  word-break: break-word;
}
.ptag {
  font-size: 0.8rem; color: var(--c-dim);
  font-weight: 400; line-height: 1.5;
  margin-bottom: 0.8rem; word-break: break-word;
}

/* Bio */
.pbio { width: 100%; text-align: left; }
.bio-md { font-size: 0.82rem; line-height: 1.7; color: rgba(255,255,255,0.72); }
.bio-md h1,.bio-md h2,.bio-md h3,.bio-md h4 {
  color: var(--c-text); margin: 0.8rem 0 0.3rem; font-weight: 600; line-height: 1.3;
}
.bio-md h1 { font-size: 1.1rem; }
.bio-md h2 { font-size: 0.95rem; }
.bio-md h3 { font-size: 0.88rem; }
.bio-md p { margin: 0.4rem 0; }
.bio-md ul,.bio-md ol { padding-left: 1.2rem; margin: 0.4rem 0; }
.bio-md li { margin: 0.15rem 0; }
.bio-md code {
  background: rgba(255,255,255,0.08);
  padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.85em;
  font-family: 'SF Mono','Fira Code','Consolas',monospace;
}
.bio-md pre {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--c-border); border-radius: 8px;
  padding: 0.75rem 1rem; overflow-x: auto; margin: 0.6rem 0;
}
.bio-md pre code { background:none; padding:0; }
.bio-md a { color: var(--c-accent); text-decoration:none; border-bottom: 1px solid rgba(212,165,116,0.3); transition: border-color 0.2s; }
.bio-md a:hover { border-color: var(--c-accent); }
.bio-md strong { color: var(--c-text); font-weight: 600; }
.bio-md blockquote { border-left: 3px solid var(--c-accent); padding-left: 0.85rem; margin: 0.5rem 0; opacity: 0.8; font-style: italic; }
.bio-md hr { border:none; border-top: 1px solid var(--c-border); margin: 0.8rem 0; }

/* ═══ Profile Social Links ═══ */
.profile-links {
  width: 100%; margin-top: 1rem; padding-top: 1rem;
  border-top: 1px solid var(--c-border);
  display: flex; flex-direction: column; gap: 0.3rem;
}
.profile-link {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.45rem 0.65rem; border-radius: 8px;
  text-decoration: none; color: var(--c-text);
  font-size: 0.78rem; font-weight: 500;
  transition: all 0.2s; background: var(--c-surface);
  border: 1px solid transparent;
}
.profile-link:hover { background: var(--c-hover); border-color: var(--c-border); transform: translateX(3px); }
.profile-link-icon { width: 18px; height: 18px; border-radius: 4px; object-fit: contain; flex-shrink: 0; opacity: 0.85; }
.profile-link-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-link-arrow { font-size: 0.6rem; color: var(--c-dim); opacity: 0; transition: all 0.2s; }
.profile-link:hover .profile-link-arrow { opacity: 1; transform: translateX(2px); }

/* ═══ Content Area ═══ */
.content { padding: 2rem 2rem 3rem; min-width: 0; }

/* Tabs */
.tabs {
  display: flex; gap: 0.15rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  overflow-y: hidden; /* Убиваем вертикальный скролл */
  scrollbar-width: none; /* Скрываем скроллбар в Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Скрываем скроллбар в Chrome/Edge/Safari */

.tab-btn {
  padding: 0.6rem 1.1rem; background: none; border: none;
  color: var(--c-dim); font-family: inherit;
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.2s; display: flex; align-items: center; gap: 0.35rem;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--c-text); }
.tab-btn.active { color: var(--c-accent); border-bottom-color: var(--c-accent); }
.tab-badge {
  font-size: 0.62rem; background: rgba(255,255,255,0.08);
  color: var(--c-dim); padding: 0.08rem 0.4rem; border-radius: 8px; font-weight: 600;
}

/* Panels */
.panels { display: flex; gap: 2rem; }
.panels.mode-tabs { flex-direction: column; gap: 0; }
.panels.mode-columns { flex-direction: row; align-items: flex-start; }
.panels.mode-columns .panel { flex: 1; min-width: 0; }
.panels.mode-columns .panel + .panel { border-left: 1px solid var(--c-border); padding-left: 2rem; }
.panel { animation: fadeIn 0.3s ease; }
.panel.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.panel-head {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--c-border);
}
.panel-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--c-dim); }
.panel-badge { font-size: 0.65rem; font-weight: 600; background: rgba(255,255,255,0.08); color: var(--c-dim); padding: 0.1rem 0.45rem; border-radius: 10px; }
.panels.mode-tabs .panel-head { display: none; }

/* ═══ Link Cards ═══ */
.links-list { display: flex; flex-direction: column; gap: 0.5rem; }
.link-card {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.9rem 1.1rem; border-radius: 12px;
  text-decoration: none; color: var(--c-text);
  background: var(--c-surface); border: 1px solid var(--c-border);
  transition: all 0.2s cubic-bezier(0.22,1,0.36,1); cursor: pointer;
  animation: cardSlide 0.45s ease-out backwards;
}
@keyframes cardSlide { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform: translateY(0); } }
.link-card:hover { background: var(--c-hover); border-color: rgba(255,255,255,0.12); transform: translateY(-1px); box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.link-icon { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; flex-shrink: 0; background: rgba(255,255,255,0.04); padding: 4px; }
.link-body { flex: 1; min-width: 0; }
.link-title { font-size: 0.88rem; font-weight: 600; line-height: 1.3; }
.link-desc { font-size: 0.72rem; color: var(--c-dim); margin-top: 0.15rem; line-height: 1.4; }
.link-arrow { font-size: 0.75rem; color: var(--c-dim); opacity: 0.4; transition: all 0.2s; }
.link-card:hover .link-arrow { opacity: 1; transform: translateX(3px); }

/* ═══ Feed Posts ═══ */
.feed-posts { display: flex; flex-direction: column; gap: 1rem; }
.post-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 14px; overflow: hidden;
  animation: cardSlide 0.45s ease-out backwards; transition: border-color 0.2s;
}
.post-card:hover { border-color: rgba(255,255,255,0.1); }
.post-card.pinned { border-color: var(--c-accent); }
.post-pin {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--c-accent); padding: 0.6rem 1rem 0;
}
.post-body { padding: 0.8rem 1rem 1rem; }
.post-body .bio-md { font-size: 0.82rem; }
.post-img { width: 100%; height: 200px; object-fit: cover; object-position: center 50%; display: block; }
.post-link {
  display: flex; flex-direction: column; gap: 0.15rem;
  margin: 0 1rem 0.8rem; padding: 0.55rem 0.8rem;
  border-radius: 8px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--c-border); text-decoration: none;
  color: var(--c-accent); font-size: 0.78rem; font-weight: 500; transition: all 0.2s;
}
.post-link-main { display: flex; align-items: center; gap: 0.3rem; }
.post-link-desc { font-size: 0.68rem; color: var(--c-dim); font-weight: 400; }
.post-link:hover { background: var(--c-hover); border-color: rgba(255,255,255,0.12); }
.post-links-wrap { display: flex; flex-direction: column; gap: 0.4rem; padding: 0 1rem 0.5rem; }
.post-links-wrap .post-link { margin: 0; }
.post-date { font-size: 0.65rem; color: var(--c-dim); padding: 0 1rem 0.7rem; }
.post-empty { text-align: center; padding: 2rem; color: var(--c-dim); font-size: 0.8rem; }

/* ═══════════════════════════════════
   DESKTOP / TABLET OVERRIDES
   ═══════════════════════════════════ */
@media (min-width: 769px) {
  .panels.mode-columns { flex-direction: row; align-items: flex-start; }
  .panels.mode-columns .panel { flex: 1; min-width: 0; }
  .panels.mode-columns .panel + .panel { border-left: 1px solid var(--c-border); padding-left: 2rem; }
  
  .panels.mode-columns .panel.hidden { display: block !important; }
  .tabs.hide-on-desktop { display: none !important; }
}

/* ═══════════════════════════════════
   MOBILE — stacked, sticky tabs
   ═══════════════════════════════════ */
@media (max-width: 768px) {
  .shell {
    display: flex !important;
    flex-direction: column;
    max-width: 100% !important;
  }
  .shell.profile-only { max-width: 100% !important; }

  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: 1.8rem 1.2rem 1.4rem;
  }

  .av-frame { width: 90px; height: 90px; }
  .pname { font-size: 1.2rem; }
  .ptag { font-size: 0.75rem; margin-bottom: 0.6rem; }
  .bio-md { font-size: 0.78rem; }

  .content { padding: 0 1rem 2.5rem; }

  /* Липкая шапочка с идеальным цветом фона */
  .tabs {
    position: sticky; top: -1px; z-index: 50;
    margin: 0 -1rem 1rem -1rem; 
    padding: 1rem 1rem 0.8rem 1rem;
    background: var(--c-bg); /* Идеально сливается с цветом фона */
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    -webkit-overflow-scrolling: touch;
    display: flex !important;
  }
  .tab-btn { padding: 0.55rem 0.9rem; font-size: 0.78rem; }

  /* Исправление ширины постов в Колонках на мобилке (stretch) */
  .panels.mode-columns { flex-direction: column; gap: 0; align-items: stretch; }
  .panels.mode-columns .panel + .panel {
    border-left: none; padding-left: 0; border-top: none; padding-top: 0;
  }
  .panel { width: 100%; }

  .link-card { padding: 0.75rem 0.9rem; gap: 0.7rem; }
  .link-icon { width: 32px; height: 32px; }
  .link-title { font-size: 0.82rem; }
  .post-img { /* height controlled inline */ }

  .top-controls {
    top: 0.5rem; right: 0.5rem;
    padding: 0.25rem 0.45rem;
  }
  .font-ctl-label { display: none; }
}

/* Small phones */
@media (max-width: 380px) {
  .sidebar { padding: 1.5rem 1rem 1.2rem; }
  .content { padding: 0 0.8rem 2rem; }
  .av-frame { width: 76px; height: 76px; }
  .pname { font-size: 1.1rem; }
  .tabs { margin: 0 -0.8rem 1rem -0.8rem; padding: 1rem 0.8rem 0.8rem 0.8rem; }
}