:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #2b2a27;
  --text-muted: #767268;
  --border: #e3e0d6;
  --accent: #3a3934;
  --accent-hover: #55534b;
  --danger: #8a4a3f;
  --success: #4a6a52;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

h1, h2, h3 {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

h1 { font-size: 1.4rem; margin: 0.4rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; }
h3 { font-size: 0.98rem; margin: 0.8rem 0 0.3rem; color: var(--text-muted); }

a { color: var(--accent); }

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

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

.nav {
  display: flex;
  gap: 0.9rem;
  overflow-x: auto;
  font-size: 0.85rem;
}

.nav a {
  text-decoration: none;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0.3rem 0.1rem;
  border-bottom: 2px solid transparent;
}

.nav a.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.9rem 0 0.3rem;
}

label:first-of-type { margin-top: 0; }

input[type="text"],
input[type="date"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}

textarea { resize: vertical; }

button {
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  margin-top: 1.3rem;
  padding: 0.75rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  min-height: 46px;
}

.btn-primary:active { background: var(--accent-hover); }

.btn-secondary {
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 44px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0.4rem 0;
  font-size: 0.85rem;
  text-decoration: underline;
}

.add-species-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.add-species-row input { flex: 1; }

.map {
  height: 240px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 0.4rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.3rem 0;
}

.error, .error-box { color: var(--danger); }
.success { color: var(--success); }

.login-wrap {
  max-width: 340px;
  margin: 3rem auto;
}

.filters .filter-row {
  display: flex;
  gap: 0.7rem;
}

.filters .filter-row > div { flex: 1; }

.group-block { margin-bottom: 1rem; }

.species-block {
  padding: 0.4rem 0 0.2rem;
  border-top: 1px solid var(--border);
}

.species-block h3 { display: flex; justify-content: space-between; }

.count { color: var(--text-muted); font-weight: 400; }

.obs-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.obs-row {
  padding: 0.4rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.obs-row:active { background: var(--border); }

.obs-photo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43, 42, 39, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 100;
}

.modal {
  background: var(--surface);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 1.2rem;
  position: relative;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; justify-content: center; }
  .modal { max-width: 480px; border-radius: 16px; }
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.modal-meta { color: var(--text-muted); font-size: 0.85rem; margin-top: -0.4rem; }

.modal-photo {
  width: 100%;
  border-radius: 10px;
  margin: 0.7rem 0;
}

.modal-description { white-space: pre-wrap; }

.year-picker { display: flex; align-items: center; gap: 0.6rem; }
.year-picker label { margin: 0; }
.year-picker select { width: auto; }

.yl-search {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.yl-list { padding: 0.4rem 1rem; }

.yl-row {
  display: flex;
  align-items: left;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.yl-row:last-child { border-bottom: none; }

.yl-check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  flex: 1 1 45%;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

.yl-checkbox {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.yl-location, .yl-date {
  flex: 1 1 45%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

@media (min-width: 480px) {
  .month-grid { grid-template-columns: repeat(3, 1fr); }
}

.month-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  text-decoration: none;
  color: var(--text);
}

.month-card.has-obs { border-color: var(--accent); }

.month-name { font-weight: 600; font-size: 0.9rem; }
.month-count { font-size: 1.3rem; font-weight: 700; margin: 0.15rem 0; }
.month-species { font-size: 0.72rem; color: var(--text-muted); }
