/* PhotoStop — shared styles. Cloudflare-inspired light theme. */
:root {
  --bg: #f4f4f5;          /* page background */
  --panel: #ffffff;       /* cards, header, form panels */
  --panel-2: #fafafa;     /* input backgrounds, drop zone */
  --text: #1d1d1f;        /* primary text */
  --muted: #71717a;       /* secondary / hint text */
  --accent: #f6821f;      /* Cloudflare orange — primary buttons */
  --accent-2: #d96c10;    /* hover state */
  --link: #2563eb;        /* nav / inline links */
  --border: #e5e7eb;      /* card + input borders */
  --good: #15803d;        /* "from EXIF" hint, success status */
  --bad: #dc2626;         /* errors, delete button */
  --warn: #d97706;        /* "fill manually" hint */
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* Page header / nav */
.app-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.app-header h1 a {
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.app-header h1 a:hover { text-decoration: none; }
.brand-icon {
  width: 28px;
  height: 28px;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}
.app-nav { display: flex; gap: 16px; }
.app-nav a {
  color: var(--muted);
  font-weight: 500;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.app-nav a:hover { color: var(--text); text-decoration: none; }
.app-nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.app-spacer { flex: 1; }
.app-header .api-base { color: var(--muted); font-size: 12px; }

/* Forms */
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
textarea,
select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font: inherit;
  width: 100%;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
button {
  background: var(--accent);
  border: 0;
  color: white;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}
button:hover:not(:disabled) { background: var(--accent-2); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--panel); border: 1px solid var(--border); color: var(--text); }
button.secondary:hover:not(:disabled) { background: var(--panel-2); }
button.danger { background: var(--bad); }
button.danger:hover:not(:disabled) { background: #b91c1c; }

/* Layout */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.toolbar > div { min-width: 100px; }
#status, .status {
  color: var(--muted);
  margin-bottom: 16px;
  font-size: 13px;
}
.status.error { color: var(--bad); }
.status.ok { color: var(--good); }

/* Tile grid */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 6px rgba(15, 23, 42, 0.06), 0 10px 20px rgba(15, 23, 42, 0.08);
}
.card a.thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--panel-2);
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card .meta { padding: 12px 14px; }
.card .meta .name { font-weight: 600; margin-bottom: 2px; }
.card .meta .where {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ── Justified tile gallery (Flickr-style) ──────────────────────────── */
.tile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  /* a tiny last-row trick: the final flex item can over-grow if we don't
     rein it in. Acceptable — last row may end short. */
}
.tile {
  position: relative;
  height: 240px;
  overflow: hidden;
  background: var(--panel-2);
  text-decoration: none;
  color: white;
  /* default flex set inline per tile in JS once aspect ratio is known */
  flex: 1 1 240px;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.4s ease;
}
.tile img.loaded { opacity: 1; }
.tile:hover img { transform: scale(1.04); }
.tile:hover { text-decoration: none; }

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 14px 16px 12px;
  /* darken the bottom for white-text legibility, fade out toward the top */
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.70) 0%,
    rgba(0, 0, 0, 0.35) 35%,
    rgba(0, 0, 0, 0.00) 70%);
  color: #ffffff;
  pointer-events: none; /* clicks pass through to the <a> */
}
.tile-name {
  font-size: 15px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  letter-spacing: -0.005em;
  /* ellipsize long names on a single line */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-meta {
  font-size: 12px;
  margin-top: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  opacity: 0.92;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Distance badge: top-right corner pill, only visible if geolocation
   was granted (toggled via the `hidden` attribute in JS). */
.tile-distance[hidden] { display: none; }
.tile-distance {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  backdrop-filter: blur(2px);
  pointer-events: none;
}
@media (max-width: 600px) {
  .tile { height: 180px; }
}

/* Definition list (used on detail page) */
dl.exif {
  margin: 0;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 16px;
  font-size: 13px;
}
dl.exif dt { color: var(--muted); }
dl.exif dd { margin: 0; }

/* Detail layout */
.detail {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 24px;
  align-items: flex-start;
}
.detail .photo {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.detail .photo img {
  width: 100%;
  display: block;
  background: #f4f4f5;
}
.detail .info {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.detail .info h2 { margin: 0 0 4px; font-size: 18px; }
.detail .info .where { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
@media (max-width: 800px) { .detail { grid-template-columns: 1fr; } }

/* ── Detail v2 (locationscout-inspired layout) ────────────────────────── */
.detail-v2 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 24px;
  align-items: flex-start;
}
@media (max-width: 900px) { .detail-v2 { grid-template-columns: 1fr; } }

.detail-main { min-width: 0; }
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.title-row h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.01em;
  font-weight: 700;
}
.header-actions { display: flex; gap: 8px; }
.header-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
}
.header-actions button svg { display: block; }

.meta-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row a { color: var(--muted); }
.meta-row a:hover { color: var(--link); }

.photo-frame {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.photo-frame img {
  display: block;
  width: 100%;
  height: auto;
  background: #f4f4f5;
  cursor: zoom-in;
}

/* ── Lightbox overlay (click photo to view full) ────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 32px;
  animation: lightbox-fade 120ms ease-out;
}
@keyframes lightbox-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: default;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

.text-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.text-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}
.text-body { white-space: pre-wrap; line-height: 1.55; }

/* Empty state on the spot page when the id doesn't exist */
.empty-state {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
  max-width: 520px;
  margin: 32px auto;
}
.empty-state h2 { margin: 0 0 8px; font-size: 20px; }
.empty-state p { margin: 6px 0; color: var(--muted); }
.empty-link {
  display: inline-block;
  margin-top: 12px;
  font-weight: 500;
}

/* Sun-path map on the spot detail page */
.sun-map-section .sun-map-wrap {
  position: relative;
  height: 400px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.sun-map-section .sun-map {
  width: 100%;
  height: 100%;
}
.sun-legend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.sun-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}
/* Map / Satellite toggle (used in picker modal + sun-path map) */
.map-canvas, .sun-map { position: relative; }
.map-type-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  padding: 3px;
  display: flex;
  gap: 2px;
}
.map-type-toggle button {
  background: transparent;
  color: var(--text);
  border: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
}
.map-type-toggle button.active {
  background: var(--accent);
  color: #fff;
}
.map-type-toggle button:not(.active):hover { background: var(--panel-2); }

.sun-map-error {
  padding: 20px;
  color: var(--bad);
  font-size: 13px;
}

.detail-side { display: flex; flex-direction: column; gap: 16px; }
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 0;
  box-shadow: var(--shadow);
}
.info-card h4 {
  margin: 8px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.info-card .exif {
  padding: 4px 16px 12px;
  grid-template-columns: 110px 1fr;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: 0; }
.info-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  margin-top: 1px;
}
.info-body { flex: 1; min-width: 0; }
.info-label { font-size: 12px; color: var(--muted); margin-bottom: 1px; }
.info-value { font-size: 14px; }
.muted { color: var(--muted); }

/* Two-column row (e.g. Sunset / Sunrise side-by-side) */
.info-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
}
.info-pair:last-child { border-bottom: 0; }
.info-pair .cell {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  min-width: 0;
}
.info-pair .cell + .cell { border-left: 1px solid var(--border); }
@media (max-width: 480px) {
  .info-pair { grid-template-columns: 1fr; }
  .info-pair .cell + .cell { border-left: 0; border-top: 1px solid var(--border); }
}

