/* === CSS Reset === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #ffffff;
  color: #262626;
  line-height: 1.5;
  min-height: 100vh;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  text-decoration: none;
  color: #00376b;
}

/* === Toolbar === */
.view-toggle-float {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  border: 1px solid #dbdbdb;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.toggle-btn {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #8e8e8e;
  background: #ffffff;
  transition: background 0.2s, color 0.2s;
}

.toggle-btn.active {
  background: #0095f6;
  color: #ffffff;
}

/* === Shell === */
.ig-shell {
  margin: 0 auto;
  padding: 30px 0 60px;
  background: #ffffff;
  min-height: 100vh;
  transition: max-width 0.3s ease;
}

.ig-shell[data-view="desktop"] {
  max-width: 935px;
}

.ig-shell[data-view="mobile"] {
  max-width: 375px;
}

/* === Profile Header — Desktop === */
.ig-shell[data-view="desktop"] .profile-header {
  display: flex;
  flex-direction: row;
  gap: 80px;
  padding: 30px 16px 20px;
}

.ig-shell[data-view="desktop"] .profile-pic-wrapper {
  flex-shrink: 0;
  width: 150px;
  display: flex;
  justify-content: center;
  position: relative;
}

/* Gradient ring */
.profile-pic-gradient-ring {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-pic-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #ffffff;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.profile-pic-gradient-ring-mobile {
  width: 83px;
  height: 83px;
}

.profile-pic-inner-mobile {
  width: 100%;
  height: 100%;
}

.ig-shell[data-view="desktop"] .profile-pic {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  background: #efefef;
  cursor: pointer;
}

/* Profile pic placeholder */
.profile-pic-placeholder {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 50%;
  border: none;
  background: #efefef;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
}

.profile-pic-placeholder-mobile {
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border: none;
  position: absolute;
  top: 3px;
  left: 3px;
}

.profile-pic-placeholder.has-picture {
  display: none;
}

.ig-shell[data-view="desktop"] .profile-info {
  flex: 1;
}

/* Hide mobile-only pic in desktop */
.ig-shell[data-view="desktop"] .profile-pic-mobile {
  display: none;
}

/* === Profile Header — Mobile === */
.ig-shell[data-view="mobile"] .profile-header {
  display: flex;
  flex-direction: column;
  padding: 16px 16px 0;
}

.ig-shell[data-view="mobile"] .profile-header > .profile-pic-wrapper {
  display: none;
}

.ig-shell[data-view="mobile"] .profile-info {
  display: grid;
  grid-template-columns: 83px 1fr;
  grid-template-rows: auto auto;
  gap: 0 16px;
}

.ig-shell[data-view="mobile"] .profile-top-row {
  display: contents;
}

.ig-shell[data-view="mobile"] .profile-pic-mobile {
  grid-row: 1;
  grid-column: 1;
  align-self: center;
  position: relative;
}

.ig-shell[data-view="mobile"] .profile-pic-mobile-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  background: #efefef;
  cursor: pointer;
}

/* Hide username on mobile (shown in toolbar instead) */
.ig-shell[data-view="mobile"] .profile-top-row .username {
  display: none;
}

.ig-shell[data-view="mobile"] .username-more {
  display: none;
}

.ig-shell[data-view="mobile"] .profile-stats {
  grid-row: 1;
  grid-column: 2;
  align-self: center;
  font-size: 14px;
  gap: 0;
  margin: 0;
  justify-content: space-around;
}

.ig-shell[data-view="mobile"] .profile-bio,
.ig-shell[data-view="mobile"] .profile-actions {
  grid-column: 1 / -1;
}

/* === Username === */
.username {
  font-size: 22px;
  font-weight: 400;
  line-height: 1.4;
}

.profile-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.username-more {
  cursor: pointer;
  color: #262626;
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.username-more:hover {
  opacity: 0.6;
}

/* === Category Label === */
.category-label {
  font-size: 14px;
  color: #8e8e8e;
  line-height: 1.4;
  font-weight: 400;
}

/* === Profile Stats === */
.profile-stats {
  display: flex;
  flex-direction: row;
  gap: 40px;
  margin: 20px 0;
  font-size: 16px;
}

.stat {
  color: #262626;
}

.stat-count {
  font-weight: 600;
}

.stat-label {
  font-weight: 400;
}

/* === Bio === */
.profile-bio {
  margin-bottom: 16px;
}

.display-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.4;
}

.bio-text {
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.website-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: #00376b;
  line-height: 1.4;
}

.website-link::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23262626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.threads-handle {
  font-size: 14px;
  color: #8e8e8e;
  line-height: 1.4;
}

