:root {
  --forest: #4c5d3f;
  --cream: #f8f4e9;
  --ink: #384630;
  --muted: #75935f;
  --danger: #a13d3d;
  --border: #e1ead9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}

header#nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--forest);
  color: white;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

header .brand {
  font-weight: 600;
  font-size: 1rem;
}

header nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

header nav a {
  color: white;
  text-decoration: none;
  opacity: 0.85;
  font-size: 0.95rem;
}

header nav a:hover {
  opacity: 1;
}

.link-btn {
  background: none;
  border: none;
  color: white;
  opacity: 0.85;
  font-size: 0.95rem;
  padding: 0;
  margin-left: auto;
  cursor: pointer;
}

main#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.centered {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

h1 {
  font-size: 1.3rem;
  margin: 0 0 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.65rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-family: inherit;
}

label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

label.checkbox input {
  width: auto;
  margin: 0;
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 1rem;
  padding: 0.9rem;
}

legend {
  padding: 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--forest);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn.primary {
  background: var(--forest);
  color: white;
}

.btn.secondary {
  background: var(--border);
  color: var(--ink);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn.small {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.btn.full-width {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.form-actions .btn {
  flex: 1;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.loading {
  color: var(--muted);
  padding: 2rem 0;
  text-align: center;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
}

.tabs a {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.tabs a.active {
  background: var(--forest);
  border-color: var(--forest);
  color: white;
}

ul.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.item-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}

.item-thumb.broken {
  opacity: 0;
}

.item-thumb.placeholder {
  background: linear-gradient(135deg, var(--border), var(--cream));
}

.item-title {
  font-weight: 600;
}

.item-meta {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: capitalize;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
  list-style: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.photo-thumb {
  position: relative;
}

.photo-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.photo-thumb-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: white;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-thumb-delete:disabled {
  opacity: 0.6;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.stat-card.highlight {
  background: var(--forest);
  color: white;
  border-color: var(--forest);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.stat-card.highlight .stat-label {
  color: rgba(255, 255, 255, 0.8);
}

.publish-card {
  margin-top: 1.25rem;
}

.publish-card h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}