/* ── Map picker modal (Leaflet + OSM) ─────────────────────────────────── */
.map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.map-modal {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.map-close {
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 22px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.map-close:hover { color: var(--text); }
.map-search {
  position: relative;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.map-search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--panel);
}
.map-search-results {
  position: absolute;
  top: calc(100% - 1px);
  left: 14px;
  right: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
  max-height: 240px;
  overflow-y: auto;
  z-index: 5;
}
.map-search-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.map-search-item:last-child { border-bottom: 0; }
.map-search-item:hover { background: var(--panel-2); }
.map-search-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
}

.map-area {
  flex: 1;
  position: relative;
  min-height: 400px;
  display: flex;
}
.map-canvas {
  flex: 1;
  min-height: 400px;
  /* MapKit takes full ownership of this element — no other children. */
  position: relative;
}
.map-hint {
  padding: 8px 18px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}
.map-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.map-coords {
  display: flex;
  gap: 16px;
  font-size: 13px;
}
.map-coords code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.map-actions { display: flex; gap: 8px; }

/* Edit layout on the spot page — photo stays visible above the form. */
.edit-layout {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.edit-layout .title-row { margin-bottom: 0; }
.edit-photo {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  /* cap photo height in edit mode so the form stays in view */
  max-height: 50vh;
  display: flex;
  justify-content: center;
}
.edit-photo img {
  display: block;
  max-width: 100%;
  max-height: 50vh;
  object-fit: contain;
  background: #f4f4f5;
}
.photo-caption {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: -8px;
}

/* Edit form on the spot page */
.edit-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.edit-form label { margin-top: 10px; }
.edit-form .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.edit-form .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* Upload page */
.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 480px);
  gap: 24px;
  align-items: flex-start;
}
@media (max-width: 800px) { .upload-layout { grid-template-columns: 1fr; } }
.preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.preview .drop {
  aspect-ratio: 4 / 3;
  background: var(--panel-2);
  border: 1px dashed #d4d4d8;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 12px;
  overflow: hidden;
}
.preview .drop img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fields {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  box-shadow: var(--shadow);
}
.fields .full { grid-column: 1 / -1; }
.field-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.field-hint.auto { color: var(--good); }
.field-hint.manual { color: var(--warn); }
.actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ── Header user widget ─────────────────────────────────────────── */
.header-signin {
  font-weight: 500;
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
}
.header-signin:hover { background: var(--accent); color: #fff; text-decoration: none; }

.user-menu { position: relative; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
}
.user-chip:hover { border-color: var(--accent); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.user-avatar-fallback {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.user-name { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 8px;
  min-width: 200px;
  z-index: 10;
}
.user-menu-email {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  word-break: break-all;
}
.user-menu-pop button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
.user-menu-pop button:hover { background: var(--panel-2); color: var(--bad); }

/* ── Login / sign-up page ───────────────────────────────────────── */
.auth-main {
  display: flex;
  justify-content: center;
  padding: 60px 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
}
.auth-card h2 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.auth-sub {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 14px;
}

.sso {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.sso:hover { border-color: #c7c7cc; background: var(--panel-2); }
.sso svg { flex: 0 0 auto; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span { text-transform: uppercase; letter-spacing: 0.08em; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 4px; }
.auth-field label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.auth-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font: inherit;
  color: var(--text);
}
.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.15);
}

.auth-error {
  font-size: 13px;
  color: var(--bad);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 12px;
}

.auth-submit {
  margin-top: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.auth-submit:hover { background: var(--accent-2); }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }

.auth-toggle {
  text-align: center;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.auth-toggle a { color: var(--link); font-weight: 500; }

/* :not([hidden]) so the `hidden` attribute actually wins — otherwise
   display:flex overrides it and the verify box shows on the sign-in form. */
.auth-verify:not([hidden]) { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.auth-verify h3 { margin: 0; }
.auth-verify input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font: 18px ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.4em;
  text-align: center;
}
.auth-verify input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.15);
}

/* ── Tile author link (clickable photographer name on gallery tiles) ──
   Rendered as <span> not <a> because HTML forbids nested anchors;
   index.html attaches a delegated click handler. */
.tile-author {
  color: inherit;
  cursor: pointer;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.5);
}
.tile-author:hover {
  color: #fff;
  border-bottom-color: #fff;
}

/* ── User menu "View profile" link ──────────────────────────────── */
.user-menu-link {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
}
.user-menu-link:hover { background: var(--panel-2); text-decoration: none; }

/* ── Profile page ───────────────────────────────────────────────── */
.profile-header {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 32px 24px 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  border: 3px solid var(--panel);
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.profile-avatar-fallback {
  background: var(--accent);
  color: #fff;
  font-size: 44px;
  font-weight: 600;
}
.profile-meta { flex: 1; min-width: 0; }
.profile-name {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.profile-handle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}
.profile-bio {
  margin: 8px 0 12px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  max-width: 640px;
  white-space: pre-wrap;
}
.profile-websites {
  margin-bottom: 12px;
  font-size: 13px;
}
.profile-websites a { color: var(--link); }
.profile-stats {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 12px;
}
.profile-stats strong { font-weight: 600; }
.profile-actions { margin-top: 4px; }

.profile-photos {
  padding: 0 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}
.profile-photos h3 {
  margin: 16px 0 12px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}
.empty-state-mini {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

/* ── Profile edit form ──────────────────────────────────────────── */
.profile-edit {
  max-width: 600px;
  margin: 32px auto;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.profile-edit h2 { margin: 0 0 20px; font-size: 22px; }
.profile-form { display: flex; flex-direction: column; gap: 6px; }
.profile-form label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 12px;
}
.profile-form input,
.profile-form textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  font: inherit;
  color: var(--text);
}
.profile-form textarea { resize: vertical; min-height: 80px; }
.profile-form input:focus,
.profile-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(246, 130, 31, 0.15);
}
.profile-form .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .profile-header { flex-direction: column; align-items: center; text-align: center; }
  .profile-bio { text-align: left; }
}
