* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: #f6f7f9;
  color: #1f2328;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #1f6feb;
  color: #fff;
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
}

.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.topbar nav a,
.topbar nav .user,
.topbar nav .linklike {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
}

.topbar nav .linklike {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.topbar nav a:hover,
.topbar nav .linklike:hover { text-decoration: underline; }

form.inline { display: inline; }

main {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 { margin-top: 0; }

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
.flash-ok    { background: #ddf4e6; color: #135b3a; }
.flash-error { background: #ffe1e1; color: #8a1f1f; }

.auth-form, .item-form {
  background: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 480px;
}
.item-form { max-width: 640px; }

.auth-form label,
.item-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  font-weight: 500;
  gap: 0.3rem;
}

.auth-form input,
.item-form input,
.item-form textarea,
.item-form select {
  padding: 0.5rem 0.65rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font: inherit;
}

.item-form fieldset {
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0.5rem 1rem;
}
.item-form fieldset legend {
  padding: 0 0.4rem;
  font-weight: 500;
  font-size: 0.9rem;
}
.item-form .radio {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
}

button, .auth-form button, .item-form button {
  background: #1f6feb;
  color: #fff;
  border: 0;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
button:hover { background: #1957c4; }
button.danger { background: #cf222e; }
button.danger:hover { background: #a40e1f; }

.filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters input[type=search] { flex: 1; min-width: 200px; padding: 0.45rem 0.6rem;
  border: 1px solid #d0d7de; border-radius: 6px; font: inherit; }
.filters select { padding: 0.45rem 0.6rem; border: 1px solid #d0d7de; border-radius: 6px; }

.items { list-style: none; padding: 0; margin: 0; }
.item-row {
  background: #fff;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.item-title { font-size: 1.05rem; font-weight: 600; color: #1f2328; text-decoration: none; }
.item-title:hover { text-decoration: underline; }
.item-meta { color: #57606a; font-size: 0.85rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.badge-lost     { background: #fff1d6; color: #92500a; }
.badge-found    { background: #d6f0ff; color: #0a4a92; }
.badge-resolved { background: #dcdcdc; color: #444; }

.item-detail { background: #fff; padding: 1rem 1.25rem; border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.item-detail dt { font-weight: 600; color: #57606a; font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.6rem; }
.item-detail dt:first-child { margin-top: 0; }
.item-detail dd { margin: 0.2rem 0 0; }

.owner-actions { margin-top: 1rem; display: flex; gap: 0.5rem; }

.empty { color: #57606a; }

/* image + thumbs + search */

.item-row-flex { display: flex; gap: 0.85rem; align-items: flex-start; }
.item-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.thumb {
  flex-shrink: 0;
  width: 72px; height: 72px;
  border-radius: 6px; overflow: hidden;
  background: #eef0f3; display: block;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

.item-image {
  margin: 0 0 1rem;
  text-align: center;
  background: #fff;
  padding: 0.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.item-image img { max-width: 100%; max-height: 480px; border-radius: 4px; }

.ai-tag { font-style: italic; color: #1f6feb; }

.hint { color: #57606a; font-size: 0.8rem; font-weight: 400; margin-top: 0.15rem; }
.muted { color: #57606a; }

.search-form {
  background: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 640px;
  margin-bottom: 1.5rem;
}
.search-form label {
  display: flex; flex-direction: column;
  font-size: 0.9rem; font-weight: 500; gap: 0.3rem;
}
.search-form textarea,
.search-form select,
.search-form input[type=file] {
  padding: 0.5rem 0.65rem;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font: inherit;
}

.badge-score { background: #e4f4ec; color: #135b3a; }
.match-reason { color: #57606a; font-size: 0.9rem; margin: 0.2rem 0 0; }

.kw {
  display: inline-block;
  background: #eef2ff;
  color: #3949ab;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  margin: 0 0.2rem 0.2rem 0;
  font-weight: 500;
}

.ai-preview {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.4rem;
  background: #f0f4ff;
  border: 1px dashed #b9c5e8;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #3949ab;
}
.ai-preview img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 4px; background: #fff;
}
button:disabled { opacity: 0.6; cursor: wait; }

footer {
  text-align: center;
  padding: 2rem 1rem 3rem;
  color: #8b949e;
}
