/* ================================================
   CosplayGram – Stile Instagram (tema chiaro)
   Replica fedele dei colori e layout di Instagram
   ================================================ */

:root {
  /* Palette Instagram autentica */
  --ig-bg:          #fafafa;   /* sfondo pagina */
  --ig-white:       #ffffff;   /* card/post */
  --ig-border:      #dbdbdb;   /* bordi */
  --ig-border-2:    #efefef;   /* bordi tenui */
  --ig-text:        #262626;   /* testo principale */
  --ig-muted:       #8e8e8e;   /* testo secondario */
  --ig-link:        #00376b;   /* link scuri */
  --ig-blue:        #0095f6;   /* blu azioni */
  --ig-blue-hover:  #1877f2;
  --ig-red:         #ed4956;   /* like */
  --ig-gradient:    linear-gradient(45deg,#feda75,#fa7e1e,#d62976,#962fbf,#4f5bd5); /* ring storie */

  --radius:    8px;
  --radius-lg: 12px;
  --nav-h:     54px;
  --bnav-h:    50px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: var(--ig-bg); color: var(--ig-text); font-family: var(--font);
  min-height: 100vh; padding-top: var(--nav-h); padding-bottom: var(--bnav-h);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; color: inherit; font: inherit; }
input, textarea { font: inherit; }
.hidden { display: none !important; }

/* ── Top navbar ──────────────────────────────── */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--ig-white);
  border-bottom: 1px solid var(--ig-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.nav-logo {
  font-size: 1.4rem; font-weight: 700; letter-spacing: -1px;
  font-family: var(--font); color: var(--ig-text);
  display: flex; align-items: center;
}
.nav-logo::before {
  content: ""; display: inline-block; width: 9px; height: 9px;
  border-radius: 50%; background: var(--ig-text); margin-right: 8px;
  flex-shrink: 0;
}
.nav-actions { display: flex; align-items: center; gap: 18px; }
.nav-icon-btn svg {
  width: 24px; height: 24px; stroke: var(--ig-text); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.nav-avatar-btn img {
  width: 26px; height: 26px; border-radius: 50%;
  object-fit: cover; border: 1px solid var(--ig-border);
}

/* ── Bottom nav (mobile) ─────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--bnav-h);
  background: var(--ig-white);
  border-top: 1px solid var(--ig-border);
  display: flex; align-items: center; justify-content: space-around;
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 0; color: var(--ig-text);
}
.bnav-item svg {
  width: 24px; height: 24px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.bnav-item span { display: none; }            /* Instagram mostra solo le icone */
.bnav-item.active svg { fill: var(--ig-text); stroke: var(--ig-text); }
.bnav-add svg { stroke: var(--ig-text); }
.bnav-item .nav-avatar-mini {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
}
.bnav-item.active .nav-avatar-mini { border: 2px solid var(--ig-text); }

/* ── Auth pages ──────────────────────────────── */
body.auth-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; min-height: 100vh; background: var(--ig-bg);
}
.auth-container { width: 100%; max-width: 350px; display: flex; flex-direction: column; gap: 10px; }
.auth-card {
  background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: 1px;
  padding: 40px 40px 24px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { display: none; }
.logo-text {
  font-size: 2.2rem; font-weight: 700; color: var(--ig-text);
  font-family: var(--font); letter-spacing: -1.5px;
}
.logo-sub { color: var(--ig-muted); font-size: .9rem; margin-top: 8px; font-weight: 600; }
.auth-switch {
  text-align: center; color: var(--ig-text); font-size: .9rem;
  padding: 20px; border-radius: 1px;
}
.auth-switch a, .auth-footer a { color: var(--ig-blue); font-weight: 600; }
.auth-divider {
  display: flex; align-items: center; gap: 16px; color: var(--ig-muted);
  font-size: .76rem; font-weight: 600; margin: 16px 0;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--ig-border); }
.auth-footer { text-align: center; color: var(--ig-text); font-size: .88rem; margin-top: 16px; }
.terms-note { color: var(--ig-muted); font-size: .76rem; text-align: center; margin: 8px 0 14px; line-height: 1.4; }

/* ── Form inputs ─────────────────────────────── */
.input-group { margin-bottom: 6px; }
.input-field {
  width: 100%; background: var(--ig-bg); border: 1px solid var(--ig-border);
  border-radius: 3px; padding: 9px 8px; color: var(--ig-text); font-size: .85rem;
}
.input-field:focus { outline: none; border-color: #a8a8a8; }
.input-field::placeholder { color: var(--ig-muted); }
textarea.input-field { resize: vertical; min-height: 72px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px; font-weight: 600; font-size: .87rem;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--ig-blue); color: #fff; }
.btn-primary:hover { background: var(--ig-blue-hover); }
.btn-primary:disabled { opacity: .4; cursor: default; }
.btn-outline { background: #efefef; color: var(--ig-text); }
.btn-outline:hover { background: #dbdbdb; }
.btn-full { width: 100%; padding: 8px; margin-top: 8px; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }

/* ── Alert ───────────────────────────────────── */
.alert { border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: .85rem; }
.alert-error { background: #fde8e8; border: 1px solid #f5b5b5; color: #c0392b; }
.alert p { margin-bottom: 3px; }

/* ── Feed layout ─────────────────────────────── */
.feed-layout { max-width: 470px; margin: 0 auto; padding: 0; }

/* ── Stories bar ─────────────────────────────── */
.stories-bar {
  background: var(--ig-white); border-bottom: 1px solid var(--ig-border);
  padding: 12px 0; margin-bottom: 12px; overflow: hidden;
}
@media (min-width:768px){
  .stories-bar { border: 1px solid var(--ig-border); border-radius: var(--radius); margin-top: 12px; }
}
.stories-scroll { display: flex; gap: 14px; overflow-x: auto; padding: 0 12px; scrollbar-width: none; }
.stories-scroll::-webkit-scrollbar { display: none; }
.story-item { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; flex-shrink: 0; }
.story-avatar-wrap {
  width: 62px; height: 62px; border-radius: 50%; padding: 2px;
  background: var(--ig-border);
}
.story-unseen { background: var(--ig-gradient); }
.story-avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--ig-white); }
.story-name { font-size: .72rem; color: var(--ig-text); max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-add-btn {
  position: absolute; bottom: -2px; right: -2px;
  background: var(--ig-blue); color: #fff; border-radius: 50%;
  width: 20px; height: 20px; font-size: .8rem; font-weight: 400;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--ig-white);
}
.story-add .story-avatar-wrap { position: relative; background: var(--ig-border); }

/* ── Post card ───────────────────────────────── */
.post-card {
  background: var(--ig-white); border-bottom: 1px solid var(--ig-border);
  margin-bottom: 12px;
}
@media (min-width:768px){
  .post-card { border: 1px solid var(--ig-border); border-radius: var(--radius); margin-bottom: 16px; }
}
.post-header { display: flex; align-items: center; padding: 8px 12px; justify-content: space-between; }
.post-user-link { display: flex; align-items: center; gap: 10px; }
.post-avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  padding: 2px; background: var(--ig-gradient);
}
.post-username { font-weight: 600; font-size: .85rem; display: flex; align-items: center; gap: 4px; color: var(--ig-text); }
.post-location { font-size: .76rem; color: var(--ig-text); }
.post-more-btn { color: var(--ig-text); font-size: 1.3rem; padding: 0 4px; line-height: 1; }
.verified { color: var(--ig-blue); font-size: .8rem; }

.post-image-wrap { position: relative; background: #000; }
.post-image { width: 100%; aspect-ratio: 1; object-fit: cover; user-select: none; }
.heart-anim {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) scale(0);
  font-size: 6rem; pointer-events: none; opacity: 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.3));
}
.heart-anim.pop { animation: heartPop .9s ease; }
@keyframes heartPop {
  0%   { transform: translate(-50%,-50%) scale(0);   opacity: 0; }
  15%  { transform: translate(-50%,-50%) scale(1.2); opacity: 1; }
  30%  { transform: translate(-50%,-50%) scale(.95); opacity: 1; }
  45%  { transform: translate(-50%,-50%) scale(1);   opacity: 1; }
  80%  { transform: translate(-50%,-50%) scale(1);   opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(1);   opacity: 0; }
}

