:root {
  --bg: #f3f1ea;
  --card: #fffdf7;
  --ink: #1f2a30;
  --muted: #607178;
  --accent: #1f7a8c;
  --ok: #2b9348;
  --warn: #cb7a00;
  --err: #bc4749;
  --line: #d9d6cb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f4ec 0%, #ecebe5 100%);
}

h1, h2, p { margin: 0; }

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.container {
  max-width: 1100px;
  margin: 1rem auto 2rem;
  padding: 0 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(31, 42, 48, 0.06);
}

.upload-card {
  padding: 1rem;
  margin-bottom: 1rem;
}

.upload-card form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.8rem;
}

.feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.admin-tools {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.photo-card {
  overflow: hidden;
  position: relative;
}

.photo-card.is-downloaded {
  opacity: 0.82;
}

.photo-open {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.photo-open img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.meta {
  padding: 0.7rem;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  font-size: 0.9rem;
}

.meta span { color: var(--muted); }

.inline-link {
  display: block;
  border-top: 1px solid var(--line);
  padding: 0.65rem 0.7rem;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}

.select-box {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 0.2rem;
}

.photo-status {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid var(--line);
}

.photo-status.new {
  color: var(--warn);
  border-color: #f0c581;
  background: #fff8eb;
}

.photo-status.done {
  color: var(--ok);
  border-color: #9dd8af;
  background: #effaf2;
}

.select-input {
  width: 1.1rem;
  height: 1.1rem;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

button.ghost {
  background: #fff;
  color: var(--accent);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid;
}

.flash.success {
  color: var(--ok);
  border-color: #86d39d;
  background: #ebf8ef;
}

.flash.error {
  color: var(--err);
  border-color: #f3a3a4;
  background: #fdebec;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  padding: 1rem;
  display: grid;
  gap: 0.7rem;
}

.auth-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: #fff;
}

dialog {
  border: 0;
  padding: 0.6rem;
  border-radius: 12px;
  max-width: min(92vw, 900px);
}

dialog img {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
