/* Profile page layout, components, and equal-height rules */

@import url('https://fonts.googleapis.com/css2?family=Great+Vibes&family=Merriweather&display=swap');

/* Global page baseline for profile pages */
body {
  margin: 0;
  padding: 0;
  background: url('../../dark\ paper.jpg') center/cover no-repeat fixed;
  font-family: 'Merriweather', serif;
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.05rem);
}
img, video { max-width: 100%; height: auto; display: block; }

/* Page grid and header */
.page-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  grid-template-rows: auto auto auto;
  row-gap: clamp(12px, 1vw, 20px);
  padding: 0 clamp(6px, 2vw, 16px) 24px;
  max-width: 1500px;
  width: min(100%, 1500px);
  margin: 0 auto;
  overflow-x: hidden;
}
@media (min-width: 1025px) {
  .page-grid {
    row-gap: 4px;
  }
}

#header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0,1fr) auto;
  grid-template-areas: 'left center right';
  align-items: center;
  padding: 16px 20px 0;
  gap: 16px;
  position: relative;
  z-index: 5;
}
#scroll {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--ink);
  user-select: none;
  margin-bottom: 0;
}
#scroll h1 {
  font-family: 'Great Vibes', cursive;
  font-size: clamp(2rem, 1.6rem + 2vw, 3.2rem);
  margin: 0;
  text-shadow: 2px 2px 8px var(--surface), 0 2px 12px var(--border);
  color: #000;
  border-bottom: 3px solid var(--border);
  padding-bottom: 3px;
  animation: scrollTitleUnroll .8s cubic-bezier(.8,0,.2,1) forwards;
  transform-origin: center;
}
@keyframes scrollTitleUnroll { 0%{opacity:0;transform:scaleX(0);} 10%{opacity:1;transform:scaleX(.1);} 100%{opacity:1;transform:scaleX(1);} }

.banner-buttons { display: contents; }
.banner-buttons-col { display:flex; gap:10px; align-items:center; }
.banner-buttons-col.left { grid-area:left; }
.banner-buttons-col.right { grid-area:right; justify-content:flex-end; }
.banner-buttons .pen-link-banner { display:flex; align-items:center; font-size:1.1rem; font-weight:700; color: var(--ink); text-decoration:none; }
.banner-buttons .pen-link-banner span { background: var(--surface); padding:4px 12px; border-radius:8px; box-shadow:1px 2px 4px var(--shadow-soft); color: var(--ink); border:1px solid var(--border); }
.banner-buttons .pen-link-banner:hover span { background: var(--accent); color: var(--accent-contrast); }

/* Content two-column grid on desktop; stack with sidebar below main on small screens */
#content-area {
  display:grid;
  grid-template-columns: minmax(0,1.85fr) minmax(280px,400px);
  column-gap: clamp(12px, 1.5vw, 26px);
  align-items:start;
}
body.profile-page #content-area {
  margin-top: 0;
}
@media (max-width:1024px){
  #content-area {
    display:flex;
    flex-direction:column;
    gap: 20px;
  }
  /* main first, comments after on smaller devices */
  #main { order: 1; }
  #right-sidebar { order: 2; }
}
body.profile-page .page-grid {
  row-gap: 0;
}
@media (max-width:1024px){
  body.profile-page .page-grid {
    row-gap: 0;
  }
}

