* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: #0d1117;
  color: #e6edf3;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

#app {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#header-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0 4px;
}

#date-picker {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
  color: #e6edf3;
  font-size: 0.82rem;
  padding: 4px 10px;
  cursor: pointer;
}

#date-picker::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

#creature-label {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7d8590;
}

#date-display {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#location-btn {
  background: none;
  border: none;
  color: #7d8590;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

#location-btn:hover { color: #c9d1d9; }

#location-panel {
  width: 100%;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#gps-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.8rem;
  font-family: inherit;
  padding: 5px 12px;
  cursor: pointer;
  align-self: flex-start;
  transition: color 0.15s, border-color 0.15s;
}

#gps-btn:hover { color: #e6edf3; border-color: #8b949e; }

.loc-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.loc-presets button {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.78rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.loc-presets button:hover { border-color: #58a6ff; color: #58a6ff; }

.loc-manual {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
}

.loc-manual input {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  padding: 4px 8px;
  font-size: 0.78rem;
  width: 108px;
}

.loc-manual button {
  background: none;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #8b949e;
  font-size: 0.78rem;
  font-family: inherit;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.loc-manual button:hover { border-color: #58a6ff; color: #58a6ff; }

#card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  overflow: hidden;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- loading --- */
#loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #7d8590;
  font-size: 0.9rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #30363d;
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- creature card --- */
#creature {
  width: 100%;
  display: flex;
  flex-direction: column;
}

#photo-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
}

#photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#photo-placeholder {
  display: none;
  width: 100%;
  aspect-ratio: 4/3;
  background: #21262d;
  align-items: center;
  justify-content: center;
  color: #444;
  font-size: 0.85rem;
}

#photo-credit {
  position: absolute;
  bottom: 0;
  right: 0;
  background: rgba(0,0,0,0.55);
  font-size: 0.65rem;
  color: #aaa;
  padding: 3px 7px;
  max-width: 90%;
  text-align: right;
}

#photo-credit a { color: #aaa; text-decoration: none; }

footer#license-notice {
  font-size: 0.68rem;
  color: #3a3f47;
  text-align: center;
  padding: 0 4px 4px;
}

footer#license-notice a { color: #3a3f47; text-decoration: none; }
footer#license-notice a:hover { color: #555; }

#github-link {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  color: #484f58;
  text-decoration: none;
  padding-bottom: 8px;
  transition: color 0.15s;
}

#github-link:hover { color: #8b949e; }

#info {
  padding: 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#common-name {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

#sci-name {
  font-size: 0.85rem;
  color: #7d8590;
  font-style: italic;
}

#stats {
  margin-top: 6px;
  font-size: 0.82rem;
  color: #8b949e;
  line-height: 1.6;
}

#inat-link {
  margin-top: 12px;
  font-size: 0.82rem;
  color: #58a6ff;
  text-decoration: none;
  align-self: flex-start;
}

#inat-link:hover { text-decoration: underline; }

/* --- error --- */
#error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  color: #7d8590;
  text-align: center;
}

.hint {
  font-size: 0.78rem;
  color: #555;
  margin-bottom: 8px;
}

#presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 10px;
}

#presets button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
}

#presets button:hover { border-color: #58a6ff; color: #58a6ff; }

#latlng-form {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

#latlng-form input {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  padding: 5px 8px;
  font-size: 0.82rem;
  width: 130px;
}

#error button {
  background: #21262d;
  border: 1px solid #30363d;
  color: #e6edf3;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* --- debug --- */
#algo-debug {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 12px;
  padding: 16px;
  font-size: 0.78rem;
}

#algo-debug h3 {
  margin-bottom: 10px;
  color: #8b949e;
  font-weight: 500;
}

#debug-table {
  width: 100%;
  border-collapse: collapse;
  color: #8b949e;
}

#debug-table th, #debug-table td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid #21262d;
}

#debug-table th { color: #58a6ff; }

#debug-toggle {
  background: none;
  border: none;
  color: #7d8590;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  align-self: center;
}

.hidden { display: none !important; }