.post-actions { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px; }
.post-actions-left { display: flex; gap: 14px; }
.action-btn svg {
  width: 24px; height: 24px; fill: none; stroke: var(--ig-text);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .1s;
}
.action-btn:active svg { transform: scale(.85); }
.like-btn.liked svg { fill: var(--ig-red); stroke: var(--ig-red); }
.save-btn.saved svg { fill: var(--ig-text); }

.post-likes { padding: 0 12px; font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.post-caption { padding: 0 12px 4px; font-size: .85rem; line-height: 1.4; word-break: break-word; }
.post-caption-user { font-weight: 600; margin-right: 5px; }
.post-time { display: block; padding: 4px 12px 12px; font-size: .68rem; color: var(--ig-muted); letter-spacing: .02em; text-transform: uppercase; }
.comments-preview { display: block; padding: 2px 12px; color: var(--ig-muted); font-size: .85rem; }

/* ── Cosplay chips (accento cosplay) ─────────── */
.cosplay-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  border-radius: 6px; padding: 3px 8px; font-size: .76rem; font-weight: 500;
  background: #f0f0f5; color: var(--ig-link);
}
.chip:hover { background: #e8e8f0; }
.chip-char   { color: #962fbf; }
.chip-fandom { color: #d62976; }
.chip-anime  { color: #4f5bd5; }
.chip-event  { color: #1f8a4c; }
.chips-small .chip { font-size: .72rem; padding: 2px 7px; }

/* ── Empty feed ──────────────────────────────── */
.empty-feed { text-align: center; padding: 60px 20px; color: var(--ig-muted); }
.empty-feed .empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.empty-feed h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--ig-text); }
.empty-feed a { color: var(--ig-blue); font-weight: 600; }

/* ── Explore ─────────────────────────────────── */
.explore-layout { max-width: 935px; margin: 0 auto; padding: 12px; }
.search-form { margin-bottom: 14px; }
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: #efefef; border-radius: var(--radius); padding: 0 12px; max-width: 100%;
}
.search-icon { width: 16px; height: 16px; fill: none; stroke: var(--ig-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.search-input { flex: 1; background: none; border: none; padding: 9px 0; color: var(--ig-text); outline: none; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 14px; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  border: 1px solid var(--ig-border); border-radius: 20px; padding: 6px 14px;
  font-size: .82rem; font-weight: 600; white-space: nowrap; color: var(--ig-text); flex-shrink: 0;
}
.filter-chip.active { border-color: var(--ig-text); background: var(--ig-text); color: #fff; }
.explore-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width:768px){ .explore-grid { gap: 4px; } }
.grid-item { position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer; background: #efefef; }
.grid-item img { width: 100%; height: 100%; object-fit: cover; }
.grid-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; gap: 22px;
  opacity: 0; transition: opacity .15s; font-weight: 700; color: #fff;
}
.grid-item:hover .grid-overlay { opacity: 1; }
.no-results { grid-column: 1/-1; text-align: center; padding: 50px 20px; color: var(--ig-muted); }
.no-results span { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.no-results a { color: var(--ig-blue); font-weight: 600; }

/* ── Profile ─────────────────────────────────── */
.profile-layout { max-width: 935px; margin: 0 auto; padding: 24px 16px; }
.profile-header { display: flex; gap: 30px; margin-bottom: 30px; align-items: center; }
.profile-avatar-wrap { position: relative; flex-shrink: 0; width: 150px; height: 150px; }
@media (max-width:600px){ .profile-avatar-wrap { width: 86px; height: 86px; } }
.profile-avatar-img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  padding: 3px; background: var(--ig-gradient);
}
.avatar-edit-btn {
  position: absolute; bottom: 4px; right: 4px;
  background: var(--ig-blue); border: 3px solid var(--ig-white); border-radius: 50%;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; cursor: pointer;
}
@media (max-width:600px){ .avatar-edit-btn { width: 26px; height: 26px; font-size: .72rem; } }
.profile-info { flex: 1; }
.profile-name-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.profile-username { font-size: 1.4rem; font-weight: 400; }
.profile-stats { display: flex; gap: 40px; margin-bottom: 18px; }
@media (max-width:600px){ .profile-stats { gap: 24px; } }
.profile-stat { font-size: .95rem; }
.profile-stat strong { font-weight: 600; }
.profile-stat span { color: var(--ig-muted); }
.profile-display-name { font-weight: 600; margin-bottom: 3px; font-size: .9rem; }
.profile-bio-text { font-size: .9rem; line-height: 1.4; }
.profile-website { color: var(--ig-link); font-size: .9rem; font-weight: 600; }

.profile-tabs { display: flex; justify-content: center; gap: 60px; border-top: 1px solid var(--ig-border); margin-bottom: 2px; }
.ptab {
  display: flex; align-items: center; gap: 6px; padding: 16px 0;
  font-size: .76rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ig-muted); border-top: 1px solid transparent; margin-top: -1px;
}
.ptab.active { color: var(--ig-text); border-top-color: var(--ig-text); }
.ptab svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }
.profile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
@media (min-width:768px){ .profile-grid { gap: 4px; } }

/* ── Upload ──────────────────────────────────── */
.upload-layout { max-width: 540px; margin: 0 auto; padding: 16px; }
.upload-card { background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: var(--radius-lg); overflow: hidden; }
.upload-title { font-size: 1rem; font-weight: 600; text-align: center; padding: 14px; border-bottom: 1px solid var(--ig-border); }
.upload-card .alert { margin: 14px; }
.drop-zone {
  border: none; min-height: 280px; position: relative; cursor: pointer;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--ig-white);
}
.drop-zone.drag-over { background: #f0f8ff; }
.drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2; }
.drop-label { text-align: center; color: var(--ig-text); pointer-events: none; }
.drop-icon { font-size: 3rem; display: block; margin-bottom: 14px; }
.drop-label p { font-size: 1.2rem; font-weight: 300; }
.drop-label small { font-size: .85rem; color: var(--ig-muted); }
.preview-image { width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.upload-fields { padding: 16px; }
.upload-section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ig-muted); margin: 16px 0 8px; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.upload-card .btn-full { margin: 0 16px 16px; width: calc(100% - 32px); }

/* Quality toggle */
.quality-box { margin: 14px 16px 0; padding: 12px 14px; background: var(--ig-bg); border: 1px solid var(--ig-border); border-radius: var(--radius); }
.quality-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quality-label { font-size: .85rem; font-weight: 600; }
.quality-hint { font-size: .75rem; color: var(--ig-muted); margin-top: 4px; line-height: 1.4; }
.quality-stats { font-size: .74rem; color: var(--ig-muted); margin-top: 8px; }
.quality-stats strong { color: var(--ig-text); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #ccc; border-radius: 24px; transition: .2s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--ig-blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ── Events ──────────────────────────────────── */
.events-layout { max-width: 640px; margin: 0 auto; padding: 16px; }
.events-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.events-header h2 { font-size: 1.2rem; font-weight: 600; }
.city-search-form { display: flex; gap: 8px; }
.city-input { max-width: 170px; margin: 0; }
.calendar-card { background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 20px; }
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.calendar-nav h3 { font-size: 1rem; font-weight: 600; }
.cal-nav-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: #efefef; border-radius: 8px; font-size: 1.1rem; }
.cal-nav-btn:hover { background: #dbdbdb; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day-header { text-align: center; font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--ig-muted); padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .85rem; position: relative; }
.cal-cell.has-events { cursor: pointer; }
.cal-cell.has-events:hover { background: #efefef; }
.cal-cell.today .cal-day-num { background: var(--ig-text); color: #fff; border-radius: 50%; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.cal-cell.has-events .cal-day-num { font-weight: 700; }
.cal-dots { display: flex; gap: 2px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; }
.dot-convention { background: #962fbf; }
.dot-competition { background: #d62976; }
.dot-meetup { background: #1f8a4c; }
.dot-photoshoot { background: #0095f6; }
.dot-workshop { background: #fa7e1e; }
.dot-parade { background: #f97316; }
.dot-other { background: var(--ig-muted); }
.day-group { margin-bottom: 20px; }
.day-label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ig-muted); margin-bottom: 8px; }
.event-card { background: var(--ig-white); border: 1px solid var(--ig-border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 10px; }
.event-badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 3px 9px; font-size: .72rem; font-weight: 700; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.badge-convention { background: #f3e8fb; color: #962fbf; }
.badge-competition { background: #fce4f0; color: #d62976; }
.badge-meetup { background: #e3f5ea; color: #1f8a4c; }
.badge-photoshoot { background: #e1f0fe; color: #0095f6; }
.badge-workshop { background: #fdeee0; color: #d9690f; }
.badge-parade { background: #fdeee0; color: #ea580c; }
.badge-other { background: #efefef; color: var(--ig-muted); }
.event-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.event-meta { font-size: .82rem; color: var(--ig-muted); margin-bottom: 6px; }
.event-desc { font-size: .85rem; color: var(--ig-text); margin-bottom: 8px; line-height: 1.4; }
.event-link { color: var(--ig-blue); font-size: .85rem; font-weight: 600; }
.event-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.event-attendees { font-size: .78rem; color: var(--ig-muted); margin-left: auto; }

/* ── Spinner ─────────────────────────────────── */
.spinner { text-align: center; padding: 20px; color: var(--ig-muted); font-size: .85rem; }
.spinner-ring {
  display: inline-block; width: 28px; height: 28px; border: 2px solid var(--ig-border);
  border-top-color: var(--ig-muted); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); }
.modal-content { position: relative; z-index: 1; background: var(--ig-white); border-radius: var(--radius); width: 100%; max-width: 900px; max-height: 90vh; overflow: hidden; }
.modal-loader { padding: 40px; text-align: center; color: var(--ig-muted); }
.modal-post-wrap { display: flex; height: min(82vh, 600px); }
.modal-image-col { flex: 0 0 58%; background: #000; }
.modal-image { width: 100%; height: 100%; object-fit: contain; }
.modal-info-col { flex: 1; display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid var(--ig-border); }
.modal-info-col .post-header { border-bottom: 1px solid var(--ig-border); }
.modal-comments-area { flex: 1; overflow-y: auto; padding: 14px; }
.modal-actions { padding: 8px 14px 4px; border-top: 1px solid var(--ig-border); }
.modal-close-btn { background: none; border: none; color: var(--ig-text); font-size: 1.3rem; cursor: pointer; padding: 4px; margin-left: auto; }
.comment-item { display: flex; gap: 12px; margin-bottom: 14px; align-items: flex-start; }
.comment-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.comment-body { font-size: .85rem; line-height: 1.4; flex: 1; }
.comment-user { font-weight: 600; margin-right: 5px; }
.comment-time { display: block; font-size: .72rem; color: var(--ig-muted); margin-top: 3px; }
.comment-form { display: flex; border-top: 1px solid var(--ig-border); padding: 10px 14px; gap: 8px; align-items: center; }
.comment-input { flex: 1; background: none; border: none; color: var(--ig-text); font-size: .88rem; outline: none; }
.comment-input::placeholder { color: var(--ig-muted); }
.btn-comment-send { color: var(--ig-blue); font-weight: 600; font-size: .88rem; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
  .modal { padding: 0; }
  .modal-content { max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
  .modal-post-wrap { flex-direction: column; height: 100vh; overflow-y: auto; }
  .modal-image-col { flex: 0 0 auto; }
  .modal-image { max-height: 50vh; }
  .modal-info-col { border-left: none; }
  .profile-header { gap: 20px; }
  .input-row { grid-template-columns: 1fr; }
}
@media (min-width: 768px) {
  .feed-layout { padding-bottom: calc(var(--bnav-h) + 24px); }
  /* La bottom nav resta visibile anche su desktop (richiesta) */
  .bottom-nav { max-width: 470px; margin: 0 auto; border: 1px solid var(--ig-border);
                border-bottom: none; border-radius: 12px 12px 0 0; }
}

/* ================================================
   ANIMAZIONI
   ================================================ */

/* Fade-in pagina */
body { animation: pageIn .35s ease; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

/* Post che entrano dal basso (stagger) */
.post-card { animation: cardUp .45s cubic-bezier(.22,.61,.36,1) both; }
.post-card:nth-child(1) { animation-delay: .02s; }
.post-card:nth-child(2) { animation-delay: .08s; }
.post-card:nth-child(3) { animation-delay: .14s; }
.post-card:nth-child(4) { animation-delay: .20s; }
.post-card:nth-child(n+5) { animation-delay: .24s; }
@keyframes cardUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Grid item entrata */
.grid-item { animation: gridIn .4s ease both; }
@keyframes gridIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

/* Hover post (desktop) */
@media (hover:hover) and (min-width:768px) {
  .post-card { transition: box-shadow .25s, transform .25s; }
  .post-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.08); transform: translateY(-2px); }
  .grid-item img { transition: transform .35s ease; }
  .grid-item:hover img { transform: scale(1.06); }
}

/* Pulsanti: feedback al tap */
.btn { transition: background .15s, transform .12s, opacity .15s; }
.btn:active { transform: scale(.96); }
.action-btn { transition: transform .15s; }
.action-btn:active svg { transform: scale(.8); }

/* Like: rimbalzo quando diventa rosso */
.like-btn.liked svg { animation: likePop .45s cubic-bezier(.17,.89,.32,1.49); }
@keyframes likePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.35); }
  60% { transform: scale(.85); }
  100% { transform: scale(1); }
}

/* Save bounce */
.save-btn.saved svg { animation: likePop .4s ease; }

/* Story ring: leggera pulsazione per le non viste */
.story-unseen { transition: transform .2s; }
.story-item:active .story-avatar-wrap { transform: scale(.92); }
.story-item { transition: transform .15s; }

/* Bottom nav: rimbalzo icona attiva */
.bnav-item svg, .bnav-item .nav-avatar-mini { transition: transform .2s; }
.bnav-item:active svg, .bnav-item:active .nav-avatar-mini { transform: scale(.82); }
.bnav-add { transition: transform .2s; }
.bnav-add:active { transform: scale(.9); }

/* Modal: fade + scale */
.modal:not(.hidden) { animation: fadeIn .2s ease; }
.modal-content { animation: modalUp .28s cubic-bezier(.22,.61,.36,1); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalUp {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Chip hover */
.chip { transition: background .15s, transform .12s; }
.chip:active { transform: scale(.94); }

/* Heart double-tap (già animato sopra con heartPop) */

/* Input focus glow */
.input-field { transition: border-color .2s, box-shadow .2s; }
.input-field:focus { box-shadow: 0 0 0 3px rgba(0,149,246,.12); }

/* Toggle switch smooth (già transizionato) */

/* Skeleton shimmer (per caricamenti) */
.skeleton {
  background: linear-gradient(90deg, #efefef 25%, #f7f7f7 50%, #efefef 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Comment item entrata */
.comment-item { animation: cardUp .3s ease both; }

/* Rispetta chi preferisce meno movimento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================================================
   STORY VIEWER (visualizzatore storie a schermo intero)
   ================================================ */
.story-viewer {
  position: fixed; inset: 0; z-index: 300;
  background: #000; display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.story-vimage { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-progress {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 3;
  display: flex; gap: 4px;
}
.story-progress .bar {
  flex: 1; height: 3px; background: rgba(255,255,255,.35); border-radius: 3px; overflow: hidden;
}
.story-progress .bar > i {
  display: block; height: 100%; width: 0; background: #fff; border-radius: 3px;
}
.story-progress .bar.done > i { width: 100%; }
.story-progress .bar.active > i { animation: storyBar 5s linear forwards; }
@keyframes storyBar { from { width: 0; } to { width: 100%; } }
.story-vheader {
  position: absolute; top: 22px; left: 12px; right: 12px; z-index: 3;
  display: flex; align-items: center; gap: 10px;
}
.story-vavatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.5); }
.story-vusername { color: #fff; font-weight: 600; font-size: .9rem; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.story-vclose { margin-left: auto; color: #fff; font-size: 1.4rem; background: none; padding: 4px 8px; }
.story-nav-left, .story-nav-right {
  position: absolute; top: 0; bottom: 0; width: 35%; z-index: 2; cursor: pointer;
}
.story-nav-left { left: 0; }
.story-nav-right { right: 0; }

/* Upload progress overlay */
.upload-progress {
  position: fixed; top: 0; left: 0; height: 3px; background: var(--ig-blue);
  z-index: 400; width: 0; transition: width .3s ease;
}