/* Main profile panel */
#main { background: var(--surface); border-radius:12px; padding:24px 28px; box-shadow:0 2px 8px var(--shadow-soft), inset 0 0 10px var(--shadow-soft); display:flex; flex-direction:column; gap:24px; color: var(--ink); }
body.profile-page #main { margin-top: 0; }
#profile { display:flex; gap:24px; align-items:center; flex-wrap:wrap; }
#profile-pic-wrap { position:relative; display:inline-block; }
#profile-pic-upload-btn { 
  position:absolute; 
  right:6px; 
  bottom:6px; 
  width:40px; 
  height:40px; 
  border-radius:50%; 
  border:2px solid var(--accent); 
  background: var(--accent); 
  color: var(--accent-contrast); 
  font-size:1.2rem; 
  cursor:pointer; 
  box-shadow:0 2px 6px var(--shadow-soft); 
  display:flex; 
  align-items:center; 
  justify-content:center; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
}
#profile-pic-upload-btn:hover { 
  background: var(--accent-hover); 
  border-color: var(--accent-hover); 
  transform: scale(1.1); 
  box-shadow:0 4px 10px var(--shadow-med);
}
#profile-pic-upload-btn:active {
  transform: scale(1.0);
  box-shadow:0 2px 6px var(--shadow-soft);
}
#profile-pic-input { display:none; }
#profile-pic { width:120px; height:120px; border-radius:50%; object-fit:cover; box-shadow:0 0 10px var(--shadow-soft); border:3px solid var(--border); background: var(--surface) url('../../profile-placeholder.png') center/cover no-repeat; transition:border-color .25s ease, box-shadow .25s ease, transform .15s ease; }
#profile-pic.default-icon { background:none; }
#profile-pic.gilded-border {
  border-width:4px;
  border-style:double;
  border-color:#f5d37a;
  box-shadow:0 0 0 2px rgba(255,255,255,0.4), 0 0 18px rgba(245,211,122,0.9);
  transform:translateY(-1px);
}
#profile-info { flex:1; display:flex; flex-direction:column; gap:8px; }
#profile-info h2 { margin:0; font-family:'Great Vibes',cursive; font-size:2.8rem; color: var(--ink); display:flex; flex-wrap:wrap; align-items:baseline; gap:10px; }
#profile-info p { margin:0; font-weight:600; word-break:break-word; }

#profile-points {
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  background: var(--surface-2);
  border:1px solid var(--border);
  box-shadow: inset 0 0 4px var(--shadow-soft);
  font-family:'Merriweather',serif;
  font-size:0.8rem;
}
.points-drops::before { content:'4A7 '; }
.points-pots::before { content:'F9F6 '; }
.points-separator { opacity:0.7; }

/* Inline edit buttons */
.inline-edit-btn { 
  background: var(--accent); 
  color: var(--accent-contrast); 
  border: 2px solid var(--accent); 
  padding: 4px 12px; 
  border-radius: 16px; 
  font-weight: 700; 
  font-size: 0.75rem; 
  cursor: pointer; 
  font-family: 'Merriweather', serif; 
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1); 
  box-shadow: 0 2px 4px var(--shadow-soft); 
  margin-left: 8px; 
  text-transform: uppercase; 
  letter-spacing: 0.5px;
}
.inline-edit-btn:hover { 
  background: var(--accent-hover); 
  border-color: var(--accent-hover); 
  transform: translateY(-1px); 
  box-shadow: 0 4px 8px var(--shadow-med); 
}
.inline-edit-btn:active { 
  transform: translateY(0); 
  box-shadow: 0 1px 2px var(--shadow-soft); 
}
.inline-edit-btn:focus { 
  outline: 3px solid var(--focus-ring); 
  outline-offset: 2px; 
}
#toggle-stats-btn { 
  align-self:flex-start; 
  background: var(--accent); 
  color: var(--accent-contrast); 
  border:2px solid var(--accent); 
  padding:8px 16px; 
  border-radius:20px; 
  font-weight:700; 
  cursor:pointer; 
  box-shadow:0 2px 5px var(--shadow-soft); 
  font-family:'Merriweather',serif; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.9rem;
}
#toggle-stats-btn:hover { 
  background: var(--accent-hover); 
  border-color: var(--accent-hover); 
  transform: translateY(-2px); 
  box-shadow:0 4px 10px var(--shadow-med);
}
#toggle-stats-btn:active {
  transform: translateY(0);
  box-shadow:0 2px 5px var(--shadow-soft);
}

#profile-stats { background: var(--surface); border:1px solid var(--border); border-radius:12px; padding:18px 22px; box-shadow:0 2px 6px var(--shadow-soft), inset 0 0 6px var(--shadow-soft); }
.stat-list { list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:14px; }
.stat-list li { background: var(--surface-2); border-radius:10px; padding:10px 14px; min-width:150px; box-shadow:inset 0 0 4px var(--shadow-soft); display:flex; flex-direction:column; gap:4px; }
.stat-label { font-size:0.8rem; letter-spacing:0.05em; text-transform:uppercase; color: var(--ink-muted); }
.stat-value { font-size:1.1rem; font-weight:700; color: var(--accent); }