/* === Profile Actions === */
.profile-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.action-btn {
  flex: 1;
  padding: 7px 16px;
  background: #efefef;
  color: #262626;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  text-align: center;
  transition: background 0.15s;
}

.action-btn:hover {
  background: #dbdbdb;
}

/* Mobile bio full width */
.ig-shell[data-view="mobile"] .profile-bio {
  width: 100%;
  margin-top: 12px;
}

/* Mobile action buttons: full width, smaller padding */
.ig-shell[data-view="mobile"] .profile-actions {
  margin-top: 12px;
}

.ig-shell[data-view="mobile"] .action-btn {
  padding: 5px 8px;
  font-size: 13px;
}

/* === Highlights === */
.highlights {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.highlights::-webkit-scrollbar {
  display: none;
}

.highlight-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  cursor: pointer;
}

.highlight-circle {
  width: 77px;
  height: 77px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.highlight-circle-new {
  border: 2px dashed #c7c7c7;
}

.highlight-plus {
  font-size: 32px;
  font-weight: 300;
  color: #8e8e8e;
  line-height: 1;
}

.highlight-label {
  font-size: 12px;
  color: #262626;
  max-width: 75px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Highlight with gradient ring */
.highlight-circle.has-story {
  border: none;
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  padding: 2px;
}

.highlight-circle.has-story img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid #ffffff;
  object-fit: cover;
}

/* === Tab Bar === */
.tab-bar {
  display: flex;
  justify-content: center;
  border-top: 1px solid #dbdbdb;
  padding: 0;
  gap: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 24px;
  color: #8e8e8e;
  border-top: 1px solid transparent;
  margin-top: -1px;
  transition: color 0.15s;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.tab-btn.active {
  color: #262626;
  border-top-color: #262626;
}

.tab-btn:hover {
  color: #262626;
}

.tab-label {
  display: none;
}

.ig-shell[data-view="desktop"] .tab-label {
  display: inline;
}

/* === Grid — Desktop === */
.ig-shell[data-view="desktop"] .grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0;
}

/* === Grid — Mobile === */
.ig-shell[data-view="mobile"] .grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 0;
}

/* === Grid Items === */
.grid-item {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  position: relative;
  background: #efefef;
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Grid hover overlay */
.grid-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.15s;
  pointer-events: none;
}

.grid-item:hover::after {
  background: rgba(0, 0, 0, 0.3);
}

/* Grid slot cursors */
.grid-item {
  cursor: pointer;
}

.grid-item.dragging {
  cursor: grabbing;
}

/* Grid empty slot */
.grid-slot-empty {
  aspect-ratio: 1 / 1;
  border: 2px dashed #dbdbdb;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.grid-slot-empty:hover {
  border-color: #8e8e8e;
  background: #efefef;
}

/* Drag-over feedback */
.grid-item.drag-over,
.grid-slot-empty.drag-over {
  outline: 2px solid #0095f6;
  outline-offset: -2px;
  background: rgba(0, 149, 246, 0.05);
}

/* Drag visual feedback */
.grid-item.dragging {
  opacity: 0.4;
}

.grid-item.drag-target,
.grid-slot-empty.drag-target {
  outline: 2px solid #0095f6;
  outline-offset: -2px;
}

/* Remove button on filled slots */
.grid-item-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
  border: none;
  z-index: 2;
}

.grid-item:hover .grid-item-remove {
  opacity: 1;
}

.grid-slot-empty::after {
  content: "+";
  font-size: 28px;
  font-weight: 300;
  color: #8e8e8e;
}

/* === Contenteditable === */
[contenteditable] {
  outline: none;
  border-radius: 4px;
  transition: background 0.15s;
}

[contenteditable]:hover {
  background: rgba(0, 0, 0, 0.04);
}

[contenteditable]:focus {
  background: rgba(0, 0, 0, 0.04);
}

/* === Grid Controls === */
.grid-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 20px 0;
}

.control-btn {
  padding: 8px 20px;
  background: #efefef;
  color: #262626;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.15s;
}

.control-btn:hover {
  background: #dbdbdb;
}

/* === Grid Empty State === */
.grid-empty-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #8e8e8e;
  font-size: 14px;
  text-align: center;
}

/* === Mobile Top Bar === */
.mobile-top-bar {
  display: none;
}

.ig-shell[data-view="mobile"] .mobile-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #dbdbdb;
  background: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
}

.mobile-back-btn {
  font-size: 24px;
  font-weight: 300;
  color: #262626;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: 28px;
  text-align: left;
}

.mobile-top-username {
  font-size: 16px;
  font-weight: 600;
  color: #262626;
}

.mobile-top-spacer {
  width: 28px;
}

/* === Mobile Bottom Navigation === */
.mobile-bottom-nav {
  display: none;
}

