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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-2: #242424;
  --text: #e8e6e3;
  --text-muted: #9a9690;
  --accent: #c4a882;
  --border: #2e2e2e;
  --radius: 12px;
  --font-body: "Times New Roman", Times, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Profile Header (Tumblr-style) ===== */
.profile-header {
  position: relative;
  margin-bottom: 0;
}

.banner {
  height: 200px;
  background: linear-gradient(135deg, #1c1c1c 0%, #2a2520 50%, #1a1814 100%);
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--border);
}

.profile-info {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  transform: translateY(-40px);
  margin-bottom: 8px;
}

.avatar-wrapper {
  flex-shrink: 0;
  cursor: pointer;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  object-fit: cover;
  background: var(--surface);
  display: block;
}

.user-details {
  padding-bottom: 6px;
}

.username {
  font-family: var(--font-ui);
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  cursor: pointer;
}

.bio {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 2px;
  cursor: pointer;
}

/* ===== Navigation ===== */
.main-nav {
  max-width: 720px;
  margin: 0 auto 28px;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  padding-top: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.nav-btn.active {
  background: var(--nav-active-bg, #f0ece6);
  color: var(--nav-active-text, #111);
  font-weight: 600;
}

/* Hide the Write button completely */
#writeBtn {
  display: none !important;
}

/* ===== Views ===== */
.view {
  display: none;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.view.active {
  display: block;
}

/* ===== Posts (Journal) ===== */
.posts-container {
  display: flex;
  flex-direction: column;
  gap: 36px;
}

.post {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px 28px;
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.post:hover {
  border-color: #3a3a3a;
}

.post-content {
  font-family: var(--font-body);
  font-size: 1.12rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .hint {
  font-size: 0.9rem;
  margin-top: 8px;
  opacity: 0.7;
}

/* ===== Photos ===== */
.photos-toolbar {
  display: none; /* Hidden by default – secret */
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.photos-toolbar.visible {
  display: flex;
}

.subtle-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.subtle-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  cursor: grab;
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.photo-item:active {
  cursor: grabbing;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-item:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.photo-controls {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.photo-item:hover .photo-controls {
  opacity: 1;
}

.photo-btn {
  background: rgba(0,0,0,0.75);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.photo-btn:hover {
  background: rgba(0,0,0,0.95);
}

.replace-btn:hover {
  background: #4a7c59;
}

.remove-btn:hover {
  background: #a33;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(6px);
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.modal-content.small {
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.close-btn:hover {
  color: var(--text);
}

#postContent {
  width: 100%;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.7;
  padding: 24px;
  resize: vertical;
  min-height: 260px;
  outline: none;
}

#postContent::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

.cancel-btn, .submit-btn {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.cancel-btn {
  background: transparent;
  color: var(--text-muted);
}

.cancel-btn:hover {
  color: var(--text);
}

.submit-btn {
  background: var(--accent);
  color: var(--bg);
}

.submit-btn:hover {
  filter: brightness(1.1);
}

#photoInput {
  display: block;
  width: 100%;
  padding: 24px;
  color: var(--text-muted);
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .banner {
    height: 150px;
  }

  .profile-info {
    transform: translateY(-32px);
  }

  .avatar {
    width: 78px;
    height: 78px;
  }

  .username {
    font-size: 1.3rem;
  }

  .post {
    padding: 20px 18px;
  }

  .post-content {
    font-size: 1.05rem;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}