.post-header { margin-bottom:10px; }
.post-header .submission-title { margin-bottom:4px; }
.post-header .submission-snippet { margin:0; color: var(--ink-muted); font-style:italic; }

#social-media-icons { margin-top:6px; display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
#social-media-icons a { width:30px; height:30px; background: var(--border); color: var(--accent-contrast); border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-size:18px; transition:background .25s; text-decoration:none; }
#social-media-icons a:hover { background: var(--accent); color: var(--accent-contrast); }
#social-media-icons .friend-btn, #social-media-icons .share-btn { display:inline-flex; align-items:center; gap:6px; padding:6px 12px; background: var(--border); color: var(--accent-contrast); border:none; border-radius:16px; font-weight:700; font-size:.95rem; cursor:pointer; transition:background .25s, transform .08s; }
#social-media-icons .friend-btn:hover, #social-media-icons .share-btn:hover { background: var(--accent); }
#social-media-icons .friend-btn:active, #social-media-icons .share-btn:active { transform:translateY(1px); }
#social-media-icons .friend-btn.is-friend { background: var(--accent-strong); }
#social-media-icons .friend-btn.is-friend:hover { background: var(--accent); }
#social-media-icons .push-end { margin-left:auto; display:inline-flex; gap:8px; }

/* Submissions list */
#user-submissions { display:flex; flex-direction:column; gap:12px; }
#user-submissions-header { font-family:'Great Vibes',cursive; font-size:clamp(2rem,1.7rem + 1vw,2.4rem); margin:0 0 12px; border-bottom:2px solid var(--border); padding-bottom:6px; color: var(--ink); }
#user-submissions-list { list-style:none; margin:0; padding:0; }
#user-submissions-list li { background: var(--surface); border-radius:10px; padding:14px 18px; box-shadow:inset 0 0 4px var(--shadow-soft); margin-bottom:10px; cursor:pointer; outline:none; transition: box-shadow .25s, background .25s; border:1px solid var(--border); }
#user-submissions-list li:focus { box-shadow:0 0 0 3px var(--focus-ring); background: var(--surface-2); }
.submission-title { font-weight:700; font-size:1.1rem; margin:0 0 4px; color: var(--ink); }
.submission-snippet { font-style:italic; color: var(--ink-muted); margin:0; }

/* Sidebar (comments / AI) */
#right-sidebar { background: var(--surface); color: var(--ink); border-radius:12px; padding:24px 20px; box-shadow:0 2px 8px var(--shadow-soft), inset 0 0 8px var(--shadow-soft); display:flex; flex-direction:column; gap:16px; border:1px solid var(--border); }
#right-sidebar h3 { font-family:'Great Vibes',cursive; font-size:1.9rem; margin:0 0 8px; border-bottom:2px solid var(--border); padding-bottom:6px; color: var(--accent); }
#comments { flex:1 1 auto; min-height:0; overflow-y:auto; padding-right:6px; display:flex; flex-direction:column; gap:10px; background: var(--surface); border-radius:12px; padding: 8px 6px 12px; }

@media (max-width: 600px) {
  #right-sidebar {
    background: transparent;
    box-shadow: none;
    padding: 0;
    border: none;
  }

  #comments {
    background: var(--surface);
    border-radius: 16px;
    padding: 12px 10px 14px;
    margin-top: 8px;
    box-shadow: 0 2px 8px var(--shadow-soft);
  }

  #sidebar-title {
    margin: 0 4px -6px;
    padding: 10px 10px 0;
    background: var(--surface);
    border-radius: 16px 16px 0 0;
    position: relative;
    z-index: 1;
  }
}
.comment { background: var(--surface-2); padding:12px 16px; border-radius:16px; box-shadow:0 1px 3px var(--shadow-soft); border-left:4px solid var(--accent); max-width:90%; transition:transform .25s, box-shadow .25s; color: var(--ink); }
.comment:hover { box-shadow:0 2px 6px var(--shadow-med); transform:translateY(-1px); }
.comment.highlighted { background: var(--accent-contrast); box-shadow:0 0 12px var(--shadow-med),0 2px 8px var(--shadow-soft); border-left-color: var(--accent); }
.comment.me { align-self:flex-end; background: var(--accent-contrast); border-left-color: var(--accent); }
.comment-author { font-weight:700; margin-bottom:6px; color: var(--accent); font-size:.95rem; }
.comment-text { font-style:italic; color: var(--ink-muted); line-height:1.5; }

