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

:root {
  --bg:        #0f1117;
  --surface:   #1c1f2b;
  --border:    #2d3149;
  --text:      #e8eaf0;
  --muted:     #8b90a8;
  --accent:    #5b8af5;
  --c-taken:   #4caf7d;
  --c-upload:  #a78bfa;
  --c-archive: #5b8af5;
  --c-changed: #f5a623;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

main {
  max-width: 740px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* ── Header ── */
header { margin-bottom: 2.5rem; }

h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
}

header p {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 520px;
}

/* ── Search ── */
.search { margin-bottom: 0.75rem; }

.search form {
  display: flex;
  gap: 0.625rem;
}

.search input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.search input:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--muted); }

.search button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.7rem 1.4rem;
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.search button:hover:not(:disabled) { opacity: 0.88; }
.search button:disabled { opacity: 0.45; cursor: not-allowed; }

.hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.6rem;
}

.tag {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  margin-left: 0.2rem;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.tag.optional { opacity: 0.55; cursor: help; }

/* ── Utilities ── */
.hidden { display: none !important; }
.muted  { color: var(--muted); }

/* ── Loading ── */
.loading {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 2rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.error-box {
  background: #2d1515;
  border: 1px solid #5c2828;
  border-radius: 8px;
  color: #ff8080;
  font-size: 0.875rem;
  margin-top: 1.5rem;
  padding: 0.9rem 1.1rem;
}

/* ── Photo card ── */
.photo-card {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 2rem;
  padding: 1.1rem 1.25rem;
}

.photo-card img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--border);
}

.photo-meta h2 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.photo-meta p {
  font-size: 0.85rem;
}

.photo-meta a {
  color: var(--accent);
  font-size: 0.82rem;
  text-decoration: none;
  display: inline-block;
  margin-top: 0.45rem;
}

.photo-meta a:hover { text-decoration: underline; }

/* ── Sources row ── */
.sources-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.sources-row span:first-child { margin-right: 0.15rem; }

/* ── Timeline ── */
.timeline-section { margin-top: 1.75rem; }

.section-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.timeline-list {
  position: relative;
  padding-left: 1.75rem;
}

.timeline-list::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
  border-radius: 1px;
}

.timeline-event {
  position: relative;
  padding: 0.55rem 0 0.55rem 1rem;
}

.timeline-event::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  flex-shrink: 0;
}

.timeline-event.taken::before    { background: var(--c-taken);   }
.timeline-event.uploaded::before { background: var(--c-upload);  }
.timeline-event.archived::before { background: var(--c-archive); }
.timeline-event.changed::before  { background: var(--c-changed); }

.event-date {
  color: var(--muted);
  font-size: 0.775rem;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.1rem;
}

.event-label {
  font-size: 0.9rem;
  font-weight: 500;
}

.event-detail {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.1rem;
}

.event-link {
  color: var(--accent);
  font-size: 1rem;
  text-decoration: none;
  margin-left: 0.5rem;
  opacity: 0.85;
  vertical-align: middle;
}

.event-link:hover { opacity: 1; text-decoration: none; }

.no-history {
  color: var(--muted);
  font-size: 0.875rem;
  padding: 0.5rem 0;
}

/* ── Legend ── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .search form { flex-direction: column; }
  .photo-card  { flex-direction: column; }
  .photo-card img { width: 100%; height: 180px; }
}
