:root {
  color-scheme: light;
  --bg: #f5f1e9;
  --panel: #fffdfa;
  --ink: #2f2a22;
  --muted: #685f52;
  --line: #d8cdbc;
  --primary: #1f6b58;
  --primary-dark: #165141;
  --soft: #e7f1ee;
  --danger: #a33123;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 17px;
  letter-spacing: 0;
}

button,
input,
textarea,
select,
a {
  font: inherit;
  letter-spacing: 0;
}

button,
a.button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

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

.app-shell {
  min-height: 100vh;
}

.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card,
.metadata-panel {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 50px rgb(47 42 34 / 10%);
}

.login-card {
  padding: 28px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 28px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.55rem;
}

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

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-weight: 700;
}

.field input,
.field textarea,
.search-input,
.choice-select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.search-input:focus,
.choice-select:focus,
button:focus-visible {
  outline: 4px solid rgb(31 107 88 / 22%);
  outline-offset: 2px;
}

.primary-button {
  width: 100%;
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  font-size: 1.15rem;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.error {
  color: var(--danger);
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgb(255 253 250 / 94%);
  backdrop-filter: blur(12px);
}

.topbar-inner,
.content,
.viewer-inner {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding-inline: 20px;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-block: 16px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.small-button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  text-decoration: none;
}

.content {
  padding-block: 20px 36px;
}

.controls {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tab.active,
.filter-pill.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.search-row {
  display: grid;
  gap: 10px;
}

.choice-select {
  max-width: 360px;
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-pill {
  padding: 0 16px;
}

.status {
  padding: 36px 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.photo-card {
  overflow: hidden;
  padding: 0;
  text-align: left;
  background: var(--panel);
  box-shadow: 0 8px 26px rgb(47 42 34 / 8%);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #ded7cc;
}

.photo-caption {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.photo-title,
.photo-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-title {
  font-weight: 800;
}

.photo-detail {
  color: var(--muted);
  font-size: 0.9rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
}

.pagination button,
.viewer-nav button {
  padding-inline: 20px;
  font-size: 1.1rem;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  background: var(--bg);
}

.viewer-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: rgb(255 253 250 / 96%);
}

.viewer-bar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-block: 12px;
}

.viewer-inner {
  display: grid;
  gap: 20px;
  padding-block: 20px 40px;
}

.viewer-photo {
  width: 100%;
  max-height: 72vh;
  border-radius: 8px;
  object-fit: contain;
  background: #ded7cc;
}

.viewer-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.metadata-panel {
  width: 100%;
  padding: 18px;
}

.filename {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-weight: 700;
}

.identify-box {
  margin-bottom: 18px;
  border: 1px solid rgb(31 107 88 / 35%);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}

.identify-box p {
  margin-bottom: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  font-weight: 700;
}

.check-row input {
  width: 24px;
  height: 24px;
}

.saved {
  margin-top: 12px;
  color: var(--primary);
  font-weight: 800;
}

@media (min-width: 720px) {
  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1020px) {
  .controls {
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    align-items: start;
  }

  .gallery-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .viewer-inner {
    grid-template-columns: minmax(0, 1fr) 380px;
    align-items: start;
  }
}

@media (min-width: 1260px) {
  .tabs {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .gallery-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