/* AI messages */
#ai-messages { flex:1 1 auto; min-height:0; overflow-y:auto; padding-right:6px; display:flex; flex-direction:column; gap:10px; }
.ai-msg { background: var(--surface-2); padding:12px 16px; border-radius:16px; box-shadow:0 1px 3px var(--shadow-soft); border-left:4px solid var(--accent); max-width:90%; transition:transform .25s, box-shadow .25s; }
.ai-msg:hover { box-shadow:0 2px 6px var(--shadow-med); transform:translateY(-1px); }
.ai-msg.me { align-self:flex-end; background: var(--accent-contrast); border-left-color: var(--accent); }
.ai-author { font-weight:700; margin-bottom:6px; color: var(--accent); font-size:.95rem; }
.ai-text { font-style:italic; color: var(--ink-muted); line-height:1.5; }

/* Reply UI (comments) */
.reply-box { margin-top:10px; display:grid; gap:8px; }
.reply-row { display:flex; gap:8px; min-width:0; align-items:stretch; }
.reply-input-wrap { position:relative; flex:1; display:flex; align-items:stretch; min-width:0; }
.reply-input-wrap input { 
  flex:1; 
  padding:11px 45px 11px 14px; 
  border-radius:25px 0 0 25px; 
  border:2px solid var(--border); 
  background: var(--surface-2); 
  font-family:'Merriweather',serif; 
  color: var(--ink); 
  font-size:.95rem; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  box-shadow: inset 0 1px 3px var(--shadow-soft);
}
.reply-input-wrap input:focus { 
  outline:none; 
  border-color: var(--accent); 
  box-shadow:0 0 0 3px rgba(var(--shadow-color) / 0.15), inset 0 1px 3px var(--shadow-soft); 
  background: var(--surface); 
}
.reply-input-wrap input::placeholder {
  color: var(--ink-muted);
  opacity: 0.7;
}
[id^="reply-toggle"] { 
  position:absolute; 
  right:8px; 
  top:50%; 
  transform:translateY(-50%); 
  background: var(--accent); 
  color: var(--accent-contrast); 
  border:2px solid var(--accent); 
  border-radius:8px; 
  padding:6px 12px; 
  cursor:pointer; 
  box-shadow:0 2px 4px var(--shadow-soft); 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  font-size:.9rem; 
  font-weight:700;
}
[id^="reply-toggle"]:hover { 
  background: var(--accent-hover); 
  border-color: var(--accent-hover); 
  transform:translateY(-50%) scale(1.08); 
  box-shadow:0 3px 6px var(--shadow-med);
}
[id^="reply-toggle"]:active {
  transform:translateY(-50%) scale(1.0);
  box-shadow:0 1px 3px var(--shadow-soft);
}
[id^="reply-suggestions"] { position:absolute; left:0; right:0; top:calc(100% + 6px); background: var(--surface); border:2px solid var(--border); border-radius:10px; box-shadow:inset 0 0 6px var(--shadow-soft), 0 4px 12px var(--shadow-soft); max-height:220px; overflow-y:auto; z-index:50; }
[id^="reply-suggestions"][hidden] { display:none; }
[id^="reply-suggestions"] .option { padding:8px 10px; cursor:pointer; border-bottom:1px dotted var(--border); }
[id^="reply-suggestions"] .option:last-child { border-bottom:none; }
[id^="reply-suggestions"] .option[aria-selected="true"], [id^="reply-suggestions"] .option:hover { background: var(--surface-2); }
[id^="reply-send"], #ai-send { 
  padding:11px 26px; 
  background: var(--accent); 
  border:2px solid var(--accent); 
  color: var(--accent-contrast); 
  font-weight:700; 
  border-radius:0 25px 25px 0; 
  cursor:pointer; 
  font-family:'Merriweather',serif; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  box-shadow:0 2px 5px var(--shadow-soft); 
  font-size:.95rem; 
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
[id^="reply-send"]:hover, #ai-send:hover { 
  background: var(--accent-hover); 
  border-color: var(--accent-hover); 
  transform:translateY(-2px); 
  box-shadow:0 4px 8px var(--shadow-med);
}
[id^="reply-send"]:active, #ai-send:active { 
  transform:translateY(0); 
  box-shadow:0 1px 3px var(--shadow-soft);
}
#ai-input { 
  flex:1; 
  padding:11px 14px; 
  border-radius:25px 0 0 25px; 
  border:2px solid var(--border); 
  background: var(--surface-2); 
  font-family:'Merriweather',serif; 
  color: var(--ink); 
  font-size:.95rem; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  box-shadow: inset 0 1px 3px var(--shadow-soft);
}
#ai-input:focus { 
  outline:none; 
  border-color: var(--accent); 
  box-shadow:0 0 0 3px rgba(var(--shadow-color) / 0.15), inset 0 1px 3px var(--shadow-soft); 
  background: var(--surface); 
}
#ai-input::placeholder { 
  color: var(--ink-muted); 
  opacity: 0.7;
}

