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

:root {
  --bg: #f9f9f9;
  --surface: #f0f0f0;
  --border: #e0e0e0;
  --text: #1a1a1a;
  --text-muted: #888888;
  --accent: #1a1a1a;
  --accent-hover: #000000;
  --danger: #cc4444;
  --danger-hover: #ee4444;
  --radius: 2px;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, monospace;
}

html { font-size: 16px; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

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

/* =========================================================
   Header
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: lowercase;
  color: var(--text);
}

.site-nav {
  display: flex;
  gap: 2rem;
}

.site-nav a {
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .08em;
  text-transform: lowercase;
  transition: color .15s;
}

.site-nav a:hover { color: var(--text); }

/* =========================================================
   Main
   ========================================================= */
.site-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  width: 100%;
}

/* =========================================================
   Flash messages
   ========================================================= */
.flash-container { margin-bottom: 1.5rem; }

.flash {
  background: #fffde7;
  border: 1px solid #e8e4c0;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  font-size: .78rem;
  letter-spacing: .03em;
  margin-bottom: .5rem;
}

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-block;
  padding: .5rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .78rem;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: .06em;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  text-align: center;
  text-transform: lowercase;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  border-color: var(--accent-hover);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

/* =========================================================
   Gallery grid
   ========================================================= */
.gallery-header {
  margin-bottom: 2rem;
}

.gallery-header h1 {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.photo-grid {
  columns: 3 260px;
  gap: .6rem;
}

.photo-card {
  display: block;
  break-inside: avoid;
  margin-bottom: .6rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: opacity .2s;
}

.photo-card:hover {
  opacity: .8;
}

.photo-card-img-wrap img,
.photo-card-img-wrap video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.photo-card-caption {
  padding: .45rem .6rem;
  font-size: .68rem;
  color: var(--text-muted);
  letter-spacing: .03em;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.photo-card-date {
  font-size: .63rem;
  letter-spacing: .06em;
}

/* =========================================================
   Photo detail
   ========================================================= */
.photo-detail {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 3rem;
}

.photo-detail-img-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: #e8e8e8;
}

.photo-detail-img-wrap img,
.photo-detail-img-wrap video {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

.photo-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: .25rem;
}

.photo-caption {
  font-size: .88rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}

.photo-date {
  font-size: .72rem;
  color: var(--text-muted);
  letter-spacing: .06em;
}

.delete-form { margin-top: auto; }

/* =========================================================
   Multi-photo badge (gallery)
   ========================================================= */
.photo-card-img-wrap {
  position: relative;
}

.multi-photo-badge {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(0,0,0,0.72);
  color: rgba(255,255,255,.8);
  font-size: .65rem;
  font-family: var(--mono);
  font-weight: 600;
  padding: .15rem .4rem;
  border-radius: var(--radius);
  pointer-events: none;
  letter-spacing: .05em;
}

/* =========================================================
   Carousel (photo detail)
   ========================================================= */
.carousel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: #e8e8e8;
  line-height: 0;
}

.carousel-track {
  display: flex;
  transition: transform 0.3s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
}

.carousel-slide img,
.carousel-slide video {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  font-size: 1rem;
  font-family: var(--mono);
  line-height: 1;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
  z-index: 2;
}

.carousel-btn:hover {
  background: rgba(0,0,0,0.8);
  color: #fff;
}

.carousel-prev { left: 0.75rem; }
.carousel-next { right: 0.75rem; }

.carousel-dots {
  position: absolute;
  bottom: .75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: .4rem;
  z-index: 2;
}

.carousel-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0,0,0,.2);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background .15s, transform .15s;
}

.carousel-dot.active {
  background: rgba(0,0,0,.8);
  transform: scale(1.4);
}

/* =========================================================
   Comments
   ========================================================= */
.comments-section { max-width: 580px; }

.comments-section h2 {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.comment-count {
  color: var(--text-muted);
  font-weight: 400;
}

.comment-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: 2rem;
}

.comment {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem .9rem;
}

.comment-content {
  position: relative;
}

.comment-author {
  font-weight: 600;
  font-size: .78rem;
  margin-bottom: .2rem;
  color: var(--text);
  letter-spacing: .04em;
}

.comment-body {
  font-size: .82rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.55;
}

.comment-date {
  font-size: .68rem;
  color: var(--text-muted);
  margin-top: .4rem;
  letter-spacing: .05em;
}

/* =========================================================
   Comment like / heart badge
   ========================================================= */
.comment-actions {
  position: absolute;
  top: 50%;
  right: .9rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: .5rem;
  z-index: 1;
}

.heart-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #e05555;
  font-size: 1.4rem;
  line-height: 1;
  user-select: none;
}

.heart-s {
  position: absolute;
  font-size: .55rem;
  font-weight: 700;
  color: #fff;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -52%);
  letter-spacing: 0;
  pointer-events: none;
}

.like-form { display: inline; }

.like-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: .72rem;
  cursor: pointer;
  padding: 0;
  letter-spacing: .04em;
  transition: color .15s;
}

.like-btn:hover { color: #e05555; }
.like-btn--active { color: #e05555; }

/* =========================================================
   Reply button & form
   ========================================================= */
.reply-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  cursor: pointer;
  padding: 0;
  margin-top: .4rem;
  text-transform: lowercase;
  transition: color .15s;
}

.reply-toggle:hover { color: var(--text); }

.reply-form {
  display: none;
  flex-direction: column;
  gap: .5rem;
  margin-top: .75rem;
  padding: .75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.reply-form--open { display: flex; }

.reply-form-actions {
  display: flex;
  gap: .5rem;
}

.reply-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-top: .75rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.comment-reply {
  background: var(--bg);
}

/* =========================================================
   Comment form
   ========================================================= */
.comment-form-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.comment-form-wrap h3 {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

/* =========================================================
   Shared form styles
   ========================================================= */
label {
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: .82rem;
  font-family: var(--mono);
  color: var(--text);
  transition: border-color .15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--text-muted);
}

textarea { resize: vertical; }

.optional {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: .7rem;
}

/* =========================================================
   Auth / Upload forms
   ========================================================= */
.auth-wrap,
.upload-wrap {
  max-width: 380px;
}

.auth-wrap h1,
.upload-wrap h1 {
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.auth-form,
.upload-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* =========================================================
   Empty / error states
   ========================================================= */
.empty-state {
  color: var(--text-muted);
  font-size: .78rem;
  padding: 2rem 0;
  letter-spacing: .04em;
}

.error-wrap {
  text-align: center;
  padding: 4rem 0;
}

.error-wrap h1 {
  font-size: 5rem;
  font-weight: 700;
  margin-bottom: .5rem;
  letter-spacing: -.02em;
  color: var(--text);
}

.error-wrap p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: .82rem;
}

/* =========================================================
   Footer
   ========================================================= */
.site-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: .68rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  letter-spacing: .1em;
  text-transform: lowercase;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 720px) {
  .photo-detail {
    grid-template-columns: 1fr;
  }

  .photo-grid {
    columns: 2 150px;
  }
}

@media (max-width: 400px) {
  .photo-grid {
    columns: 1;
  }
}