.ig-shell[data-view="mobile"] .mobile-bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 375px;
  max-width: 100%;
  height: 50px;
  background: #ffffff;
  border-top: 1px solid #dbdbdb;
  z-index: 100;
}

.bottom-nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: #262626;
  background: none;
  border: none;
  cursor: pointer;
}

.bottom-nav-profile svg {
  stroke-width: 2.5;
}

/* Add bottom padding to shell in mobile so content isn't hidden behind bottom nav */
.ig-shell[data-view="mobile"] {
  padding-bottom: 70px !important;
}

/* === Stacked Stats (mobile) === */
.ig-shell[data-view="mobile"] .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.ig-shell[data-view="mobile"] .stat .stat-count {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  display: block;
}

.ig-shell[data-view="mobile"] .stat .stat-label {
  font-size: 13px;
  font-weight: 400;
  color: #262626;
  line-height: 1.2;
  display: block;
}

/* === Post Detail Modal === */
.post-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-modal-close {
  position: fixed;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  z-index: 1001;
  line-height: 1;
}

/* Desktop modal: side by side */
.post-modal {
  display: flex;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  max-width: 960px;
  max-height: 90vh;
  width: 90vw;
}

.post-modal .post-modal-image {
  flex: 1.2;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.post-modal .post-modal-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 90vh;
}

.post-modal .post-modal-info {
  width: 335px;
  min-width: 335px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #efefef;
}

.post-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #efefef;
}

.post-modal-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #efefef;
}

.post-modal-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-modal-avatar-placeholder {
  width: 100%;
  height: 100%;
  background: #dbdbdb;
}

.post-modal-username {
  font-weight: 600;
  font-size: 14px;
  color: #262626;
}

.post-modal-dots {
  margin-left: auto;
  color: #262626;
  font-size: 16px;
  cursor: pointer;
  letter-spacing: 2px;
}

/* Comments area */
.post-modal-comments-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.post-comment {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.post-comment .post-modal-avatar {
  width: 32px;
  height: 32px;
}

.post-comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dbdbdb;
  flex-shrink: 0;
}

.post-comment-content {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: #262626;
}

.post-comment-user {
  font-weight: 600;
  color: #262626;
}

.post-comment-meta {
  font-size: 12px;
  color: #8e8e8e;
  margin-top: 4px;
}

.post-comment-like {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #8e8e8e;
  padding: 0;
  margin-top: 4px;
}

/* Actions bar */
.post-modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid #efefef;
}

.post-modal-actions svg {
  cursor: pointer;
  color: #262626;
}

.post-modal-actions-left {
  display: flex;
  gap: 16px;
}

.post-modal-likes {
  padding: 0 16px 4px;
  font-size: 14px;
  font-weight: 600;
  color: #262626;
}

.post-modal-date {
  padding: 0 16px 12px;
  font-size: 10px;
  color: #8e8e8e;
  text-transform: uppercase;
}

.post-modal-add-comment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid #efefef;
}

.post-modal-emoji {
  font-size: 24px;
  cursor: pointer;
}

.post-modal-add-comment input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: #262626;
}

.post-modal-add-comment input::placeholder {
  color: #8e8e8e;
}

.post-modal-publish {
  background: none;
  border: none;
  color: #0095f6;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.3;
}

/* Mobile modal: stacked */
.post-modal.mobile {
  flex-direction: column;
  max-width: 375px;
  width: 100%;
  max-height: 95vh;
  overflow-y: auto;
  border-radius: 0;
}

.post-modal-overlay.mobile {
  background: rgba(0, 0, 0, 0.4);
}

.post-modal-overlay.mobile .post-modal-close {
  display: none;
}

.post-modal.mobile .post-modal-image {
  width: 100%;
  aspect-ratio: 1/1;
  flex: none;
}

.post-modal.mobile .post-modal-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-modal-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #efefef;
  font-weight: 600;
  font-size: 16px;
}

.post-modal-back {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #262626;
  line-height: 1;
  padding: 0;
}

.post-modal-mobile-author {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}

.post-modal-mobile-author .post-modal-dots {
  margin-left: auto;
}

.post-modal.mobile .post-modal-actions {
  border-top: none;
  padding: 6px 12px;
}

.post-modal-caption {
  padding: 0 16px 4px;
  font-size: 14px;
  line-height: 1.4;
  color: #262626;
}

.post-modal-caption strong {
  font-weight: 600;
}

.post-modal-more {
  color: #8e8e8e;
  cursor: pointer;
}

.post-modal-view-comments {
  padding: 4px 16px;
  font-size: 14px;
  color: #8e8e8e;
  cursor: pointer;
}

.post-modal.mobile .post-modal-date {
  padding: 4px 16px 12px;
}