/* Tabs */
#tab-switcher { display:flex; justify-content:space-between; gap:10px; background: var(--surface); border:2px solid var(--border); border-radius:14px; padding:8px; box-shadow:0 2px 5px var(--shadow-soft); margin-top:12px; }
.tab-btn { 
  flex:1; 
  background: var(--surface-2); 
  color: var(--ink); 
  border:2px solid var(--border); 
  border-radius:12px; 
  padding:10px 12px; 
  font-weight:700; 
  cursor:pointer; 
  box-shadow:0 1px 3px var(--shadow-soft); 
  display:inline-flex; 
  align-items:center; 
  justify-content:center; 
  gap:8px; 
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1); 
  font-family: 'Merriweather', serif;
}
.tab-btn:hover { 
  background: var(--accent); 
  color: var(--accent-contrast); 
  border-color: var(--accent); 
  transform:translateY(-2px); 
  box-shadow:0 3px 8px var(--shadow-med); 
}
.tab-btn:active {
  transform:translateY(0);
  box-shadow:0 1px 3px var(--shadow-soft);
}
.tab-btn.active { 
  background: var(--accent); 
  color: var(--accent-contrast); 
  border-color: var(--accent); 
  box-shadow:0 2px 6px var(--shadow-soft); 
}
.tab-btn:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
.tab-btn .badge { min-width:20px; height:20px; padding:0 6px; border-radius:10px; background: var(--danger); color: #fff; font-size:11px; font-weight:700; line-height:20px; display:none; }
.tab-btn.active .badge { background: var(--danger); border: 2px solid var(--accent); }

/* Scrollbars */
html, body, #comments, #ai-messages { scrollbar-width:thin; scrollbar-color: var(--border) var(--surface); }
html::-webkit-scrollbar, body::-webkit-scrollbar, #comments::-webkit-scrollbar, #ai-messages::-webkit-scrollbar { width:10px; }
html::-webkit-scrollbar-track, body::-webkit-scrollbar-track, #comments::-webkit-scrollbar-track, #ai-messages::-webkit-scrollbar-track { background: var(--surface); border-radius:10px; }
html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb, #comments::-webkit-scrollbar-thumb, #ai-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius:10px; border:2px solid var(--surface); }
html::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover, #comments::-webkit-scrollbar-thumb:hover, #ai-messages::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Tooltip used by profile page */
#ui-tooltip {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 6px 12px var(--shadow-soft), inset 0 0 4px var(--shadow-soft);
  pointer-events: none;
  font-size: .9rem;
  display: none;
}

/* Ensure equal-height columns on desktop */
#content-area {
  align-items: stretch; /* make both columns match height */
}
#main,
#right-sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}
#comments,
#ai-messages {
  flex: 1 1 auto;
  min-height: 0;
}

/* On mobile/tablet, allow natural heights and stacking */
@media (max-width: 1024px) {
  #main,
  #right-sidebar {
    height: auto;
  }
  #comments,
  #ai-messages { max-height: none; overflow: visible; flex: none; height: auto; min-height: auto; }
  #content-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 18px;
  }
}

/* Slight tune so tab switcher sits at bottom in sidebar when tall */
#right-sidebar { justify-content: flex-start; }

@media (max-width: 900px) {
  #content-area {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 20px;
  }
  #main { order: 1; }
  #right-sidebar {
    order: 2;
    display:flex;
    flex-direction:column;
    gap:12px;
    width:100%;
    border:1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 2px 8px var(--shadow-soft), inset 0 0 6px var(--shadow-soft);
    background: var(--surface);
  }
  #sidebar-title { order:1; background: transparent; }
  #comments { background: transparent; padding: 0; border-radius: 0; }
  #comments { order:2; }
  #ai-messages { order:3; }
  #reply-box { order:4; }
  #ai-input-box { order:5; }
  #tab-switcher { order:6; }
  #comments,
  #ai-messages,
  #reply-box,
  #ai-input-box,
  #tab-switcher {
    width: 100%;
    margin-top: 10px;
    flex: none;
  }
  #comments,
  #ai-messages {
    margin-top: 8px;
  }
  #tab-switcher {
    margin-bottom: 6px;
    align-self:stretch;
    flex-wrap:wrap;
  }
  .tab-btn {
    flex: 1 1 45%;
    min-width: 140px;
  }
}

/* Small-screen tweaks */
@media (max-width:768px){ 
  #header{padding:12px 12px 6px; gap:12px;} 
  #main{margin-top:0;} 
  #right-sidebar{padding:16px;} 
  #profile{flex-direction:column; align-items:stretch;} 
  #profile-info{width:100%;}
  body.profile-page .page-grid{padding-left:clamp(10px,4vw,18px); padding-right:clamp(10px,4vw,18px);} 
  body.profile-page #main{padding:26px 20px; margin-top:18px; width:100%;}
  body.profile-page #profile{width:100%;}
  #social-media-icons{gap:10px;} 
  #social-media-icons .push-end{flex-basis:100%; margin-left:0;} 
  #social-media-icons .friend-btn,#social-media-icons .share-btn{font-size:.85rem; padding:6px 10px;} 
  #profile {align-items:flex-start; }
  #profile-pic-wrap { width:120px; }
  #profile-pic-upload-btn { right:6px; bottom:6px; }
}
@media (max-width:600px){ 
   body{font-size:clamp(.9rem,.85rem + .5vw,1rem);} 
   #header{grid-template-columns:auto minmax(0,1fr) auto; padding:0; gap:8px;} 
   #scroll{margin:0; margin-bottom:0;}
   #scroll h1{font-size:clamp(1.6rem,1.2rem + 3vw,2rem); padding-bottom:2px; margin-bottom:0;}
  #profile-info h2{font-size:2.1rem;} 
  #right-sidebar,#main{padding:16px 12px;} 
  #right-sidebar { background: var(--surface); box-shadow: 0 2px 8px var(--shadow-soft); padding: 16px 10px 18px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; position: relative; z-index: 1; isolation: isolate; }
  #right-sidebar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--surface); z-index: -1; border-radius: 12px; }
  #right-sidebar #sidebar-title { background: transparent; border-bottom: none; padding: 0; margin: 0 0 8px 0; border: none; box-shadow: none; position: relative; z-index: 2; }
  #comments { background: transparent !important; padding: 0 !important; border-radius: 0 !important; box-shadow: none !important; margin-top: 0; position: relative; z-index: 2; }
  footer { margin: 60px 0 24px; font-size: 0.85rem; width: 100%; padding: 16px 12px; border-radius: 0; border-left: none; border-right: none; text-align: center; background: #ede2c7; color: #4b3b2b; border-top: 2px solid #bfa97c; }
  body.profile-page .page-grid{padding-left:8px; padding-right:8px;} 

  body.profile-page #main{padding:22px 16px;} 
  body.profile-page #profile{margin-left:-4px; margin-right:-4px;}
  #social-media-icons{width:100%; gap:10px;} 
  #social-media-icons .friend-btn{flex:1 0 100%; justify-content:center;} 
  /* Make profile section feel wider by reducing side padding influence */
  #main{width:100%;}
  /* Hide site title on mobile only */
  body.profile-page #scroll{display:none;}
  body.profile-page .page-grid{row-gap:0;}
}

/* Inline editing styles */
.inline-edit-active {
  position: relative;
  display: inline-block;
  width: 100%;
}

.inline-edit-input {
  width: 100%;
  padding: 8px 12px;
  font-family: 'Merriweather', serif;
  font-size: inherit;
  border: 2px solid var(--accent, #8b7355);
  border-radius: 6px;
  background: var(--surface, #fdf8f3);
  color: var(--ink, #2c2416);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  outline: none;
  transition: border-color 0.2s ease;
}

.inline-edit-input:focus {
  border-color: var(--accent-bright, #bfa97c);
  box-shadow: 0 2px 12px rgba(191, 169, 124, 0.3);
}

.inline-edit-textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.5;
}

.inline-edit-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.inline-edit-btn-save,
.inline-edit-btn-cancel {
  padding: 6px 16px;
  font-family: 'Merriweather', serif;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border, #d4c4a8);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.inline-edit-btn-save {
  background: var(--accent, #8b7355);
  color: var(--accent-contrast, #fff);
  border-color: var(--accent, #8b7355);
}

.inline-edit-btn-save:hover {
  background: var(--accent-bright, #bfa97c);
  border-color: var(--accent-bright, #bfa97c);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.inline-edit-btn-cancel {
  background: var(--surface, #fdf8f3);
  color: var(--ink, #2c2416);
}

.inline-edit-btn-cancel:hover {
  background: #e8e0d5;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.inline-edit-btn-save:active,
.inline-edit-btn-cancel:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Post card simplification: hide engagement until modal */
li.post .post-engagement { display: none; }
li.post .post-actions { display: none; }

/* Post footer with latest comment and reply button */
.post-footer {
  margin-top: 8px;
  padding: 8px 10px 10px;
  background: var(--surface, #fdf8f3);
  border: 1px solid var(--border, #d4c4a8);
  border-radius: 10px;
  box-shadow: 1px 2px 4px var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.post-footer .latest-comment {
  font-size: .85rem;
  color: var(--ink, #2c2416);
  line-height: 1.3;
  min-height: 1.2em;
}
.post-footer .open-post-btn {
  align-self: flex-end;
  padding: 6px 14px;
  font-size: .85rem;
  font-weight: 600;
  background: var(--accent, #8b7355);
  color: var(--accent-contrast, #fff);
  border: 1px solid var(--accent, #8b7355);
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
  transition: background .2s, transform .15s;
}
.post-footer .open-post-btn:hover { background: var(--accent-bright, #bfa97c); }
.post-footer .open-post-btn:active { transform: translateY(1px); }

/* Modal for full post */
#post-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 40px;
  z-index: 1000;
}
#post-modal {
  width: min(900px, 100% - 20px);
  background: var(--surface, #fdf8f3);
  border: 2px solid var(--border, #d4c4a8);
  border-radius: 16px;
  padding: 24px 26px 28px;
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}
/* show engagement inside modal */
#post-modal .post-engagement { display: block; }
#post-modal .post-actions { display: flex; }
#post-modal h3 {
  margin-top: 0;
  font-size: 1.6rem;
}
#post-modal .full-text {
  white-space: pre-wrap;
  line-height: 1.5;
  margin-bottom: 18px;
}
#post-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent, #8b7355);
  color: var(--accent-contrast, #fff);
  border: 1px solid var(--accent, #8b7355);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
}
#post-modal-close:hover { background: var(--accent-bright, #bfa97c); }

@media (max-width: 600px){
  #post-modal { padding: 18px 18px 24px; }
  #post-modal h3 { font-size: 1.3rem; }
}
